[gnome-control-center] wacom: Fix ~100 pixel offset when calibrating



commit 95f613bee17a8701f79cf4dd87e43219c4842892
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Oct 9 12:55:29 2013 +0200

    wacom: Fix ~100 pixel offset when calibrating
    
    The calibration gui code moved the targets to x,y, instead of
    placing the centre of the target at x,y, leading to a 47 pixel
    (half the target's size) offset in both directions (thus 67 pixels
    deviation as Pythagorus would tell us).

 panels/wacom/calibrator/calibrator-gui.c  |   13 ++++++-------
 panels/wacom/calibrator/cc-target-actor.c |   12 ++++++++----
 panels/wacom/calibrator/cc-target-actor.h |   10 +++++-----
 3 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/panels/wacom/calibrator/calibrator-gui.c b/panels/wacom/calibrator/calibrator-gui.c
index 3494b27..898fd38 100644
--- a/panels/wacom/calibrator/calibrator-gui.c
+++ b/panels/wacom/calibrator/calibrator-gui.c
@@ -131,9 +131,9 @@ resize_display(CalibArea *calib_area)
     {
       gint i = calib_area->calibrator.num_clicks;
       set_display_size(calib_area, width, height);
-      cc_target_actor_move (CC_TARGET_ACTOR (calib_area->target),
-                            calib_area->X[i],
-                            calib_area->Y[i]);
+      cc_target_actor_move_center (CC_TARGET_ACTOR (calib_area->target),
+                                   calib_area->X[i],
+                                   calib_area->Y[i]);
     }
 }
 
@@ -346,10 +346,9 @@ on_button_press_event(ClutterActor       *actor,
       return FALSE;
     }
 
-  cc_target_actor_move (CC_TARGET_ACTOR (area->target),
-                        area->X[num_clicks],
-                        area->Y[num_clicks]);
-
+  cc_target_actor_move_center (CC_TARGET_ACTOR (area->target),
+                               area->X[num_clicks],
+                               area->Y[num_clicks]);
 
   return FALSE;
 }
diff --git a/panels/wacom/calibrator/cc-target-actor.c b/panels/wacom/calibrator/cc-target-actor.c
index 69f4012..a0961c6 100644
--- a/panels/wacom/calibrator/cc-target-actor.c
+++ b/panels/wacom/calibrator/cc-target-actor.c
@@ -24,6 +24,7 @@
 #define CC_TARGET_ACTOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TARGET_ACTOR_TYPE, 
CcTargetActorPrivate))
 
 #define CROSS_LINES                    47
+#define TARGET_DIMENSION               (CROSS_LINES * 2)
 #define CROSS_CIRCLE                   7
 #define CROSS_CIRCLE2                  27
 #define TARGET_SHOW_ANIMATION_DURATION 500
@@ -185,8 +186,10 @@ cc_target_actor_class_init (CcTargetActorClass *klass)
   g_type_class_add_private (klass, sizeof (CcTargetActorPrivate));
 }
 
+
+/* Move the _center_ of the target to be at (x,y) */
 void
-cc_target_actor_move (CcTargetActor *self, gdouble x, gdouble y)
+cc_target_actor_move_center (CcTargetActor *self, gdouble x, gdouble y)
 {
   g_return_if_fail (CC_IS_TARGET_ACTOR (self));
 
@@ -195,8 +198,9 @@ cc_target_actor_move (CcTargetActor *self, gdouble x, gdouble y)
   gboolean target_visible;
 
   priv = CC_TARGET_ACTOR_GET_PRIVATE (self);
-  priv->pos_x = x;
-  priv->pos_y = y;
+
+  priv->pos_x = x - (TARGET_DIMENSION / 2);
+  priv->pos_y = y - (TARGET_DIMENSION / 2);
 
   g_object_get (self, "visible", &target_visible, NULL);
 
@@ -216,7 +220,7 @@ cc_target_actor_move (CcTargetActor *self, gdouble x, gdouble y)
     {
       clutter_actor_show (CLUTTER_ACTOR (self));
 
-      clutter_actor_set_position (CLUTTER_ACTOR (self), x, y);
+      clutter_actor_set_position (CLUTTER_ACTOR (self), priv->pos_x, priv->pos_y);
 
       show_target (self);
     }
diff --git a/panels/wacom/calibrator/cc-target-actor.h b/panels/wacom/calibrator/cc-target-actor.h
index c7d63f8..6667e5c 100644
--- a/panels/wacom/calibrator/cc-target-actor.h
+++ b/panels/wacom/calibrator/cc-target-actor.h
@@ -50,11 +50,11 @@ struct _CcTargetActorClass
   ClutterActorClass parent_class;
 };
 
-ClutterActor * cc_target_actor_new      (void);
-void           cc_target_actor_move     (CcTargetActor *target,
-                                         gdouble        x,
-                                         gdouble        y);
+ClutterActor * cc_target_actor_new         (void);
+void           cc_target_actor_move_center (CcTargetActor *target,
+                                            gdouble        x,
+                                            gdouble        y);
 
-GType          cc_target_actor_get_type (void);
+GType          cc_target_actor_get_type    (void);
 
 #endif /* __CC_TARGET_ACTOR_H__ */


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