After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668547 - Wacom g-s-d plugin does not take into account output rotation when applying 'display'
Wacom g-s-d plugin does not take into account output rotation when applying '...
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: wacom
3.3.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on: 678872
Blocks: 676170
 
 
Reported: 2012-01-24 00:31 UTC by Jason Gerecke
Modified: 2012-07-03 07:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (6.15 KB, patch)
2012-05-16 15:00 UTC, Olivier Fourdan
accepted-commit_now Details | Review
Updated patch (8.95 KB, patch)
2012-06-06 12:06 UTC, Olivier Fourdan
needs-work Details | Review
Updated patch (8.16 KB, patch)
2012-06-20 14:18 UTC, Olivier Fourdan
none Details | Review
Updated patch (8.40 KB, patch)
2012-06-26 12:24 UTC, Olivier Fourdan
reviewed Details | Review
Updated patch (10.33 KB, patch)
2012-06-27 09:03 UTC, Olivier Fourdan
reviewed Details | Review
Updated patch (10.50 KB, patch)
2012-06-27 11:49 UTC, Olivier Fourdan
reviewed Details | Review
Updated patch (11.28 KB, patch)
2012-07-02 09:10 UTC, Olivier Fourdan
accepted-commit_now Details | Review

Description Jason Gerecke 2012-01-24 00:31:48 UTC
If a display tablet has been mapped to a specific output through the use of the 'display' gsettings key, the rotation of the output is not taken into account. The 'rotation' key specifies the rotation of the tablet, and should be updated to match the output's rotation when the 'display' key is used to initialize the device, is updated, or the associated output is rotated through gnome-control-center's Display panel.
Comment 1 Olivier Fourdan 2012-05-16 15:00:30 UTC
Created attachment 214186 [details] [review]
Proposed patch

Note: This patch goes on top of attachment 214071 [details] [review] from bug 668614 since it relies on GnomeRRScreen notifications to apply rotation.
Comment 2 Bastien Nocera 2012-05-17 17:42:55 UTC
Review of attachment 214186 [details] [review]:

Can you please make sure that the code in rotate_touchscreens() doesn't get triggered too for wacom touch devices?
Otherwise we'd end up with conflicting changes to the input device setup.

Looks good otherwise.
Comment 3 Bastien Nocera 2012-05-18 10:03:18 UTC
Review of attachment 214186 [details] [review]:

