From 0d402601b2b857a04c0d049d1c80457267b5bf6e Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 23 May 2014 23:01:27 -0400 Subject: [PATCH] wayland: Add support for show_window_menu --- gdk/wayland/gdkwindow-wayland.c | 35 ++++++++++++++++++++++++++++++ gdk/wayland/protocol/xdg-shell.xml | 20 +++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 7f67e1be85..14ffc5706b 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -1934,6 +1934,40 @@ gdk_wayland_window_set_shadow_width (GdkWindow *window, gdk_wayland_window_sync_margin (window); } +static gboolean +gdk_wayland_window_show_window_menu (GdkWindow *window, + GdkEvent *event) +{ + GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + GdkEventButton *event_button = (GdkEventButton *) event; + struct wl_seat *seat; + double x, y; + GdkWaylandDeviceData *device; + + switch (event->type) + { + case GDK_BUTTON_PRESS: + case GDK_BUTTON_RELEASE: + break; + default: + return FALSE; + } + + if (!impl->xdg_surface) + return FALSE; + + seat = gdk_wayland_device_get_wl_seat (event_button->device); + device = wl_seat_get_user_data (seat); + + gdk_event_get_coords (event, &x, &y); + + xdg_surface_show_window_menu (impl->xdg_surface, + seat, + _gdk_wayland_device_get_button_press_serial (device), + x, y); + return TRUE; +} + static void _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass) { @@ -2023,6 +2057,7 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass) impl_class->get_scale_factor = gdk_wayland_window_get_scale_factor; impl_class->set_opaque_region = gdk_wayland_window_set_opaque_region; impl_class->set_shadow_width = gdk_wayland_window_set_shadow_width; + impl_class->show_window_menu = gdk_wayland_window_show_window_menu; } void diff --git a/gdk/wayland/protocol/xdg-shell.xml b/gdk/wayland/protocol/xdg-shell.xml index 3c186102bb..28add4054c 100644 --- a/gdk/wayland/protocol/xdg-shell.xml +++ b/gdk/wayland/protocol/xdg-shell.xml @@ -198,6 +198,26 @@ + + + Clients implementing client-side decorations might want to show + a context menu when right-clicking on the decorations, giving the + user a menu that they can use to maximize or minimize the window. + + This request asks the compositor to pop up such a window menu at + the given position, relative to the parent surface. There are + no guarantees as to what the window menu contains. + + Your surface must have focus on the seat passed in to pop up the + window menu. + + + + + + + + Start a pointer-driven move of the surface.