~darkxst/ubuntu/utopic/gnome-settings-daemon/lp1372346-nodatetime

« back to all changes in this revision

Viewing changes to debian/patches/touchscreen_rotation.patch

  • Committer: Martin Pitt
  • Author(s): Tim Lunn
  • Date: 2014-09-30 12:36:07 UTC
  • mfrom: (474.1.2 gnome-settings-daemon)
  • Revision ID: martin.pitt@ubuntu.com-20140930123607-nwsohpn1kdowlv3b
merge with 3.12.2-1 from Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
5
 
 
6
 
Bug #691691.
7
 
 
8
 
Signed-off-by: Jani Monoses <jani@ubuntu.com>
9
 
---
10
 
 plugins/xrandr/gsd-xrandr-manager.c | 61 ++++++++++++++++---------------------
11
 
 1 file changed, 27 insertions(+), 34 deletions(-)
12
 
 
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
18
 
 
19
 
 struct {
20
 
         GnomeRRRotation rotation;
21
 
-        /* evdev */
22
 
-        gboolean x_axis_inversion;
23
 
-        gboolean y_axis_inversion;
24
 
-        gboolean axes_swap;
25
 
+        /* Coordinate Transformation Matrix */
26
 
+        gfloat matrix[9];
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}}
36
 
 };
37
 
 
38
 
 static guint
39
 
@@ -1566,6 +1564,7 @@ rotate_touchscreens (GsdXrandrManager *mgr,
40
 
         XDeviceInfo *device_info;
41
 
         gint n_devices;
42
 
         guint i, rot_idx;
43
 
+        Atom float_atom;
44
 
 
45
 
         if (!supports_xinput_devices ())
46
 
                 return;
47
 
@@ -1578,6 +1577,8 @@ rotate_touchscreens (GsdXrandrManager *mgr,
48
 
 
49
 
         rot_idx = get_rotation_index (rotation);
50
 
 
51
 
+        float_atom = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "FLOAT", True);
52
 
+
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])) {
59
 
                         XDevice *device;
60
 
-                        char c = evdev_rotations[rot_idx].axes_swap;
61
 
-                        PropertyHelper axes_swap = {
62
 
-                                .name = "Evdev Axes Swap",
63
 
-                                .nitems = 1,
64
 
-                                .format = 8,
65
 
-                                .type   = XA_INTEGER,
66
 
-                                .data.c = &c,
67
 
+                        gfloat *m = evdev_rotations[rot_idx].matrix;
68
 
+                        PropertyHelper matrix = {
69
 
+                                .name = "Coordinate Transformation Matrix",
70
 
+                                .nitems = 9,
71
 
+                                .format = 32,
72
 
+                                .type = float_atom,
73
 
+                                .data.i = (int *)m,
74
 
                         };
75
 
 
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))
79
 
                                 continue;
80
 
 
81
 
-                        if (device_set_property (device, device_info[i].name, &axes_swap) != FALSE) {
82
 
-                                char axis[] = {
83
 
-                                        evdev_rotations[rot_idx].x_axis_inversion,
84
 
-                                        evdev_rotations[rot_idx].y_axis_inversion
85
 
-                                };
86
 
-                                PropertyHelper axis_invert = {
87
 
-                                        .name = "Evdev Axis Inversion",
88
 
-                                        .nitems = 2,
89
 
-                                        .format = 8,
90
 
-                                        .type   = XA_INTEGER,
91
 
-                                        .data.c = axis,
92
 
-                                };
93
 
-
94
 
-                                device_set_property (device, device_info[i].name, &axis_invert);
95
 
-
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",
99
 
                                          device_info[i].name,
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]);
112
 
                         }
113
 
 
114
 
                         XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);