1
From c1dbf0ad1b49356346f1eb0690e66be428814ef0 Mon Sep 17 00:00:00 2001
2
From: Jani Monoses <jani@ubuntu.com>
3
Date: Wed, 30 Jan 2013 11:18:48 +0200
4
Subject: [PATCH] Use transformation matrix to rotate touchscreens.
8
Signed-off-by: Jani Monoses <jani@ubuntu.com>
10
plugins/xrandr/gsd-xrandr-manager.c | 61 ++++++++++++++++---------------------
11
1 file changed, 27 insertions(+), 34 deletions(-)
13
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
14
index 2fb6204..790d9c9 100644
15
--- a/plugins/xrandr/gsd-xrandr-manager.c
16
+++ b/plugins/xrandr/gsd-xrandr-manager.c
17
@@ -1502,15 +1502,13 @@ get_next_rotation (GnomeRRRotation allowed_rotations, GnomeRRRotation current_ro
20
GnomeRRRotation rotation;
22
- gboolean x_axis_inversion;
23
- gboolean y_axis_inversion;
25
+ /* Coordinate Transformation Matrix */
27
} evdev_rotations[] = {
28
- { GNOME_RR_ROTATION_0, 0, 0, 0 },
29
- { GNOME_RR_ROTATION_90, 1, 0, 1 },
30
- { GNOME_RR_ROTATION_180, 1, 1, 0 },
31
- { GNOME_RR_ROTATION_270, 0, 1, 1 }
32
+ { GNOME_RR_ROTATION_0, {1, 0, 0, 0, 1, 0, 0, 0, 1}},
33
+ { GNOME_RR_ROTATION_90, {0, -1, 1, 1, 0, 0, 0, 0, 1}},
34
+ { GNOME_RR_ROTATION_180, {-1, 0, 1, 0, -1, 1, 0, 0, 1}},
35
+ { GNOME_RR_ROTATION_270, {0, 1, 0, -1, 0, 1, 0, 0, 1}}
39
@@ -1566,6 +1564,7 @@ rotate_touchscreens (GsdXrandrManager *mgr,
40
XDeviceInfo *device_info;
45
if (!supports_xinput_devices ())
47
@@ -1578,6 +1577,8 @@ rotate_touchscreens (GsdXrandrManager *mgr,
49
rot_idx = get_rotation_index (rotation);
51
+ float_atom = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "FLOAT", True);
53
for (i = 0; i < n_devices; i++) {
54
if (is_wacom_tablet_device (mgr, &device_info[i])) {
55
g_debug ("Not rotating tablet device '%s'", device_info[i].name);
56
@@ -1587,13 +1588,13 @@ rotate_touchscreens (GsdXrandrManager *mgr,
57
if (device_info_is_touchscreen (&device_info[i]) ||
58
device_info_is_tablet (&device_info[i])) {
60
- char c = evdev_rotations[rot_idx].axes_swap;
61
- PropertyHelper axes_swap = {
62
- .name = "Evdev Axes Swap",
67
+ gfloat *m = evdev_rotations[rot_idx].matrix;
68
+ PropertyHelper matrix = {
69
+ .name = "Coordinate Transformation Matrix",
76
g_debug ("About to rotate '%s'", device_info[i].name);
77
@@ -1603,26 +1604,18 @@ rotate_touchscreens (GsdXrandrManager *mgr,
78
if (gdk_error_trap_pop () || (device == NULL))
81
- if (device_set_property (device, device_info[i].name, &axes_swap) != FALSE) {
83
- evdev_rotations[rot_idx].x_axis_inversion,
84
- evdev_rotations[rot_idx].y_axis_inversion
86
- PropertyHelper axis_invert = {
87
- .name = "Evdev Axis Inversion",
94
- device_set_property (device, device_info[i].name, &axis_invert);
96
- g_debug ("Rotated '%s' to configuration '%d, %d, %d'",
97
+ if (device_set_property (device, device_info[i].name, &matrix) != FALSE) {
98
+ g_debug ("Rotated '%s' to configuration '%f, %f, %f, %f, %f, %f, %f, %f, %f'\n",
100
- evdev_rotations[rot_idx].x_axis_inversion,
101
- evdev_rotations[rot_idx].y_axis_inversion,
102
- evdev_rotations[rot_idx].axes_swap);
103
+ evdev_rotations[rot_idx].matrix[0],
104
+ evdev_rotations[rot_idx].matrix[1],
105
+ evdev_rotations[rot_idx].matrix[2],
106
+ evdev_rotations[rot_idx].matrix[3],
107
+ evdev_rotations[rot_idx].matrix[4],
108
+ evdev_rotations[rot_idx].matrix[5],
109
+ evdev_rotations[rot_idx].matrix[6],
110
+ evdev_rotations[rot_idx].matrix[7],
111
+ evdev_rotations[rot_idx].matrix[8]);
114
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);