[gnome-color-manager/colord] Add and remove X11 outputs to colord as they are hotplugged



commit b8aed2dbdd15b15fab8b91599015ccc6dce9b181
Author: Richard Hughes <richard hughsie com>
Date:   Sun Jan 16 20:45:07 2011 +0000

    Add and remove X11 outputs to colord as they are hotplugged

 src/gcm-client.c        |  125 ++-------------------------
 src/gcm-client.h        |    1 -
 src/gcm-profile-store.c |    4 +-
 src/gcm-session.c       |  220 +++++++++++++++++++++++++++++++++++++----------
 src/gcm-x11-output.c    |    6 --
 src/gcm-x11-screen.c    |   14 ++-
 src/gcm-x11-screen.h    |    2 +
 7 files changed, 193 insertions(+), 179 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index 6d650cf..621f223 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -37,9 +37,7 @@
  #include <sane/sane.h>
 #endif
 
-#include "gcm-x11-screen.h"
 #include "gcm-client.h"
-#include "gcm-device-xrandr.h"
 #ifdef HAVE_SANE
  #include "gcm-device-sane.h"
 #endif
@@ -50,8 +48,6 @@ static void     gcm_client_finalize	(GObject     *object);
 
 #define GCM_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_CLIENT, GcmClientPrivate))
 
-static void gcm_client_xrandr_add (GcmClient *client, GcmX11Output *output);
-
 #ifdef HAVE_SANE
 static gboolean gcm_client_coldplug_devices_sane (GcmClient *client, GError **error);
 static gpointer gcm_client_coldplug_devices_sane_thrd (GcmClient *client);
@@ -68,7 +64,6 @@ struct _GcmClientPrivate
 	GPtrArray			*array;
 	GUdevClient			*gudev_client;
 	GSettings			*settings;
-	GcmX11Screen			*screen;
 	gboolean			 loading;
 	guint				 loading_refcount;
 	gboolean			 use_threads;
@@ -534,7 +529,7 @@ gcm_client_get_device_by_window (GcmClient *client, GdkWindow *window)
 	guint width, height;
 	GcmX11Output *output;
 	GcmX11Output *output_best = NULL;
-	GPtrArray *outputs;
+	GPtrArray *outputs = NULL;
 	GcmDevice *device = NULL;
 
 	/* get the window parameters, in root co-ordinates */
@@ -543,7 +538,7 @@ gcm_client_get_device_by_window (GcmClient *client, GdkWindow *window)
 	window_height = gdk_window_get_height (window);
 
 	/* get list of updates */
-	outputs = gcm_x11_screen_get_outputs (client->priv->screen, NULL);
+	//outputs = gcm_x11_screen_get_outputs (client->priv->screen, NULL);
 	if (outputs == NULL)
 		goto out;
 
@@ -587,86 +582,14 @@ out:
 	/* if we found an output, get the device */
 	if (output_best != NULL) {
 		GcmDevice *device_tmp;
-		device_tmp = gcm_device_xrandr_new ();
-		gcm_device_xrandr_set_from_output (device_tmp, output_best, NULL);
-		device = gcm_client_get_device_by_id (client, gcm_device_get_id (device_tmp));
+//		device_tmp = gcm_device_xrandr_new ();
+//		gcm_device_xrandr_set_from_output (device_tmp, output_best, NULL);
+//		device = gcm_client_get_device_by_id (client, gcm_device_get_id (device_tmp));
 		g_object_unref (device_tmp);
 	}
 	return device;
 }
 
