Blame SOURCES/0001-compositor-Ignore-some-of-the-builtin-keybindings.patch

f5e75e
From 28a560fdc1a8571d0e1d34da5cb57f43d2fe1a54 Mon Sep 17 00:00:00 2001
f5e75e
From: Ray Strode <rstrode@redhat.com>
f5e75e
Date: Wed, 11 Aug 2021 14:47:05 -0400
f5e75e
Subject: [PATCH 1/6] compositor: Ignore some of the builtin keybindings
f5e75e
f5e75e
Mutter on wayland currently has a bug where it crashes if the run dialog
f5e75e
keybinding is pressed. No one notices the bug for gnome-shell, since
f5e75e
gnome-shell overrides mutters run dialog keybinding.
f5e75e
f5e75e
This commit makes GNOME Kiosk also override the keybinding to avoid the
f5e75e
crash. At the same time it neuters a few other builtin keybindings that
f5e75e
aren't so useful to GNOME Kiosk.
f5e75e
---
f5e75e
 compositor/kiosk-compositor.c | 90 +++++++++++++++++++++++++++++++++++
f5e75e
 1 file changed, 90 insertions(+)
f5e75e
f5e75e
diff --git a/compositor/kiosk-compositor.c b/compositor/kiosk-compositor.c
f5e75e
index 43329c7..2db58ed 100644
f5e75e
--- a/compositor/kiosk-compositor.c
f5e75e
+++ b/compositor/kiosk-compositor.c
f5e75e
@@ -1,42 +1,43 @@
f5e75e
 #include "config.h"
f5e75e
 #include "kiosk-compositor.h"
f5e75e
 
f5e75e
 #include <stdlib.h>
f5e75e
 #include <string.h>
f5e75e
 
f5e75e
 #include <glib-object.h>
f5e75e
 
f5e75e
 #include <clutter/clutter.h>
f5e75e
 #include <clutter/x11/clutter-x11.h>
f5e75e
 #include <meta/common.h>
f5e75e
 #include <meta/display.h>
f5e75e
+#include <meta/keybindings.h>
f5e75e
 #include <meta/main.h>
f5e75e
 #include <meta/util.h>
f5e75e
 #include <meta/meta-window-group.h>
f5e75e
 
f5e75e
 #include <systemd/sd-daemon.h>
f5e75e
 
f5e75e
 #include "kiosk-backgrounds.h"
f5e75e
 #include "kiosk-input-sources-manager.h"
f5e75e
 #include "kiosk-service.h"
f5e75e
 
f5e75e
 #include "org.gnome.DisplayManager.Manager.h"
f5e75e
 
f5e75e
 struct _KioskCompositor
f5e75e
 {
f5e75e
         MetaPlugin parent;
f5e75e
 
f5e75e
         /* weak references */
f5e75e
         MetaDisplay *display;
f5e75e
         ClutterBackend *backend;
f5e75e
         ClutterActor *stage;
f5e75e
 
f5e75e
         /* strong references */
f5e75e
         GCancellable *cancellable;
f5e75e
         KioskBackgrounds *backgrounds;
f5e75e
         KioskInputSourcesManager *input_sources_manager;
f5e75e
         KioskService *service;
f5e75e
 };
f5e75e
 
f5e75e
 enum {
f5e75e
         X_SERVER_EVENT,
f5e75e
@@ -103,82 +104,171 @@ register_with_display_manager (KioskCompositor *self)
f5e75e
         g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
f5e75e
 
f5e75e
         gdm_manager_call_register_display_sync (display_manager,
f5e75e
                                                 g_variant_builder_end (&builder),
f5e75e
                                                 self->cancellable,
f5e75e
                                                 &error);
f5e75e
 
f5e75e
         if (error != NULL) {
f5e75e
                 g_debug ("KioskCompositor: Could not register with display manager: %s",
f5e75e
                          error->message);
f5e75e
                 return;
f5e75e
         }
f5e75e
 }
f5e75e
 
f5e75e
 static void
f5e75e
 register_with_systemd (KioskCompositor *self)
f5e75e
 {
f5e75e
         sd_notify (TRUE, "READY=1");
f5e75e
 }
f5e75e
 
f5e75e
 static void
f5e75e
 register_session (KioskCompositor *self)
f5e75e
 {
f5e75e
         meta_register_with_session ();
f5e75e
 
f5e75e
         register_with_display_manager (self);
f5e75e
 
f5e75e
         register_with_systemd (self);
f5e75e
 }
f5e75e
 
