[openbox] [PATCH 2/2] Warp cursor to center of new window on cycle

Jim Rees rees at umich.edu
Fri Dec 7 23:51:20 EST 2012


This is mostly for discussion, as I haven't fully tested it, and it may not
be what people want.

If you have "focus under mouse" configured, and invoke a non-interactive
window cycle, you can end up with a new window focused while the pointer is
still over the old, now-unfocused window.

To reproduce:
    <underMouse>yes</underMouse>
    <action name="NextWindow">
      <dialog>none</dialog>
      <bar>yes</bar>
      <raise>yes</raise>
      <linear>yes</linear>
      <interactive>no</interactive>
    </action>

This patch warps the cursor to the center of the new window, preserving the
"focus under mouse" requirement.

Signed-off-by: Jim Rees <rees at umich.edu>
---
 openbox/actions/cyclewindows.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c
index f834951..3edf8db 100644
--- a/openbox/actions/cyclewindows.c
+++ b/openbox/actions/cyclewindows.c
@@ -1,4 +1,6 @@
 #include "openbox/actions.h"
+#include "openbox/client.h"
+#include "openbox/config.h"
 #include "openbox/stacking.h"
 #include "openbox/window.h"
 #include "openbox/event.h"
@@ -176,7 +178,15 @@ static gboolean run_func(ObActionsData *data, gpointer options)
         done, cancel);
 
     stacking_restore();
-    if (o->raise && ft) stacking_temp_raise(CLIENT_AS_WINDOW(ft));
+    if (o->raise && ft) {
+	stacking_temp_raise(CLIENT_AS_WINDOW(ft));
+	if (config_focus_under_mouse) {
+	    XWarpPointer(obt_display, None, window_top(CLIENT_AS_WINDOW(ft)),
+			 0, 0, 0, 0,
+			 ft->area.width / 2,
+			 ft->area.height / 2);
+	}
+    }
 
     return o->interactive;
 }
-- 
1.7.9.5



More information about the openbox mailing list