[gtk: 2/3] gtk/windowhandle: Delegate titlebar action to the compositor if possible
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 2/3] gtk/windowhandle: Delegate titlebar action to the compositor if possible
- Date: Mon, 2 Aug 2021 01:14:10 +0000 (UTC)
commit 23e79d2eb2bc9aa4b630ab2dee4b38a8fc70af5c
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jul 29 04:00:22 2021 +0200
gtk/windowhandle: Delegate titlebar action to the compositor if possible
Delegating the action to the compositor not only improves consistency
with server-side decorations, but also allows for actions that aren't
available client-side (like lower-in-middle-click).
https://gitlab.gnome.org/GNOME/mutter/-/issues/602
gtk/gtkwindowhandle.c | 52 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkwindowhandle.c b/gtk/gtkwindowhandle.c
index 1cf9067405..b1494043f2 100644
--- a/gtk/gtkwindowhandle.c
+++ b/gtk/gtkwindowhandle.c
@@ -266,26 +266,24 @@ do_popup (GtkWindowHandle *self,
}
static gboolean
-perform_titlebar_action (GtkWindowHandle *self,
- GdkEvent *event,
- guint button,
- int n_press)
+perform_titlebar_action_fallback (GtkWindowHandle *self,
+ GdkEvent *event,
+ GdkTitlebarGesture gesture)
{
GtkSettings *settings;
char *action = NULL;
gboolean retval = TRUE;
settings = gtk_widget_get_settings (GTK_WIDGET (self));
- switch (button)
+ switch (gesture)
{
- case GDK_BUTTON_PRIMARY:
- if (n_press == 2)
- g_object_get (settings, "gtk-titlebar-double-click", &action, NULL);
+ case GDK_TITLEBAR_GESTURE_DOUBLE_CLICK:
+ g_object_get (settings, "gtk-titlebar-double-click", &action, NULL);
break;
- case GDK_BUTTON_MIDDLE:
+ case GDK_TITLEBAR_GESTURE_MIDDLE_CLICK:
g_object_get (settings, "gtk-titlebar-middle-click", &action, NULL);
break;
- case GDK_BUTTON_SECONDARY:
+ case GDK_TITLEBAR_GESTURE_RIGHT_CLICK:
g_object_get (settings, "gtk-titlebar-right-click", &action, NULL);
break;
default:
@@ -320,6 +318,40 @@ perform_titlebar_action (GtkWindowHandle *self,
return retval;
}
+static gboolean
+perform_titlebar_action (GtkWindowHandle *self,
+ GdkEvent *event,
+ guint button,
+ int n_press)
+{
+ GdkSurface *surface =
+ gtk_native_get_surface (gtk_widget_get_native (GTK_WIDGET (self)));
+ GdkTitlebarGesture gesture;
+
+ switch (button)
+ {
+ case GDK_BUTTON_PRIMARY:
+ if (n_press == 2)
+ gesture = GDK_TITLEBAR_GESTURE_DOUBLE_CLICK;
+ else
+ return FALSE;
+ break;
+ case GDK_BUTTON_MIDDLE:
+ gesture = GDK_TITLEBAR_GESTURE_MIDDLE_CLICK;
+ break;
+ case GDK_BUTTON_SECONDARY:
+ gesture = GDK_TITLEBAR_GESTURE_RIGHT_CLICK;
+ break;
+ default:
+ break;
+ }
+
+ if (gdk_toplevel_titlebar_gesture (GDK_TOPLEVEL (surface), gesture))
+ return TRUE;
+
+ return perform_titlebar_action_fallback (self, event, gesture);
+}
+
static void
click_gesture_pressed_cb (GtkGestureClick *gesture,
int n_press,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]