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 663990 - Tablet pressure is broken on MacOSX
Tablet pressure is broken on MacOSX
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Quartz
2.24.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-quartz maintainers
gtk-bugs
: 682921 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-11-13 22:36 UTC by Clayton Walker
Modified: 2013-03-12 13:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add extended input support to GTK Quartz (15.82 KB, patch)
2012-04-30 20:46 UTC, Daniel Sabo
none Details | Review
Cleaned up formatting based on code review comments. (14.85 KB, patch)
2012-05-16 16:05 UTC, Daniel Sabo
none Details | Review
Add extended input support to GTK Quartz (15.99 KB, patch)
2012-05-23 02:01 UTC, Daniel Sabo
none Details | Review
Add extended input support to GTK Quartz (15.98 KB, patch)
2012-09-09 21:26 UTC, Daniel Sabo
none Details | Review
Same patch with some minor fixes and cleanups (16.02 KB, patch)
2012-11-16 21:47 UTC, Michael Natterer
needs-work Details | Review

Description Clayton Walker 2011-11-13 22:36:08 UTC
Tablet's aren't being recognized by GTK on Mac as a pressure sensitive device. Or any device at all, for that matter.

1) Plug in graphics tablet. (In my case a lowly wacom bamboo tablet.)
1) Run MyPaint, either from compiled source, or via MacPorts.
2) View printout in Console.app or in Terminal.app.

Actual Results:
MyPaint says: No pressure sensitive devices found.

Expected Results:
MyPaint wouldn't say this, and I would instead have pressure support.

Using latest source from version 2.24.8, compiled on my Mac.

When using the latest version from source, going to "Help" - "Debug" - "Input device dialog" produces a dialog which says "No extended input devices".

Mac OSX 10.6.8
GTK 2.24.8

Personal note: Kind of a deal breaker for mypaint/gimp with quartz.
Comment 1 John Ralls 2011-11-13 22:58:02 UTC
Does it recognize the device at all? IOW, can you use it as a plain pointing device?
Comment 2 Clayton Walker 2011-11-13 23:45:32 UTC
Yes, in the sense that I can draw and click with it.
Comment 3 John Ralls 2011-11-26 02:20:20 UTC
Have you tested with Win32 or X11 (i.e., Linux)? The only mention I can find in the source code is in the Windows devicemanager, and it isn't clear to me that it's actually doing anything there (there are just some enums in a block labeled "wintab debug").
Comment 4 Michael Natterer 2011-11-26 09:03:27 UTC
There is zero code in the quartz backend to handle pressure, let alone
other axes or multiple input devices. This is simply a missing feature,
but it's going to be fixed at some point.
Comment 5 John Ralls 2011-11-26 16:19:10 UTC
That's what I concluded. Is there any support in the X11 backend, or is it only in Win32?
Comment 6 Martin Renold 2011-12-26 15:49:54 UTC
Yes there are reports that pressure is working fine on OSX with the X11 backend.

On the Win32 backend pressure has been supported for a long time, allthough broken every now and then.
Comment 7 Daniel Sabo 2012-04-30 20:46:35 UTC
Created attachment 213140 [details] [review]
Add extended input support to GTK Quartz

Here's a patch for basic tablet support in the quartz backend. It's missing some functionality but it's sufficient to draw comfortably with gimp+quartz.

Missing features:
* It only supports "screen" mode.
* It doesn't allow remaping of axes (not necessary since MacOS should have mapped them correctly to begin with).
* Doesn't support non-coalesced event history.
Comment 8 Clayton Walker 2012-05-11 18:24:40 UTC
A follow-up to the talk we had on IRC:

After excessive use of the tablet, like rapid strokes and lots of drawing, I managed to get the drivers to crash again. This time it was a bit more extreme, though.
The first thing I noticed was that I wasn't able to click anything. Anything quartz, anything Mac.
The keyboard still worked though.
Then came the reverting of the tablet. It started behaving like a mouse again. System Prefs said there was something wrong, and that a restart might fix the issue. Of course, navigating through windows with nothing but a keyboard was difficult at that point.

The only error I received was a bunch of these in the terminal window:

