From c9d5da1d62b6fb330c236a1911c1fd73c30456fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Mon, 16 Apr 2018 19:32:21 +0200
Subject: [PATCH] Get wl_seat via GTK+

Binding to wl_seat breaks GTK+ input since GTK+ binds it as well.
Needs to be investigated.
---
 src/phosh.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/phosh.c b/src/phosh.c
index d150ed5..d8022f3 100644
--- a/src/phosh.c
+++ b/src/phosh.c
@@ -56,7 +56,6 @@ typedef struct
 
   GdkDisplay *gdk_display;
   gint rotation;
-  struct wl_seat *seat;
 
   /* Top panel */
   struct elem *panel;
@@ -295,13 +294,17 @@ static void
 lockscreen_prepare (PhoshShell *self)
 {
   PhoshShellPrivate *priv = phosh_shell_get_instance_private (self);
+  GdkSeat *gdk_seat;
+  struct wl_seat *seat;
 
-  g_return_if_fail(priv->seat);
   g_return_if_fail(priv->idle_manager);
+  g_return_if_fail(priv->gdk_display);
 
+  gdk_seat = gdk_display_get_default_seat(priv->gdk_display);
+  seat = gdk_wayland_seat_get_wl_seat (gdk_seat);
   priv->lock_timer = org_kde_kwin_idle_get_idle_timeout(
     priv->idle_manager,
-    priv->seat,
+    seat,
     LOCKSCREEN_TIMEOUT);
 
   g_return_if_fail (priv->lock_timer);
@@ -446,7 +449,9 @@ registry_handle_global (void *data,
                                            name,
                                            &org_kde_kwin_idle_interface, 1);
   } else if (!strcmp(interface, "wl_seat")) {
+#if 0 /* FIXME: this breaks GTK+ input since GTK+ binds it as well */
     priv->seat = wl_registry_bind(registry, name, &wl_seat_interface, 1);
+#endif
   }
 }
 
@@ -531,11 +536,12 @@ phosh_shell_constructed (GObject *object)
 
   /* Wait until we have been notified about the compositor,
    * shell, and shell helper objects */
-  if (!priv->output || !priv->layer_shell)
+  if (!priv->output || !priv->layer_shell || !priv->idle_manager)
     wl_display_roundtrip (priv->display);
-  if (!priv->output || !priv->layer_shell) {
-      g_error ("Could not find output or layer_shellmodules\n"
-               "output: %p, layer_shell: %p\n", priv->output, priv->mshell);
+  if (!priv->output || !priv->layer_shell || !priv->idle_manager) {
+      g_error ("Could not find needed globals\n"
+               "output: %p, layer_shell: %p, seat: %p\n",
+               priv->output, priv->mshell, priv->idle_manager);
   }
 
   env_setup ();
-- 
GitLab