On Thu, May 11, 2000 at 07:02:58PM -0400, Jeff Raven wrote:
> OK, I spent a little while looking through the blackbox code
> today, and I think I came up with a better way to do what
> yesterday's patch intended. The patch also makes a few other
> changes to the way focus acts that I only noticed when I
> started using ClickToFocus to test this stuff.
>
> <snip>
Hmm. The patch seems to have a bug -- the proper combination
of iconification and closings can put blackbox in a nice,
tight infinite loop. I've made what's hopefully a straight-forward
enough fix, but I ended up also modifying Screen.cc so that window
cycling was uniform in raising windows (previously if no
window had the focus, cycling windows would give a window the
focus but not raise it).
I've included both a patch to the alpha as well as an upgrade
patch if you've already used the one from earlier today (ie. use
focusfix-upgrade.patch if you used the previous one).
I'm not completely happy with the way the focusing behaves
after the patch; this is mainly because blackbox doesn't order
the windows internally by their stacking order but instead by
their order of creation, which means you often get hit with
a confusing jump as an unexpected window is given the next
focus.
Also, using the Send To menu off the window menu can appear a
little flickery -- I think it seems that way because the code
raises a window over the currently focused one (while in
Workspace::removeWindow) and then later unmaps the previously
focused window, which is now in the background. Ideally it
would be in the other order, since disappearing background windows
can be a little disconcerting.
Anyway, sorry for the trouble. If you continue to feel
adventurous and try the new patch, let me know how the
focusing strikes you. At this point it alters a number of little
focus behaviors, and I'm not sure what everyone will think of them
(especially since some of the changes also affect little things under
SloppyFocus too). I'm going to need to play with it for a while
myself to see if I think it's really an improvement -- although I
already like the fact that I don't need to touch my mouse.
Jeff Raven
diff -ur blackbox-0.60.0/src/Screen.cc blackbox-0.60.0-focusfix/src/Screen.cc
--- blackbox-0.60.0/src/Screen.cc Thu Mar 30 18:37:21 2000
+++ blackbox-0.60.0-focusfix/src/Screen.cc Thu May 11 22:17:44 2000
@@ -1342,7 +1342,11 @@
if (next_window_number != focused_window_number)
getCurrentWorkspace()->raiseWindow(next);
} else if (getCurrentWorkspace()->getCount() >= 1) {
- getCurrentWorkspace()->getWindow(0)->setInputFocus();
+ // Jeff Raven (2000-05-11)
+ BlackboxWindow *next = getCurrentWorkspace()->getWindow(0);
+
+ next->setInputFocus();
+ getCurrentWorkspace()->raiseWindow(next);
}
}
diff -ur blackbox-0.60.0/src/Workspace.cc blackbox-0.60.0-focusfix/src/Workspace.cc
--- blackbox-0.60.0/src/Workspace.cc Thu May 11 22:19:23 2000
+++ blackbox-0.60.0-focusfix/src/Workspace.cc Thu May 11 21:27:03 2000
@@ -138,8 +138,10 @@
else if (w->isTransient() && w->getTransientFor() &&
w->getTransientFor()->isVisible())
w->getTransientFor()->setInputFocus();
- else
+ else {
+ screen->getBlackbox()->setFocusedWindow((BlackboxWindow *) 0);
screen->nextFocus();
+ }
}
clientmenu->remove(w->getWindowNumber());
diff -ur blackbox-0.60.0/src/Icon.cc blackbox-0.60.0-focusfix/src/Icon.cc
--- blackbox-0.60.0/src/Icon.cc Thu Mar 16 20:04:12 2000
+++ blackbox-0.60.0-focusfix/src/Icon.cc Thu May 11 18:29:19 2000
@@ -98,6 +98,9 @@
screen->getWorkspace(window->getWorkspaceNumber())->raiseWindow(window);
window->deiconify();
+ // Jeff Raven (2000-05-11)
+ window->setInputFocus();
+
if (! (screen->getWorkspacemenu()->isTorn() || isTorn()))
hide();
}
diff -ur blackbox-0.60.0/src/Screen.cc blackbox-0.60.0-focusfix/src/Screen.cc
--- blackbox-0.60.0/src/Screen.cc Thu Mar 30 18:37:21 2000
+++ blackbox-0.60.0-focusfix/src/Screen.cc Thu May 11 22:17:44 2000
@@ -1342,7 +1342,11 @@
if (next_window_number != focused_window_number)
getCurrentWorkspace()->raiseWindow(next);
} else if (getCurrentWorkspace()->getCount() >= 1) {
- getCurrentWorkspace()->getWindow(0)->setInputFocus();
+ // Jeff Raven (2000-05-11)
+ BlackboxWindow *next = getCurrentWorkspace()->getWindow(0);
+
+ next->setInputFocus();
+ getCurrentWorkspace()->raiseWindow(next);
}
}
diff -ur blackbox-0.60.0/src/Window.cc blackbox-0.60.0-focusfix/src/Window.cc
--- blackbox-0.60.0/src/Window.cc Sun Mar 19 20:05:40 2000
+++ blackbox-0.60.0-focusfix/src/Window.cc Thu May 11 18:29:19 2000
@@ -1183,9 +1183,8 @@
else {
if (! focused) {
if (focus_mode == F_LocallyActive || focus_mode == F_Passive)
- XSetInputFocus(display, client.window,
- ((screen->isSloppyFocus()) ? RevertToPointerRoot :
- RevertToParent), CurrentTime);
+ // Jeff Raven (2000-05-11)
+ XSetInputFocus(display, client.window, RevertToPointerRoot, CurrentTime);
else
XSetInputFocus(display, screen->getRootWindow(),
RevertToNone, CurrentTime);
@@ -1234,6 +1233,14 @@
XUnmapWindow(display, frame.window);
visible = False;
iconic = True;
+
+ // Jeff Raven (2000-05-11)
+ if (focused) {
+ if (screen->isSloppyFocus())
+ screen->getBlackbox()->setFocusedWindow((BlackboxWindow *) 0);
+ else
+ screen->nextFocus();
+ }
setFocusFlag(False);
if (transient && client.transient_for) {
diff -ur blackbox-0.60.0/src/Workspace.cc blackbox-0.60.0-focusfix/src/Workspace.cc
--- blackbox-0.60.0/src/Workspace.cc Sun Mar 19 20:11:07 2000
+++ blackbox-0.60.0-focusfix/src/Workspace.cc Thu May 11 21:27:03 2000
@@ -131,8 +131,18 @@
windowList->remove((const int) w->getWindowNumber());
- if (w->isFocused())
- screen->getBlackbox()->setFocusedWindow((BlackboxWindow *) 0);
+ // Jeff Raven (2000-05-11)
+ if (w->isFocused()) {
+ if (screen->isSloppyFocus())
+ screen->getBlackbox()->setFocusedWindow((BlackboxWindow *) 0);
+ else if (w->isTransient() && w->getTransientFor() &&
+ w->getTransientFor()->isVisible())
+ w->getTransientFor()->setInputFocus();
+ else {
+ screen->getBlackbox()->setFocusedWindow((BlackboxWindow *) 0);
+ screen->nextFocus();
+ }
+ }
clientmenu->remove(w->getWindowNumber());
clientmenu->update();