[gnome-color-manager/colord] Remove GcmClient, it's not required anymore



commit 6f307e63291a5803c0818d4d09c42d5bb79dfa1c
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jan 17 14:19:35 2011 +0000

    Remove GcmClient, it's not required anymore

 src/Makefile.am      |  112 ++++----
 src/cc-color-panel.c |   41 ++--
 src/gcm-client.c     |  796 --------------------------------------------------
 src/gcm-client.h     |   94 ------
 src/gcm-self-test.c  |   22 +-
 src/gcm-session.c    |   13 +-
 src/gcm-x11-screen.c |  124 ++++++++-
 src/gcm-x11-screen.h |    2 +
 8 files changed, 216 insertions(+), 988 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 5f0aca5..7231e7b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,83 +36,81 @@ ccpanels_CFLAGS =					\
 
 noinst_LIBRARIES = libgcmshared.a
 libgcmshared_a_SOURCES =				\
+	gcm-brightness.c				\
+	gcm-brightness.h				\
+	gcm-buffer.c					\
+	gcm-buffer.h					\
+	gcm-calibrate-argyll.c				\
+	gcm-calibrate-argyll.h				\
+	gcm-calibrate.c					\
+	gcm-calibrate-dialog.c				\
+	gcm-calibrate-dialog.h				\
+	gcm-calibrate.h					\
+	gcm-calibrate-manual.c				\
+	gcm-calibrate-manual.h				\
+	gcm-calibrate-native.c				\
+	gcm-calibrate-native.h				\
+	gcm-cie-widget.c				\
+	gcm-cie-widget.h				\
+	gcm-clut.c					\
+	gcm-clut.h					\
+	gcm-color.c					\
+	gcm-color.h					\
 	gcm-debug.c					\
 	gcm-debug.h					\
-	gcm-sample-window.c				\
-	gcm-sample-window.h				\
+	gcm-device.c					\
+	gcm-device.h					\
+	gcm-device-xrandr.c				\
+	gcm-device-xrandr.h				\
+	gcm-dmi.c					\
+	gcm-dmi.h					\
+	gcm-edid.c					\
+	gcm-edid.h					\
+	gcm-enum.c					\
+	gcm-enum.h					\
+	gcm-exif.c					\
+	gcm-exif.h					\
+	gcm-gamma-widget.c				\
+	gcm-gamma-widget.h				\
+	gcm-image.c					\
+	gcm-image.h					\
 	gcm-math.c					\
 	gcm-math.h					\
-	gcm-color.c					\
-	gcm-color.h					\
+	gcm-print.c					\
+	gcm-print.h					\
+	gcm-profile.c					\
+	gcm-profile.h					\
+	gcm-profile-store.c				\
+	gcm-profile-store.h				\
+	gcm-sample-window.c				\
+	gcm-sample-window.h				\
 	gcm-sensor.c					\
-	gcm-sensor.h					\
 	gcm-sensor-client.c				\
 	gcm-sensor-client.h				\
-	gcm-sensor-huey.c				\
-	gcm-sensor-huey.h				\
-	gcm-sensor-huey-private.c			\
-	gcm-sensor-huey-private.h			\
 	gcm-sensor-colormunki.c				\
 	gcm-sensor-colormunki.h				\
 	gcm-sensor-colormunki-private.c			\
 	gcm-sensor-colormunki-private.h			\
 	gcm-sensor-dummy.c				\
 	gcm-sensor-dummy.h				\
+	gcm-sensor.h					\
+	gcm-sensor-huey.c				\
+	gcm-sensor-huey.h				\
+	gcm-sensor-huey-private.c			\
+	gcm-sensor-huey-private.h			\
 	gcm-tables.c					\
 	gcm-tables.h					\
-	gcm-edid.c					\
-	gcm-edid.h					\
-	gcm-dmi.c					\
-	gcm-dmi.h					\
-	gcm-buffer.c					\
-	gcm-buffer.h					\
-	gcm-profile.c					\
-	gcm-profile.h					\
-	gcm-clut.c					\
-	gcm-clut.h					\
-	gcm-image.c					\
-	gcm-image.h					\
-	gcm-enum.c					\
-	gcm-enum.h					\
+	gcm-trc-widget.c				\
+	gcm-trc-widget.h				\
 	gcm-usb.c					\
 	gcm-usb.h					\
