[gtk+] wayland: Add support for show_window_menu



commit 0d402601b2b857a04c0d049d1c80457267b5bf6e
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri May 23 23:01:27 2014 -0400

    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(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 7f67e1b..14ffc57 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 3c18610..28add40 100644
--- a/gdk/wayland/protocol/xdg-shell.xml
+++ b/gdk/wayland/protocol/xdg-shell.xml
@@ -198,6 +198,26 @@
       <arg name="app_id" type="string"/>
     </request>
 
+    <request name="show_window_menu">
+      <description summary="show the window menu">
+        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.
+      </description>
+
+      <arg name="seat" type="object" interface="wl_seat" summary="the seat to pop the window up on"/>
+      <arg name="serial" type="uint" summary="serial of the event to pop up the window for"/>
+      <arg name="x" type="int" summary="the x position to pop up the window menu at"/>
+      <arg name="y" type="int" summary="the y position to pop up the window menu at"/>
+    </request>
+
     <request name="move">
       <description summary="start an interactive move">
        Start a pointer-driven move of the surface.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]