backends/x11: Account for non-zero device origin when setting tablet area

Wacom's display tablets typically do not have (0,0) coincident with the top
left corner of the screen. This "outbound" area must be taken into account
when setting the area or else an unexpected offset of the pointer will
occur.

https://bugzilla.gnome.org/show_bug.cgi?id=784009
This commit is contained in:
Jason Gerecke 2017-06-20 15:36:34 -07:00 committed by Carlos Garnacho
parent 5f49bda591
commit 74882b2502

View File

@ -555,6 +555,8 @@ meta_input_settings_x11_set_tablet_mapping (MetaInputSettings *settings,
static gboolean
device_query_area (ClutterInputDevice *device,
gint *x,
gint *y,
gint *width,
gint *height)
{
@ -580,10 +582,16 @@ device_query_area (ClutterInputDevice *device,
if (valuator->type != XIValuatorClass)
continue;
if (valuator->label == abs_x)
{
*x = valuator->min;
*width = valuator->max - valuator->min;
}
else if (valuator->label == abs_y)
{
*y = valuator->min;
*height = valuator->max - valuator->min;
}
}
XIFreeDeviceInfo (info);
return TRUE;
@ -606,15 +614,15 @@ meta_input_settings_x11_set_tablet_area (MetaInputSettings *settings,
gdouble padding_top,
gdouble padding_bottom)
{
gint32 width, height, area[4] = { 0 };
gint32 x, y, width, height, area[4] = { 0 };
if (!device_query_area (device, &width, &height))
if (!device_query_area (device, &x, &y, &width, &height))
return;
area[0] = width * padding_left;
area[1] = height * padding_top;
area[2] = width - (width * padding_right);
area[3] = height - (height * padding_bottom);
area[0] = (width * padding_left) + x;
area[1] = (height * padding_top) + y;
area[2] = width - (width * padding_right) + x;
area[3] = height - (height * padding_bottom) + y;
update_tablet_area (settings, device, area);
}
@ -624,9 +632,9 @@ meta_input_settings_x11_set_tablet_keep_aspect (MetaInputSettings *settings,
MetaLogicalMonitor *logical_monitor,
gboolean keep_aspect)
{
gint32 width, height, dev_width, dev_height, area[4] = { 0 };
gint32 width, height, dev_x, dev_y, dev_width, dev_height, area[4] = { 0 };
if (!device_query_area (device, &dev_width, &dev_height))
if (!device_query_area (device, &dev_x, &dev_y, &dev_width, &dev_height))
return;
if (keep_aspect)
@ -658,8 +666,10 @@ meta_input_settings_x11_set_tablet_keep_aspect (MetaInputSettings *settings,
dev_height = dev_width / aspect_ratio;
}
area[2] = dev_width;
area[3] = dev_height;
area[0] = dev_x;
area[1] = dev_y;
area[2] = dev_width + dev_x;
area[3] = dev_height + dev_y;
update_tablet_area (settings, device, area);
}