mutter/mutter-wayland-fixes.patch

197 lines
8.0 KiB
Diff

From 07f6c85cc737b2f7d106490cc4d336f2404ac9b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Tue, 12 Sep 2017 12:20:31 +0800
Subject: wayland/inhibit-shortcuts-dialog: Use g_new0 instead of g_new
The code assumed the newly allocated blocked was initialized to 0, but
it wasn't since g_new was used. Fix that by using g_new0.
https://bugzilla.gnome.org/show_bug.cgi?id=787570
---
src/wayland/meta-wayland-inhibit-shortcuts-dialog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
index da897b9..5f883f7 100644
--- a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
+++ b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
@@ -112,7 +112,7 @@ meta_wayland_surface_ensure_inhibit_shortcuts_dialog (MetaWaylandSurface *surfac
if (data)
return data;
- data = g_new (InhibitShortcutsData, 1);
+ data = g_new0 (InhibitShortcutsData, 1);
surface_inhibit_shortcuts_data_set (surface, data);
g_signal_connect (surface, "destroy",
G_CALLBACK (on_surface_destroyed),
--
cgit v0.12
From 9c16e4e2f3c198d3ac6a13b02b63b91f3ab56850 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofourdan@redhat.com>
Date: Tue, 12 Sep 2017 09:39:24 +0200
Subject: wayland: Keep the inhibit shortcut dialog
On Wayland, the grab()/ungrab() in gtk+/gdk are wired to the shortcut
inhibitor mechanism, which in turn shows the dialog, which can take
focus away from the client window when the dialog is shown.
If the client issues an ungrab() when the keyboard focus is lost, we
would hide the dialog, causing the keyboard focus to be returned to the
client surface, which in turn would issue a new grab(), so forth and so
on, causing a continuous show/hide of the shortcut inhibitor dialog.
To avoid this issue, keep the dialog around even if the shortcut inhibit
is canceled by the client, so that the user is forced to make a choice
that we can reuse on the next request without showing the dialog again.
Instead of hiding the dialog when the shortcut inhibitor is destroyed by
the client, we simply mark the request as canceled and do not apply the
user's choice.
https://bugzilla.gnome.org/show_bug.cgi?id=787568
---
src/wayland/meta-wayland-inhibit-shortcuts-dialog.c | 15 +++++++++++----
src/wayland/meta-wayland-inhibit-shortcuts-dialog.h | 2 +-
src/wayland/meta-wayland-inhibit-shortcuts.c | 2 +-
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
index 5f883f7..a432a41 100644
--- a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
+++ b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
@@ -32,6 +32,7 @@ typedef struct _InhibitShortcutsData
MetaInhibitShortcutsDialog *dialog;
gulong response_handler_id;
gboolean has_last_response;
+ gboolean request_canceled;
MetaInhibitShortcutsDialogResponse last_response;
} InhibitShortcutsData;
@@ -93,7 +94,10 @@ inhibit_shortcuts_dialog_response_cb (MetaInhibitShortcutsDialog *dialog,
{
data->last_response = response;
data->has_last_response = TRUE;
- inhibit_shortcuts_dialog_response_apply (data);
+
+ /* If the request was canceled, we don't need to apply the choice made */
+ if (!data->request_canceled)
+ inhibit_shortcuts_dialog_response_apply (data);
meta_inhibit_shortcuts_dialog_hide (data->dialog);
surface_inhibit_shortcuts_data_destroy_dialog (data);
@@ -154,11 +158,14 @@ meta_wayland_surface_show_inhibit_shortcuts_dialog (MetaWaylandSurface *surface,
}
data = meta_wayland_surface_ensure_inhibit_shortcuts_dialog (surface, seat);
+ /* This is a new request */
+ data->request_canceled = FALSE;
+
meta_inhibit_shortcuts_dialog_show (data->dialog);
}
void
-meta_wayland_surface_hide_inhibit_shortcuts_dialog (MetaWaylandSurface *surface)
+meta_wayland_surface_cancel_inhibit_shortcuts_dialog (MetaWaylandSurface *surface)
{
InhibitShortcutsData *data;
@@ -168,8 +175,8 @@ meta_wayland_surface_hide_inhibit_shortcuts_dialog (MetaWaylandSurface *surface)
data = surface_inhibit_shortcuts_data_get (surface);
g_return_if_fail (data);
- if (data->dialog)
- meta_inhibit_shortcuts_dialog_hide (data->dialog);
+ /* Keep the dialog on screen, but mark the request as canceled */
+ data->request_canceled = TRUE;
}
void
diff --git a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.h b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.h
index bd3fc42..a7d60cf 100644
--- a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.h
+++ b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.h
@@ -24,7 +24,7 @@
void meta_wayland_surface_show_inhibit_shortcuts_dialog (MetaWaylandSurface *surface,
MetaWaylandSeat *seat);
-void meta_wayland_surface_hide_inhibit_shortcuts_dialog (MetaWaylandSurface *surface);
+void meta_wayland_surface_cancel_inhibit_shortcuts_dialog (MetaWaylandSurface *surface);
void meta_wayland_surface_inhibit_shortcuts_dialog_init (void);
diff --git a/src/wayland/meta-wayland-inhibit-shortcuts.c b/src/wayland/meta-wayland-inhibit-shortcuts.c
index cd07891..a7ba3c2 100644
--- a/src/wayland/meta-wayland-inhibit-shortcuts.c
+++ b/src/wayland/meta-wayland-inhibit-shortcuts.c
@@ -49,7 +49,7 @@ zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client *client,
shortcut_inhibit = wl_resource_get_user_data (resource);
if (shortcut_inhibit->surface)
{
- meta_wayland_surface_hide_inhibit_shortcuts_dialog (shortcut_inhibit->surface);
+ meta_wayland_surface_cancel_inhibit_shortcuts_dialog (shortcut_inhibit->surface);
g_signal_handler_disconnect (shortcut_inhibit->surface,
shortcut_inhibit->surface_destroyed_handler);
--
cgit v0.12
From 2bf7974076ea99c9b30fe5b3d49456dba5a20c19 Mon Sep 17 00:00:00 2001
From: Olivier Fourdan <ofourdan@redhat.com>
Date: Tue, 12 Sep 2017 10:27:32 +0200
Subject: wayland: do not leak shortcut inhibit data
We would free the shortcut inhibit data only when the client destroys
its request, which is not the case when the clients itself is
destroyed, leading to a leak of the shortcut inhibit data.
Free the data on resource destruction instead, and simply destroy the
resource on destroy request.
https://bugzilla.gnome.org/show_bug.cgi?id=787568
---
src/wayland/meta-wayland-inhibit-shortcuts.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/wayland/meta-wayland-inhibit-shortcuts.c b/src/wayland/meta-wayland-inhibit-shortcuts.c
index a7ba3c2..8e5ed24 100644
--- a/src/wayland/meta-wayland-inhibit-shortcuts.c
+++ b/src/wayland/meta-wayland-inhibit-shortcuts.c
@@ -41,8 +41,7 @@ struct _MetaWaylandKeyboardShotscutsInhibit
};
static void
-zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client *client,
- struct wl_resource *resource)
+zwp_keyboard_shortcuts_inhibit_destructor (struct wl_resource *resource)
{
MetaWaylandKeyboardShotscutsInhibit *shortcut_inhibit;
@@ -64,6 +63,12 @@ zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client *client,
shortcut_inhibit->seat);
}
g_free (shortcut_inhibit);
+}
+
+static void
+zwp_keyboard_shortcuts_inhibit_destroy (struct wl_client *client,
+ struct wl_resource *resource)
+{
wl_resource_destroy (resource);
}
@@ -148,7 +153,7 @@ zwp_keyboard_shortcuts_inhibit_manager_inhibit_shortcuts (struct wl_client *cl
wl_resource_set_implementation (keyboard_shortcuts_inhibit_resource,
&meta_keyboard_shortcuts_inhibit_interface,
shortcut_inhibit,
- NULL);
+ zwp_keyboard_shortcuts_inhibit_destructor);
}
static const struct zwp_keyboard_shortcuts_inhibit_manager_v1_interface
--
cgit v0.12