[mutter/wip/compositor-menu: 13/13] wayland: Add support for show_window_menu



commit 27bec68c67464f72379d48d1ba3d6a7b81979a5b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Mar 13 16:54:04 2014 -0400

    wayland: Add support for show_window_menu

 protocol/xdg-shell.xml             |   14 ++++++++++++++
 src/wayland/meta-wayland-surface.c |   18 ++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/protocol/xdg-shell.xml b/protocol/xdg-shell.xml
index 47ff260..4d2dfd9 100644
--- a/protocol/xdg-shell.xml
+++ b/protocol/xdg-shell.xml
@@ -218,6 +218,20 @@
       <arg name="surface_type" type="uint" summary="a surface type from surface_type"/>
     </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.
+
+        The seat passed must have either pointer or keyboard focus to pop
+        up the window menu for a surface.
+      </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"/>
+    </request>
+
     <request name="move">
       <description summary="start an interactive move">
        Start a pointer-driven move of the surface.
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 2f386ec..4a304f1 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -775,6 +775,23 @@ xdg_surface_set_surface_type (struct wl_client *client,
                         window_type_from_surface_type (surface_type));
 }
 
+static void
+xdg_surface_show_window_menu (struct wl_client *client,
+                              struct wl_resource *resource,
+                              struct wl_resource *seat_resource,
+                              uint32_t serial)
+{
+  MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
+  MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
+
+  if (seat->pointer.button_count == 0 ||
+      seat->pointer.grab_serial != serial ||
+      seat->pointer.focus_surface != surface)
+    return;
+
+  meta_window_show_menu (surface->window);
+}
+
 static gboolean
 begin_grab_op_on_surface (MetaWaylandSurface *surface,
                           MetaWaylandSeat    *seat,
@@ -925,6 +942,7 @@ static const struct xdg_surface_interface meta_wayland_xdg_surface_interface = {
   xdg_surface_set_title,
   xdg_surface_set_app_id,
   xdg_surface_set_surface_type,
+  xdg_surface_show_window_menu,
   xdg_surface_move,
   xdg_surface_resize,
   xdg_surface_set_output,


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