[gnome-control-center] wacom: Have calibrator take into account window geometry



commit bb38492e52bdd1060eb30b1c297e069449230480
Author: Jason Gerecke <killertofu gmail com>
Date:   Thu Jan 12 15:12:01 2012 -0800

    wacom: Have calibrator take into account window geometry
    
    Current calculations assume the window is anchored at 0,0. This
    obviously poses a problem in a multi-monitor setup.

 panels/wacom/calibrator/calibrator.c |   14 ++++++--------
 panels/wacom/calibrator/calibrator.h |    5 +++--
 panels/wacom/calibrator/gui_gtk.c    |    7 ++++++-
 3 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/panels/wacom/calibrator/calibrator.c b/panels/wacom/calibrator/calibrator.c
index a907a29..c597d79 100644
--- a/panels/wacom/calibrator/calibrator.c
+++ b/panels/wacom/calibrator/calibrator.c
@@ -120,8 +120,6 @@ add_click (struct Calib *c,
 /* calculate and apply the calibration */
 gboolean
 finish (struct Calib *c,
-        int           width,
-        int           height,
         XYinfo       *new_axis,
         gboolean         *swap)
 {
@@ -145,12 +143,12 @@ finish (struct Calib *c,
 
     /* Compute min/max coordinates. */
     /* These are scaled using the values of old_axis */
-    scale_x = (c->old_axis.x_max - c->old_axis.x_min)/(float)width;
-    axis.x_min = ((c->clicked_x[UL] + c->clicked_x[LL]) * scale_x/2) + c->old_axis.x_min;
-    axis.x_max = ((c->clicked_x[UR] + c->clicked_x[LR]) * scale_x/2) + c->old_axis.x_min;
-    scale_y = (c->old_axis.y_max - c->old_axis.y_min)/(float)height;
-    axis.y_min = ((c->clicked_y[UL] + c->clicked_y[UR]) * scale_y/2) + c->old_axis.y_min;
-    axis.y_max = ((c->clicked_y[LL] + c->clicked_y[LR]) * scale_y/2) + c->old_axis.y_min;
+    scale_x = (c->old_axis.x_max - c->old_axis.x_min)/(float)c->geometry.width;
+    axis.x_min = ((((c->clicked_x[UL] + c->clicked_x[LL]) / 2) - c->geometry.x) * scale_x) + c->old_axis.x_min;
+    axis.x_max = ((((c->clicked_x[UR] + c->clicked_x[LR]) / 2) - c->geometry.x) * scale_x) + c->old_axis.x_min;
+    scale_y = (c->old_axis.y_max - c->old_axis.y_min)/(float)c->geometry.height;
+    axis.y_min = ((((c->clicked_y[UL] + c->clicked_y[UR]) / 2) - c->geometry.y) * scale_y) + c->old_axis.y_min;
+    axis.y_max = ((((c->clicked_y[LL] + c->clicked_y[LR]) / 2) - c->geometry.y) * scale_y) + c->old_axis.y_min;
 
     /* Add/subtract the offset that comes from not having the points in the
      * corners (using the same coordinate system they are currently in)
diff --git a/panels/wacom/calibrator/calibrator.h b/panels/wacom/calibrator/calibrator.h
index cf79291..75d72d7 100644
--- a/panels/wacom/calibrator/calibrator.h
+++ b/panels/wacom/calibrator/calibrator.h
@@ -69,6 +69,9 @@ struct Calib
     /* original axis values */
     XYinfo old_axis;
 
+    /* Geometry of the calibration window */
+    GdkRectangle geometry;
+
     /* nr of clicks registered */
     int num_clicks;
 
@@ -92,8 +95,6 @@ gboolean add_click  (struct Calib *c,
                  int           x,
                  int           y);
 gboolean finish     (struct Calib *c,
-                 int           width,
-                 int           height,
                  XYinfo       *new_axis,
                  gboolean         *swap);
 
diff --git a/panels/wacom/calibrator/gui_gtk.c b/panels/wacom/calibrator/gui_gtk.c
index 718ce8c..3e39ba0 100644
--- a/panels/wacom/calibrator/gui_gtk.c
+++ b/panels/wacom/calibrator/gui_gtk.c
@@ -403,6 +403,11 @@ calib_area_new (GdkScreen      *screen,
 	gtk_window_move (GTK_WINDOW (calib_area->window), rect.x, rect.y);
 	gtk_window_set_default_size (GTK_WINDOW (calib_area->window), rect.width, rect.height);
 
+	calib_area->calibrator.geometry.x = rect.x;
+	calib_area->calibrator.geometry.y = rect.y;
+	calib_area->calibrator.geometry.width = rect.width;
+	calib_area->calibrator.geometry.height = rect.height;
+
 	gtk_widget_show_all (calib_area->window);
 
 	return calib_area;
@@ -419,7 +424,7 @@ calib_area_finish (CalibArea *area,
 
 	g_return_val_if_fail (area != NULL, FALSE);
 
-	success = finish (&area->calibrator, area->display_width, area->display_height, new_axis, swap_xy);
+	success = finish (&area->calibrator, new_axis, swap_xy);
 
 	if (success)
 		g_debug ("Final calibration: %d, %d, %d, %d\n",



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