[mutter] wayland/gtk-shell: Add titlebar_gesture request
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland/gtk-shell: Add titlebar_gesture request
- Date: Wed, 4 Aug 2021 15:07:30 +0000 (UTC)
commit 111055acdd5433c648509e190509d861fb1ef03a
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jul 29 02:42:18 2021 +0200
wayland/gtk-shell: Add titlebar_gesture request
This allows client to delegate titlebar gestures to the compositor,
which allows for better consistency with server-side decorations,
and a wider range of actions (including lower-on-middle-click).
The protocol addition is based on a suggestion from Carlos Garnacho
and Jonas Ådahl.
https://gitlab.gnome.org/GNOME/mutter/-/issues/602
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1944>
src/wayland/meta-wayland-gtk-shell.c | 93 +++++++++++++++++++++++++++++++++++-
src/wayland/meta-wayland-versions.h | 2 +-
src/wayland/protocol/gtk-shell.xml | 21 +++++++-
3 files changed, 112 insertions(+), 4 deletions(-)
---
diff --git a/src/wayland/meta-wayland-gtk-shell.c b/src/wayland/meta-wayland-gtk-shell.c
index 12e1b0e4a9..1ec5ffdf45 100644
--- a/src/wayland/meta-wayland-gtk-shell.c
+++ b/src/wayland/meta-wayland-gtk-shell.c
@@ -208,6 +208,96 @@ gtk_surface_request_focus (struct wl_client *client,
}
}
+static void
+gtk_surface_titlebar_gesture (struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t serial,
+ struct wl_resource *seat_resource,
+ uint32_t gesture)
+{
+ MetaWaylandGtkSurface *gtk_surface = wl_resource_get_user_data (resource);
+ MetaWaylandSurface *surface = gtk_surface->surface;
+ MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
+ GDesktopTitlebarAction action = G_DESKTOP_TITLEBAR_ACTION_NONE;
+ MetaWindow *window;
+ float x, y;
+
+ if (!surface)
+ return;
+
+ window = meta_wayland_surface_get_window (surface);
+ if (!window)
+ return;
+
+ if (!meta_wayland_seat_get_grab_info (seat, surface, serial, FALSE, &x, &y))
+ return;
+
+ switch (gesture)
+ {
+ case GTK_SURFACE1_GESTURE_DOUBLE_CLICK:
+ action = meta_prefs_get_action_double_click_titlebar ();
+ break;
+ case GTK_SURFACE1_GESTURE_RIGHT_CLICK:
+ action = meta_prefs_get_action_right_click_titlebar ();
+ break;
+ case GTK_SURFACE1_GESTURE_MIDDLE_CLICK:
+ action = meta_prefs_get_action_middle_click_titlebar ();
+ break;
+ default:
+ wl_resource_post_error (resource,
+ GTK_SURFACE1_ERROR_INVALID_GESTURE,
+ "Invalid gesture passed");
+ break;
+ }
+
+ switch (action)
+ {
+ case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE:
+ if (META_WINDOW_MAXIMIZED (window))
+ meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
+ else
+ meta_window_maximize (window, META_MAXIMIZE_BOTH);
+ break;
+
+ case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY:
+ if (META_WINDOW_MAXIMIZED_HORIZONTALLY (window))
+ meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL);
+ else
+ meta_window_maximize (window, META_MAXIMIZE_HORIZONTAL);
+ break;
+
+ case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE_VERTICALLY:
+ if (META_WINDOW_MAXIMIZED_VERTICALLY (window))
+ meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
+ else
+ meta_window_maximize (window, META_MAXIMIZE_VERTICAL);
+ break;
+
+ case G_DESKTOP_TITLEBAR_ACTION_MINIMIZE:
+ meta_window_minimize (window);
+ break;
+
+ case G_DESKTOP_TITLEBAR_ACTION_LOWER:
+ {
+ uint32_t timestamp;
+
+ timestamp = meta_display_get_current_time_roundtrip (window->display);
+ meta_window_lower_with_transients (window, timestamp);
+ }
+ break;
+
+ case G_DESKTOP_TITLEBAR_ACTION_MENU:
+ meta_window_show_menu (window, META_WINDOW_MENU_WM, x, y);
+ break;
+
+ case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_SHADE:
+ g_warning ("No shade! The library is closed.");
+ G_GNUC_FALLTHROUGH;
+ default:
+ return;
+ }
+}
+
static void
gtk_surface_release (struct wl_client *client,
struct wl_resource *resource)
@@ -221,7 +311,8 @@ static const struct gtk_surface1_interface meta_wayland_gtk_surface_interface =
gtk_surface_unset_modal,
gtk_surface_present,
gtk_surface_request_focus,
- gtk_surface_release
+ gtk_surface_release,
+ gtk_surface_titlebar_gesture
};
static void
diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h
index 05dd937b29..0e859b900a 100644
--- a/src/wayland/meta-wayland-versions.h
+++ b/src/wayland/meta-wayland-versions.h
@@ -43,7 +43,7 @@
#define META_WL_SEAT_VERSION 5
#define META_WL_OUTPUT_VERSION 2
#define META_XSERVER_VERSION 1
-#define META_GTK_SHELL1_VERSION 4
+#define META_GTK_SHELL1_VERSION 5
#define META_WL_SUBCOMPOSITOR_VERSION 1
#define META_ZWP_POINTER_GESTURES_V1_VERSION 1
#define META_ZXDG_EXPORTER_V1_VERSION 1
diff --git a/src/wayland/protocol/gtk-shell.xml b/src/wayland/protocol/gtk-shell.xml
index 1aab593c42..a8d51c65d3 100644
--- a/src/wayland/protocol/gtk-shell.xml
+++ b/src/wayland/protocol/gtk-shell.xml
@@ -1,6 +1,6 @@
<protocol name="gtk">
- <interface name="gtk_shell1" version="4">
+ <interface name="gtk_shell1" version="5">
<description summary="gtk specific extensions">
gtk_shell is a protocol extension providing additional features for
clients implementing it.
@@ -35,7 +35,7 @@
</request>
</interface>
- <interface name="gtk_surface1" version="4">
+ <interface name="gtk_surface1" version="5">
<request name="set_dbus_properties">
<arg name="application_id" type="string" allow-null="true"/>
<arg name="app_menu_path" type="string" allow-null="true"/>
@@ -85,6 +85,23 @@
<!-- Version 4 additions -->
<request name="release" type="destructor" since="4"/>
+
+ <!-- Version 5 additions -->
+ <enum name="gesture" since="5">
+ <entry name="double_click" value="1"/>
+ <entry name="right_click" value="2"/>
+ <entry name="middle_click" value="3"/>
+ </enum>
+
+ <enum name="error" since="5">
+ <entry name="invalid_gesture" value="0"/>
+ </enum>
+
+ <request name="titlebar_gesture" since="5">
+ <arg name="serial" type="uint"/>
+ <arg name="seat" type="object" interface="wl_seat"/>
+ <arg name="gesture" type="uint" enum="gesture"/>
+ </request>
</interface>
</protocol>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]