[gnome-remote-desktop] context: Initialize EGL thread when daemon is ready



commit a1f07591f5a4a2ba3a89ea7fa24055f744dca9d5
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Sun Apr 24 09:30:39 2022 +0200

    context: Initialize EGL thread when daemon is ready
    
    Since recently, gnome-remote-desktops systemd service file requires the
    WantedBy property in order to be started automatically upon login.
    However, it does not seem to be possible to defer the launch until
    gnome-shell is also started.
    As a result, the EGL thread never initializes with the platform
    EGL_PLATFORM_WAYLAND_EXT.
    gnome-remote-desktop, however, does know when gnome-shell is started,
    as it waits on mutters remote desktop and screencast dbus interfaces to
    appear, before starting the server backends.
    
    Do the same for the EGL thread by adding a new method to notify the
    context, when the daemon is ready.
    Hook up to this method in maybe_enable_services() to ensure, that the
    EGL thread can be initialized with EGL_PLATFORM_WAYLAND_EXT.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/issues/89

 src/grd-context.c | 19 +++++++++++++------
 src/grd-context.h |  2 ++
 src/grd-daemon.c  |  2 ++
 3 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/src/grd-context.c b/src/grd-context.c
index 3a3c18ad..7bf2930e 100644
--- a/src/grd-context.c
+++ b/src/grd-context.c
@@ -95,6 +95,19 @@ grd_context_get_debug_flags (GrdContext *context)
   return context->debug_flags;
 }
 
+void
+grd_context_notify_daemon_ready (GrdContext *context)
+{
+  g_autoptr (GError) error = NULL;
+
+  if (context->egl_thread)
+    return;
+
+  context->egl_thread = grd_egl_thread_new (&error);
+  if (!context->egl_thread)
+    g_debug ("Failed to create EGL thread: %s", error->message);
+}
+
 static void
 init_debug_flags (GrdContext *context)
 {
@@ -126,15 +139,9 @@ grd_context_finalize (GObject *object)
 static void
 grd_context_init (GrdContext *context)
 {
-  g_autoptr (GError) error = NULL;
-
   init_debug_flags (context);
 
   context->settings = g_object_new (GRD_TYPE_SETTINGS, NULL);
-
-  context->egl_thread = grd_egl_thread_new (&error);
-  if (!context->egl_thread)
-    g_debug ("Failed to create EGL thread: %s", error->message);
 }
 
 static void
diff --git a/src/grd-context.h b/src/grd-context.h
index a5a9f036..24a4432c 100644
--- a/src/grd-context.h
+++ b/src/grd-context.h
@@ -55,4 +55,6 @@ GrdEglThread * grd_context_get_egl_thread (GrdContext *context);
 
 GrdDebugFlags grd_context_get_debug_flags (GrdContext *context);
 
+void grd_context_notify_daemon_ready (GrdContext *context);
+
 #endif /* GRD_CONTEXT_H */
diff --git a/src/grd-daemon.c b/src/grd-daemon.c
index f04f4532..78cbb0e5 100644
--- a/src/grd-daemon.c
+++ b/src/grd-daemon.c
@@ -144,6 +144,8 @@ maybe_enable_services (GrdDaemon *daemon)
   if (!is_daemon_ready (daemon))
     return;
 
+  grd_context_notify_daemon_ready (daemon->context);
+
 #ifdef HAVE_RDP
   if (grd_settings_is_rdp_enabled (settings))
     start_rdp_server (daemon);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]