diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 36569d16b..94ac78178 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -1366,3 +1366,12 @@ meta_compositor_show_window_menu (MetaCompositor *compositor, { meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, menu, x, y); } + +void +meta_compositor_show_window_menu_for_rect (MetaCompositor *compositor, + MetaWindow *window, + MetaWindowMenuType menu, + MetaRectangle *rect) +{ + meta_plugin_manager_show_window_menu_for_rect (compositor->plugin_mgr, window, menu, rect); +} diff --git a/src/compositor/meta-plugin-manager.c b/src/compositor/meta-plugin-manager.c index c3c9b72b9..d36c289f8 100644 --- a/src/compositor/meta-plugin-manager.c +++ b/src/compositor/meta-plugin-manager.c @@ -374,3 +374,20 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr, if (klass->show_window_menu) klass->show_window_menu (plugin, window, menu, x, y); } + +void +meta_plugin_manager_show_window_menu_for_rect (MetaPluginManager *plugin_mgr, + MetaWindow *window, + MetaWindowMenuType menu, + MetaRectangle *rect) +{ + MetaPlugin *plugin = plugin_mgr->plugin; + MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); + MetaDisplay *display = plugin_mgr->compositor->display; + + if (display->display_opening) + return; + + if (klass->show_window_menu_for_rect) + klass->show_window_menu_for_rect (plugin, window, menu, rect); +} diff --git a/src/compositor/meta-plugin-manager.h b/src/compositor/meta-plugin-manager.h index da5a7262e..c425d827e 100644 --- a/src/compositor/meta-plugin-manager.h +++ b/src/compositor/meta-plugin-manager.h @@ -87,5 +87,10 @@ void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr, int x, int y); +void meta_plugin_manager_show_window_menu_for_rect (MetaPluginManager *mgr, + MetaWindow *window, + MetaWindowMenuType menu, + MetaRectangle *rect); + #endif diff --git a/src/core/core.c b/src/core/core.c index 07c424f41..c9ba035b3 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -392,6 +392,22 @@ meta_core_show_window_menu (Display *xdisplay, meta_window_show_menu (window, menu, root_x, root_y); } +void +meta_core_show_window_menu_for_rect (Display *xdisplay, + Window frame_xwindow, + MetaWindowMenuType menu, + MetaRectangle *rect, + guint32 timestamp) +{ + MetaWindow *window = get_window (xdisplay, frame_xwindow); + + if (meta_prefs_get_raise_on_click ()) + meta_window_raise (window); + meta_window_focus (window, timestamp); + + meta_window_show_menu_for_rect (window, menu, rect); +} + const char* meta_core_get_workspace_name_with_index (Display *xdisplay, Window xroot, diff --git a/src/core/core.h b/src/core/core.h index ecbe425f7..a42884f39 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -26,6 +26,7 @@ /* Don't include core headers here */ #include #include +#include typedef enum { @@ -138,6 +139,12 @@ void meta_core_show_window_menu (Display *xdisplay, int root_y, guint32 timestamp); +void meta_core_show_window_menu_for_rect (Display *xdisplay, + Window frame_xwindow, + MetaWindowMenuType menu, + MetaRectangle *rect, + guint32 timestamp); + gboolean meta_core_begin_grab_op (Display *xdisplay, Window frame_xwindow, MetaGrabOp op, diff --git a/src/core/window-private.h b/src/core/window-private.h index aa8c2ef59..5970db184 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -575,6 +575,10 @@ void meta_window_show_menu (MetaWindow *window, int x, int y); +void meta_window_show_menu_for_rect (MetaWindow *window, + MetaWindowMenuType menu, + MetaRectangle *rect); + gboolean meta_window_handle_mouse_grab_op_event (MetaWindow *window, const ClutterEvent *event); diff --git a/src/core/window.c b/src/core/window.c index df4b9240e..438368392 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -5251,6 +5251,15 @@ meta_window_show_menu (MetaWindow *window, meta_compositor_show_window_menu (window->display->compositor, window, menu, x, y); } +void +meta_window_show_menu_for_rect (MetaWindow *window, + MetaWindowMenuType menu, + MetaRectangle *rect) +{ + g_return_if_fail (!window->override_redirect); + meta_compositor_show_window_menu_for_rect (window->display->compositor, window, menu, rect); +} + void meta_window_shove_titlebar_onscreen (MetaWindow *window) { diff --git a/src/meta/compositor.h b/src/meta/compositor.h index 792602e6e..209074856 100644 --- a/src/meta/compositor.h +++ b/src/meta/compositor.h @@ -127,5 +127,9 @@ void meta_compositor_show_window_menu (MetaCompositor *compositor, MetaWindowMenuType menu, int x, int y); +void meta_compositor_show_window_menu_for_rect (MetaCompositor *compositor, + MetaWindow *window, + MetaWindowMenuType menu, + MetaRectangle *rect); #endif /* META_COMPOSITOR_H */ diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h index 6cf8b41d6..d1089e5be 100644 --- a/src/meta/meta-plugin.h +++ b/src/meta/meta-plugin.h @@ -170,6 +170,11 @@ struct _MetaPluginClass int x, int y); + void (*show_window_menu_for_rect) (MetaPlugin *plugin, + MetaWindow *window, + MetaWindowMenuType menu, + MetaRectangle *rect); + /** * MetaPluginClass::kill_window_effects: * @actor: a #MetaWindowActor diff --git a/src/ui/frames.c b/src/ui/frames.c index aaa39086c..976c71c71 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -1218,30 +1218,31 @@ meta_frames_button_press_event (GtkWidget *widget, { MetaFrameGeometry fgeom; GdkRectangle *rect; + MetaRectangle root_rect; MetaWindowMenuType menu; - int dx, dy; + int win_x, win_y; meta_frames_calc_geometry (frames, frame, &fgeom); rect = control_rect (control, &fgeom); - /* get delta to convert to root coords */ - dx = event->x_root - event->x; - dy = event->y_root - event->y; + /* convert to root coords */ + win_x = event->x_root - event->x; + win_y = event->y_root - event->y; - /* Align to the right end of the menu rectangle if RTL */ - if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) - dx += rect->width; + root_rect.x = win_x + rect->x; + root_rect.y = win_y + rect->y; + root_rect.width = rect->width; + root_rect.height = rect->height; menu = control == META_FRAME_CONTROL_MENU ? META_WINDOW_MENU_WM : META_WINDOW_MENU_APP; - meta_core_show_window_menu (display, - frame->xwindow, - menu, - rect->x + dx, - rect->y + rect->height + dy, - event->time); + meta_core_show_window_menu_for_rect (display, + frame->xwindow, + menu, + &root_rect, + event->time); } } else if (event->button == 1 &&