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.
This commit is contained in:
Jason Gerecke 2012-01-12 15:12:01 -08:00 committed by Bastien Nocera
parent 73d53ef096
commit bb38492e52
3 changed files with 15 additions and 11 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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",