Note: There are a few cases of duplicates in user autocompletion which are being worked on.

MouseEvent pressure does not work for drawing tablets on Linux

NEW
Unassigned

Status

()

Core
Event Handling
8 years ago
3 years ago

People

(Reporter: Ilmari Heikkinen, Unassigned)

Tracking

(Depends on: 1 bug, Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 1 obsolete attachment)

(Reporter)

Description

8 years ago
Created attachment 414781 [details]
Test that displays the current mousemove event mozPressure

Mouse events fired by drawing tablets on Linux have a mozPressure of 0.0, regardless of the actual pressure.

The reason why this happens is two-fold:
 1. the extended input devices are disabled by default 
 2. GDK windows need to call gdk_input_set_extension_events to receive extended input events


To solve 1., extended input devices need to be enabled on app startup by calling gdk_device_set_mode(device, GDK_MODE_SCREEN). 

Note that calling that for the regular mouse will cause its event->x and event->y to be zeroes (I don't know why). And the regular mouse identifies itself as a pen device by default, so it's a bit tricky to detect.

Assuming that the regular mouse does not have a pressure axis, the initialization could be done by enabling only devices with a pressure axis:

for (GList *iter = gdk_devices_list(); iter; iter = g_list_next(iter)) {
    GdkDevice *device = (GdkDevice*)(iter->data);
    for (int i=0; i<device->num_axes; i++) {
        if (device->axes[i].use == GDK_AXIS_PRESSURE) {
            gdk_device_set_mode(device, GDK_MODE_SCREEN);
            break;
        }
    }
}

An alternative would be to have the user manually enable devices they want to use. Implementation would be a gtk_input_dialog_new -call in application settings, and saving & restoring thus obtained device modes from prefs on app startup.


To solve 2., each widget that wants to receive extended input events needs to call gdk_input_set_extension_events. I had success for content widgets by adding the following to /widget/src/gtk2/nsWindow.cpp:CreateGdkWindow:

gdk_input_set_extension_events (window,
                                GDK_POINTER_MOTION_MASK |
                                GDK_BUTTON_PRESS_MASK |
                                GDK_BUTTON_RELEASE_MASK,
                                GDK_EXTENSION_EVENTS_CURSOR);


For chrome, /widget/src/gtk2/mozcontainer.c:moz_container_realize should have a similar call:

gdk_input_set_extension_events (widget->window,
                                GDK_POINTER_MOTION_MASK |
                                GDK_BUTTON_PRESS_MASK |
                                GDK_BUTTON_RELEASE_MASK,
                                GDK_EXTENSION_EVENTS_CURSOR);


The above changes work on my system, debian testing, gtk+2.0 2.16.6-1, Xorg 7.3+18, xserver-xorg-input-wacom [from wacom-tools] 0.8.1.6-1

There's a strange input bug in GTK+ or X where to right mouse-button doesn't register after using the stylus, requiring a left-click or moving the mouse over a new widget to make right-click work again. Happens in GIMP and the GTK+ scribble-xinput.c example program as well.
(Reporter)

Comment 1

8 years ago
Created attachment 414783 [details] [diff] [review]
Experimental patch that sets up devices in nsWindow:initialize_prefs and makes gdk widgets use extended input events
Do you want this patch to be reviewed?
(Reporter)

Comment 3

8 years ago
Reviewed, yeah I guess. 

There are two things I'm not all that sure about, though. The first is where to put the device mode sets (needs to be called on app startup). The second is that I'd really like to know that this doesn't break people's input handling. Because if there is some hypothetical mouse device with a pressure axis and it stops reporting x-y-coords after setting device mode to screen, it's going to break.

FWIW, here's what my GDK input axes look like:

Mouse0 has X
Mouse0 has Y

Cursor has X
Cursor has Y
Cursor has PRESSURE
Cursor has XTILT
Cursor has YTILT
Cursor has WHEEL

Stylus has X
Stylus has Y
Stylus has PRESSURE
Stylus has XTILT
Stylus has YTILT
Stylus has WHEEL

Eraser has X
Eraser has Y
Eraser has PRESSURE
Eraser has XTILT
Eraser has YTILT
Eraser has WHEEL

Core Pointer has X
Core Pointer has Y
(Reporter)

Comment 4

8 years ago
Created attachment 414848 [details]
program that lists axes for xinput devices

Compile by doing
gcc `pkg-config --cflags --libs gtk+-2.0` -o xinput-list xinput-list.c
(Reporter)

Updated

8 years ago
Attachment #414783 - Flags: review?(karlt)
Reason 1 is really bug 469756.  Unfortunately we'll need to sort out the
performance issues before we can fix this.  Perhaps minimizing the number of
extension events selected could help a little.  Those issues are even without
enabling any devices.  Perhaps the core pointer can have extension events
also?
Depends on: 469756
Re reason 2, the description of GtkInputDialog says,

"NOTE this widget is considered too specialized/little-used for GTK+, and will
 in the future be moved to some other package. If your application needs this
 widget, feel free to use it, as the widget does work and is useful in some
 applications; it's just not of general interest. However, we are not
 accepting new features for the widget, and it will eventually move out of the
 GTK+ distribution."

so we should probably find another means.

It seems to me that there should be some global means of selecting input
devices, rather than having to configure each app independently.

Enabling only devices with a pressure axis makes sense.

It doesn't seem right to me though to enable even devices that don't send
core pointer events.  Would it make sense to only enable devices that send
core events?
(I don't know how to get that information.)
Attachment #414783 - Flags: review?(karlt)
(Reporter)

Updated

7 years ago
Blocks: 531466
(Reporter)

Comment 7

7 years ago
Created attachment 511504 [details]
program that lists info for xinput devices

This one lists the data in the GDKDevice struct, see http://library.gnome.org/devel/gdk/stable/gdk-Input-Devices.html

Output looks like this:

Device: Virtual core XTEST pointer
  Source: MOUSE
  Mode: DISABLED
  Has 0 keys and 2 axes.
  Axes: X Y 

Device: Wacom Intuos2 9x12 stylus
  Source: PEN
  Mode: DISABLED
  Has 248 keys and 6 axes.
  Axes: X Y PRESSURE XTILT YTILT WHEEL 

Device: Wacom Intuos2 9x12 eraser
  Source: ERASER
  Mode: DISABLED
  Has 248 keys and 6 axes.
  Axes: X Y PRESSURE XTILT YTILT WHEEL 

Device: Wacom Intuos2 9x12 cursor
  Source: CURSOR
  Mode: DISABLED
  Has 248 keys and 6 axes.
  Axes: X Y PRESSURE XTILT YTILT WHEEL 

Device: Microsft Microsoft Wireless Desktop Receiver 3.1A
  Source: MOUSE
  Mode: DISABLED
  Has 248 keys and 5 axes.
  Axes: X Y PRESSURE XTILT YTILT 

Device: Core Pointer
  Is the core pointer.
  Has cursor.
  Source: MOUSE
  Mode: SCREEN
  Has 0 keys and 2 axes.
  Axes: X Y
Attachment #414848 - Attachment is obsolete: true

Comment 8

3 years ago
Would this be a strong fingerprinting tool?
You need to log in before you can comment on or make changes to this bug.