mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
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
This commit is contained in:
parent
0c7b1431d7
commit
23e79d2eb2
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user