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, 8 Feb 2009 07:51:32 +0000 (08:51 +0100)
openbox/client_list_combined_menu.c
openbox/menu.h
openbox/menuframe.c
openbox/menuframe.h

index 203614c94afaa263d845a37263c0d316bc337814..49f11853da113ab317e153bf8563024260d0ea20 100644 (file)
@@ -155,6 +155,7 @@ void client_list_combined_menu_startup(gboolean reconfig)
     combined_menu = menu_new(MENU_NAME, _("Windows"), TRUE, NULL);
     menu_set_update_func(combined_menu, self_update);
     menu_set_execute_func(combined_menu, menu_execute);
+    combined_menu->warp = TRUE;
 }
 
 void client_list_combined_menu_shutdown(gboolean reconfig)
index 43efd41372c727744e68604cf54c9a5cb262a29d..ef2484daa41d69b4c4e2a7fffcb4f5b2b94481a5 100644 (file)
@@ -86,6 +86,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 1e767e965f45cdbdc92830b7190aa6319376ece0..28d5219cf9390e5aa36d6077a26a1ba5bd338bd9 100644 (file)
@@ -975,15 +975,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;
 }
 
@@ -1056,6 +1064,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);
+
     XUnmapWindow(obt_display, self->window);
 
     menu_frame_free(self);
index 1d5dd0cb11b3d13b1ebe7e0a04de388ddf0d9103..fda942d660d782fc69124978c257beb9809d41bf 100644 (file)
@@ -46,6 +46,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;