f5e75e
+static void
f5e75e
+on_builtin_keybinding_triggered (MetaDisplay     *display,
f5e75e
+                                 MetaWindow      *window,
f5e75e
+                                 ClutterKeyEvent *event,
f5e75e
+                                 MetaKeyBinding  *binding,
f5e75e
+                                 KioskCompositor *self)
f5e75e
+{
f5e75e
+        g_debug ("KioskCompositor: Ignoring '%s' request",
f5e75e
+                 meta_key_binding_get_name (binding));
f5e75e
+}
f5e75e
+
f5e75e
+static void
f5e75e
+neuter_builtin_keybindings (KioskCompositor *self)
f5e75e
+{
f5e75e
+        const char *builtin_keybindings[] = {
f5e75e
+                "switch-to-workspace-1",
f5e75e
+                "switch-to-workspace-2",
f5e75e
+                "switch-to-workspace-3",
f5e75e
+                "switch-to-workspace-4",
f5e75e
+                "switch-to-workspace-5",
f5e75e
+                "switch-to-workspace-6",
f5e75e
+                "switch-to-workspace-7",
f5e75e
+                "switch-to-workspace-8",
f5e75e
+                "switch-to-workspace-9",
f5e75e
+                "switch-to-workspace-10",
f5e75e
+                "switch-to-workspace-11",
f5e75e
+                "switch-to-workspace-12",
f5e75e
+                "switch-to-workspace-left",
f5e75e
+                "switch-to-workspace-right",
f5e75e
+                "switch-to-workspace-up",
f5e75e
+                "switch-to-workspace-down",
f5e75e
+                "switch-to-workspace-last",
f5e75e
+                "panel-main-menu",
f5e75e
+                "panel-run-dialog",
f5e75e
+                "set-spew-mark",
f5e75e
+                "switch-monitor",
f5e75e
+                "rotate-monitor",
f5e75e
+                "switch-to-session-1",
f5e75e
+                "switch-to-session-2",
f5e75e
+                "switch-to-session-3",
f5e75e
+                "switch-to-session-4",
f5e75e
+                "switch-to-session-5",
f5e75e
+                "switch-to-session-6",
f5e75e
+                "switch-to-session-7",
f5e75e
+                "switch-to-session-8",
f5e75e
+                "switch-to-session-9",
f5e75e
+                "switch-to-session-10",
f5e75e
+                "switch-to-session-11",
f5e75e
+                "switch-to-session-12",
f5e75e
+                "restore-shortcuts",
f5e75e
+                "activate-window-menu",
f5e75e
+                "toggle-above",
f5e75e
+                "toggle-shaded",
f5e75e
+                "minimize",
f5e75e
+                "toggle-on-all-workspaces",
f5e75e
+                "move-to-workspace-1",
f5e75e
+                "move-to-workspace-2",
f5e75e
+                "move-to-workspace-3",
f5e75e
+                "move-to-workspace-4",
f5e75e
+                "move-to-workspace-5",
f5e75e
+                "move-to-workspace-6",
f5e75e
+                "move-to-workspace-7",
f5e75e
+                "move-to-workspace-8",
f5e75e
+                "move-to-workspace-9",
f5e75e
+                "move-to-workspace-10",
f5e75e
+                "move-to-workspace-11",
f5e75e
+                "move-to-workspace-12",
f5e75e
+                "move-to-workspace-last",
f5e75e
+                "move-to-workspace-left",
f5e75e
+                "move-to-workspace-right",
f5e75e
+                "move-to-workspace-up",
f5e75e
+                "move-to-workspace-down",
f5e75e
+                NULL
f5e75e
+        };
f5e75e
+        size_t i;
f5e75e
+
f5e75e
+        g_debug ("KioskCompositor: Neutering builtin keybindings");
f5e75e
+
f5e75e
+        for (i = 0; builtin_keybindings[i] != NULL; i++) {
f5e75e
+                meta_keybindings_set_custom_handler (builtin_keybindings[i],
f5e75e
+                                                     (MetaKeyHandlerFunc)
f5e75e
+                                                     on_builtin_keybinding_triggered,
f5e75e
+                                                     self,
f5e75e
+                                                     NULL);
f5e75e
+        }
f5e75e
+}
f5e75e
+
f5e75e
 static void
f5e75e
 kiosk_compositor_start (MetaPlugin *plugin)
f5e75e
 {
f5e75e
         KioskCompositor *self = KIOSK_COMPOSITOR (plugin);
f5e75e
         g_autoptr (GError) error = NULL;
f5e75e
 
f5e75e
         g_set_weak_pointer (&self->display, meta_plugin_get_display (META_PLUGIN (self)));
f5e75e
         g_set_weak_pointer (&self->backend, clutter_get_default_backend ());
f5e75e
         g_set_weak_pointer (&self->stage, meta_get_stage_for_display (self->display));
f5e75e
 
f5e75e
         clutter_actor_show (self->stage);
f5e75e
 
f5e75e
         self->cancellable = g_cancellable_new ();
f5e75e
 
f5e75e
         self->service = kiosk_service_new (self);
f5e75e
         kiosk_service_start (self->service, &error);
f5e75e
 
f5e75e
         if (error != NULL) {
f5e75e
                 g_debug ("KioskCompositor: Could not start D-Bus service: %s", error->message);
f5e75e
                 g_clear_error (&error);
f5e75e
         }
f5e75e
 
f5e75e
+        neuter_builtin_keybindings (self);
f5e75e
+
f5e75e
         self->backgrounds = kiosk_backgrounds_new (self);
f5e75e
         self->input_sources_manager = kiosk_input_sources_manager_new (self);
f5e75e
 
f5e75e
         register_session (self);
f5e75e
 }
f5e75e
 
f5e75e
 static void
f5e75e
 kiosk_compositor_minimize (MetaPlugin      *plugin,
f5e75e
                            MetaWindowActor *actor)
f5e75e
 {
f5e75e
         meta_plugin_minimize_completed (plugin, actor);
f5e75e
 }
f5e75e
 
f5e75e
 static void
f5e75e
 kiosk_compositor_unminimize (MetaPlugin      *plugin,
f5e75e
                              MetaWindowActor *actor)
f5e75e
 {
f5e75e
         meta_plugin_unminimize_completed (plugin, actor);
f5e75e
 }
f5e75e
 
f5e75e
 static void
f5e75e
 kiosk_compositor_size_changed (MetaPlugin      *plugin,
f5e75e
                                MetaWindowActor *actor)
f5e75e
 {
f5e75e
         g_assert (META_PLUGIN_CLASS (kiosk_compositor_parent_class)->size_changed == NULL);
f5e75e
 }
f5e75e
 
f5e75e
 static void
f5e75e
 kiosk_compositor_size_change (MetaPlugin      *plugin,
f5e75e
                               MetaWindowActor *actor,
f5e75e
-- 
f5e75e
2.31.1
f5e75e