[gnome-control-center] wacom: Set the last-calibrated-resolution key after calibrating



commit 2b34736ea81484d950135839b1c2760e48e7646d
Author: Joaquim Rocha <jrocha redhat com>
Date:   Fri Apr 19 16:37:59 2013 +0200

    wacom: Set the last-calibrated-resolution key after calibrating
    
    So g-s-d will know if calibration is needed when the monitor resolution
    changes.
    
    This is related to https://bugzilla.gnome.org/show_bug.cgi?id=677095

 panels/wacom/calibrator/gui_gtk.c |    7 +++++++
 panels/wacom/calibrator/gui_gtk.h |    2 ++
 panels/wacom/cc-wacom-page.c      |   29 +++++++++++++++++++++++------
 3 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/panels/wacom/calibrator/gui_gtk.c b/panels/wacom/calibrator/gui_gtk.c
index 62bffbe..e6a398c 100644
--- a/panels/wacom/calibrator/gui_gtk.c
+++ b/panels/wacom/calibrator/gui_gtk.c
@@ -582,3 +582,10 @@ calib_area_free (CalibArea *area)
        gtk_widget_destroy (area->window);
        g_free (area);
 }
+
+void
+calib_area_get_display_size (CalibArea *area, gint *width, gint *height)
+{
+       *width = area->display_width;
+       *height = area->display_height;
+}
diff --git a/panels/wacom/calibrator/gui_gtk.h b/panels/wacom/calibrator/gui_gtk.h
index d3d12fc..d2d3bd2 100644
--- a/panels/wacom/calibrator/gui_gtk.h
+++ b/panels/wacom/calibrator/gui_gtk.h
@@ -53,4 +53,6 @@ gboolean calib_area_finish (CalibArea *area,
 
 void calib_area_free (CalibArea *area);
 
+void calib_area_get_display_size (CalibArea *area, gint *width, gint *height);
+
 #endif /* _gui_gtk_h */
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index daa6372..22fc282 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -147,15 +147,19 @@ get_layout_type (GsdWacomDevice *device)
 }
 
 static void
-set_calibration (gint      *cal,
-                 gsize      ncal,
-                 GSettings *settings)
+set_calibration (GsdWacomDevice *device,
+                 const gint      display_width,
+                 const gint      display_height,
+                 gint           *cal,
+                 gsize           ncal,
+                 GSettings      *settings)
 {
        GVariant    *current; /* current calibration */
        GVariant    *array;   /* new calibration */
+       GVariant    *last_resolution;
        GVariant   **tmp;
        gsize        nvalues;
-       int          i;
+       gint         i;
 
        current = g_settings_get_value (settings, "area");
        g_variant_get_fixed_array (current, &nvalues, sizeof (gint32));
@@ -172,6 +176,14 @@ set_calibration (gint      *cal,
        g_settings_set_value (settings, "area", array);
 
        g_free (tmp);
+
+       /* set the last-calibration-resolution */
+       last_resolution = g_variant_new ("(ii)", display_width, display_height);
+       settings = gsd_wacom_device_get_settings (device);
+       g_settings_set_value (settings,
+                             "last-calibrated-resolution",
+                             last_resolution);
+       g_clear_pointer (&last_resolution, g_variant_unref);
 }
 
 static void
@@ -182,7 +194,7 @@ finish_calibration (CalibArea *area,
        CcWacomPagePrivate *priv = page->priv;
        XYinfo axis;
        gboolean swap_xy;
-       int cal[4];
+       gint cal[4], display_width, display_height;
 
        if (calib_area_finish (area, &axis, &swap_xy)) {
                cal[0] = axis.x_min;
@@ -190,7 +202,12 @@ finish_calibration (CalibArea *area,
                cal[2] = axis.x_max;
                cal[3] = axis.y_max;
 
-               set_calibration(cal, 4, priv->wacom_settings);
+               calib_area_get_display_size (area, &display_width, &display_height);
+
+               set_calibration (page->priv->stylus,
+                                display_width,
+                                display_height,
+                                cal, 4, priv->wacom_settings);
        }
 
        calib_area_free (area);


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