GNOME Bugzilla – Bug 663990
Tablet pressure is broken on MacOSX
Last modified: 2013-03-12 13:40:02 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.
Does it recognize the device at all? IOW, can you use it as a plain pointing device?
Yes, in the sense that I can draw and click with it.
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").
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.
That's what I concluded. Is there any support in the X11 backend, or is it only in Win32?
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.
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.
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
No crashes so far when used in a bundled version of gimp.
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.
Created attachment 214193 [details] [review] Cleaned up formatting based on code review comments.
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.
*** Bug 682921 has been marked as a duplicate of this bug. ***
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.
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
Kris, do you have a comment on the patch? I'd like to get it in this week.
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?
(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.
So you mean that num_axes can be < 5, but NSEvent will always give you values for 5 axes?
(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.
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(-)
Nice work everyone! One quick note, does this patch still crash input on osx when used from a non-bundled app?
(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.
Review of attachment 229180 [details] [review]: <mitch_> mclasen: that needs to be redone for master, daniel sabo said he's going to do that
The GTK3 patch will require different code to support hotplug and the new axes system, I've now opened bug 695701 to track it.