[gnome-color-manager] It turns out gnome_rr_screen_new() is pretty slow. Cache this and take 0.7 seconds off the start tim
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] It turns out gnome_rr_screen_new() is pretty slow. Cache this and take 0.7 seconds off the start tim
- Date: Tue, 19 Jan 2010 13:54:23 +0000 (UTC)
commit b50c8fd664b32fe80c6628c394a08b211845545d
Author: Richard Hughes <richard hughsie com>
Date: Tue Jan 19 13:34:13 2010 +0000
It turns out gnome_rr_screen_new() is pretty slow. Cache this and take 0.7 seconds off the start time
src/Makefile.am | 2 +
src/gcm-calibrate-argyll.c | 15 +--
src/gcm-client.c | 60 ++++++------
src/gcm-dump-edid.c | 19 ++--
src/gcm-inspect.c | 19 ++--
src/gcm-prefs.c | 8 ++
src/gcm-screen.c | 220 ++++++++++++++++++++++++++++++++++++++++++++
src/gcm-screen.h | 86 +++++++++++++++++
src/gcm-utils.c | 17 ++--
9 files changed, 377 insertions(+), 69 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0ee2838..fc23fce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,6 +26,8 @@ libgcmshared_a_SOURCES = \
egg-debug.h \
gcm-image.c \
gcm-image.h \
+ gcm-screen.c \
+ gcm-screen.h \
gcm-xyz.c \
gcm-xyz.h \
gcm-utils.c \
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index b054983..e84a52c 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -40,6 +40,7 @@
#include "gcm-calibrate-argyll.h"
#include "gcm-utils.h"
+#include "gcm-screen.h"
#include "egg-debug.h"
@@ -60,7 +61,7 @@ struct _GcmCalibrateArgyllPrivate
GtkBuilder *builder;
pid_t child_pid;
GtkResponseType response;
- GnomeRRScreen *rr_screen;
+ GcmScreen *screen;
};
enum {
@@ -264,9 +265,8 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
}
/* get the device */
- output = gnome_rr_screen_get_output_by_name (priv->rr_screen, output_name);
+ output = gcm_screen_get_output_by_name (priv->screen, output_name, error);
if (output == NULL) {
- g_set_error (error, 1, 0, "failed to get output for %s", output_name);
ret = FALSE;
goto out;
}
@@ -1180,12 +1180,7 @@ gcm_calibrate_argyll_init (GcmCalibrateArgyll *calibrate_argyll)
}
/* get screen */
- calibrate_argyll->priv->rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, &error);
- if (calibrate_argyll->priv->rr_screen == NULL) {
- egg_warning ("failed to get rr screen: %s", error->message);
- g_error_free (error);
- return;
- }
+ calibrate_argyll->priv->screen = gcm_screen_new ();
/* set icon */
main_window = GTK_WIDGET (gtk_builder_get_object (calibrate_argyll->priv->builder, "dialog_calibrate"));
@@ -1234,7 +1229,7 @@ gcm_calibrate_argyll_finalize (GObject *object)
g_main_loop_unref (priv->loop);
g_object_unref (priv->builder);
- gnome_rr_screen_destroy (priv->rr_screen);
+ g_object_unref (priv->screen);
G_OBJECT_CLASS (gcm_calibrate_argyll_parent_class)->finalize (object);
}
diff --git a/src/gcm-client.c b/src/gcm-client.c
index c38ac9f..65876e5 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -36,6 +36,7 @@
#include <math.h>
#include "gcm-client.h"
+#include "gcm-screen.h"
#include "gcm-utils.h"
#include "gcm-edid.h"
#include "gcm-dmi.h"
@@ -46,6 +47,8 @@ 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, GnomeRROutput *output);
+
/**
* GcmClientPrivate:
*
@@ -56,7 +59,7 @@ struct _GcmClientPrivate
gchar *display_name;
GPtrArray *array;
GUdevClient *gudev_client;
- GnomeRRScreen *rr_screen;
+ GcmScreen *screen;
GcmEdid *edid;
GcmDmi *dmi;
};
@@ -567,7 +570,9 @@ gcm_client_get_device_by_window (GcmClient *client, GdkWindow *window)
gdk_drawable_get_size (GDK_DRAWABLE(window), &window_width, &window_height);
/* get list of updates */
- outputs = gnome_rr_screen_list_outputs (client->priv->rr_screen);
+ outputs = gcm_screen_get_outputs (client->priv->screen, NULL);
+ if (outputs == NULL)
+ goto out;
/* find length */
for (i=0; outputs[i] != NULL; i++)
@@ -743,23 +748,6 @@ out:
}
/**
- * gcm_client_randr_event_cb:
- **/
-static void
-gcm_client_randr_event_cb (GnomeRRScreen *screen, GcmClient *client)
-{
- GnomeRROutput **outputs;
- guint i;
-
- egg_debug ("screens may have changed");
-
- /* replug devices */
- outputs = gnome_rr_screen_list_outputs (client->priv->rr_screen);
- for (i=0; outputs[i] != NULL; i++)
- gcm_client_xrandr_add (client, outputs[i]);
-}
-
-/**
* gcm_client_add_connected_devices_xrandr:
**/
static gboolean
@@ -769,7 +757,9 @@ gcm_client_add_connected_devices_xrandr (GcmClient *client, GError **error)
guint i;
GcmClientPrivate *priv = client->priv;
- outputs = gnome_rr_screen_list_outputs (priv->rr_screen);
+ outputs = gcm_screen_get_outputs (priv->screen, error);
+ if (outputs == NULL)
+ return FALSE;
for (i=0; outputs[i] != NULL; i++)
gcm_client_xrandr_add (client, outputs[i]);
return TRUE;
@@ -1018,6 +1008,23 @@ 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 (GcmScreen *screen, GcmClient *client)
+{
+ GnomeRROutput **outputs;
+ guint i;
+
+ egg_debug ("screens may have changed");
+
+ /* replug devices */
+ outputs = gcm_screen_get_outputs (screen, NULL);
+ for (i=0; outputs[i] != NULL; i++)
+ gcm_client_xrandr_add (client, outputs[i]);
+}
+
+/**
* gcm_client_class_init:
**/
static void
@@ -1066,7 +1073,6 @@ gcm_client_class_init (GcmClientClass *klass)
static void
gcm_client_init (GcmClient *client)
{
- GError *error = NULL;
const gchar *subsystems[] = {"usb", "video4linux", NULL};
client->priv = GCM_CLIENT_GET_PRIVATE (client);
@@ -1074,18 +1080,14 @@ gcm_client_init (GcmClient *client)
client->priv->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
client->priv->edid = gcm_edid_new ();
client->priv->dmi = gcm_dmi_new ();
+ client->priv->screen = gcm_screen_new ();
+ g_signal_connect (client->priv->screen, "outputs-changed",
+ G_CALLBACK (gcm_client_randr_event_cb), client);
/* use GUdev to find devices */
client->priv->gudev_client = g_udev_client_new (subsystems);
g_signal_connect (client->priv->gudev_client, "uevent",
G_CALLBACK (gcm_client_uevent_cb), client);
-
- /* get screen */
- client->priv->rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), (GnomeRRScreenChanged) gcm_client_randr_event_cb, client, &error);
- if (client->priv->rr_screen == NULL) {
- egg_error ("failed to get rr screen: %s", error->message);
- g_error_free (error);
- }
}
/**
@@ -1102,7 +1104,7 @@ gcm_client_finalize (GObject *object)
g_object_unref (priv->gudev_client);
g_object_unref (priv->edid);
g_object_unref (priv->dmi);
- gnome_rr_screen_destroy (priv->rr_screen);
+ g_object_unref (priv->screen);
G_OBJECT_CLASS (gcm_client_parent_class)->finalize (object);
}
diff --git a/src/gcm-dump-edid.c b/src/gcm-dump-edid.c
index 5dc5d6f..09a4cfe 100644
--- a/src/gcm-dump-edid.c
+++ b/src/gcm-dump-edid.c
@@ -29,6 +29,7 @@
#include "egg-debug.h"
#include "gcm-utils.h"
+#include "gcm-screen.h"
#include "gcm-edid.h"
/**
@@ -134,7 +135,7 @@ main (int argc, char **argv)
guint retval = 0;
GError *error = NULL;
GnomeRROutput **outputs;
- GnomeRRScreen *rr_screen = NULL;
+ GcmScreen *screen = NULL;
GOptionContext *context;
const GOptionEntry options[] = {
@@ -169,16 +170,14 @@ main (int argc, char **argv)
goto out;
}
- /* get screen */
- rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, &error);
- if (rr_screen == NULL) {
- egg_warning ("failed to get rr screen: %s", error->message);
+ /* coldplug devices */
+ screen = gcm_screen_new ();
+ outputs = gcm_screen_get_outputs (screen, &error);
+ if (screen == NULL) {
+ egg_warning ("failed to get outputs: %s", error->message);
retval = 1;
goto out;
}
-
- /* coldplug devices */
- outputs = gnome_rr_screen_list_outputs (rr_screen);
for (i=0; outputs[i] != NULL; i++) {
/* only try to get edid if connected */
@@ -216,8 +215,8 @@ main (int argc, char **argv)
}
out:
g_strfreev (files);
- if (rr_screen != NULL)
- gnome_rr_screen_destroy (rr_screen);
+ if (screen != NULL)
+ g_object_unref (screen);
return retval;
}
diff --git a/src/gcm-inspect.c b/src/gcm-inspect.c
index fad9700..5b01d8d 100644
--- a/src/gcm-inspect.c
+++ b/src/gcm-inspect.c
@@ -32,6 +32,7 @@
#include "gcm-utils.h"
#include "gcm-profile.h"
#include "gcm-xserver.h"
+#include "gcm-screen.h"
/**
* gcm_inspect_print_data_info:
@@ -89,7 +90,7 @@ gcm_inspect_show_x11_atoms (void)
GcmXserver *xserver = NULL;
GnomeRROutput **outputs;
guint i;
- GnomeRRScreen *rr_screen = NULL;
+ GcmScreen *screen = NULL;
const gchar *output_name;
gchar *title;
GError *error = NULL;
@@ -109,17 +110,15 @@ gcm_inspect_show_x11_atoms (void)
gcm_inspect_print_data_info (_("Root window profile (deprecated):"), data, length);
}
- /* get screen */
- rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, &error);
- if (rr_screen == NULL) {
+ /* coldplug devices */
+ screen = gcm_screen_new ();
+ outputs = gcm_screen_get_outputs (screen, &error);
+ if (outputs == NULL) {
ret = FALSE;
- egg_warning ("failed to get rr screen: %s", error->message);
+ egg_warning ("failed to get outputs: %s", error->message);
g_error_free (error);
goto out;
}
-
- /* coldplug devices */
- outputs = gnome_rr_screen_list_outputs (rr_screen);
for (i=0; outputs[i] != NULL; i++) {
/* get output name */
@@ -144,8 +143,8 @@ gcm_inspect_show_x11_atoms (void)
}
out:
g_free (data);
- if (rr_screen != NULL)
- gnome_rr_screen_destroy (rr_screen);
+ if (screen != NULL)
+ g_object_unref (screen);
if (xserver != NULL)
g_object_unref (xserver);
return ret;
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index a789483..77c1c17 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -2490,6 +2490,14 @@ gcm_prefs_startup_phase1_idle_cb (gpointer user_data)
g_signal_connect (G_OBJECT (widget), "changed",
G_CALLBACK (gcm_prefs_renderer_combo_changed_cb), (gpointer) "softproof");
+ /* coldplug saved devices */
+ ret = gcm_client_add_saved (gcm_client, &error);
+ if (!ret) {
+ egg_warning ("failed to coldplug: %s", error->message);
+ g_error_free (error);
+ /* do not fail */
+ }
+
/* coldplug plugged in devices */
ret = gcm_client_add_connected (gcm_client, &error);
if (!ret) {
diff --git a/src/gcm-screen.c b/src/gcm-screen.c
new file mode 100644
index 0000000..e876162
--- /dev/null
+++ b/src/gcm-screen.c
@@ -0,0 +1,220 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:gcm-screen
+ * @short_description: For querying data about PackageKit
+ *
+ * A GObject to use for accessing PackageKit asynchronously.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "egg-debug.h"
+
+#include "gcm-screen.h"
+
+static void gcm_screen_finalize (GObject *object);
+
+#define GCM_SCREEN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCM_TYPE_SCREEN, GcmScreenPrivate))
+
+#define GCM_SCREEN_DBUS_METHOD_TIMEOUT 1500 /* ms */
+
+/**
+ * GcmScreenPrivate:
+ *
+ * Private #GcmScreen data
+ **/
+struct _GcmScreenPrivate
+{
+ GnomeRRScreen *rr_screen;
+};
+
+enum {
+ SIGNAL_OUTPUTS_CHANGED,
+ SIGNAL_LAST
+};
+
+enum {
+ PROP_0,
+ PROP_LAST
+};
+
+static guint signals[SIGNAL_LAST] = { 0 };
+static gpointer gcm_screen_object = NULL;
+
+G_DEFINE_TYPE (GcmScreen, gcm_screen, G_TYPE_OBJECT)
+
+/**
+ * gcm_screen_randr_event_cb:
+ **/
+static void
+gcm_screen_randr_event_cb (GnomeRRScreen *rr_screen, GcmScreen *screen)
+{
+ egg_debug ("emit outputs-changed");
+ g_signal_emit (screen, signals[SIGNAL_OUTPUTS_CHANGED], 0);
+}
+
+/**
+ * gcm_screen_ensure_instance:
+ **/
+static gboolean
+gcm_screen_ensure_instance (GcmScreen *screen, GError **error)
+{
+ gboolean ret = TRUE;
+ GcmScreenPrivate *priv = screen->priv;
+
+ /* already got */
+ if (priv->rr_screen != NULL)
+ goto out;
+
+ /* get screen (this is slow) */
+ priv->rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), (GnomeRRScreenChanged) gcm_screen_randr_event_cb, screen, error);
+ if (priv->rr_screen == NULL) {
+ ret = FALSE;
+ goto out;
+ }
+out:
+ return ret;
+}
+
+/**
+ * gcm_screen_get_output_by_name:
+ **/
+GnomeRROutput *
+gcm_screen_get_output_by_name (GcmScreen *screen, const gchar *output_name, GError **error)
+{
+ gboolean ret;
+ GnomeRROutput *output = NULL;
+ GcmScreenPrivate *priv = screen->priv;
+
+ g_return_val_if_fail (GCM_IS_SCREEN (screen), NULL);
+ g_return_val_if_fail (output_name != NULL, NULL);
+
+ /* get instance */
+ ret = gcm_screen_ensure_instance (screen, error);
+ if (!ret)
+ goto out;
+
+ /* get output */
+ output = gnome_rr_screen_get_output_by_name (priv->rr_screen, output_name);
+ if (output == NULL) {
+ g_set_error (error, 1, 0, "no output for name: %s", output_name);
+ goto out;
+ }
+out:
+ return output;
+}
+
+/**
+ * gcm_screen_get_outputs:
+ **/
+GnomeRROutput **
+gcm_screen_get_outputs (GcmScreen *screen, GError **error)
+{
+ gboolean ret;
+ GnomeRROutput **outputs = NULL;
+ GcmScreenPrivate *priv = screen->priv;
+
+ g_return_val_if_fail (GCM_IS_SCREEN (screen), NULL);
+
+ /* get instance */
+ ret = gcm_screen_ensure_instance (screen, error);
+ if (!ret)
+ goto out;
+
+ /* get output */
+ outputs = gnome_rr_screen_list_outputs (priv->rr_screen);
+ if (outputs == NULL) {
+ g_set_error (error, 1, 0, "no outputs for screen");
+ goto out;
+ }
+out:
+ return outputs;
+}
+
+/**
+ * gcm_screen_class_init:
+ **/
+static void
+gcm_screen_class_init (GcmScreenClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = gcm_screen_finalize;
+
+ /**
+ * GcmScreen::outputs-changed:
+ **/
+ signals[SIGNAL_OUTPUTS_CHANGED] =
+ g_signal_new ("outputs-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GcmScreenClass, outputs_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private (klass, sizeof (GcmScreenPrivate));
+}
+
+/**
+ * gcm_screen_init:
+ **/
+static void
+gcm_screen_init (GcmScreen *screen)
+{
+ screen->priv = GCM_SCREEN_GET_PRIVATE (screen);
+}
+
+/**
+ * gcm_screen_finalize:
+ **/
+static void
+gcm_screen_finalize (GObject *object)
+{
+ GcmScreen *screen = GCM_SCREEN (object);
+ GcmScreenPrivate *priv = screen->priv;
+
+ if (priv->rr_screen != NULL)
+ gnome_rr_screen_destroy (priv->rr_screen);
+
+ G_OBJECT_CLASS (gcm_screen_parent_class)->finalize (object);
+}
+
+/**
+ * gcm_screen_new:
+ *
+ * Return value: a new GcmScreen object.
+ **/
+GcmScreen *
+gcm_screen_new (void)
+{
+ if (gcm_screen_object != NULL) {
+ g_object_ref (gcm_screen_object);
+ } else {
+ gcm_screen_object = g_object_new (GCM_TYPE_SCREEN, NULL);
+ g_object_add_weak_pointer (gcm_screen_object, &gcm_screen_object);
+ }
+ return GCM_SCREEN (gcm_screen_object);
+}
+
diff --git a/src/gcm-screen.h b/src/gcm-screen.h
new file mode 100644
index 0000000..0744332
--- /dev/null
+++ b/src/gcm-screen.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GCM_SCREEN_H
+#define __GCM_SCREEN_H
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <libgnomeui/gnome-rr.h>
+
+G_BEGIN_DECLS
+
+#define GCM_TYPE_SCREEN (gcm_screen_get_type ())
+#define GCM_SCREEN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GCM_TYPE_SCREEN, GcmScreen))
+#define GCM_SCREEN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GCM_TYPE_SCREEN, GcmScreenClass))
+#define GCM_IS_SCREEN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GCM_TYPE_SCREEN))
+#define GCM_IS_SCREEN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GCM_TYPE_SCREEN))
+#define GCM_SCREEN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GCM_TYPE_SCREEN, GcmScreenClass))
+#define GCM_SCREEN_ERROR (gcm_screen_error_quark ())
+#define GCM_SCREEN_TYPE_ERROR (gcm_screen_error_get_type ())
+
+typedef struct _GcmScreenPrivate GcmScreenPrivate;
+typedef struct _GcmScreen GcmScreen;
+typedef struct _GcmScreenClass GcmScreenClass;
+
+/**
+ * GcmScreenError:
+ * @GCM_SCREEN_ERROR_FAILED: the transaction failed for an unknown reason
+ *
+ * Errors that can be thrown
+ */
+typedef enum
+{
+ GCM_SCREEN_ERROR_FAILED
+} GcmScreenError;
+
+struct _GcmScreen
+{
+ GObject parent;
+ GcmScreenPrivate *priv;
+};
+
+struct _GcmScreenClass
+{
+ GObjectClass parent_class;
+
+ /* signals */
+ void (* outputs_changed) (GcmScreen *screen);
+ /* padding for future expansion */
+ void (*_gcm_reserved1) (void);
+ void (*_gcm_reserved2) (void);
+ void (*_gcm_reserved3) (void);
+ void (*_gcm_reserved4) (void);
+ void (*_gcm_reserved5) (void);
+};
+
+GType gcm_screen_get_type (void);
+GcmScreen *gcm_screen_new (void);
+
+GnomeRROutput *gcm_screen_get_output_by_name (GcmScreen *screen,
+ const gchar *output_name,
+ GError **error);
+GnomeRROutput **gcm_screen_get_outputs (GcmScreen *screen,
+ GError **error);
+G_END_DECLS
+
+#endif /* __GCM_SCREEN_H */
+
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index a2f6bdc..5d7a2af 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -31,6 +31,7 @@
#include <dbus/dbus-glib.h>
#include "gcm-utils.h"
+#include "gcm-screen.h"
#include "gcm-clut.h"
#include "gcm-xserver.h"
@@ -400,7 +401,7 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
gboolean use_atom;
gboolean leftmost_screen = FALSE;
GcmDeviceTypeEnum type;
- GnomeRRScreen *rr_screen = NULL;
+ GcmScreen *screen = NULL;
GConfClient *gconf_client = NULL;
g_return_val_if_fail (device != NULL, FALSE);
@@ -443,14 +444,10 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
}
/* check we have an output */
- rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, error);
- if (rr_screen == NULL)
+ screen = gcm_screen_new ();
+ output = gcm_screen_get_output_by_name (screen, output_name, error);
+ if (output == NULL)
goto out;
- output = gnome_rr_screen_get_output_by_name (rr_screen, output_name);
- if (output == NULL) {
- g_set_error (error, 1, 0, "no output for device: %s [%s]", id, output_name);
- goto out;
- }
/* get crtc size */
crtc = gnome_rr_output_get_crtc (output);
@@ -541,8 +538,8 @@ out:
g_free (output_name);
if (gconf_client != NULL)
g_object_unref (gconf_client);
- if (rr_screen != NULL)
- gnome_rr_screen_destroy (rr_screen);
+ if (screen != NULL)
+ g_object_unref (screen);
if (clut != NULL)
g_object_unref (clut);
if (profile != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]