Add back coordinates to the window menu

It looks weird to have Alt+Space pop up under the cursor instead
of the top-left corner of the window, and the Wayland request will
pass through the coordinates as well.

Add it to the compositor interface, and extend the
_GTK_SHOW_WINDOW_MENU ClientMessage to support it as well.
This commit is contained in:
Jasper St. Pierre 2014-05-22 08:35:11 -04:00
parent 50b81fe4b9
commit 6513cbb470
12 changed files with 74 additions and 17 deletions

View File

@ -1359,7 +1359,9 @@ meta_compositor_hide_tile_preview (MetaCompositor *compositor)
void
meta_compositor_show_window_menu (MetaCompositor *compositor,
MetaWindow *window)
MetaWindow *window,
int x,
int y)
{
meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window);
meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, x, y);
}

View File

@ -359,7 +359,9 @@ meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
void
meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
MetaWindow *window)
MetaWindow *window,
int x,
int y)
{
MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
@ -369,5 +371,5 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
return;
if (klass->show_window_menu)
klass->show_window_menu (plugin, window);
klass->show_window_menu (plugin, window, x, y);
}

View File

@ -82,6 +82,8 @@ gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr,
gboolean meta_plugin_manager_hide_tile_preview (MetaPluginManager *mgr);
void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
MetaWindow *window);
MetaWindow *window,
int x,
int y);
#endif

View File

@ -374,6 +374,8 @@ meta_core_change_workspace (Display *xdisplay,
void
meta_core_show_window_menu (Display *xdisplay,
Window frame_xwindow,
int root_x,
int root_y,
guint32 timestamp)
{
MetaWindow *window = get_window (xdisplay, frame_xwindow);
@ -382,7 +384,7 @@ meta_core_show_window_menu (Display *xdisplay,
meta_window_raise (window);
meta_window_focus (window, timestamp);
meta_window_show_menu (window);
meta_window_show_menu (window, root_x, root_y);
}
const char*

View File

@ -134,6 +134,8 @@ const char* meta_core_get_workspace_name_with_index (Display *xdisplay,
void meta_core_show_window_menu (Display *xdisplay,
Window frame_xwindow,
int root_x,
int root_y,
guint32 timestamp);

View File

@ -2726,7 +2726,16 @@ handle_activate_window_menu (MetaDisplay *display,
gpointer dummy)
{
if (display->focus_window)
meta_window_show_menu (display->focus_window);
{
int x, y;
meta_window_get_position (display->focus_window, &x, &y);
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
x += display->focus_window->rect.width;
meta_window_show_menu (display->focus_window, x, y);
}
}
static void

View File

@ -605,7 +605,9 @@ void meta_window_set_focused_internal (MetaWindow *window,
void meta_window_current_workspace_changed (MetaWindow *window);
void meta_window_show_menu (MetaWindow *window);
void meta_window_show_menu (MetaWindow *window,
int x,
int y);
gboolean meta_window_handle_mouse_grab_op_event (MetaWindow *window,
const ClutterEvent *event);

View File

@ -5313,10 +5313,12 @@ meta_window_recalc_features (MetaWindow *window)
}
void
meta_window_show_menu (MetaWindow *window)
meta_window_show_menu (MetaWindow *window,
int x,
int y)
{
g_return_if_fail (!window->override_redirect);
meta_compositor_show_window_menu (window->display->compositor, window);
meta_compositor_show_window_menu (window->display->compositor, window, x, y);
}
void
@ -7976,7 +7978,9 @@ meta_window_handle_ungrabbed_event (MetaWindow *window,
{
if (meta_prefs_get_raise_on_click ())
meta_window_raise (window);
meta_window_show_menu (window);
meta_window_show_menu (window,
event->button.x,
event->button.y);
return TRUE;
}
else if (fully_modified && (int) event->button.button == 1)

View File

@ -123,6 +123,8 @@ void meta_compositor_show_tile_preview (MetaCompositor *compositor,
int tile_monitor_number);
void meta_compositor_hide_tile_preview (MetaCompositor *compositor);
void meta_compositor_show_window_menu (MetaCompositor *compositor,
MetaWindow *window);
MetaWindow *window,
int x,
int y);
#endif /* META_COMPOSITOR_H */

View File

@ -165,7 +165,9 @@ struct _MetaPluginClass
void (*hide_tile_preview) (MetaPlugin *plugin);
void (*show_window_menu) (MetaPlugin *plugin,
MetaWindow *window);
MetaWindow *window,
int x,
int y);
/**
* MetaPluginClass::kill_window_effects:

View File

@ -1101,6 +1101,8 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
case G_DESKTOP_TITLEBAR_ACTION_MENU:
meta_core_show_window_menu (display,
frame->xwindow,
event->x_root,
event->y_root,
event->time);
break;
}
@ -1210,9 +1212,29 @@ meta_frames_button_press_event (GtkWidget *widget,
redraw_control (frames, frame, control);
if (control == META_FRAME_CONTROL_MENU)
meta_core_show_window_menu (display,
frame->xwindow,
event->time);
{
MetaFrameGeometry fgeom;
GdkRectangle *rect;
int dx, dy;
meta_frames_calc_geometry (frames, frame, &fgeom);
rect = control_rect (META_FRAME_CONTROL_MENU, &fgeom);
/* get delta to convert to root coords */
dx = event->x_root - event->x;
dy = 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;
meta_core_show_window_menu (display,
frame->xwindow,
rect->x + dx,
rect->y + rect->height + dy,
event->time);
}
}
else if (event->button == 1 &&
(control == META_FRAME_CONTROL_RESIZE_SE ||

View File

@ -2729,7 +2729,13 @@ meta_window_x11_client_message (MetaWindow *window,
else if (event->xclient.message_type ==
display->atom__GTK_SHOW_WINDOW_MENU)
{
meta_window_show_menu (window);
gulong x, y;
/* l[0] is device_id, which we don't use */
x = event->xclient.data.l[1];
y = event->xclient.data.l[2];
meta_window_show_menu (window, x, y);
}
return FALSE;