From cb188c246067b50bdee96c3a51edb3b04c8c0d00 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 8 Feb 2009 08:51:25 +0100 Subject: [PATCH] Warp to the top of the combined menu and back. --- openbox/client_list_combined_menu.c | 1 + openbox/menu.h | 2 ++ openbox/menuframe.c | 19 +++++++++++++++---- openbox/menuframe.h | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c index 28d769c..dfae21e 100644 --- a/openbox/client_list_combined_menu.c +++ b/openbox/client_list_combined_menu.c @@ -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) diff --git a/openbox/menu.h b/openbox/menu.h index 3f5d024..50a301e 100644 --- a/openbox/menu.h +++ b/openbox/menu.h @@ -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; diff --git a/openbox/menuframe.c b/openbox/menuframe.c index c390c07..fab2696 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -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); diff --git a/openbox/menuframe.h b/openbox/menuframe.h index 7b295b6..01548b0 100644 --- a/openbox/menuframe.h +++ b/openbox/menuframe.h @@ -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; -- 1.9.1