1
0
Fork 0

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:
Florian Müllner 2014-05-23 23:14:51 +02:00
parent c2ea650b3c
commit 31db32e826
14 changed files with 78 additions and 47 deletions

View file

@ -1358,10 +1358,11 @@ meta_compositor_hide_tile_preview (MetaCompositor *compositor)
}
void
meta_compositor_show_window_menu (MetaCompositor *compositor,
MetaWindow *window,
int x,
int y)
meta_compositor_show_window_menu (MetaCompositor *compositor,
MetaWindow *window,
MetaWindowMenuType menu,
int x,
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);
}

View file

@ -358,10 +358,11 @@ meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
}
void
meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
MetaWindow *window,
int x,
int y)
meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
MetaWindow *window,
MetaWindowMenuType menu,
int x,
int y)
{
MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
@ -371,5 +372,5 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
return;
if (klass->show_window_menu)
klass->show_window_menu (plugin, window, x, y);
klass->show_window_menu (plugin, window, menu, x, y);
}

View file

@ -81,9 +81,11 @@ gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr,
int tile_monitor_number);
gboolean meta_plugin_manager_hide_tile_preview (MetaPluginManager *mgr);
void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
MetaWindow *window,
int x,
int y);
void meta_plugin_manager_show_window_menu (MetaPluginManager *mgr,
MetaWindow *window,
MetaWindowMenuType menu,
int x,
int y);
#endif

View file

@ -374,11 +374,12 @@ 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)
meta_core_show_window_menu (Display *xdisplay,
Window frame_xwindow,
MetaWindowMenuType menu,
int root_x,
int root_y,
guint32 timestamp)
{
MetaWindow *window = get_window (xdisplay, frame_xwindow);
@ -386,7 +387,7 @@ meta_core_show_window_menu (Display *xdisplay,
meta_window_raise (window);
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*

View file

@ -132,12 +132,12 @@ const char* meta_core_get_workspace_name_with_index (Display *xdisplay,
Window xroot,
int index);
void meta_core_show_window_menu (Display *xdisplay,
Window frame_xwindow,
int root_x,
int root_y,
guint32 timestamp);
void meta_core_show_window_menu (Display *xdisplay,
Window frame_xwindow,
MetaWindowMenuType menu,
int root_x,
int root_y,
guint32 timestamp);
gboolean meta_core_begin_grab_op (Display *xdisplay,
Window frame_xwindow,

View file

@ -2751,7 +2751,7 @@ handle_activate_window_menu (MetaDisplay *display,
x += child_rect.width;
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);
}
}

View file

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

View file

@ -5314,12 +5314,13 @@ meta_window_recalc_features (MetaWindow *window)
}
void
meta_window_show_menu (MetaWindow *window,
int x,
int y)
meta_window_show_menu (MetaWindow *window,
MetaWindowMenuType menu,
int x,
int y)
{
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
@ -7980,6 +7981,7 @@ 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_MENU_WM,
event->button.x,
event->button.y);
return TRUE;

View file

@ -387,6 +387,19 @@ struct _MetaButtonLayout
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:
* @visible: inner visible portion of frame border

View file

@ -122,9 +122,10 @@ void meta_compositor_show_tile_preview (MetaCompositor *compositor,
MetaRectangle *tile_rect,
int tile_monitor_number);
void meta_compositor_hide_tile_preview (MetaCompositor *compositor);
void meta_compositor_show_window_menu (MetaCompositor *compositor,
MetaWindow *window,
int x,
int y);
void meta_compositor_show_window_menu (MetaCompositor *compositor,
MetaWindow *window,
MetaWindowMenuType menu,
int x,
int y);
#endif /* META_COMPOSITOR_H */

View file

@ -164,10 +164,11 @@ struct _MetaPluginClass
int tile_monitor_number);
void (*hide_tile_preview) (MetaPlugin *plugin);
void (*show_window_menu) (MetaPlugin *plugin,
MetaWindow *window,
int x,
int y);
void (*show_window_menu) (MetaPlugin *plugin,
MetaWindow *window,
MetaWindowMenuType menu,
int x,
int y);
/**
* MetaPluginClass::kill_window_effects:

View file

@ -1101,6 +1101,7 @@ meta_frame_titlebar_event (MetaUIFrame *frame,
case G_DESKTOP_TITLEBAR_ACTION_MENU:
meta_core_show_window_menu (display,
frame->xwindow,
META_WINDOW_MENU_WM,
event->x_root,
event->y_root,
event->time);
@ -1202,7 +1203,8 @@ meta_frames_button_press_event (GtkWidget *widget,
control == META_FRAME_CONTROL_UNABOVE ||
control == META_FRAME_CONTROL_STICK ||
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;
@ -1211,15 +1213,17 @@ meta_frames_button_press_event (GtkWidget *widget,
frame->prelit_control = 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;
GdkRectangle *rect;
MetaWindowMenuType menu;
int dx, dy;
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 */
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)
dx += rect->width;
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);

View file

@ -784,7 +784,7 @@ xdg_surface_show_window_menu (struct wl_client *client,
if (!meta_wayland_seat_can_grab_surface (seat, surface, serial))
return;
meta_window_show_menu (surface->window, x, y);
meta_window_show_menu (surface->window, META_WINDOW_MENU_WM, x, y);
}
static gboolean

View file

@ -2723,7 +2723,7 @@ meta_window_x11_client_message (MetaWindow *window,
x = event->xclient.data.l[1];
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;