[gdm/wip/wayland-take-2: 6/9] session: Add a simple and naive way to detect Wayland sessions



commit 129a76dec0dd16bb73efd8e0aa8cbd366a20c70d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Mar 6 13:54:34 2014 -0500

    session: Add a simple and naive way to detect Wayland sessions
    
    Simply look for "wayland-sessions" as a path element.

 daemon/gdm-session.c |   38 +++++++++++++++++++++++++++++++++-----
 1 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index 3627b94..da4687a 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -383,7 +383,7 @@ is_prog_in_path (const char *prog)
 }
 
 static GKeyFile *
-load_key_file_for_file (const char *file)
+load_key_file_for_file (const char *file, char **full_path)
 {
         GKeyFile   *key_file;
         GError     *error;
@@ -397,7 +397,7 @@ load_key_file_for_file (const char *file)
         res = g_key_file_load_from_dirs (key_file,
                                          file,
                                          get_system_session_dirs (),
-                                         NULL,
+                                         full_path,
                                          G_KEY_FILE_NONE,
                                          &error);
         if (! res) {
@@ -426,7 +426,7 @@ get_session_command_for_file (const char *file,
                 *command = NULL;
         }
 
-        key_file = load_key_file_for_file (file);
+        key_file = load_key_file_for_file (file, NULL);
         if (key_file == NULL) {
                 goto out;
         }
@@ -2655,6 +2655,34 @@ gdm_session_get_session_id (GdmSession *self)
         return g_strdup (conversation->session_id);
 }
 
+static char *
+get_session_filename (GdmSession *self)
+{
+        return g_strdup_printf ("%s.desktop", get_session_name (self));
+}
+
+static gboolean
+gdm_session_is_wayland_session (GdmSession *self)
+{
+        GKeyFile   *key_file;
+        gboolean    is_wayland_session = FALSE;
+        char       *filename;
+        char       *full_path;
+
+        g_return_val_if_fail (self != NULL, FALSE);
+        g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
+
+        filename = get_session_filename (self);
+
+        key_file = load_key_file_for_file (filename, &full_path);
+        if (full_path && strstr (full_path, "/wayland-sessions/"))
+                is_wayland_session = TRUE;
+
+        g_key_file_free (key_file);
+        g_free (filename);
+        return is_wayland_session;
+}
+
 gboolean
 gdm_session_bypasses_xsession (GdmSession *self)
 {
@@ -2667,9 +2695,9 @@ gdm_session_bypasses_xsession (GdmSession *self)
         g_return_val_if_fail (self != NULL, FALSE);
         g_return_val_if_fail (GDM_IS_SESSION (self), FALSE);
 
-        filename = g_strdup_printf ("%s.desktop", get_session_name (self));
+        filename = get_session_filename (self);
 
-        key_file = load_key_file_for_file (filename);
+        key_file = load_key_file_for_file (filename, NULL);
 
         error = NULL;
         res = g_key_file_has_key (key_file, G_KEY_FILE_DESKTOP_GROUP, "X-GDM-BypassXsession", NULL);


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