diff options
author | Jani Monoses <jani@ubuntu.com> | 2013-01-30 11:18:48 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2013-07-04 13:11:16 +0200 |
commit | 1a5bd5756f6209909b02e81a2a2ac37b10a2e5e9 (patch) | |
tree | 8f6699617d70ee83ce8fe0cdb030e6e72cb11431 /plugins/xrandr | |
parent | f52dfede2ccbc20319e33e1fd6e7fb5caabc2348 (diff) | |
download | gnome-settings-daemon-1a5bd5756f6209909b02e81a2a2ac37b10a2e5e9.tar.gz |
xrandr: Use transformation matrix to rotate touchscreens
https://bugzilla.gnome.org/show_bug.cgi?id=691691
Diffstat (limited to 'plugins/xrandr')
-rw-r--r-- | plugins/xrandr/gsd-xrandr-manager.c | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c index ec3da9cd..a03018e5 100644 --- a/plugins/xrandr/gsd-xrandr-manager.c +++ b/plugins/xrandr/gsd-xrandr-manager.c @@ -1502,15 +1502,13 @@ get_next_rotation (GnomeRRRotation allowed_rotations, GnomeRRRotation current_ro struct { GnomeRRRotation rotation; - /* evdev */ - gboolean x_axis_inversion; - gboolean y_axis_inversion; - gboolean axes_swap; + /* Coordinate Transformation Matrix */ + gfloat matrix[9]; } evdev_rotations[] = { - { GNOME_RR_ROTATION_0, 0, 0, 0 }, - { GNOME_RR_ROTATION_90, 1, 0, 1 }, - { GNOME_RR_ROTATION_180, 1, 1, 0 }, - { GNOME_RR_ROTATION_270, 0, 1, 1 } + { GNOME_RR_ROTATION_0, {1, 0, 0, 0, 1, 0, 0, 0, 1}}, + { GNOME_RR_ROTATION_90, {0, -1, 1, 1, 0, 0, 0, 0, 1}}, + { GNOME_RR_ROTATION_180, {-1, 0, 1, 0, -1, 1, 0, 0, 1}}, + { GNOME_RR_ROTATION_270, {0, 1, 0, -1, 0, 1, 0, 0, 1}} }; static guint @@ -1566,6 +1564,7 @@ rotate_touchscreens (GsdXrandrManager *mgr, XDeviceInfo *device_info; gint n_devices; guint i, rot_idx; + Atom float_atom; if (!supports_xinput_devices ()) return; @@ -1578,6 +1577,8 @@ rotate_touchscreens (GsdXrandrManager *mgr, rot_idx = get_rotation_index (rotation); + float_atom = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "FLOAT", True); + for (i = 0; i < n_devices; i++) { if (is_wacom_tablet_device (mgr, &device_info[i])) { g_debug ("Not rotating tablet device '%s'", device_info[i].name); @@ -1587,13 +1588,13 @@ rotate_touchscreens (GsdXrandrManager *mgr, if (device_info_is_touchscreen (&device_info[i]) || device_info_is_tablet (&device_info[i])) { XDevice *device; - char c = evdev_rotations[rot_idx].axes_swap; - PropertyHelper axes_swap = { - .name = "Evdev Axes Swap", - .nitems = 1, - .format = 8, - .type = XA_INTEGER, - .data.c = &c, + gfloat *m = evdev_rotations[rot_idx].matrix; + PropertyHelper matrix = { + .name = "Coordinate Transformation Matrix", + .nitems = 9, + .format = 32, + .type = float_atom, + .data.i = (int *)m, }; g_debug ("About to rotate '%s'", device_info[i].name); @@ -1603,26 +1604,18 @@ rotate_touchscreens (GsdXrandrManager *mgr, if (gdk_error_trap_pop () || (device == NULL)) continue; - if (device_set_property (device, device_info[i].name, &axes_swap) != FALSE) { - char axis[] = { - evdev_rotations[rot_idx].x_axis_inversion, - evdev_rotations[rot_idx].y_axis_inversion - }; - PropertyHelper axis_invert = { - .name = "Evdev Axis Inversion", - .nitems = 2, - .format = 8, - .type = XA_INTEGER, - .data.c = axis, - }; - - device_set_property (device, device_info[i].name, &axis_invert); - - g_debug ("Rotated '%s' to configuration '%d, %d, %d'", + if (device_set_property (device, device_info[i].name, &matrix) != FALSE) { + g_debug ("Rotated '%s' to configuration '%f, %f, %f, %f, %f, %f, %f, %f, %f'\n", device_info[i].name, - evdev_rotations[rot_idx].x_axis_inversion, - evdev_rotations[rot_idx].y_axis_inversion, - evdev_rotations[rot_idx].axes_swap); + evdev_rotations[rot_idx].matrix[0], + evdev_rotations[rot_idx].matrix[1], + evdev_rotations[rot_idx].matrix[2], + evdev_rotations[rot_idx].matrix[3], + evdev_rotations[rot_idx].matrix[4], + evdev_rotations[rot_idx].matrix[5], + evdev_rotations[rot_idx].matrix[6], + evdev_rotations[rot_idx].matrix[7], + evdev_rotations[rot_idx].matrix[8]); } XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); |