better workspace changing patch
Jason 'vanRijn' Kasper
vR at movingparts.net
Sat Aug 24 00:03:25 EDT 2002
Attached is a patch that:
- stops XUnmap/XMap'ing sticky windows on a workspace change. Doing so
causes all sticky windows to flash when you change workspaces, and was
strictly annoying.
- adds a check to showAll() to map a window if it's supposed to be
visible, but isn't (openbox/blackbox crashes/is killed, etc., and kicker
decides to XUnmap all windows, etc., etc.)
- runs the following logic on a workspace change:
-- try to find the window underneath the pointer if we're in sloppy
focus mode and focus it if we find it
-- if we aren't in sloppy focus mode, or the above failed, and we're
asked to focus the last window, try to do so
-- if the above attempts have failed, set focus on nothing
The affect of this patch is a much-cleaner transition between
workspaces. No longer do my windows flash from being unmapped/mapped on
workspace changes. I've tested this running in kde3's environment, with
openbox running instead of kwin, as well (briefly) in a regular openbox
environment.
Um. Okay, bye.
--
,-----------------------------------------------------------------//
| Jason 'vanRijn' Kasper :: Numbers 6:22-26
`
| All brontosauruses are thin at one end, much MUCH thicker
| in the middle, and then thin again at the far end. That is
| the theory that I have and which is mine, and what it is too.
,
| bash$ :(){ :|:&};:
`----------------------//
-------------- next part --------------
? workspaceChange.diff
Index: Screen.cc
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Screen.cc,v
retrieving revision 1.129
diff -u -3 -p -r1.129 Screen.cc
--- Screen.cc 2002/08/22 03:46:45 1.129
+++ Screen.cc 2002/08/24 03:49:57
@@ -1233,7 +1233,7 @@ void BScreen::changeWorkspaceID(unsigned
}
// when we switch workspaces, unfocus whatever was focused
- blackbox->setFocusedWindow((BlackboxWindow *) 0);
+ if (! focused->isStuck()) blackbox->setFocusedWindow((BlackboxWindow *) 0);
current_workspace->hideAll();
workspacemenu->setItemSelected(current_workspace->getID() + 2, False);
@@ -1248,10 +1248,33 @@ void BScreen::changeWorkspaceID(unsigned
current_workspace->showAll();
- if (resource.focus_last && current_workspace->getLastFocusedWindow()) {
- XSync(blackbox->getXDisplay(), False);
- current_workspace->getLastFocusedWindow()->setInputFocus();
+ int x, y, rx, ry;
+ Window c, r;
+ unsigned int m;
+ BlackboxWindow *win = 0;
+ bool f = false;
+
+ XSync(blackbox->getXDisplay(), False);
+
+ // If sloppy focus and we can find the client window under the pointer,
+ // try to focus it.
+ if ( resource.sloppy_focus && XQueryPointer(blackbox->getXDisplay(),
+ getRootWindow(), &r, &c, &rx, &ry, &x, &y, &m) && c != None) {
+ if ( (win = blackbox->searchWindow(c)) ) {
+ f = win->setInputFocus();
+ if (f) blackbox->setFocusedWindow(win);
+ }
}
+
+ // If that fails, and we're doing focus_last, try to focus the last window.
+ if (!f && resource.focus_last && current_workspace->getLastFocusedWindow()) {
+ win = current_workspace->getLastFocusedWindow();
+ f = win->setInputFocus();
+ if (f) blackbox->setFocusedWindow(win);
+ }
+
+ // If that fails, then set focus on our root window.
+ if (!f ) blackbox->setFocusedWindow((BlackboxWindow *) 0);
updateNetizenCurrentWorkspace();
}
Index: Workspace.cc
===================================================================
RCS file: /cvs/cvsroot/openbox/src/Workspace.cc,v
retrieving revision 1.91
diff -u -3 -p -r1.91 Workspace.cc
--- Workspace.cc 2002/08/23 23:13:21 1.91
+++ Workspace.cc 2002/08/24 03:49:58
@@ -239,7 +239,7 @@ void Workspace::showAll(void) {
BlackboxWindow *bw = *it;
// not normal windows cant focus from mouse enters anyways, so we dont
// need to unmap/remap them on workspace changes
- if (! bw->isStuck() || bw->isNormal())
+ if (! bw->isStuck() || ! bw->isVisible() )
bw->show();
}
}
@@ -256,7 +256,7 @@ void Workspace::hideAll(void) {
BlackboxWindow *bw = *it;
// not normal windows cant focus from mouse enters anyways, so we dont
// need to unmap/remap them on workspace changes
- if (! bw->isStuck() || bw->isNormal())
+ if (! bw->isStuck() )
bw->withdraw();
}
}
More information about the openbox
mailing list