Thinking about it, is there any reason why we can't just use the GNOME_RR_ROTATION constants and names, instead of using our own wacom specific one?
Comment 4 Olivier Fourdan 2012-05-21 12:25:36 UTC
(In reply to comment #3)

> Thinking about it, is there any reason why we can't just use the
> GNOME_RR_ROTATION constants and names, instead of using our own wacom specific
> one?

The GsdWacomRotation is used in the schema, I suspect the reason is mostly historical (as the rotation names come from xsetwacom(1) I guess).

GNOME_RR_ROTATION constants are bit fields (as it also supports reflection which can be combined with rotation) whereas the Wacom equivalent are just plain enums.

Other than that I don't see any particular reason.
Comment 5 Olivier Fourdan 2012-06-06 12:06:55 UTC
Created attachment 215733 [details] [review]
Updated patch

Updated patch as per comment #2

To avoid wacom touch devices in rotate_touchscreens() which is in xrandr plugin, easiest (and safest) is to make xrandr plugin depend on libwacom as well, I hope it's OK.

Also there's something quite unclear to me. It's not just Wacom touch devices which need to be avoided, but Wacom screen tablets as well, as the tablet (input) rotates along with the output (tablet/monitor). Am I right here (I don't have any device to test)?

Assuming the above, the patch avoids bith libwacom_has_touch () and libwacom_is_builtin ()
Comment 6 Bastien Nocera 2012-06-14 16:49:45 UTC
Comment on attachment 215733 [details] [review]
Updated patch

Doesn't apply anymore after the changes in bug 677032.
Comment 7 Olivier Fourdan 2012-06-20 14:18:40 UTC
Created attachment 216840 [details] [review]
Updated patch

Updated patch for current git head.

Also, adds libwacom test to xrandr only for platforms with Wacom support.
Comment 8 Olivier Fourdan 2012-06-26 12:24:29 UTC
Created attachment 217280 [details] [review]
Updated patch

Updated patch after the fix for bug #668547 (ie the patch for bug #668547 changes the parameters passed to find_output() in gsd-wacom-device.c so if we apply the proposed patch for bug #668547 we need to get this one updated as well).
Comment 9 Olivier Fourdan 2012-06-26 12:25:34 UTC
Sorry I meant pdated patch after the fix for bug #678872 ...
Comment 10 Bastien Nocera 2012-06-26 15:57:01 UTC
Review of attachment 217280 [details] [review]:

::: plugins/xrandr/Makefile.am
@@ +63,3 @@
 
+if HAVE_WACOM
+libxrandr_la_CFLAGS += $(WACOM_CFLAGS)

No need to have those in an if, they would be empty if wacom isn't built.

::: plugins/xrandr/gsd-xrandr-manager.c
@@ +1518,3 @@
+#ifdef HAVE_WACOM
+static gboolean
+is_wacom_tablet_device (XDeviceInfo *device_info)

I would ifdef inside is_wacom_tablet_device() instead, and return FALSE when unsupported.

@@ +1522,3 @@
+        gchar       *device_node;
+        WacomDevice *wacom_device;
+        gboolean     wacom_tablet_device = FALSE;

is_wacom_tablet_device, or is_tablet would be enough. The variable name looks like it should be a WacomDevice.

@@ +1531,3 @@
+                return FALSE;
+
+        wacom_device = libwacom_new_from_path (db, device_node, FALSE, NULL);

free device_node here, you don't need it afterwards.

@@ +1536,3 @@
+                return FALSE;
+        }
+        wacom_tablet_device = libwacom_has_touch (wacom_device) || libwacom_is_builtin (wacom_device);

This should work:
is_tablet = libwacom_has_touch (wacom_device);
is_tablet &= libwacom_is_builtin (wacom_device);

@@ +1565,2 @@
         for (i = 0; i < n_devices; i++) {
+#ifdef HAVE_WACOM

This saves you the ifdef here, and the hope that your platform will have support soon.
Comment 11 Olivier Fourdan 2012-06-27 09:03:03 UTC
Created attachment 217356 [details] [review]
Updated patch

(In reply to comment #10)
> Review of attachment 217280 [details] [review]:
> No need to have those in an if, they would be empty if wacom isn't built.

Oh right!

> I would ifdef inside is_wacom_tablet_device() instead, and return FALSE when
> unsupported.

Agreed, it's better.

> is_wacom_tablet_device, or is_tablet would be enough. The variable name looks
> like it should be a WacomDevice.

Agreed, it's better.

> free device_node here, you don't need it afterwards.

Agreed, there's a possible leak otherwise...

> libwacom_is_builtin (wacom_device);
> 
> This should work:
> is_tablet = libwacom_has_touch (wacom_device);
> is_tablet &= libwacom_is_builtin (wacom_device);

It should yet I'm not entirely sure gcc does the same kind of optimizations with this though (but I am far from being a compiler expert), so I would rather keep "&&" (it would save a call to the second function)

But you're right, we want to avoid changing built-in touch screens here so it should be an AND and not an OR there, my bad.

> This saves you the ifdef here, and the hope that your platform will have
> support soon.

Yeap, agreed.

I also spotted a bug in my initial version. If the device already has a rotation set (for example, rotation set to "half" for left-handed users) then that would have reset the rotation to match the output rotation once the output rotation is changed, which is not what we want.

A much better approach is to compute the relative rotation between the device and the output so that initial rotation is /translated/ to the resulting output rotation.

New patch attached with this added, tested with touch device, left-handed rotation is applied after the output rotation.
Comment 12 Bastien Nocera 2012-06-27 09:13:16 UTC
Review of attachment 217356 [details] [review]:

::: plugins/wacom/gsd-wacom-device.c
@@ +1807,3 @@
+        }
+
+	/* Default */

Remove this.

@@ +1821,3 @@
+        }
+
+	/* Default - not reached */

Remove that.

::: plugins/wacom/gsd-wacom-manager.c
@@ +251,3 @@
+		return device_rotation;
+
+	n = G_N_ELEMENTS (rotations);

This is a macro, use G_N_ELEMENTS directly everywhere.

@@ +258,3 @@
+
+	if (output_rotation == GSD_WACOM_ROTATION_HALF)
+		return rotations[(i + n / 2) % n];

i + n - 2?

::: plugins/xrandr/gsd-xrandr-manager.c
@@ +1569,2 @@
         for (i = 0; i < n_devices; i++) {
+                if (is_wacom_tablet_device  (&device_info[i]))

Add a g_debug() here saying that the tablet has been skipped for rotation. (you might want to add such debug for other cases, in a separate commit).
Comment 13 Olivier Fourdan 2012-06-27 11:49:51 UTC
Created attachment 217389 [details] [review]
Updated patch

(In reply to comment #12)
> Review of attachment 217356 [details] [review]:

All done, although I am not sure the following

  > This is a macro, use G_N_ELEMENTS directly everywhere.

helps with clarity of the code.
Comment 14 Bastien Nocera 2012-06-29 14:11:24 UTC
Review of attachment 217389 [details] [review]:

::: plugins/xrandr/gsd-xrandr-manager.c
@@ +105,3 @@
 
+#ifdef HAVE_WACOM
+static WacomDeviceDatabase *db = NULL;

I just realised this. You need to put this in the ManagerPrivate structure instead, and make sure to destroy it when shutting down.
Comment 15 Olivier Fourdan 2012-07-02 09:10:43 UTC
Created attachment 217811 [details] [review]
Updated patch

Updated patch as per comment #14
Comment 16 Bastien Nocera 2012-07-02 16:58:14 UTC
Review of attachment 217811 [details] [review]:

Looks good.

::: plugins/xrandr/gsd-xrandr-manager.c
@@ +2099,3 @@
+#ifdef HAVE_WACOM
+        if (manager->priv->wacom_db != NULL) {
+                libwacom_database_destroy(manager->priv->wacom_db);

Space needed between the function name and the bracket.
Comment 17 Olivier Fourdan 2012-07-03 07:28:42 UTC
Committed with space added.

commit ecb0e2d0b15c732007a611258fd3d916953c0b7c

    wacom: apply display rotation to device
    
    When an output is mapped to a device, match the device rotation
    with the output (bug #668547).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668547