[mutter] Pass button_rect when opening window menu from button
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Pass button_rect when opening window menu from button
- Date: Mon, 2 Jun 2014 21:51:00 +0000 (UTC)
commit b64548ee1fa5fa0dcb459fb40d518d38ee9a8b88
Author: Florian Müllner <fmuellner gnome org>
Date: Sat May 31 00:52:06 2014 +0200
Pass button_rect when opening window menu from button
When opening the window menu without an associated control - e.g.
by right-clicking the titlebar or by keyboard - using coordinates
for the menu position is appropriate. However when the menu is
associated with a window button, the expected behavior in the
shell can be implemented much easier with the full button geometry:
the menu will point to the center of the button's bottom edge
rather than align to the left/right side of the titlebar as it
does now, and the clickable area where a release event does not
dismiss the menu will match the actual clickable area in mutter.
So add an additional show_window_menu_for_rect() function and
use it when opening the menu from a button.
https://bugzilla.gnome.org/show_bug.cgi?id=731058
src/compositor/compositor.c | 9 +++++++++
src/compositor/meta-plugin-manager.c | 17 +++++++++++++++++
src/compositor/meta-plugin-manager.h | 5 +++++
src/core/core.c | 16 ++++++++++++++++
src/core/core.h | 7 +++++++
src/core/window-private.h | 4 ++++
src/core/window.c | 9 +++++++++
src/meta/compositor.h | 4 ++++
src/meta/meta-plugin.h | 5 +++++
src/ui/frames.c | 27 ++++++++++++++-------------
10 files changed, 90 insertions(+), 13 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 36569d1..94ac781 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 c3c9b72..d36c289 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 da5a726..c425d82 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 07c424f..c9ba035 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 ecbe425..a42884f 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -26,6 +26,7 @@
/* Don't include core headers here */
#include <gdk/gdkx.h>
#include <meta/common.h>
+#include <meta/boxes.h>
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 aa8c2ef..5970db1 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 df4b924..4383683 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -5252,6 +5252,15 @@ meta_window_show_menu (MetaWindow *window,
}
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)
{
MetaRectangle frame_rect;
diff --git a/src/meta/compositor.h b/src/meta/compositor.h
index 792602e..2090748 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 6cf8b41..d1089e5 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 aaa3908..976c71c 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 &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]