Warp to the top of the combined menu and back.
authorMikael Magnusson <mikachu@gmail.com>
Sun, 8 Feb 2009 07:51:25 +0000 (08:51 +0100)
committerMikael Magnusson <mikachu@gmail.com>
Sat, 11 Oct 2014 00:17:18 +0000 (02:17 +0200)
openbox/client_list_combined_menu.c
openbox/menu.h
openbox/menuframe.c
openbox/menuframe.h

index 28d769c..dfae21e 100644 (file)
@@ -164,6 +164,7 @@ void client_list_combined_menu_startup(gboolean reconfig)
     menu_set_update_func(combined_menu, self_update);
     menu_set_cleanup_func(combined_menu, self_cleanup);
     menu_set_execute_func(combined_menu, menu_execute);
+    combined_menu->warp = TRUE;
 }
 
 void client_list_combined_menu_shutdown(gboolean reconfig)
index 3f5d024..50a301e 100644 (file)
@@ -89,6 +89,8 @@ struct _ObMenu
     ObMenuDestroyFunc destroy_func;
     ObMenuPlaceFunc place_func;
 
+    gboolean warp;
+
     /* Pipe-menu parent, we get destroyed when it is destroyed */
     ObMenu *pipe_creator;
 
index c390c07..fab2696 100644 (file)
@@ -1019,15 +1019,23 @@ gboolean menu_frame_show_topmenu(ObMenuFrame *self, const GravityPoint *pos,
     }
 
     menu_frame_move(self, x, y);
-
     XMapWindow(obt_display, self->window);
 
     if (screen_pointer_pos(&px, &py)) {
-        ObMenuEntryFrame *e = menu_entry_frame_under(px, py);
-        if (e && e->frame == self)
-            e->ignore_enters++;
+
+        if (self->menu->warp) {
+            x += self->area.width / 2;
+            XWarpPointer(obt_display, None, obt_root(ob_screen), 0, 0, 0, 0, x, y);
+            self->ox = px;
+            self->oy = py;
+        } else {
+            ObMenuEntryFrame *e = menu_entry_frame_under(px, py);
+            if (e && e->frame == self)
+                e->ignore_enters++;
+        }
     }
 
+
     return TRUE;
 }
 
@@ -1121,6 +1129,9 @@ static void menu_frame_hide(ObMenuFrame *self)
         ungrab_keyboard();
     }
 
+    if (self->menu->warp)
+        XWarpPointer(obt_display, None, obt_root(ob_screen), 0, 0, 0, 0, self->ox, self->oy);
+
     ignore_start = event_start_ignore_all_enters();
     XUnmapWindow(obt_display, self->window);
     event_end_ignore_all_enters(ignore_start);
index 7b295b6..01548b0 100644 (file)
@@ -47,6 +47,7 @@ struct _ObMenuFrame
     /* The client that the visual instance of the menu is associated with for
        its actions */
     struct _ObClient *client;
+    gint ox, oy;
 
     ObMenuFrame *parent;
     ObMenuEntryFrame *parent_entry;