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
This commit is contained in:
parent
53425fa721
commit
b64548ee1f
@ -1366,3 +1366,12 @@ meta_compositor_show_window_menu (MetaCompositor *compositor,
|
|||||||
{
|
{
|
||||||
meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, menu, x, y);
|
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);
|
||||||
|
}
|
||||||
|
@ -374,3 +374,20 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
|
|||||||
if (klass->show_window_menu)
|
if (klass->show_window_menu)
|
||||||
klass->show_window_menu (plugin, window, menu, x, y);
|
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);
|
||||||
|
}
|
||||||
|
@ -87,5 +87,10 @@ void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
|
|||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
|
||||||
|
void meta_plugin_manager_show_window_menu_for_rect (MetaPluginManager *mgr,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
|
MetaRectangle *rect);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -392,6 +392,22 @@ meta_core_show_window_menu (Display *xdisplay,
|
|||||||
meta_window_show_menu (window, menu, root_x, root_y);
|
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*
|
const char*
|
||||||
meta_core_get_workspace_name_with_index (Display *xdisplay,
|
meta_core_get_workspace_name_with_index (Display *xdisplay,
|
||||||
Window xroot,
|
Window xroot,
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
/* Don't include core headers here */
|
/* Don't include core headers here */
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include <meta/common.h>
|
#include <meta/common.h>
|
||||||
|
#include <meta/boxes.h>
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -138,6 +139,12 @@ void meta_core_show_window_menu (Display *xdisplay,
|
|||||||
int root_y,
|
int root_y,
|
||||||
guint32 timestamp);
|
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,
|
gboolean meta_core_begin_grab_op (Display *xdisplay,
|
||||||
Window frame_xwindow,
|
Window frame_xwindow,
|
||||||
MetaGrabOp op,
|
MetaGrabOp op,
|
||||||
|
@ -575,6 +575,10 @@ void meta_window_show_menu (MetaWindow *window,
|
|||||||
int x,
|
int x,
|
||||||
int y);
|
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,
|
gboolean meta_window_handle_mouse_grab_op_event (MetaWindow *window,
|
||||||
const ClutterEvent *event);
|
const ClutterEvent *event);
|
||||||
|
|
||||||
|
@ -5251,6 +5251,15 @@ meta_window_show_menu (MetaWindow *window,
|
|||||||
meta_compositor_show_window_menu (window->display->compositor, window, menu, x, y);
|
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
|
void
|
||||||
meta_window_shove_titlebar_onscreen (MetaWindow *window)
|
meta_window_shove_titlebar_onscreen (MetaWindow *window)
|
||||||
{
|
{
|
||||||
|
@ -127,5 +127,9 @@ void meta_compositor_show_window_menu (MetaCompositor *compositor,
|
|||||||
MetaWindowMenuType menu,
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
void meta_compositor_show_window_menu_for_rect (MetaCompositor *compositor,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
|
MetaRectangle *rect);
|
||||||
|
|
||||||
#endif /* META_COMPOSITOR_H */
|
#endif /* META_COMPOSITOR_H */
|
||||||
|
@ -170,6 +170,11 @@ struct _MetaPluginClass
|
|||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
|
||||||
|
void (*show_window_menu_for_rect) (MetaPlugin *plugin,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
|
MetaRectangle *rect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MetaPluginClass::kill_window_effects:
|
* MetaPluginClass::kill_window_effects:
|
||||||
* @actor: a #MetaWindowActor
|
* @actor: a #MetaWindowActor
|
||||||
|
@ -1218,29 +1218,30 @@ meta_frames_button_press_event (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
MetaFrameGeometry fgeom;
|
MetaFrameGeometry fgeom;
|
||||||
GdkRectangle *rect;
|
GdkRectangle *rect;
|
||||||
|
MetaRectangle root_rect;
|
||||||
MetaWindowMenuType menu;
|
MetaWindowMenuType menu;
|
||||||
int dx, dy;
|
int win_x, win_y;
|
||||||
|
|
||||||
meta_frames_calc_geometry (frames, frame, &fgeom);
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
||||||
|
|
||||||
rect = control_rect (control, &fgeom);
|
rect = control_rect (control, &fgeom);
|
||||||
|
|
||||||
/* get delta to convert to root coords */
|
/* convert to root coords */
|
||||||
dx = event->x_root - event->x;
|
win_x = event->x_root - event->x;
|
||||||
dy = event->y_root - event->y;
|
win_y = event->y_root - event->y;
|
||||||
|
|
||||||
/* Align to the right end of the menu rectangle if RTL */
|
root_rect.x = win_x + rect->x;
|
||||||
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
root_rect.y = win_y + rect->y;
|
||||||
dx += rect->width;
|
root_rect.width = rect->width;
|
||||||
|
root_rect.height = rect->height;
|
||||||
|
|
||||||
menu = control == META_FRAME_CONTROL_MENU ? META_WINDOW_MENU_WM
|
menu = control == META_FRAME_CONTROL_MENU ? META_WINDOW_MENU_WM
|
||||||
: META_WINDOW_MENU_APP;
|
: META_WINDOW_MENU_APP;
|
||||||
|
|
||||||
meta_core_show_window_menu (display,
|
meta_core_show_window_menu_for_rect (display,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
menu,
|
menu,
|
||||||
rect->x + dx,
|
&root_rect,
|
||||||
rect->y + rect->height + dy,
|
|
||||||
event->time);
|
event->time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user