From c02638e614a5116d949c3b2ecb4fbbffd9e3462f Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Tue, 20 Jun 2017 15:36:34 -0700 Subject: [PATCH] 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 --- src/backends/x11/meta-input-settings-x11.c | 34 ++++++++++++++-------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c index d2e2d99f1..894e4bb9e 100644 --- a/src/backends/x11/meta-input-settings-x11.c +++ b/src/backends/x11/meta-input-settings-x11.c @@ -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,9 +582,15 @@ device_query_area (ClutterInputDevice *device, if (valuator->type != XIValuatorClass) continue; if (valuator->label == abs_x) - *width = valuator->max - valuator->min; + { + *x = valuator->min; + *width = valuator->max - valuator->min; + } else if (valuator->label == abs_y) - *height = valuator->max - valuator->min; + { + *y = valuator->min; + *height = valuator->max - valuator->min; + } } XIFreeDeviceInfo (info); @@ -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); }