-/**
- * gcm_client_xrandr_add:
- **/
-static void
-gcm_client_xrandr_add (GcmClient *client, GcmX11Output *output)
-{
-	gboolean ret;
-	GError *error = NULL;
-	GcmDevice *device = NULL;
-
-	/* if nothing connected then ignore */
-	ret = gcm_x11_output_get_connected (output);
-	if (!ret) {
-		g_debug ("%s is not connected", gcm_x11_output_get_name (output));
-		goto out;
-	}
-
-	/* create new device */
-	device = gcm_device_xrandr_new ();
-	ret = gcm_device_xrandr_set_from_output (device, output, &error);
-	if (!ret) {
-		g_debug ("failed to set for output: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-
-	/* add device */
-	ret = gcm_client_add_device (client, device, &error);
-	if (!ret) {
-		g_debug ("failed to set for device: %s", error->message);
-		g_error_free (error);
-		goto out;
-	}
-out:
-	if (device != NULL)
-		g_object_unref (device);
-}
-
-/**
- * gcm_client_coldplug_devices_xrandr:
- **/
-static gboolean
-gcm_client_coldplug_devices_xrandr (GcmClient *client, GError **error)
-{
-	GcmX11Output *output;
-	GPtrArray *outputs = NULL;
-	guint i;
-	gboolean ret;
-	GcmClientPrivate *priv = client->priv;
-
-	/* use the default screen */
-	ret = gcm_x11_screen_assign (priv->screen, NULL, error);
-	if (!ret)
-		goto out;
-	outputs = gcm_x11_screen_get_outputs (priv->screen, error);
-	if (outputs == NULL) {
-		ret = FALSE;
-		goto out;
-	}
-
-	/* add each device */
-	for (i=0; i<outputs->len; i++) {
-		output = g_ptr_array_index (outputs, i);
-		gcm_client_xrandr_add (client, output);
-	}
-out:
-	if (outputs != NULL)
-		g_ptr_array_unref (outputs);
-	gcm_client_done_loading (client);
-	return ret;
-}
-
 #ifdef HAVE_SANE
 /**
  * gcm_client_sane_add:
@@ -793,10 +716,8 @@ gcm_client_add_unconnected_device (GcmClient *client, GKeyFile *keyfile, const g
 	}
 
 	/* create device of specified type */
-	if (kind == CD_DEVICE_KIND_DISPLAY) {
-		device = gcm_device_xrandr_new ();
 #ifdef HAVE_SANE
-	} else if (kind == CD_DEVICE_KIND_SCANNER) {
+	if (kind == CD_DEVICE_KIND_SCANNER) {
 		device = gcm_device_sane_new ();
 #endif
 	} else {
@@ -910,15 +831,6 @@ gcm_client_coldplug (GcmClient *client, GcmClientColdplug coldplug, GError **err
 			goto out;
 	}
 
-	/* XRandR */
-	if (!coldplug || coldplug & GCM_CLIENT_COLDPLUG_XRANDR) {
-		gcm_client_add_loading (client);
-		g_debug ("adding devices of type XRandR");
-		ret = gcm_client_coldplug_devices_xrandr (client, error);
-		if (!ret)
-			goto out;
-	}
-
 #ifdef HAVE_SANE
 	/* SANE */
 	enable = g_settings_get_boolean (client->priv->settings, GCM_SETTINGS_ENABLE_SANE);
@@ -1155,27 +1067,6 @@ gcm_client_set_property (GObject *object, guint prop_id, const GValue *value, GP
 }
 
 /**
- * gcm_client_randr_event_cb:
- **/
-static void
-gcm_client_randr_event_cb (GcmX11Screen *screen, GcmClient *client)
-{
-	GPtrArray *outputs;
-	GcmX11Output *output;
-	guint i;
-
-	g_debug ("screens may have changed");
-
-	/* replug devices */
-	outputs = gcm_x11_screen_get_outputs (screen, NULL);
-	for (i=0; i<outputs->len; i++) {
-		output = g_ptr_array_index (outputs, i);
-		gcm_client_xrandr_add (client, output);
-	}
-	g_ptr_array_unref (outputs);
-}
-
-/**
  * gcm_client_class_init:
  **/
 static void
@@ -1259,9 +1150,6 @@ gcm_client_init (GcmClient *client)
 	client->priv->init_sane = FALSE;
 	client->priv->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
 	client->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
-	client->priv->screen = gcm_x11_screen_new ();
-	g_signal_connect (client->priv->screen, "changed",
-			  G_CALLBACK (gcm_client_randr_event_cb), client);
 
 	/* use GUdev to find devices */
 	client->priv->gudev_client = g_udev_client_new (subsystems);
@@ -1295,7 +1183,6 @@ gcm_client_finalize (GObject *object)
 	g_free (priv->display_name);
 	g_ptr_array_unref (priv->array);
 	g_object_unref (priv->gudev_client);
-	g_object_unref (priv->screen);
 	g_object_unref (priv->settings);
 #ifdef HAVE_SANE
 	if (client->priv->init_sane)
diff --git a/src/gcm-client.h b/src/gcm-client.h
index 64bd068..99e9ca5 100644
--- a/src/gcm-client.h
+++ b/src/gcm-client.h
@@ -62,7 +62,6 @@ struct _GcmClientClass
 
 typedef enum {
 	GCM_CLIENT_COLDPLUG_ALL		= 0x00,
-	GCM_CLIENT_COLDPLUG_XRANDR	= 0x01,
 	GCM_CLIENT_COLDPLUG_SANE	= 0x04,
 	GCM_CLIENT_COLDPLUG_SAVED	= 0x10,
 	GCM_CLIENT_COLDPLUG_LAST,
diff --git a/src/gcm-profile-store.c b/src/gcm-profile-store.c
index 838406c..b88f517 100644
--- a/src/gcm-profile-store.c
+++ b/src/gcm-profile-store.c
@@ -246,7 +246,9 @@ gcm_profile_store_add_profile (GcmProfileStore *profile_store, GFile *file)
 	/* add to array */
 	g_debug ("parsed new profile '%s'", filename);
 	g_ptr_array_add (priv->profile_array, g_object_ref (profile));
-	g_signal_connect (profile, "notify::file", G_CALLBACK(gcm_profile_store_notify_filename_cb), profile_store);
+	g_signal_connect (profile, "notify::file",
+			  G_CALLBACK(gcm_profile_store_notify_filename_cb),
+			  profile_store);
 
 	/* emit a signal */
 	g_debug ("emit added (and changed): %s", filename);
diff --git a/src/gcm-session.c b/src/gcm-session.c
index 2b0a8e8..a4ebe62 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -39,13 +39,14 @@
 static GMainLoop *loop = NULL;
 static GSettings *settings = NULL;
 static GDBusNodeInfo *introspection = NULL;
-static GcmClient *client = NULL;
+static CdClient *client = NULL;
 static GcmProfileStore *profile_store = NULL;
-static GTimer *timer = NULL;
+static GcmX11Screen *x11_screen = NULL;
 static GDBusConnection *connection = NULL;
 
 #define GCM_SESSION_NOTIFY_TIMEOUT	30000 /* ms */
 
+#if 0
 /**
  * gcm_session_notify_cb:
  **/
@@ -140,7 +141,9 @@ gcm_session_notify_device (GcmDevice *device)
 		gcm_session_notify_recalibrate (title, message, kind);
 	g_free (message);
 }
+#endif
 
+#if 0
 /**
  * gcm_session_added_cb:
  **/
@@ -182,6 +185,7 @@ gcm_session_added_cb (GcmClient *client_, GcmDevice *device, gpointer user_data)
 out:
 	g_free (basename);
 }
+#endif
 
 /**
  * gcm_session_get_profile_for_window:
@@ -189,7 +193,7 @@ out:
 static const gchar *
 gcm_session_get_profile_for_window (guint xid, GError **error)
 {
-	GcmDevice *device;
+	GcmDevice *device = NULL;
 	GdkWindow *window;
 	const gchar *filename = NULL;
 
@@ -203,7 +207,7 @@ gcm_session_get_profile_for_window (guint xid, GError **error)
 	}
 
 	/* get device for this window */
-	device = gcm_client_get_device_by_window (client, window);
+//	device = gcm_client_get_device_by_window (client, window);
 	if (device == NULL) {
 		g_set_error (error, 1, 0, "no device found for xid %i", xid);
 		goto out;
@@ -259,7 +263,7 @@ gcm_session_get_profiles_for_file (const gchar *filename, GError **error)
 	GcmExif *exif;
 	GcmDevice *device;
 	GPtrArray *array = NULL;
-	GPtrArray *array_devices;
+	GPtrArray *array_devices = NULL;
 	GFile *file;
 
 	/* get file type */
@@ -271,7 +275,7 @@ gcm_session_get_profiles_for_file (const gchar *filename, GError **error)
 
 	/* get list */
 	g_debug ("query=%s", filename);
-	array_devices = gcm_client_get_devices (client);
+//	array_devices = gcm_client_get_devices (client);
 	for (i=0; i<array_devices->len; i++) {
 		device = g_ptr_array_index (array_devices, i);
 
@@ -308,7 +312,7 @@ gcm_session_get_profiles_for_device (const gchar *device_id_with_prefix, GError
 	gboolean use_native_device = FALSE;
 	GcmDevice *device;
 	GPtrArray *array = NULL;
-	GPtrArray *array_devices;
+	GPtrArray *array_devices = NULL;
 
 	/* strip the prefix, if there is any */
 	device_id = g_strstr_len (device_id_with_prefix, -1, ":");
@@ -325,7 +329,7 @@ gcm_session_get_profiles_for_device (const gchar *device_id_with_prefix, GError
 
 	/* get list */
 	g_debug ("query=%s [%s] %i", device_id_with_prefix, device_id, use_native_device);
-	array_devices = gcm_client_get_devices (client);
+//	array_devices = gcm_client_get_devices (client);
 	for (i=0; i<array_devices->len; i++) {
 		device = g_ptr_array_index (array_devices, i);
 
@@ -441,9 +445,6 @@ gcm_session_handle_method_call (GDBusConnection *connection_, const gchar *sende
 		goto out;
 	}
 out:
-	/* reset time */
-	g_timer_reset (timer);
-
 	if (array != NULL)
 		g_ptr_array_unref (array);
 	if (tuple != NULL)
@@ -480,10 +481,6 @@ gcm_session_handle_get_property (GDBusConnection *connection_, const gchar *send
 	} else if (g_strcmp0 (property_name, "ColorspaceGray") == 0) {
 		retval = g_settings_get_value (settings, GCM_SETTINGS_COLORSPACE_GRAY);
 	}
-
-	/* reset time */
-	g_timer_reset (timer);
-
 	return retval;
 }
 
@@ -566,15 +563,7 @@ gcm_session_key_changed_cb (GSettings *settings_, const gchar *key, gpointer use
 	gcm_session_emit_changed ();
 }
 
-/**
- * gcm_session_client_changed_cb:
- **/
-static void
-gcm_session_client_changed_cb (GcmClient *client_, GcmDevice *device, gpointer user_data)
-{
-	gcm_session_emit_changed ();
-}
-
+#if 0
 /**
  * gcm_apply_create_icc_profile_for_edid:
  **/
@@ -633,6 +622,124 @@ out:
 		g_object_unref (profile);
 	return ret;
 }
+#endif
+
+/**
+ * gcm_session_profile_store_added_cb:
+ **/
+static void
+gcm_session_profile_store_added_cb (GcmProfileStore *profile_store_,
+				    GcmProfile *profile,
+				    gpointer user_data)
+{
+	//xxx
+	g_debug ("add profile");
+}
+
+/**
+ * gcm_session_profile_store_removed_cb:
+ **/
+static void
+gcm_session_profile_store_removed_cb (GcmProfileStore *profile_store_,
+				      GcmProfile *profile,
+				      gpointer user_data)
+{
+	//xxx
+	g_debug ("remove profile");
+}
+
+/**
+ * gcm_x11_screen_output_added_cb:
+ **/
+static void
+gcm_x11_screen_output_added_cb (GcmX11Screen *screen_,
+				GcmX11Output *output,
+				gpointer user_data)
+{
+	CdDevice *device;
+	gboolean ret;
+	GError *error = NULL;
+
+	g_debug ("output %s added",
+		 gcm_x11_output_get_name (output));
+	device = cd_client_create_device_sync (client,
+					       gcm_x11_output_get_name (output),
+					       CD_OBJECT_SCOPE_TEMPORARY,
+					       NULL,
+					       &error);
+	if (device == NULL) {
+		g_warning ("failed to create device: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* set kind */
+	ret = cd_device_set_kind_sync (device,
+				       CD_DEVICE_KIND_DISPLAY,
+				       NULL,
+				       &error);
+	if (device == NULL) {
+		g_warning ("failed to create device: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+	/* set model */
+	ret = cd_device_set_model_sync (device,
+					gcm_x11_output_get_name (output),
+					NULL,
+					&error);
+	if (device == NULL) {
+		g_warning ("failed to create device: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
+out:
+	if (device != NULL)
+		g_object_unref (device);
+}
+
+/**
+ * gcm_x11_screen_output_removed_cb:
+ **/
+static void
+gcm_x11_screen_output_removed_cb (GcmX11Screen *screen_,
+				  GcmX11Output *output,
+				  gpointer user_data)
+{
+	gboolean ret;
+	GError *error = NULL;
+	CdDevice *device;
+
+	g_debug ("output %s removed",
+		 gcm_x11_output_get_name (output));
+	device = cd_client_find_device_sync (client,
+					     gcm_x11_output_get_name (output),
+					     NULL,
+					     &error);
+	if (device == NULL) {
+		g_warning ("failed to find device: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
+	ret = cd_client_delete_device_sync (client,
+					    device,
+					    NULL,
+					    &error);
+	if (!ret) {
+		g_warning ("failed to delete device: %s",
+			   error->message);
+		g_error_free (error);
+		goto out;
+	}
+out:
+	if (device != NULL)
+		g_object_unref (device);
+}
 
 /**
  * main:
@@ -640,18 +747,18 @@ out:
 int
 main (int argc, char *argv[])
 {
-	const gchar *edid_md5;
+//	const gchar *edid_md5;
 	gboolean login = FALSE;
 	gboolean ret;
-	gchar *filename;
+//	gchar *filename;
 	gchar *introspection_data = NULL;
-	gchar *path;
-	GcmDevice *device;
+//	gchar *path;
+//	GcmDevice *device;
 	GError *error = NULL;
 	GFile *file = NULL;
 	GOptionContext *context;
 	GPtrArray *array = NULL;
-	guint i;
+//	guint i;
 	guint owner_id = 0;
 	guint poll_id = 0;
 	guint retval = 1;
@@ -688,16 +795,38 @@ main (int argc, char *argv[])
 
 	/* get the settings */
 	settings = g_settings_new (GCM_SETTINGS_SCHEMA);
-	g_signal_connect (settings, "changed", G_CALLBACK (gcm_session_key_changed_cb), NULL);
+	g_signal_connect (settings, "changed",
+			  G_CALLBACK (gcm_session_key_changed_cb), NULL);
 
-	/* monitor devices as they are added */
-	client = gcm_client_new ();
-	gcm_client_set_use_threads (client, TRUE);
-	g_signal_connect (client, "added", G_CALLBACK (gcm_session_added_cb), NULL);
-	g_signal_connect (client, "added", G_CALLBACK (gcm_session_client_changed_cb), NULL);
-	g_signal_connect (client, "removed", G_CALLBACK (gcm_session_client_changed_cb), NULL);
-	g_signal_connect (client, "changed", G_CALLBACK (gcm_session_client_changed_cb), NULL);
+	/* monitor daemon */
+	client = cd_client_new ();
+	ret = cd_client_connect_sync (client, NULL, &error);
+	if (!ret) {
+		g_warning ("failed to connect to colord: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
 
+	/* monitor displays */
+	x11_screen = gcm_x11_screen_new ();
+	g_signal_connect (x11_screen, "added",
+			  G_CALLBACK (gcm_x11_screen_output_added_cb), NULL);
+	g_signal_connect (x11_screen, "removed",
+			  G_CALLBACK (gcm_x11_screen_output_removed_cb), NULL);
+	ret = gcm_x11_screen_assign (x11_screen, NULL, &error);
+	if (!ret) {
+		g_warning ("failed to assign: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+	ret = gcm_x11_screen_refresh (x11_screen, &error);
+	if (!ret) {
+		g_warning ("failed to refresh: %s", error->message);
+		g_error_free (error);
+		goto out;
+	}
+
+#if 0
 	/* set for each output */
 	array = gcm_client_get_devices (client);
 	for (i=0; i<array->len; i++) {
@@ -738,18 +867,17 @@ main (int argc, char *argv[])
 			break;
 		}
 	}
+#endif
 
 	/* have access to all profiles */
 	profile_store = gcm_profile_store_new ();
 	gcm_profile_store_search (profile_store);
-	timer = g_timer_new ();
-
-	/* get all connected devices */
-	ret = gcm_client_coldplug (client, GCM_CLIENT_COLDPLUG_ALL, &error);
-	if (!ret) {
-		g_warning ("failed to coldplug: %s", error->message);
-		g_error_free (error);
-	}
+	g_signal_connect (profile_store, "added",
+			  G_CALLBACK (gcm_session_profile_store_added_cb),
+			  NULL);
+	g_signal_connect (profile_store, "removed",
+			  G_CALLBACK (gcm_session_profile_store_removed_cb),
+			  NULL);
 
 	/* create new objects */
 	loop = g_main_loop_new (NULL, FALSE);
@@ -797,8 +925,6 @@ out:
 		g_bus_unown_name (owner_id);
 	if (profile_store != NULL)
 		g_object_unref (profile_store);
-	if (timer != NULL)
-		g_timer_destroy (timer);
 	if (connection != NULL)
 		g_object_unref (connection);
 	g_dbus_node_info_unref (introspection);
diff --git a/src/gcm-x11-output.c b/src/gcm-x11-output.c
index a750b14..023aeda 100644
--- a/src/gcm-x11-output.c
+++ b/src/gcm-x11-output.c
@@ -81,7 +81,6 @@ void
 gcm_x11_output_set_display (GcmX11Output *output, gpointer display)
 {
 	g_return_if_fail (GCM_IS_X11_OUTPUT (output));
-	g_return_if_fail (output->priv->display == NULL);
 	output->priv->display = display;
 }
 
@@ -96,7 +95,6 @@ void
 gcm_x11_output_set_name (GcmX11Output *output, const gchar *name)
 {
 	g_return_if_fail (GCM_IS_X11_OUTPUT (output));
-	g_return_if_fail (output->priv->name == NULL);
 	output->priv->name = g_strdup (name);
 }
 
@@ -141,7 +139,6 @@ void
 gcm_x11_output_set_id (GcmX11Output *output, guint id)
 {
 	g_return_if_fail (GCM_IS_X11_OUTPUT (output));
-	g_return_if_fail (output->priv->id == 0);
 	output->priv->id = id;
 }
 
@@ -156,7 +153,6 @@ void
 gcm_x11_output_set_crtc_id (GcmX11Output *output, guint crtc_id)
 {
 	g_return_if_fail (GCM_IS_X11_OUTPUT (output));
-	g_return_if_fail (output->priv->crtc_id == 0);
 	output->priv->crtc_id = crtc_id;
 }
 
@@ -171,7 +167,6 @@ void
 gcm_x11_output_set_gamma_size (GcmX11Output *output, guint gamma_size)
 {
 	g_return_if_fail (GCM_IS_X11_OUTPUT (output));
-	g_return_if_fail (output->priv->gamma_size == 0);
 	output->priv->gamma_size = gamma_size;
 }
 
@@ -201,7 +196,6 @@ void
 gcm_x11_output_set_primary (GcmX11Output *output, gboolean primary)
 {
 	g_return_if_fail (GCM_IS_X11_OUTPUT (output));
-	g_return_if_fail (!output->priv->primary);
 	output->priv->primary = primary;
 }
 
diff --git a/src/gcm-x11-screen.c b/src/gcm-x11-screen.c
index 9f845ba..a5bd423 100644
--- a/src/gcm-x11-screen.c
+++ b/src/gcm-x11-screen.c
@@ -109,7 +109,7 @@ gcm_x11_screen_get_output_for_id (GcmX11Screen *screen, guint id)
 	/* find by id */
 	for (i=0; i<priv->outputs->len; i++) {
 		output_tmp = g_ptr_array_index (screen->priv->outputs, i);
-		if (id == gcm_x11_output_get_id (output)) {
+		if (id == gcm_x11_output_get_id (output_tmp)) {
 			output = output_tmp;
 			break;
 		}
@@ -120,7 +120,7 @@ gcm_x11_screen_get_output_for_id (GcmX11Screen *screen, guint id)
 /**
  * gcm_x11_screen_refresh:
  **/
-static gboolean
+gboolean
 gcm_x11_screen_refresh (GcmX11Screen *screen, GError **error)
 {
 	guint i;
@@ -158,7 +158,9 @@ gcm_x11_screen_refresh (GcmX11Screen *screen, GError **error)
 
 		/* get information about the output */
 		gdk_error_trap_push ();
-		output_info = XRRGetOutputInfo (priv->xdisplay, resources, rr_output);
+		output_info = XRRGetOutputInfo (priv->xdisplay,
+						resources,
+						rr_output);
 		gdk_flush ();
 		if (gdk_error_trap_pop ()) {
 			g_warning ("failed to get output info");
@@ -222,8 +224,10 @@ gcm_x11_screen_refresh (GcmX11Screen *screen, GError **error)
 	for (i=0; i<priv->outputs->len; i++) {
 		output = g_ptr_array_index (priv->outputs, i);
 		if (!gcm_x11_output_get_connected (output)) {
-			g_debug ("emit added: %s", output_info->name);
-			g_signal_emit (screen, signals[SIGNAL_REMOVED], 0, output);
+			g_debug ("emit removed: %s",
+				 gcm_x11_output_get_name (output));
+			g_signal_emit (screen, signals[SIGNAL_REMOVED], 0,
+				       output);
 			g_ptr_array_remove (priv->outputs, output);
 		}
 	}
diff --git a/src/gcm-x11-screen.h b/src/gcm-x11-screen.h
index dc13567..311af28 100644
--- a/src/gcm-x11-screen.h
+++ b/src/gcm-x11-screen.h
@@ -62,6 +62,8 @@ GcmX11Screen	*gcm_x11_screen_new			(void);
 gboolean	 gcm_x11_screen_assign			(GcmX11Screen		*screen,
 							 GdkScreen		*gdk_screen,
 							 GError			**error);
+gboolean	 gcm_x11_screen_refresh			(GcmX11Screen		*screen,
+							 GError			**error);
 GPtrArray	*gcm_x11_screen_get_outputs		(GcmX11Screen		*screen,
 							 GError			**error);
 GcmX11Output	*gcm_x11_screen_get_output_by_name	(GcmX11Screen		*screen,



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