-	gcm-profile-store.c				\
-	gcm-profile-store.h				\
+	gcm-utils.c					\
+	gcm-utils.h					\
+	gcm-version.h					\
 	gcm-x11-output.c				\
 	gcm-x11-output.h				\
 	gcm-x11-screen.c				\
-	gcm-x11-screen.h				\
-	gcm-version.h					\
-	gcm-brightness.c				\
-	gcm-brightness.h				\
-	gcm-exif.c					\
-	gcm-exif.h					\
-	gcm-print.c					\
-	gcm-print.h					\
-	gcm-utils.c					\
-	gcm-utils.h					\
-	gcm-client.c					\
-	gcm-client.h					\
-	gcm-device.c					\
-	gcm-device.h					\
-	gcm-device-xrandr.c				\
-	gcm-device-xrandr.h				\
-	gcm-cie-widget.c				\
-	gcm-cie-widget.h				\
-	gcm-trc-widget.c				\
-	gcm-trc-widget.h				\
-	gcm-gamma-widget.c				\
-	gcm-gamma-widget.h				\
-	gcm-calibrate.c					\
-	gcm-calibrate.h					\
-	gcm-calibrate-argyll.c				\
-	gcm-calibrate-argyll.h				\
-	gcm-calibrate-manual.c				\
-	gcm-calibrate-manual.h				\
-	gcm-calibrate-native.c				\
-	gcm-calibrate-native.h				\
-	gcm-calibrate-dialog.c				\
-	gcm-calibrate-dialog.h
+	gcm-x11-screen.h
 
 libgcmshared_a_CFLAGS =					\
 	$(WARNINGFLAGS_C)
diff --git a/src/cc-color-panel.c b/src/cc-color-panel.c
index 91ff62e..6b2f526 100644
--- a/src/cc-color-panel.c
+++ b/src/cc-color-panel.c
@@ -33,7 +33,6 @@
 #include "gcm-cell-renderer-profile-icon.h"
 #include "gcm-calibrate-argyll.h"
 #include "gcm-cie-widget.h"
-#include "gcm-client.h"
 #include "gcm-sensor-client.h"
 #include "gcm-device-xrandr.h"
 #include "gcm-exif.h"
