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>
Sun, 19 Sep 2010 16:06:21 +0000 (18:06 +0200)
openbox/client_list_combined_menu.c
openbox/menu.h
openbox/menuframe.c
openbox/menuframe.h

index 28d769cbd33bcaca2055d858657e49b8b7ecef65..dfae21ed9a778f75fc1e8331fca0fb8ade50f527 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 c0cc199d4e18b3cd91d9008fb5473110433a4489..71b029ffa18b73709906456b48ab323d32a7edca 100644 (file)
@@ -88,6 +88,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 5708cdf8d2e337c604a209cfbed53ac1525c127e..c177235f8ffcaa6ab9bfabca1321f3dd38e8dfc5 100644 (file)
@@ -994,15 +994,23 @@ gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y,
         menu_frame_place_topmenu(self, &x, &y);
 
     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;
 }
 
@@ -1093,6 +1101,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 44c02562220a983128b6fe2d36dcec3f7cb06510..f0e67bd34465f0450c9dd72a9bb01200ed95d392 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;