[gnome-settings-daemon] Partially revert "wacom: Remove some dead code from GsdWacomDevice"
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] Partially revert "wacom: Remove some dead code from GsdWacomDevice"
- Date: Tue, 20 Jan 2015 17:42:23 +0000 (UTC)
commit 3da1043cfa9843965a416f24146d5548a0a72ffc
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jan 20 18:09:42 2015 +0100
Partially revert "wacom: Remove some dead code from GsdWacomDevice"
This partially reverts commit f4b8633745c19e0f4dd5fe8fb36d1c974bd6a375. Some
code turned out to be used still in gnome-control-center, which copies the
files as-is from the g-s-d repo.
plugins/wacom/gsd-wacom-device.c | 106 ++++++++++++++++++++++++++++++++++++++
plugins/wacom/gsd-wacom-device.h | 2 +
2 files changed, 108 insertions(+), 0 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index 6bd9a4c..308bf6b 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -643,6 +643,88 @@ is_on (GnomeRROutput *output)
return gnome_rr_crtc_get_current_mode (crtc) != NULL;
}
+static GnomeRROutput *
+find_output_by_monitor (GnomeRRScreen *rr_screen,
+ GdkScreen *screen,
+ int monitor)
+{
+ GnomeRROutput **rr_outputs;
+ GnomeRROutput *ret;
+ guint i;
+
+ ret = NULL;
+
+ rr_outputs = gnome_rr_screen_list_outputs (rr_screen);
+
+ for (i = 0; rr_outputs[i] != NULL; i++) {
+ GnomeRROutput *rr_output;
+ GnomeRRCrtc *crtc;
+ int x, y;
+
+ rr_output = rr_outputs[i];
+
+ if (!is_on (rr_output))
+ continue;
+
+ crtc = gnome_rr_output_get_crtc (rr_output);
+ if (!crtc)
+ continue;
+
+ gnome_rr_crtc_get_position (crtc, &x, &y);
+
+ if (monitor == gdk_screen_get_monitor_at_point (screen, x, y)) {
+ ret = rr_output;
+ break;
+ }
+ }
+
+ if (ret == NULL)
+ g_warning ("No output found for monitor %d.", monitor);
+
+ return ret;
+}
+
+static void
+set_display_by_output (GsdWacomDevice *device,
+ GnomeRROutput *rr_output)
+{
+ GSettings *tablet;
+ GVariant *c_array;
+ GVariant *n_array;
+ gsize nvalues;
+ gchar *o_vendor, *o_product, *o_serial;
+ const gchar *values[3];
+
+ tablet = gsd_wacom_device_get_settings (device);
+ c_array = g_settings_get_value (tablet, "display");
+ g_variant_get_strv (c_array, &nvalues);
+ if (nvalues != 3) {
+ g_warning ("Unable set set display property. Got %"G_GSIZE_FORMAT" items; expected %d
items.\n", nvalues, 4);
+ return;
+ }
+
+ if (rr_output == NULL) {
+ o_vendor = g_strdup ("");
+ o_product = g_strdup ("");
+ o_serial = g_strdup ("");
+ } else {
+ gnome_rr_output_get_ids_from_edid (rr_output,
+ &o_vendor,
+ &o_product,
+ &o_serial);
+ }
+
+ values[0] = o_vendor;
+ values[1] = o_product;
+ values[2] = o_serial;
+ n_array = g_variant_new_strv ((const gchar * const *) &values, 3);
+ g_settings_set_value (tablet, "display", n_array);
+
+ g_free (o_vendor);
+ g_free (o_product);
+ g_free (o_serial);
+}
+
static GsdWacomRotation
get_rotation_wacom (GnomeRRRotation rotation)
{
@@ -655,6 +737,30 @@ get_rotation_wacom (GnomeRRRotation rotation)
g_assert_not_reached ();
}
+void
+gsd_wacom_device_set_display (GsdWacomDevice *device,
+ int monitor)
+{
+ GError *error = NULL;
+ GnomeRRScreen *rr_screen;
+ GnomeRROutput *output = NULL;
+
+ g_return_if_fail (GSD_IS_WACOM_DEVICE (device));
+
+ rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
+ if (rr_screen == NULL) {
+ g_warning ("Failed to create GnomeRRScreen: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (monitor > GSD_WACOM_SET_ALL_MONITORS)
+ output = find_output_by_monitor (rr_screen, gdk_screen_get_default (), monitor);
+ set_display_by_output (device, output);
+
+ g_object_unref (rr_screen);
+}
+
static GnomeRROutput *
find_output (GnomeRRScreen *rr_screen,
GsdWacomDevice *device)
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index 7db4b47..dd3d439 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -142,6 +142,8 @@ typedef enum {
GType gsd_wacom_device_get_type (void);
+void gsd_wacom_device_set_display (GsdWacomDevice *device,
+ int monitor);
gint gsd_wacom_device_get_display_monitor (GsdWacomDevice *device);
GsdWacomRotation gsd_wacom_device_get_display_rotation (GsdWacomDevice *device);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]