]> Dogcows Code - chaz/openbox/commitdiff
sync with bb cvs
authorDana Jansens <danakj@orodu.net>
Wed, 10 Jul 2002 22:24:48 +0000 (22:24 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 10 Jul 2002 22:24:48 +0000 (22:24 +0000)
src/Rootmenu.cc
src/Screen.cc
src/Toolbar.cc
src/Toolbar.hh
src/Workspace.cc
src/Workspace.hh
src/blackbox.cc
util/bsetroot.cc

index 148c1fcada65de96a11f90702b70d53beee6bf77..3395b4f728da28745eed496f85995e91193608cb 100644 (file)
@@ -61,6 +61,11 @@ void Rootmenu::itemSelected(int button, unsigned int index) {
   if (! item->function())
     return;
 
+  if (! (getScreen()->getRootmenu()->isTorn() || isTorn()) &&
+      item->function() != BScreen::Reconfigure &&
+      item->function() != BScreen::SetStyle)
+    hide();
+
   switch (item->function()) {
   case BScreen::Execute:
     if (item->exec())
@@ -88,9 +93,4 @@ void Rootmenu::itemSelected(int button, unsigned int index) {
     getScreen()->getBlackbox()->reconfigure();
     return;
   }
-
-  if (! (getScreen()->getRootmenu()->isTorn() || isTorn()) &&
-      item->function() != BScreen::Reconfigure &&
-      item->function() != BScreen::SetStyle)
-    hide();
 }
index 1b3860f46166ea02062e74f5ad86b4db340863e4..cebd21c03bad34d52915a4d16bf6e733ca1da097 100644 (file)
@@ -1015,41 +1015,38 @@ unsigned int BScreen::removeLastWorkspace(void) {
 
 
 void BScreen::changeWorkspaceID(unsigned int id) {
-  if (! current_workspace) return;
-
-  if (id != current_workspace->getID()) {
-    BlackboxWindow *focused = blackbox->getFocusedWindow();
-    if (focused && focused->getScreen() == this && ! focused->isStuck()) {
-      if (focused->getWorkspaceNumber() != current_workspace->getID()) {
-        fprintf(stderr, "%s is on the wrong workspace, aborting\n",
-                focused->getTitle());
-        abort();
-      }
-      current_workspace->setLastFocusedWindow(focused);
-    } else {
-      // if no window had focus, no need to store a last focus
-      current_workspace->setLastFocusedWindow((BlackboxWindow *) 0);
-    }
-    // when we switch workspaces, unfocus whatever was focused
-    blackbox->setFocusedWindow((BlackboxWindow *) 0);
+  if (! current_workspace || id == current_workspace->getID()) return;
+
+  BlackboxWindow *focused = blackbox->getFocusedWindow();
+  if (focused && focused->getScreen() == this) {
+    assert(focused->isStuck() ||
+           focused->getWorkspaceNumber() == current_workspace->getID());
+
+    current_workspace->setLastFocusedWindow(focused);
+  } else {
+    // if no window had focus, no need to store a last focus
+    current_workspace->setLastFocusedWindow((BlackboxWindow *) 0);
+  }
+
+  // when we switch workspaces, unfocus whatever was focused
+  blackbox->setFocusedWindow((BlackboxWindow *) 0);
     
-    current_workspace->hideAll();
-    workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
+  current_workspace->hideAll();
+  workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
 
-    current_workspace = getWorkspace(id);
+  current_workspace = getWorkspace(id);
 
-    xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
-                    XAtom::cardinal, id);
+  xatom->setValue(getRootWindow(), XAtom::net_current_desktop,
+                  XAtom::cardinal, id);
 
-    workspacemenu->setItemSelected(current_workspace->getID() + 2, True);
-    toolbar->redrawWorkspaceLabel(True);
+  workspacemenu->setItemSelected(current_workspace->getID() + 2, True);
+  toolbar->redrawWorkspaceLabel(True);
 
-    current_workspace->showAll();
+  current_workspace->showAll();
 
-    if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
-      XSync(blackbox->getXDisplay(), False);
-      current_workspace->getLastFocusedWindow()->setInputFocus();
-    }
+  if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
+    XSync(blackbox->getXDisplay(), False);
+    current_workspace->getLastFocusedWindow()->setInputFocus();
   }
 
   updateNetizenCurrentWorkspace();
index dac1ad7f16611b8189d8b5e29deffa92062b7e4f..23a45608871b06279b0e719d9979804d6e90f3f5 100644 (file)
@@ -96,7 +96,6 @@ Toolbar::Toolbar(BScreen *scrn) {
 
   editing = False;
   new_name_pos = 0;
-  frame.grab_x = frame.grab_y = 0;
 
   toolbarmenu = new Toolbarmenu(this);
 
index ae8353baec7d9f30f51962a1e2028cbe45cb88a1..f95d6a553435ebaa17daf4c1ab0727b0906bd9e5 100644 (file)
@@ -90,7 +90,7 @@ private:
     Window window, workspace_label, window_label, clock, psbutton, nsbutton,
       pwbutton, nwbutton;
 
-    int x_hidden, y_hidden, hour, minute, grab_x, grab_y;
+    int x_hidden, y_hidden, hour, minute;
     unsigned int window_label_w, workspace_label_w, clock_w,
       button_w, bevel_w, label_h;
 
index 90a83b2678a43a531dd78f214b668b2fb1055299..9606140d6262392dbcfdf2205757b7203f85b8e7 100644 (file)
@@ -102,39 +102,19 @@ unsigned int Workspace::removeWindow(BlackboxWindow *w) {
   // pass focus to the next appropriate window
   if ((w->isFocused() || w == lastfocus) &&
       ! screen->getBlackbox()->doShutdown()) {
-    BlackboxWindow *newfocus = 0;
-    if (w->isTransient()) {
-      newfocus = w->getTransientFor();
-      if (newfocus &&
-          (newfocus->isIconic() ||                // do not focus icons
-           newfocus->getWorkspaceNumber() != id)) // or other workspaces
-        newfocus = 0;
-    }
-    if (! newfocus && ! stackingList.empty())
-      newfocus = stackingList.front();
-
-    assert(newfocus != w);  // this would be very wrong.
-
     if (id == screen->getCurrentWorkspaceID()) {
-      /*
-        if the window is on the visible workspace, then try focus it, and fall
-        back to the default focus target if the window won't focus.
-      */
-      if (! (newfocus && newfocus->setInputFocus()))
-        screen->getBlackbox()->setFocusedWindow(0);
-    } else if (lastfocus == w) {
-      /*
-        If this workspace is not the current one do not assume that
-        w == lastfocus. If a sticky window is removed on a workspace other
-        than where it originated, it will fire the removeWindow on a
-        non-visible workspace.
-      */
-      
-      /*
-        If the window isn't on the visible workspace, don't focus the new one,
-        just mark it to be focused when the workspace comes into view.
-      */
-      setLastFocusedWindow(newfocus);
+      // The window is on the visible workspace
+      focusFallback(w);
+    } else {
+      // The window is not on the visible workspace.
+      if (lastfocus == w) {
+        // The window was the last-focus target, so we need to replace it.
+        setLastFocusedWindow(stackingList.front());
+      }
+      // if the window focused on the current workspace, then reapply that
+      // workspace's focus too
+      if (w->isFocused())
+        screen->getCurrentWorkspace()->focusFallback(w);
     }
   }
 
@@ -157,6 +137,37 @@ unsigned int Workspace::removeWindow(BlackboxWindow *w) {
 }
 
 
+void Workspace::focusFallback(const BlackboxWindow *old_window) {
+  BlackboxWindow *newfocus = 0;
+
+  // if it's a transient, then try to focus its parent
+  if (old_window && old_window->isTransient()) {
+    newfocus = old_window->getTransientFor();
+
+    if (! newfocus ||
+        newfocus->isIconic() ||                  // do not focus icons
+        newfocus->getWorkspaceNumber() != id ||  // or other workspaces
+        ! newfocus->setInputFocus())
+      newfocus = 0;
+  }
+
+  if (! newfocus) {
+    BlackboxWindowList::iterator it = stackingList.begin(),
+                                end = stackingList.end();
+    for (; it != end; ++it) {
+      BlackboxWindow *tmp = *it;
+      if (tmp && tmp->setInputFocus()) {
+        // we found our new focus target
+        newfocus = tmp;
+        break;
+      }
+    }
+  }
+
+  screen->getBlackbox()->setFocusedWindow(newfocus);
+}
+
+
 void Workspace::showAll(void) {
   std::for_each(stackingList.begin(), stackingList.end(),
                 std::mem_fun(&BlackboxWindow::show));
index 0059e293fdcd4c46d59b7e94a2b5f0dbda7be1dd..0916dce7340825085860d24936cb6fda727db762 100644 (file)
@@ -87,6 +87,7 @@ public:
   BlackboxWindow* getPrevWindowInList(BlackboxWindow *w);
   BlackboxWindow* getTopWindowOnStack(void) const;
   void sendWindowList(Netizen &n);
+  void focusFallback(const BlackboxWindow *old_window);
 
   bool isCurrent(void) const;
   bool isLastWindow(const BlackboxWindow* w) const;
index dafc6bdfa8d8ce610008dfee93a13b12b3dcb177..9eddcfdfcd8ed7192cd102b44640c40a6a0c3f7f 100644 (file)
@@ -328,10 +328,18 @@ void Blackbox::process_event(XEvent *e) {
     BlackboxWindow *win = searchWindow(e->xmaprequest.window);
 
     if (win) {
+      bool focus = False;
       if (win->isIconic()) {
         win->deiconify();
-        win->setInputFocus();
+        focus = True;
+      }
+      if (win->isShaded()) {
+        win->shade();
+        focus = True;
       }
+
+      if (focus && (win->isTransient() || win->getScreen()->doFocusNew()))
+        win->setInputFocus();
     } else {
       BScreen *screen = searchScreen(e->xmaprequest.parent);
 
index 47939aec0a1dfecb9c705b011474f7d4190939bd..6f8e122d8995c7a89fcf302e7334068ee1ecd023 100644 (file)
@@ -49,8 +49,8 @@ extern "C" {
 I18n i18n;
 
 bsetroot::bsetroot(int argc, char **argv, char *dpy_name)
-  : BaseDisplay(argv[0], dpy_name)
-{
+  : BaseDisplay(argv[0], dpy_name) {
+
   grad = fore = back = (char *) 0;
 
   bool mod = False, sol = False, grd = False;
@@ -97,8 +97,9 @@ bsetroot::bsetroot(int argc, char **argv, char *dpy_name)
     } else if (! strcmp("-display", argv[i])) {
       // -display passed through tests ealier... we just skip it now
       i++;
-    } else
+    } else {
       usage();
+    }
   }
 
   if ((mod + sol + grd) != True) {
This page took 0.030982 seconds and 4 git commands to generate.