refocus on raise or lower in the followMouse mode

Andrei Paskevich andrei at capet.iut-fbleau.fr
Sat Oct 14 15:04:08 EDT 2006


Hi,

I recently switched to Openbox 3 from Window Maker
and so far I coudn't be happier -- OB is just great!

Still, there is a feature that I missed a lot, namely,
when "focus follows mouse", it does follow mouse also
when windows are raised and lowered or, maybe, appear
under your pointer (e.g, an IM message box).

Certainly, I've seen the Q4 in the FAQ, but with all
due respect I beg to submit that the A4 is wrong, at
least in my case: I'm used to the focus _following_
mouse and I'm used to switch between windows by raising
and lowering, not by alt-tabbing. It may be that I'm not
the only one.

By no means I want to (re)start a discussion on which behaviour
should be taken by default -- it's up to developers to choose
the defaults which they like. Instead, I would like to propose
a solution which seems to be quite non-intrusive, on one hand,
and still a solution, on the other.

I wrote a little patch which adds a configure option called 
"focusRefocus". When both "followMouse" and "focusRefocus"
are set, OB calls focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING)
at the end of action_raise() and action_lower(). Once unfocused,
the window manager will then focus on the window under the mouse 
pointer, just as I want it to.  

The patch is attached at the end of this message. I tested it on 
my single-display, single-head setup and it seems to work well.
I am not sure about whether we should make a focusDelay in this
case, too, so I didn't add it. If you find the patch to be sane,
you may add it to the future version of OB. Otherwise, I would
be glad to learn why it is insane and correct that at least for
my own machine.

Best regards,
Andrei


diff -x '.*' -r -u openbox-3.3.1/data/rc.xsd openbox-3.3.1-ap/data/rc.xsd
--- openbox-3.3.1/data/rc.xsd	2006-09-07 13:48:40.000000000 +0200
+++ openbox-3.3.1-ap/data/rc.xsd	2006-10-11 21:34:49.000000000 +0200
@@ -88,6 +88,7 @@
             <xs:element minOccurs="0" name="focusNew" type="ob:bool"/>
             <xs:element minOccurs="0" name="focusLast" type="ob:bool"/>
             <xs:element minOccurs="0" name="followMouse" type="ob:bool"/>
+            <xs:element minOccurs="0" name="focusRefocus" type="ob:bool"/>
             <xs:element minOccurs="0" name="focusDelay" type="xs:integer"/>
             <xs:element minOccurs="0" name="raiseOnFocus" type="ob:bool"/>
         </xs:sequence>
diff -x '.*' -r -u openbox-3.3.1/openbox/action.c openbox-3.3.1-ap/openbox/action.c
--- openbox-3.3.1/openbox/action.c	2006-09-07 13:48:40.000000000 +0200
+++ openbox-3.3.1-ap/openbox/action.c	2006-10-11 21:18:27.000000000 +0200
@@ -1124,6 +1124,9 @@
     client_action_start(data);
     stacking_raise(CLIENT_AS_WINDOW(data->client.any.c), data->stacking.group);
     client_action_end(data);
+
+    if (config_focus_follow && config_focus_refocus)
+        focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
 }
 
 void action_unshaderaise(union ActionData *data)
@@ -1147,6 +1150,9 @@
     client_action_start(data);
     stacking_lower(CLIENT_AS_WINDOW(data->client.any.c), data->stacking.group);
     client_action_end(data);
+
+    if (config_focus_follow && config_focus_refocus)
+        focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
 }
 
 void action_close(union ActionData *data)
diff -x '.*' -r -u openbox-3.3.1/openbox/config.c openbox-3.3.1-ap/openbox/config.c
--- openbox-3.3.1/openbox/config.c	2006-09-07 13:48:40.000000000 +0200
+++ openbox-3.3.1-ap/openbox/config.c	2006-10-11 21:22:41.000000000 +0200
@@ -28,6 +28,7 @@
 #include "openbox.h"
 
 gboolean config_focus_new;
+gboolean config_focus_refocus;
 gboolean config_focus_follow;
 guint    config_focus_delay;
 gboolean config_focus_raise;
@@ -393,6 +394,8 @@
         config_focus_new = parse_bool(doc, n);
     if ((n = parse_find_node("followMouse", node)))
         config_focus_follow = parse_bool(doc, n);
+    if ((n = parse_find_node("focusRefocus", node)))
+        config_focus_refocus = parse_bool(doc, n);
     if ((n = parse_find_node("focusDelay", node)))
         config_focus_delay = parse_int(doc, n) * 1000;
     if ((n = parse_find_node("raiseOnFocus", node)))
@@ -729,6 +732,7 @@
 void config_startup(ObParseInst *i)
 {
     config_focus_new = TRUE;
+    config_focus_refocus = FALSE;
     config_focus_follow = FALSE;
     config_focus_delay = 0;
     config_focus_raise = FALSE;
diff -x '.*' -r -u openbox-3.3.1/openbox/config.h openbox-3.3.1-ap/openbox/config.h
--- openbox-3.3.1/openbox/config.h	2006-09-07 13:48:40.000000000 +0200
+++ openbox-3.3.1-ap/openbox/config.h	2006-10-11 21:20:15.000000000 +0200
@@ -32,6 +32,8 @@
 extern gboolean config_focus_new;
 /*! Focus windows when the mouse enters them */
 extern gboolean config_focus_follow;
+/*! Should we refocus on raise or lower in follow mouse mode */
+extern gboolean config_focus_refocus;
 /*! Timeout for focusing windows on focus follows mouse, in microseconds */
 extern guint    config_focus_delay;
 /*! If windows should automatically be raised when they are focused in



More information about the openbox mailing list