wayland/gtk: Only perform allowed titlebar gestures

The window functions "work" regardless of whether the client allows
the behavior or not. That is, it's up to the caller to not call
maximize and friends when the action isn't allowed.

Add appropriate checks, which should make the titlebar_gesture()
behavior identical to titlebar actions for server-side decorations.

https://gitlab.gnome.org/GNOME/mutter/-/issues/2139

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2281>
This commit is contained in:
Florian Müllner 2022-02-10 19:51:16 +01:00
parent 338eea7a37
commit 7ff52b6128

View File

@ -253,6 +253,9 @@ gtk_surface_titlebar_gesture (struct wl_client *client,
switch (action) switch (action)
{ {
case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE: case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE:
if (!window->has_maximize_func)
break;
if (META_WINDOW_MAXIMIZED (window)) if (META_WINDOW_MAXIMIZED (window))
meta_window_unmaximize (window, META_MAXIMIZE_BOTH); meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
else else
@ -260,6 +263,9 @@ gtk_surface_titlebar_gesture (struct wl_client *client,
break; break;
case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY: case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE_HORIZONTALLY:
if (!window->has_maximize_func)
break;
if (META_WINDOW_MAXIMIZED_HORIZONTALLY (window)) if (META_WINDOW_MAXIMIZED_HORIZONTALLY (window))
meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL); meta_window_unmaximize (window, META_MAXIMIZE_HORIZONTAL);
else else
@ -267,6 +273,9 @@ gtk_surface_titlebar_gesture (struct wl_client *client,
break; break;
case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE_VERTICALLY: case G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE_VERTICALLY:
if (!window->has_maximize_func)
break;
if (META_WINDOW_MAXIMIZED_VERTICALLY (window)) if (META_WINDOW_MAXIMIZED_VERTICALLY (window))
meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL); meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL);
else else
@ -274,6 +283,9 @@ gtk_surface_titlebar_gesture (struct wl_client *client,
break; break;
case G_DESKTOP_TITLEBAR_ACTION_MINIMIZE: case G_DESKTOP_TITLEBAR_ACTION_MINIMIZE:
if (!window->has_minimize_func)
break;
meta_window_minimize (window); meta_window_minimize (window);
break; break;