mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
Actually implement opening the app menu
The last commit added support for the "appmenu" button in decorations, but didn't actually implement it. Add a new MetaWindowMenuType parameter to the show_window_menu () functions and use it to ask the compositor to display the app menu when the new button is activated. https://bugzilla.gnome.org/show_bug.cgi?id=730752
This commit is contained in:
parent
c2ea650b3c
commit
31db32e826
@ -1360,8 +1360,9 @@ meta_compositor_hide_tile_preview (MetaCompositor *compositor)
|
|||||||
void
|
void
|
||||||
meta_compositor_show_window_menu (MetaCompositor *compositor,
|
meta_compositor_show_window_menu (MetaCompositor *compositor,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y)
|
int y)
|
||||||
{
|
{
|
||||||
meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, x, y);
|
meta_plugin_manager_show_window_menu (compositor->plugin_mgr, window, menu, x, y);
|
||||||
}
|
}
|
||||||
|
@ -360,6 +360,7 @@ meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
|
|||||||
void
|
void
|
||||||
meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
|
meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y)
|
int y)
|
||||||
{
|
{
|
||||||
@ -371,5 +372,5 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (klass->show_window_menu)
|
if (klass->show_window_menu)
|
||||||
klass->show_window_menu (plugin, window, x, y);
|
klass->show_window_menu (plugin, window, menu, x, y);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,9 @@ gboolean meta_plugin_manager_hide_tile_preview (MetaPluginManager *mgr);
|
|||||||
|
|
||||||
void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
|
void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -376,6 +376,7 @@ meta_core_change_workspace (Display *xdisplay,
|
|||||||
void
|
void
|
||||||
meta_core_show_window_menu (Display *xdisplay,
|
meta_core_show_window_menu (Display *xdisplay,
|
||||||
Window frame_xwindow,
|
Window frame_xwindow,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int root_x,
|
int root_x,
|
||||||
int root_y,
|
int root_y,
|
||||||
guint32 timestamp)
|
guint32 timestamp)
|
||||||
@ -386,7 +387,7 @@ meta_core_show_window_menu (Display *xdisplay,
|
|||||||
meta_window_raise (window);
|
meta_window_raise (window);
|
||||||
meta_window_focus (window, timestamp);
|
meta_window_focus (window, timestamp);
|
||||||
|
|
||||||
meta_window_show_menu (window, root_x, root_y);
|
meta_window_show_menu (window, menu, root_x, root_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
|
@ -134,11 +134,11 @@ const char* meta_core_get_workspace_name_with_index (Display *xdisplay,
|
|||||||
|
|
||||||
void meta_core_show_window_menu (Display *xdisplay,
|
void meta_core_show_window_menu (Display *xdisplay,
|
||||||
Window frame_xwindow,
|
Window frame_xwindow,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int root_x,
|
int root_x,
|
||||||
int root_y,
|
int root_y,
|
||||||
guint32 timestamp);
|
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,
|
||||||
|
@ -2751,7 +2751,7 @@ handle_activate_window_menu (MetaDisplay *display,
|
|||||||
x += child_rect.width;
|
x += child_rect.width;
|
||||||
|
|
||||||
y = frame_rect.y + child_rect.y;
|
y = frame_rect.y + child_rect.y;
|
||||||
meta_window_show_menu (display->focus_window, x, y);
|
meta_window_show_menu (display->focus_window, META_WINDOW_MENU_WM, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,6 +606,7 @@ void meta_window_set_focused_internal (MetaWindow *window,
|
|||||||
void meta_window_current_workspace_changed (MetaWindow *window);
|
void meta_window_current_workspace_changed (MetaWindow *window);
|
||||||
|
|
||||||
void meta_window_show_menu (MetaWindow *window,
|
void meta_window_show_menu (MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
|
||||||
|
@ -5315,11 +5315,12 @@ meta_window_recalc_features (MetaWindow *window)
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_window_show_menu (MetaWindow *window,
|
meta_window_show_menu (MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y)
|
int y)
|
||||||
{
|
{
|
||||||
g_return_if_fail (!window->override_redirect);
|
g_return_if_fail (!window->override_redirect);
|
||||||
meta_compositor_show_window_menu (window->display->compositor, window, x, y);
|
meta_compositor_show_window_menu (window->display->compositor, window, menu, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -7980,6 +7981,7 @@ meta_window_handle_ungrabbed_event (MetaWindow *window,
|
|||||||
if (meta_prefs_get_raise_on_click ())
|
if (meta_prefs_get_raise_on_click ())
|
||||||
meta_window_raise (window);
|
meta_window_raise (window);
|
||||||
meta_window_show_menu (window,
|
meta_window_show_menu (window,
|
||||||
|
META_WINDOW_MENU_WM,
|
||||||
event->button.x,
|
event->button.x,
|
||||||
event->button.y);
|
event->button.y);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -387,6 +387,19 @@ struct _MetaButtonLayout
|
|||||||
gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
|
gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MetaWindowMenuType:
|
||||||
|
* @META_WINDOW_MENU_WM: the window manager menu
|
||||||
|
* @META_WINDOW_MENU_APP: the (fallback) app menu
|
||||||
|
*
|
||||||
|
* Menu the compositor should display for a given window
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
META_WINDOW_MENU_WM,
|
||||||
|
META_WINDOW_MENU_APP
|
||||||
|
} MetaWindowMenuType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MetaFrameBorders:
|
* MetaFrameBorders:
|
||||||
* @visible: inner visible portion of frame border
|
* @visible: inner visible portion of frame border
|
||||||
|
@ -124,6 +124,7 @@ void meta_compositor_show_tile_preview (MetaCompositor *compositor,
|
|||||||
void meta_compositor_hide_tile_preview (MetaCompositor *compositor);
|
void meta_compositor_hide_tile_preview (MetaCompositor *compositor);
|
||||||
void meta_compositor_show_window_menu (MetaCompositor *compositor,
|
void meta_compositor_show_window_menu (MetaCompositor *compositor,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
|
||||||
|
@ -166,6 +166,7 @@ struct _MetaPluginClass
|
|||||||
|
|
||||||
void (*show_window_menu) (MetaPlugin *plugin,
|
void (*show_window_menu) (MetaPlugin *plugin,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
|
MetaWindowMenuType menu,
|
||||||
int x,
|
int x,
|
||||||
int y);
|
int y);
|
||||||
|
|
||||||
|
@ -1101,6 +1101,7 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
|
|||||||
case G_DESKTOP_TITLEBAR_ACTION_MENU:
|
case G_DESKTOP_TITLEBAR_ACTION_MENU:
|
||||||
meta_core_show_window_menu (display,
|
meta_core_show_window_menu (display,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
|
META_WINDOW_MENU_WM,
|
||||||
event->x_root,
|
event->x_root,
|
||||||
event->y_root,
|
event->y_root,
|
||||||
event->time);
|
event->time);
|
||||||
@ -1202,7 +1203,8 @@ meta_frames_button_press_event (GtkWidget *widget,
|
|||||||
control == META_FRAME_CONTROL_UNABOVE ||
|
control == META_FRAME_CONTROL_UNABOVE ||
|
||||||
control == META_FRAME_CONTROL_STICK ||
|
control == META_FRAME_CONTROL_STICK ||
|
||||||
control == META_FRAME_CONTROL_UNSTICK ||
|
control == META_FRAME_CONTROL_UNSTICK ||
|
||||||
control == META_FRAME_CONTROL_MENU))
|
control == META_FRAME_CONTROL_MENU ||
|
||||||
|
control == META_FRAME_CONTROL_APPMENU))
|
||||||
{
|
{
|
||||||
frames->grab_xwindow = frame->xwindow;
|
frames->grab_xwindow = frame->xwindow;
|
||||||
|
|
||||||
@ -1211,15 +1213,17 @@ meta_frames_button_press_event (GtkWidget *widget,
|
|||||||
frame->prelit_control = control;
|
frame->prelit_control = control;
|
||||||
redraw_control (frames, frame, control);
|
redraw_control (frames, frame, control);
|
||||||
|
|
||||||
if (control == META_FRAME_CONTROL_MENU)
|
if (control == META_FRAME_CONTROL_MENU ||
|
||||||
|
control == META_FRAME_CONTROL_APPMENU)
|
||||||
{
|
{
|
||||||
MetaFrameGeometry fgeom;
|
MetaFrameGeometry fgeom;
|
||||||
GdkRectangle *rect;
|
GdkRectangle *rect;
|
||||||
|
MetaWindowMenuType menu;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
|
||||||
meta_frames_calc_geometry (frames, frame, &fgeom);
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
||||||
|
|
||||||
rect = control_rect (META_FRAME_CONTROL_MENU, &fgeom);
|
rect = control_rect (control, &fgeom);
|
||||||
|
|
||||||
/* get delta to convert to root coords */
|
/* get delta to convert to root coords */
|
||||||
dx = event->x_root - event->x;
|
dx = event->x_root - event->x;
|
||||||
@ -1229,8 +1233,12 @@ meta_frames_button_press_event (GtkWidget *widget,
|
|||||||
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
|
||||||
dx += rect->width;
|
dx += rect->width;
|
||||||
|
|
||||||
|
menu = control == META_FRAME_CONTROL_MENU ? META_WINDOW_MENU_WM
|
||||||
|
: META_WINDOW_MENU_APP;
|
||||||
|
|
||||||
meta_core_show_window_menu (display,
|
meta_core_show_window_menu (display,
|
||||||
frame->xwindow,
|
frame->xwindow,
|
||||||
|
menu,
|
||||||
rect->x + dx,
|
rect->x + dx,
|
||||||
rect->y + rect->height + dy,
|
rect->y + rect->height + dy,
|
||||||
event->time);
|
event->time);
|
||||||
|
@ -784,7 +784,7 @@ xdg_surface_show_window_menu (struct wl_client *client,
|
|||||||
if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
|
if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
meta_window_show_menu (surface->window, x, y);
|
meta_window_show_menu (surface->window, META_WINDOW_MENU_WM, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -2723,7 +2723,7 @@ meta_window_x11_client_message (MetaWindow *window,
|
|||||||
x = event->xclient.data.l[1];
|
x = event->xclient.data.l[1];
|
||||||
y = event->xclient.data.l[2];
|
y = event->xclient.data.l[2];
|
||||||
|
|
||||||
meta_window_show_menu (window, x, y);
|
meta_window_show_menu (window, META_WINDOW_MENU_WM, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user