[gdm] daemon: Remove transient displays from display store when finished



commit 133e18ebc5eccf9e12832586038da28f4f8a15f8
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Jul 7 15:07:11 2012 -0400

    daemon: Remove transient displays from display store when finished
    
    When a display finishes (because it failed to start, or the users
    session ended) the GDM display handling code needs to remove the
    display from its display store.
    
    For static (logind or the first automatic) displays this happens in the
    
    on_static_display_status_changed
    
    function.  For transient (user-switch initiated) displays, though,
    it never happens.
    
    This commit reworks on_static_display_status_changed into a more
    generally applicable on_display_status_changed function, so the proper
    bookkeeping can happen for transient displays, too.

 daemon/gdm-local-display-factory.c |   54 ++++++++++++++++++++++-------------
 1 files changed, 34 insertions(+), 20 deletions(-)
---
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index a533d55..bef2209 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -32,6 +32,7 @@
 #include <systemd/sd-daemon.h>
 #endif
 
+#include "gdm-manager.h"
 #include "gdm-display-factory.h"
 #include "gdm-local-display-factory.h"
 #include "gdm-local-display-factory-glue.h"
@@ -77,6 +78,10 @@ static void     gdm_local_display_factory_finalize      (GObject
 static GdmDisplay *create_display                       (GdmLocalDisplayFactory      *factory,
                                                          const char                  *seat_id);
 
+static void     on_display_status_changed               (GdmDisplay                  *display,
+                                                         GParamSpec                  *arg1,
+                                                         GdmLocalDisplayFactory      *factory);
+
 static gpointer local_display_factory_object = NULL;
 
 G_DEFINE_TYPE (GdmLocalDisplayFactory, gdm_local_display_factory, GDM_TYPE_DISPLAY_FACTORY)
@@ -180,6 +185,9 @@ store_display (GdmLocalDisplayFactory *factory,
 {
         GdmDisplayStore *store;
 
+        g_signal_connect (display, "notify::status",
+                          G_CALLBACK (on_display_status_changed), factory);
+
         g_object_weak_ref (G_OBJECT (display), (GWeakNotify)on_display_disposed, factory);
 
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
@@ -255,9 +263,9 @@ gdm_local_display_factory_create_transient_display (GdmLocalDisplayFactory *fact
 }
 
 static void
-on_static_display_status_changed (GdmDisplay             *display,
-                                  GParamSpec             *arg1,
-                                  GdmLocalDisplayFactory *factory)
+on_display_status_changed (GdmDisplay             *display,
+                           GParamSpec             *arg1,
+                           GdmLocalDisplayFactory *factory)
 {
         int              status;
         GdmDisplayStore *store;
@@ -274,29 +282,40 @@ on_static_display_status_changed (GdmDisplay             *display,
 
         status = gdm_display_get_status (display);
 
-        g_debug ("GdmLocalDisplayFactory: static display status changed: %d", status);
+        g_debug ("GdmLocalDisplayFactory: display status changed: %d", status);
         switch (status) {
         case GDM_DISPLAY_FINISHED:
                 /* remove the display number from factory->priv->displays
                    so that it may be reused */
                 g_hash_table_remove (factory->priv->displays, GUINT_TO_POINTER (num));
                 gdm_display_store_remove (store, display);
-                /* reset num failures */
-                factory->priv->num_failures = 0;
-                create_display (factory, seat_id);
+
+                /* Create a new equivalent display if it was static */
+                if (GDM_IS_STATIC_DISPLAY (display)) {
+                        /* reset num failures */
+                        factory->priv->num_failures = 0;
+
+                        create_display (factory, seat_id);
+                }
                 break;
         case GDM_DISPLAY_FAILED:
                 /* leave the display number in factory->priv->displays
                    so that it doesn't get reused */
                 gdm_display_store_remove (store, display);
-                factory->priv->num_failures++;
-                if (factory->priv->num_failures > MAX_DISPLAY_FAILURES) {
-                        /* oh shit */
-                        g_warning ("GdmLocalDisplayFactory: maximum number of X display failures reached: check X server log for errors");
-                        /* FIXME: should monitor hardware changes to
-                           try again when seats change */
-                } else {
-                        create_display (factory, seat_id);
+
+                /* Create a new equivalent display if it was static */
+                if (GDM_IS_STATIC_DISPLAY (display)) {
+
+                        factory->priv->num_failures++;
+
+                        if (factory->priv->num_failures > MAX_DISPLAY_FAILURES) {
+                                /* oh shit */
+                                g_warning ("GdmLocalDisplayFactory: maximum number of X display failures reached: check X server log for errors");
+                                /* FIXME: should monitor hardware changes to
+                                   try again when seats change */
+                        } else {
+                                create_display (factory, seat_id);
+                        }
                 }
                 break;
         case GDM_DISPLAY_UNMANAGED:
@@ -354,11 +373,6 @@ create_display (GdmLocalDisplayFactory *factory,
 
         g_object_set (display, "seat-id", seat_id, NULL);
 
-        g_signal_connect (display,
-                          "notify::status",
-                          G_CALLBACK (on_static_display_status_changed),
-                          factory);
-
         store_display (factory, num, display);
 
         /* let store own the ref */



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