(gimp:42770): Gimp-Tools-CRITICAL **: gimp_tool_cursor_update: assertion `gimp_tool_control_is_active (tool->control) == FALSE' failed
Comment 9 Clayton Walker 2012-05-13 19:15:09 UTC
No crashes so far when used in a bundled version of gimp.
Comment 10 Daniel Sabo 2012-05-16 16:05:19 UTC
Regarding the tablet driver crashes:

It appears that this is a bug in the Wacom PenTabletDriver.app related to console applications. It's calling ProcessInformationCopyDictionary (probably to find the correct window to send an event to) and assuming it will have a full set of strings, however apps started from the command line will have NULL for several bundle related values.

This doesn't show up with X11 apps because everything will report being part of the X11.app bundle, and I've managed to get the same crash drawing in GTK quartz without this input patch applied. I assume will happen for any non-bundled app if you use the tablet in it long enough.
Comment 11 Daniel Sabo 2012-05-16 16:05:55 UTC
Created attachment 214193 [details] [review]
Cleaned up formatting based on code review comments.
Comment 12 Daniel Sabo 2012-05-23 02:01:48 UTC
Created attachment 214725 [details] [review]
Add extended input support to GTK Quartz

* Disable mouse motion coalescing when sending events to an extended input window.
* Move _gdk_init_input_core into _gdk_input_init with the rest of the devices.
Comment 13 André Klapper 2012-08-31 09:01:25 UTC
*** Bug 682921 has been marked as a duplicate of this bug. ***
Comment 14 Daniel Sabo 2012-09-09 21:26:35 UTC
Created attachment 223865 [details] [review]
Add extended input support to GTK Quartz

Updating the patch with the changes made for bug 663990.

* Report all axes for NSCursorPointingDevice.
Comment 15 Michael Natterer 2012-11-16 21:47:43 UTC
Created attachment 229180 [details] [review]
Same patch with some minor fixes and cleanups

The patch had some minor problems, this one works just nice for me:

- set the core pointer to screen by default and don't allow changes
- never do motion coalescing
Comment 16 Michael Natterer 2012-11-22 10:28:40 UTC
Kris, do you have a comment on the patch? I'd like to get it in this week.
Comment 17 Kristian Rietveld 2012-11-24 09:27:19 UTC
Review of attachment 229180 [details] [review]:

The patch looks pretty sane to me and cool to have tablets working again on OS X :)  I have a couple of style nitpicks inline.

::: gdk/quartz/gdkevents-quartz.c
@@ +1465,3 @@
       fill_button_event (window, event, nsevent, x, y, x_root, y_root);
+
+      input_event = gdk_event_new (GDK_NOTHING);;

Please get rid of the double semicolon.

@@ +1478,3 @@
       fill_motion_event (window, event, nsevent, x, y, x_root, y_root);
+
+      input_event = gdk_event_new (GDK_NOTHING);;

Double semicolon.

@@ +1480,3 @@
+      input_event = gdk_event_new (GDK_NOTHING);;
+      if (_gdk_input_fill_quartz_input_event (event, nsevent, input_event))
+        append_event (input_event, TRUE);

About the current use of append_event, as things are now, the input_event will reach gdk_windowing_got_event() before the regular event.  Is that a problem?  (If things work properly for you, I guess not ;).

::: gdk/quartz/gdkinput.c
@@ +255,3 @@
       break;
     }
+  */

Might be better to comment out the code with #if 0 / #endif?

@@ +499,3 @@
+
+  priv = (GdkDevicePrivate *)_gdk_quartz_pen;
+  priv->last_axes_state = g_malloc_n (_gdk_quartz_pen->num_axes, sizeof(gdouble));

Need space after sizeof

@@ +514,3 @@
+
+  priv = (GdkDevicePrivate *)_gdk_quartz_cursor;
+  priv->last_axes_state = g_malloc_n (_gdk_quartz_cursor->num_axes, sizeof(gdouble));

same here

@@ +529,3 @@
+
+  priv = (GdkDevicePrivate *)_gdk_quartz_eraser;
+  priv->last_axes_state = g_malloc_n (_gdk_quartz_eraser->num_axes, sizeof(gdouble));

and here

@@ +615,3 @@
+ * _gdk_input_fill_quartz_input_event:
+ * @event: The GDK mouse event.
+ * @nsevet: The NSEvent that generated the mouse event.

nsevet -> nsevent

@@ +681,3 @@
+    {
+      /* Return if the target window doesn't have extended events enabled or
+         hasn't asked for this type of event. */

Can the comment style be turned in what is usually used? I.e. start every line with a star and closing thingy on its own line. (Just like the comment directly above in the source code).

@@ +686,3 @@
+    }
+
+  /* The cursor is inside an extended events window, block propigation of the

propigation -> propagation

@@ +687,3 @@
+
+  /* The cursor is inside an extended events window, block propigation of the
+     core motion / button events */

Same comment wrt. comment style.

@@ +690,3 @@
+  _gdk_display->ignore_core_events = TRUE;
+
+  axes = g_malloc_n (5, sizeof (gdouble));

Can we access num_axes in the device here instead of hardcoding 5?
Comment 18 Daniel Sabo 2012-11-24 11:16:41 UTC
(In reply to comment #17)

> @@ +690,3 @@
> +  _gdk_display->ignore_core_events = TRUE;
> +
> +  axes = g_malloc_n (5, sizeof (gdouble));
> 
> Can we access num_axes in the device here instead of hardcoding 5?

No, because it doesn't respect num_axes when filling in the data:

+  axes[0] = x_root - x_target;
+  axes[1] = y_root - y_target;
+  axes[2] = [nsevent pressure];
+  axes[3] = [nsevent tilt].x;
+  axes[4] = [nsevent tilt].y;

NSEvent will always return 1 for pressure and 0 for tilt if the device doesn't have real values.
Comment 19 Kristian Rietveld 2012-11-24 12:38:49 UTC
So you mean that num_axes can be < 5, but NSEvent will always give you values for 5 axes?
Comment 20 Daniel Sabo 2012-11-24 12:43:51 UTC
(In reply to comment #19)
> So you mean that num_axes can be < 5, but NSEvent will always give you values
> for 5 axes?

Yes.
Comment 21 Michael Natterer 2012-11-25 18:42:34 UTC
Pushed to gtk-2-24 with Kris' commants applied, and some further cleanup,
leaving open because none of this is done for gtk3 yet.

commit ffd949132a06760bee81f1a1eb9d9f5fbfc0a899
Author: Daniel Sabo <DanielSabo@gmail.com>
Date:   Tue May 22 02:10:00 2012 -0700

    Bug 663990 - Tablet pressure is broken on MacOSX
    
    Add extended input support to GDK Quartz.

 gdk/quartz/gdkevents-quartz.c |   19 ++
 gdk/quartz/gdkinput.c         |  369 ++++++++++++++++++++++++++++++++++++-----
 gdk/quartz/gdkinputprivate.h  |   11 +-
 3 files changed, 354 insertions(+), 45 deletions(-)
Comment 22 Clayton Walker 2012-11-25 23:42:33 UTC
Nice work everyone!

One quick note, does this patch still crash input on osx when used from a non-bundled app?
Comment 23 Daniel Sabo 2012-11-26 00:49:16 UTC
(In reply to comment #22)
> One quick note, does this patch still crash input on osx when used from a
> non-bundled app?

The wacom driver will still crash. I don't believe its due to anything in this patch though, it's just that no one bothered to use a tablet on unbundled gimp long enough to provoke the crash when pressure didn't work.

I don't have the crash reports anymore, but it happens because the API the wacom driver is using to find the active process doesn't check that the bundle id fields are non-NULL before trying to read them.
Comment 24 Matthias Clasen 2013-03-12 11:58:06 UTC
Review of attachment 229180 [details] [review]:

<mitch_> mclasen: that needs to be redone for master, daniel sabo said he's going to do that
Comment 25 Daniel Sabo 2013-03-12 13:38:48 UTC
The GTK3 patch will require different code to support hotplug and the new axes system, I've now opened bug 695701 to track it.