@@ -52,7 +51,7 @@ struct _CcColorPanelPrivate {
 	GtkListStore		*list_store_profiles;
 	GcmDevice		*current_device;
 	GcmProfileStore		*profile_store;
-	GcmClient		*gcm_client;
+	CdClient		*cd_client;
 	GcmSensorClient		*sensor_client;
 	gboolean		 setting_up_device;
 	GtkWidget		*main_window;
@@ -175,7 +174,7 @@ cc_color_panel_default_cb (GtkWidget *widget, CcColorPanel *panel)
 	guint i;
 
 	/* set for each output */
-	array = gcm_client_get_devices (panel->priv->gcm_client);
+//	array = cd_client_get_devices (panel->priv->cd_client);
 	for (i=0; i<array->len; i++) {
 		device = g_ptr_array_index (array, i);
 
@@ -485,7 +484,7 @@ cc_color_panel_profile_add_virtual_file (CcColorPanel *panel, GFile *file)
 	}
 
 	/* add to the device list */
-	ret = gcm_client_add_device (panel->priv->gcm_client, device, &error);
+//	ret = cd_client_add_device (panel->priv->cd_client, device, &error);
 	if (!ret) {
 		/* TRANSLATORS: could not add virtual device */
 		cc_color_panel_error_dialog (panel, _("Failed to add virtual device"), error->message);
@@ -1099,7 +1098,7 @@ cc_color_panel_button_virtual_add_cb (GtkWidget *widget, CcColorPanel *panel)
 	}
 
 	/* add to the device list */
-	ret = gcm_client_add_device (panel->priv->gcm_client, device, &error);
+//	ret = cd_client_add_device (panel->priv->cd_client, device, &error);
 	if (!ret) {
 		/* TRANSLATORS: could not add virtual device */
 		cc_color_panel_error_dialog (panel, _("Failed to add virtual device"), error->message);
@@ -1221,11 +1220,11 @@ cc_color_panel_profile_delete_event_cb (GtkWidget *widget, GdkEvent *event, CcCo
 static void
 cc_color_panel_delete_cb (GtkWidget *widget, CcColorPanel *panel)
 {
-	gboolean ret;
+	gboolean ret = FALSE;
 	GError *error = NULL;
 
 	/* try to delete device */
-	ret = gcm_client_delete_device (panel->priv->gcm_client, panel->priv->current_device, &error);
+//	ret = cd_client_delete_device (panel->priv->cd_client, panel->priv->current_device, &error);
 	if (!ret) {
 		/* TRANSLATORS: could not read file */
 		cc_color_panel_error_dialog (panel, _("Failed to delete file"), error->message);
@@ -1423,7 +1422,7 @@ cc_color_panel_devices_treeview_clicked_cb (GtkTreeSelection *selection, CcColor
 		g_object_unref (panel->priv->current_device);
 		panel->priv->current_device = NULL;
 	}
-	panel->priv->current_device = gcm_client_get_device_by_id (panel->priv->gcm_client, id);
+//	panel->priv->current_device = cd_client_get_device_by_id (panel->priv->cd_client, id);
 	if (panel->priv->current_device == NULL)
 		goto out;
 
@@ -1874,7 +1873,7 @@ cc_color_panel_remove_device (CcColorPanel *panel, GcmDevice *gcm_device)
  * cc_color_panel_added_cb:
  **/
 static void
-cc_color_panel_added_cb (GcmClient *client, GcmDevice *device, CcColorPanel *panel)
+cc_color_panel_added_cb (CdClient *client, GcmDevice *device, CcColorPanel *panel)
 {
 	CdDeviceKind kind;
 	g_debug ("added: %s (connected: %i, saved: %i)",
@@ -1897,7 +1896,7 @@ cc_color_panel_added_cb (GcmClient *client, GcmDevice *device, CcColorPanel *pan
  * cc_color_panel_changed_cb:
  **/
 static void
-cc_color_panel_changed_cb (GcmClient *client, GcmDevice *device, CcColorPanel *panel)
+cc_color_panel_changed_cb (CdClient *client, GcmDevice *device, CcColorPanel *panel)
 {
 	g_debug ("changed: %s (doing nothing)", gcm_device_get_id (device));
 }
@@ -1906,7 +1905,7 @@ cc_color_panel_changed_cb (GcmClient *client, GcmDevice *device, CcColorPanel *p
  * cc_color_panel_removed_cb:
  **/
 static void
-cc_color_panel_removed_cb (GcmClient *client, GcmDevice *device, CcColorPanel *panel)
+cc_color_panel_removed_cb (CdClient *client, GcmDevice *device, CcColorPanel *panel)
 {
 	GtkTreeIter iter;
 	GtkTreeSelection *selection;
@@ -2151,7 +2150,7 @@ static gboolean
 cc_color_panel_startup_idle_cb (CcColorPanel *panel)
 {
 	GtkWidget *widget;
-	gboolean ret;
+	gboolean ret = FALSE;
 	GError *error = NULL;
 	gchar *colorspace_rgb;
 	gchar *colorspace_cmyk;
@@ -2206,7 +2205,7 @@ cc_color_panel_startup_idle_cb (CcColorPanel *panel)
 			  G_CALLBACK (cc_color_panel_renderer_combo_changed_cb), panel);
 
 	/* coldplug plugged in devices */
-	ret = gcm_client_coldplug (panel->priv->gcm_client, GCM_CLIENT_COLDPLUG_ALL, &error);
+//	ret = cd_client_coldplug (panel->priv->cd_client, &error);
 	if (!ret) {
 		g_warning ("failed to add connected devices: %s", error->message);
 		g_error_free (error);
@@ -2284,7 +2283,7 @@ cc_color_panel_select_first_device_idle_cb (CcColorPanel *panel)
  * cc_color_panel_client_notify_loading_cb:
  **/
 static void
-cc_color_panel_client_notify_loading_cb (GcmClient *client, GParamSpec *pspec, CcColorPanel *panel)
+cc_color_panel_client_notify_loading_cb (CdClient *client, GParamSpec *pspec, CcColorPanel *panel)
 {
 	/* idle callback */
 	g_idle_add ((GSourceFunc) cc_color_panel_select_first_device_idle_cb, panel);
@@ -2399,8 +2398,8 @@ cc_color_panel_finalize (GObject *object)
 		g_object_unref (panel->priv->builder);
 	if (panel->priv->profile_store != NULL)
 		g_object_unref (panel->priv->profile_store);
-	if (panel->priv->gcm_client != NULL)
-		g_object_unref (panel->priv->gcm_client);
+	if (panel->priv->cd_client != NULL)
+		g_object_unref (panel->priv->cd_client);
 	if (panel->priv->save_and_apply_id != 0)
 		g_source_remove (panel->priv->save_and_apply_id);
 	if (panel->priv->apply_all_devices_id != 0)
@@ -2553,11 +2552,11 @@ cc_color_panel_init (CcColorPanel *panel)
 			  G_CALLBACK (cc_color_panel_profile_combo_changed_cb), panel);
 
 	/* use a device client array */
-	panel->priv->gcm_client = gcm_client_new ();
-	g_signal_connect (panel->priv->gcm_client, "added", G_CALLBACK (cc_color_panel_added_cb), panel);
-	g_signal_connect (panel->priv->gcm_client, "removed", G_CALLBACK (cc_color_panel_removed_cb), panel);
-	g_signal_connect (panel->priv->gcm_client, "changed", G_CALLBACK (cc_color_panel_changed_cb), panel);
-	g_signal_connect (panel->priv->gcm_client, "notify::loading",
+	panel->priv->cd_client = cd_client_new ();
+	g_signal_connect (panel->priv->cd_client, "added", G_CALLBACK (cc_color_panel_added_cb), panel);
+	g_signal_connect (panel->priv->cd_client, "removed", G_CALLBACK (cc_color_panel_removed_cb), panel);
+	g_signal_connect (panel->priv->cd_client, "changed", G_CALLBACK (cc_color_panel_changed_cb), panel);
+	g_signal_connect (panel->priv->cd_client, "notify::loading",
 			  G_CALLBACK (cc_color_panel_client_notify_loading_cb), panel);
 
 	/* maintain a list of profiles */
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index 5cf6971..6bc15e0 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -956,7 +956,7 @@ gcm_test_calibrate_native_func (void)
 	gboolean ret;
 	GError *error = NULL;
 	GcmCalibrate *calibrate;
-	GcmClient *client;
+	CdClient *client;
 	GcmX11Screen *screen;
 	GcmDevice *device;
 	gchar *contents;
@@ -970,7 +970,7 @@ gcm_test_calibrate_native_func (void)
 		      NULL);
 
 	/* create a virtual device we can "calibrate" */
-	client = gcm_client_new ();
+	client = cd_client_new ();
 	g_assert (client != NULL);
 	g_setenv ("GCM_TEST", "1", TRUE);
 	contents = g_strdup_printf ("[xrandr_hewlett_packard_hp_lp2480zx_3cm82200kv]\n"
@@ -984,7 +984,7 @@ gcm_test_calibrate_native_func (void)
 	g_assert_no_error (error);
 	g_assert (ret);
 
-	device = gcm_client_get_device_by_id (client, "xrandr_hewlett_packard_hp_lp2480zx_3cm82200kv");
+	device = cd_client_get_device_by_id (client, "xrandr_hewlett_packard_hp_lp2480zx_3cm82200kv");
 	g_assert (device != NULL);
 
 	/* set device */
@@ -1508,7 +1508,7 @@ gcm_test_utils_func (void)
 static void
 gcm_test_client_func (void)
 {
-	GcmClient *client;
+	CdClient *client;
 	GError *error = NULL;
 	gboolean ret;
 	GPtrArray *array;
@@ -1517,10 +1517,10 @@ gcm_test_client_func (void)
 	gchar *filename;
 	gchar *data = NULL;
 
-	client = gcm_client_new ();
+	client = cd_client_new ();
 	g_assert (client != NULL);
 
-	array = gcm_client_get_devices (client);
+	array = cd_client_get_devices (client);
 	g_assert (array != NULL);
 	g_assert_cmpint (array->len, ==, 0);
 	g_ptr_array_unref (array);
@@ -1536,7 +1536,7 @@ gcm_test_client_func (void)
 	g_assert_no_error (error);
 	g_assert (ret);
 
-	array = gcm_client_get_devices (client);
+	array = cd_client_get_devices (client);
 	g_assert (array != NULL);
 	g_assert_cmpint (array->len, ==, 1);
 	device = g_ptr_array_index (array, 0);
@@ -1552,12 +1552,12 @@ gcm_test_client_func (void)
 	gcm_device_set_id (device, "xrandr_goldstar");
 	gcm_device_set_title (device, "Slightly different");
 	gcm_device_set_connected (device, TRUE);
-	ret = gcm_client_add_device (client, device, &error);
+	ret = cd_client_add_device (client, device, &error);
 	g_assert_no_error (error);
 	g_assert (ret);
 
 	/* ensure we merge saved properties into current devices */
-	array = gcm_client_get_devices (client);
+	array = cd_client_get_devices (client);
 	g_assert_cmpint (array->len, ==, 1);
 	device = g_ptr_array_index (array, 0);
 	g_assert_cmpstr (gcm_device_get_id (device), ==, "xrandr_goldstar");
@@ -1569,11 +1569,11 @@ gcm_test_client_func (void)
 
 	/* delete */
 	gcm_device_set_connected (device, FALSE);
-	ret = gcm_client_delete_device (client, device, &error);
+	ret = cd_client_delete_device (client, device, &error);
 	g_assert_no_error (error);
 	g_assert (ret);
 
-	array = gcm_client_get_devices (client);
+	array = cd_client_get_devices (client);
 	g_assert_cmpint (array->len, ==, 0);
 	g_ptr_array_unref (array);
 
diff --git a/src/gcm-session.c b/src/gcm-session.c
index 6c13fb2..d4e2403 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -25,14 +25,13 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 #include <locale.h>
+#include <colord.h>
 #include <libnotify/notify.h>
 
-#include "gcm-client.h"
 #include "gcm-device-xrandr.h"
 #include "gcm-exif.h"
 #include "gcm-device.h"
 #include "gcm-utils.h"
-#include "gcm-client.h"
 #include "gcm-profile-store.h"
 #include "gcm-debug.h"
 
@@ -148,7 +147,7 @@ gcm_session_notify_device (GcmDevice *device)
  * gcm_session_added_cb:
  **/
 static void
-gcm_session_added_cb (GcmClient *client_, GcmDevice *device, gpointer user_data)
+gcm_session_added_cb (CdClient *client_, GcmDevice *device, gpointer user_data)
 {
 	CdDeviceKind kind;
 	const gchar *profile;
@@ -207,7 +206,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 = cd_x11_screen_get_output_by_window (client, window);
 	if (device == NULL) {
 		g_set_error (error, 1, 0, "no device found for xid %i", xid);
 		goto out;
@@ -275,7 +274,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 = cd_client_get_devices (client);
 	for (i=0; i<array_devices->len; i++) {
 		device = g_ptr_array_index (array_devices, i);
 
@@ -329,7 +328,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 = cd_client_get_devices (client);
 	for (i=0; i<array_devices->len; i++) {
 		device = g_ptr_array_index (array_devices, i);
 
@@ -859,7 +858,7 @@ main (int argc, char *argv[])
 
 #if 0
 	/* set for each output */
-	array = gcm_client_get_devices (client);
+	array = cd_client_get_devices (client);
 	for (i=0; i<array->len; i++) {
 		device = g_ptr_array_index (array, i);
 
diff --git a/src/gcm-x11-screen.c b/src/gcm-x11-screen.c
index a5bd423..088c95d 100644
--- a/src/gcm-x11-screen.c
+++ b/src/gcm-x11-screen.c
@@ -356,7 +356,9 @@ gcm_x11_screen_get_outputs (GcmX11Screen *screen, GError **error)
  * Return value: A #GcmX11Output, or %NULL if nothing matched.
  **/
 GcmX11Output *
-gcm_x11_screen_get_output_by_name (GcmX11Screen *screen, const gchar *name, GError **error)
+gcm_x11_screen_get_output_by_name (GcmX11Screen *screen,
+				   const gchar *name,
+				   GError **error)
 {
 	guint i;
 	GcmX11Output *output;
@@ -383,6 +385,121 @@ gcm_x11_screen_get_output_by_name (GcmX11Screen *screen, const gchar *name, GErr
 }
 
 /**
+ * cd_x11_screen_get_output_coverage:
+ **/
+static gfloat
+cd_x11_screen_get_output_coverage (gint x, gint y,
+					    gint width, gint height,
+					    gint window_x, gint window_y,
+					    gint window_width, gint window_height)
+{
+	gfloat covered = 0.0f;
+	gint overlap_x;
+	gint overlap_y;
+
+	/* to the right of the window */
+	if (window_x > x + width)
+		goto out;
+	if (window_y > y + height)
+		goto out;
+
+	/* to the left of the window */
+	if (window_x + window_width < x)
+		goto out;
+	if (window_y + window_height < y)
+		goto out;
+
+	/* get the overlaps */
+	overlap_x = MIN((window_x + window_width - x), width) -
+		    MAX(window_x - x, 0);
+	overlap_y = MIN((window_y + window_height - y), height) -
+		    MAX(window_y - y, 0);
+
+	/* not in this window */
+	if (overlap_x <= 0)
+		goto out;
+	if (overlap_y <= 0)
+		goto out;
+
+	/* get the coverage */
+	covered = (gfloat) (overlap_x * overlap_y) /
+		  (gfloat) (window_width * window_height);
+	g_debug ("overlap_x=%i,overlap_y=%i,covered=%f",
+		  overlap_x, overlap_y, covered);
+out:
+	return covered;
+}
+
+/**
+ * cd_x11_screen_get_output_by_window:
+ **/
+GcmX11Output *
+cd_x11_screen_get_output_by_window (GcmX11Screen *screen,
+				    GdkWindow *window)
+{
+	GcmX11Output *output;
+	GcmX11Output *output_best = NULL;
+	GcmX11ScreenPrivate *priv = screen->priv;
+	gfloat covered;
+	gfloat covered_max = 0.0f;
+	gint window_width, window_height;
+	gint window_x, window_y;
+	guint i;
+	guint width, height;
+	guint x, y;
+
+	/* get the window parameters, in root co-ordinates */
+	gdk_window_get_origin (window, &window_x, &window_y);
+	window_width = gdk_window_get_width (window);
+	window_height = gdk_window_get_height (window);
+
+	/* go through each output */
+	for (i=0; i<priv->outputs->len; i++) {
+
+		/* not interesting */
+		output = g_ptr_array_index (priv->outputs, i);
+		if (!gcm_x11_output_get_connected (output))
+			continue;
+
+		/* get details about the output */
+		gcm_x11_output_get_position (output, &x, &y);
+		gcm_x11_output_get_size (output, &width, &height);
+		g_debug ("%s: %ix%i -> %ix%i (%ix%i -> %ix%i)",
+			 gcm_x11_output_get_name (output),
+			 x, y,
+			 x+width, y+height,
+			 window_x, window_y,
+			 window_x+window_width,
+			 window_y+window_height);
+
+		/* get the fraction of how much the window is covered */
+		covered = cd_x11_screen_get_output_coverage (x, y,
+							     width, height,
+							     window_x, window_y,
+							     window_width, window_height);
+
+		/* keep a running total of which one is best */
+		if (covered > 0.01f && covered > covered_max) {
+			output_best = output;
+
+			/* optimize */
+			if (covered > 0.99) {
+				g_debug ("all in one window");
+				goto out;
+			}
+
+			/* keep looking */
+			covered_max = covered;
+			g_debug ("personal best of %f for %s", covered, gcm_x11_output_get_name (output_best));
+		}
+	}
+out:
+	if (output_best != NULL)
+		g_object_ref (output_best);
+	return output_best;
+}
+
+/**
  * gcm_x11_screen_get_profile_data:
  * @screen: a valid %GcmX11Screen instance
  * @data: the data that is returned from the XServer. Free with g_free()
@@ -394,7 +511,10 @@ gcm_x11_screen_get_output_by_name (GcmX11Screen *screen, const gchar *name, GErr
  * Return value: %TRUE for success.
  **/
 gboolean
-gcm_x11_screen_get_profile_data (GcmX11Screen *screen, guint8 **data, gsize *length, GError **error)
+gcm_x11_screen_get_profile_data (GcmX11Screen *screen,
+				 guint8 **data,
+				 gsize *length,
+				 GError **error)
 {
 	gboolean ret = FALSE;
 	gchar *data_tmp = NULL;
diff --git a/src/gcm-x11-screen.h b/src/gcm-x11-screen.h
index 311af28..d366b25 100644
--- a/src/gcm-x11-screen.h
+++ b/src/gcm-x11-screen.h
@@ -69,6 +69,8 @@ GPtrArray	*gcm_x11_screen_get_outputs		(GcmX11Screen		*screen,
 GcmX11Output	*gcm_x11_screen_get_output_by_name	(GcmX11Screen		*screen,
 							 const gchar		*name,
 							 GError			**error);
+GcmX11Output	*cd_x11_screen_get_output_by_window	(GcmX11Screen		*screen,
+							 GdkWindow		*window);
 gboolean	 gcm_x11_screen_get_profile_data	(GcmX11Screen		*screen,
 							 guint8			**data,
 							 gsize			*length,



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