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 66813 - XInput gives wrong coordinates with Xinerama
XInput gives wrong coordinates with Xinerama
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Class: GdkDevice
2.14.x
Other Linux
: Normal normal
: Small fix
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-12-12 17:46 UTC by echo
Modified: 2015-02-18 00:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix for GDK_MODE_SCREEN xinput devices (1.05 KB, patch)
2006-05-28 12:52 UTC, gator_ml
none Details | Review
Fix for GDK_MODE_SCREEN xinput devices (slightly enhanced) (1.21 KB, patch)
2006-05-29 15:59 UTC, gator_ml
reviewed Details | Review

Description echo 2001-12-12 17:46:26 UTC
When I run dual-head with Xinerama and use a Wacom tablet, the 
event co-ordinates reported by the extended Xinput handler are 
wrong.
They are always too far to the left, and the distance offset is
equal to the distance of the (correct) cursor pointer from the
right hand side of the rightmost screen
eg right-hand screen maxX=1600, cursor is at 1500, extended 
input event reported at 1400. On the left-hand screen the 
offset is so far that it is never visible.

This has been verified in the Gimp. 

       |
 *  .  |
       |
eg above the tablet cursor points to the dot, and the paint in
the Gimp appears at the asterisk. The line marks the edge of 
the screen.

I don't think this is a Wacom driver bug because extended 
events are scaled later and non-extended use of the tablet 
works fine.

My XF86Config is:
Section "ServerLayout"
        Identifier     "layout1"
        Screen      0  "Screen2" 0 0
        Screen      1  "screen1" RightOf "Screen2"
        InputDevice    "Mouse1" "CorePointer"
        InputDevice    "Stylus1" "AlwaysCore"
        InputDevice    "Eraser1" "AlwaysCore"
        InputDevice    "Cursor1" "AlwaysCore"
        InputDevice    "Keyboard1" "CoreKeyboard"
EndSection

Section "ServerFlags"
        Option "allowmouseopenfail"
        Option "Xinerama" "yes"

EndSection

Section "InputDevice"
        Identifier  "Mouse1"
        Driver      "mouse"
        Option      "Protocol" "MouseManPlusPS/2"
        Option      "Device" "/dev/psaux"
        Option      "ZAxisMapping" "4 5"
EndSection


Section "InputDevice"
    Identifier  "Stylus1"
    Driver      "wacom"
    Option      "Type" "stylus"
    Option      "Device" "/dev/ttyS0"
    Option      "Mode" "Absolute"
EndSection
Section "InputDevice"
    Identifier  "Eraser1"
    Driver      "wacom"
    Option      "Type" "eraser"
    Option      "Device" "/dev/ttyS0"
    Option      "Mode" "Absolute"
EndSection
Section "InputDevice"
    Identifier  "Cursor1"
    Driver      "wacom"
    Option      "Type" "cursor"
    Option      "Device" "/dev/ttyS0"
    Option      "Mode" "Relative"
EndSection
Comment 1 Owen Taylor 2001-12-12 20:39:23 UTC
This can't be fixed without linking to the Xinerama extension, and
that is being put of for 2.2 as:

 - Xinerama still isn't properly standardized (a new standard
   is being worked on, which is quite different in detail)
 - There is interaction with separate screen multihead support, which
   is being added for 2.2.
Comment 2 Matthias Clasen 2004-12-22 20:41:54 UTC
Is this still an issue ?
Xinerama support has been in GTK+ for some years now.
Comment 3 Owen Taylor 2004-12-22 20:57:02 UTC
Don't remember anybody fixing it. It needs code written to fix.
Comment 4 Michael Natterer 2005-04-12 13:03:03 UTC
Would you have a look at GIMP bug #168884 and tell us if it's the
same problem?
Comment 5 gator_ml 2006-03-13 20:30:48 UTC
I have a very basic xinerama setup (2 identical screens side by side)
and observe the same behavior on all versions of Gimp (1.2, 2.2,2.3):
Cursor positions and everything else are normal, but drawing or other
actions on the tablet are shifted ~300 pixels to the left.
Comment 6 gator_ml 2006-03-14 14:21:08 UTC
actually, the effective coordinates are:
- left-shifted on the right screen: real position - distance from the right edge
- right-shifted on the left screen: real position + distance from the left edge
Comment 7 Matthias Clasen 2006-03-15 02:55:34 UTC
Somebody with a multihead + tablet setup will have to write a patch
for this. I have neither multihead nor a tablet...
Comment 8 gator_ml 2006-03-16 08:24:17 UTC
After looking into the issue a little deeper, I guess this
is probably a duplicate of
Bug 324562 – XInput events are at incorrect xy-coordinates
(which is still open, but has been fixed in gtk+ 2.8.14)

I could verify that the problem is gone in gtk+ 2.8.16
Comment 9 gator_ml 2006-03-16 09:22:17 UTC
with gtk+ 2.8.16, gimp obviously can't distinguish between
the different tablet devices (pen,eraser,mouse) and the mouse
anymore (maybe a collateral dammage of the fix for this bug?)
Comment 10 gator_ml 2006-03-16 12:36:09 UTC
Sorry, I've been a little too fast with my success report:
I had overlooked that xinput support has to be explicitly
requested.

Bug 324562 has nothing to do with this issue and the problem
is still there in 2.8.16. :-(
Comment 11 gator_ml 2006-05-28 12:52:19 UTC
Created attachment 66366 [details] [review]
Fix for GDK_MODE_SCREEN xinput devices

In general the problem seems to be, that the xinput-coordinates
are bound to the current monitor, while xinerama-coordinates are
referring to the whole logical screen.
This patch should fix the problem for input devices set to screen
mode (I didn't touch window mode because I have never used it and
am not so sure how it should behave.)
There is at least one pathological case left when the current window
stretches over several monitors, but there probably isn't any good
solution for this, because it obviously is not possible to get the
pointer across the monitor boundary with an xinput device (if anybody
knows how to do this trick, let me know :)
Comment 12 gator_ml 2006-05-29 15:59:18 UTC
Created attachment 66416 [details] [review]
Fix for GDK_MODE_SCREEN xinput devices (slightly enhanced)

Here's the same thing in a slightly enhanced version that always referrs
to the geometry of the screen that currently contains the core pointer.
This way windows that span across several monitors mostly work (there
still is a little glitch when the monitor boundary is crossed).

There probably can't be a solution that works under all circumstances
and for all devices: I just tried a newer wacom driver and found out
that there now is a mode where the input coordinates are mapped to the
whole logical screen (which would require different scaling). I don't
know how other input devices might handle this. This patch assumes that
the device is either in relative mode or that the corresponding
core pointer events are confined to the current monitor...
Comment 13 Michael Natterer 2006-06-08 11:27:16 UTC
Could somebody check please if bug #168884 is a duplicate of this
one? I don't have xinerame so I don't even see the problem here.
Comment 14 gator_ml 2006-06-14 11:03:25 UTC
(In reply to comment #13)
> Could somebody check please if bug #168884 is a duplicate of this

As far as I understand, bug #168884 occurs with a regular mouse, while
this issue is an error in translating xinput coordinates, so I think
it's 2 different problems.
Comment 15 Matthias Clasen 2006-12-22 19:57:57 UTC
It would be really nice if we could avoid the get_pointer call. What is the relevance of the core pointer position for this, anyway. Can't you have the core pointer on one monitor, and the tablet on the other ?
Comment 16 gator_ml 2007-01-13 17:54:35 UTC
(In reply to comment #15)
> It would be really nice if we could avoid the get_pointer call. What is the
> relevance of the core pointer position for this, anyway. Can't you have the
> core pointer on one monitor, and the tablet on the other ?

At least as far as I can tell, pretty much everybody who uses a tablet has
set it up to generate core events. Gimp in GDK_MODE_WINDOW would be pretty
much the only occasion where a different setup could make sense (but it would
be even harder to get that right).

The call to get_pointer and the other stuff is the only way I could figure out
to get the current monitor and the geometry of this monitor because that's
the coordinate system the xinput coordinates are based on.

Unfortunately, there probably is no way to fix this issue for all possible
configurations without mutual consent between the wacom driver, xinput and
GDK, which coordinate system to use on which occasion...
Comment 17 Campbell Barton 2007-10-29 18:01:33 UTC
Hi, at the blender institute we are using gimp on ubuntu gutsy with blender.

The project site is here if anyones interested.
http://peach.blender.org/

We have the same problem.
(tested xinerama and twinview) with a wacom tablet configured to use XInput with The Gimp 2.4.

Our problem is that even when mapped to 1 screen, the gimp gets coords as if the stylus was mapped to 2 screens - the cursor is often outside the view.

It seems this is definitely a GTK bug, since Krita with kde4 beta does not have this problem.

What is the state of the patch provided? would if help if we review? or are there some other issues with it?

If there is any development involved we could try to discover a solution ourselves since one of the developers here is familiar with the gimp's code and could probably try some gtk coding too... failing that I can look into it too ;)

Comment 18 Campbell Barton 2007-10-30 18:08:20 UTC
correction, krita does not work. this makes me wonder if the bug is GTK.
the qt/kde app pencil works http://www.les-stooges.org/pascal/pencil/ but that migh deal with xinput differently.
Comment 19 Campbell Barton 2007-10-31 13:13:29 UTC
Update, we managed to get the wacom tablets working perfectly with xinerama.
I need to discuss with one of the other guys, but by changing a setting in xorg.conf its possible to have it working where dual screen coords are not used in the gimp for single screen mode.

Will post an update later with teh settings to change and our configuration.
Comment 20 Campbell Barton 2007-12-22 09:46:45 UTC
This is the configuration file used to get the tablet working perfectly on one screen, using nvidia binary drivers.
################

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "stylus" "SendCoreEvents"
    InputDevice    "eraser" "SendCoreEvents"
    InputDevice    "pad" "SendCoreEvents"
EndSection

Section "Files"
    RgbPath         "/usr/X11R6/lib/X11/rgb"
EndSection

Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "type1"
    Load           "freetype"
    Load           "glx"
EndSection

Section "ServerFlags"
    Option         "Xinerama" "0"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "InputDevice"
  Driver        "wacom"
  Identifier    "stylus"
  Option        "Device"        "/dev/input/wacom"   # USB ONLY
  Option        "Type"          "stylus"
  Option        "USB"           "on"                  # USB ONLY
  Option 	"Twinview" 	"horizontal"
  Option	"ScreenNo"	"0"
EndSection

Section "InputDevice"
  Driver        "wacom"
  Identifier    "eraser"
  Option        "Device"        "/dev/input/wacom"   # USB ONLY
  Option        "Type"          "eraser"
  Option        "USB"           "on"                  # USB ONLY
  Option 	"Twinview" 	"horizontal"
  Option	"ScreenNo"	"0"
EndSection

Section "InputDevice"
  Driver        "wacom"
  Identifier    "cursor"
  Option        "Device"        "/dev/input/wacom"   # USB ONLY
  Option        "Type"          "cursor"
  Option        "USB"           "on"                  # USB ONLY
  Option 	"Twinview" 	"horizontal"
  Option	"ScreenNo"	"0"
EndSection

# This section is for Intuos3, Cintiq 21UX, Graphire4, or Bamboo
Section "InputDevice"
  Driver        "wacom"
  Identifier    "pad"
  Option        "Device"        "/dev/input/wacom"   # USB ONLY
  Option        "Type"          "pad"
  Option        "USB"           "on"                  # USB ONLY
  Option 	"Twinview" 	"horizontal"
  Option	"ScreenNo"	"0"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "EIZO S2000"
    HorizSync       31.0 - 76.0
    VertRefresh     59.0 - 61.0
    Option         "DPMS"
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "EIZO S2000"
    HorizSync       31.0 - 76.0
    VertRefresh     59.0 - 61.0
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
EndSection

Section "Device"
    Identifier     "Videocard0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 1700"
EndSection

Section "Device"
    Identifier     "Videocard1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Quadro FX 1700"
    BusID          "PCI:7:0:0"
    Screen          1
EndSection

Section "Screen"

# Removed Option "TwinView" "0"
# Removed Option "metamodes" "DFP-1: nvidia-auto-select +0+0"
# Removed Option "metamodes" "DFP-0: nvidia-auto-select +1920+0, DFP-1: nvidia-auto-select +0+0"
    Identifier     "Screen0"
    Device         "Videocard0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "TwinView" "1"
    Option         "metamodes" "DFP-0: nvidia-auto-select +0+0, DFP-1: nvidia-auto-select +1600+0"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Videocard1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "TwinView" "0"
    Option         "metamodes" "DFP-0: nvidia-auto-select +0+0"
EndSection
Comment 21 gator_ml 2008-06-01 17:37:57 UTC
(In reply to comment #20)
> Update, we managed to get the wacom tablets working perfectly with xinerama.
[...]
> This is the configuration file used to get the tablet working perfectly on one
> screen, using nvidia binary drivers.
[...]
>     Option         "TwinView" "1"

The problem in question doesn't arise in your configuration, because it is
not using Xinerama: The "TwinView" setup in Nvidia's proprietary driver
merges the 2 monitors to 1 framebuffer.
The X server (as most other programs) just sees one particularly wide screen,
so the coordinate system that is beeing used always stretches over both monitors.
(which actually even as far as the tablet is concerned isn't much progress,
because it means. that the input from a tablet with an aspect ration of 4:3
is mapped to an area of 8:3 in a typical setup).

Comment 22 IL'dar Akhmetgaleev 2008-11-18 13:01:18 UTC
This patch works well for me for me on three screen xinerama with different screen sizes.

But gtk+ still not reacts to chenging tablet's area size by xsetwacom set stylus TopY 1005. But this is another bug.
Comment 23 Patrick Hess 2009-01-10 09:24:41 UTC
(In reply to comment #22)

> This patch works well for me for me on three screen xinerama with different
> screen sizes.

This patch works great for me and finally I can use my Bamboo Fun in Gimp without any limitations. I tried on Ubuntu 8.04 (applied patch to gtk+ 2.12.9 source package). Hope the patch will make it into one of next versions. I haven't seen the code in the latest 2.14 source.
Comment 24 Andrea Franceschini 2009-02-18 18:37:50 UTC
Hi guys. I'm still having this problem and for me is a major issue, as in "blocking".

Is this going to be merged soon in the 2.14 tree? I'm currently using 2.14.7. Is there anything I'm missing?
Comment 25 troy.sobotka 2009-11-21 20:48:04 UTC
2001 to 2009 is eight years.

The patch doesn't work now because input_window->window has been removed from the struct.

Perhaps a GTK / GDK developer can help out here?  What is a suitable replacement for the variable?

Thanks guys.  It has a pretty serious impact on any production workflow as most people in those environments (see Blender developer posting above) are running dual head with dedicated video cards.
Comment 26 Javier Jardón (IRC: jjardon) 2009-11-23 00:15:52 UTC
Upgraded GTK+ affected version per comment #24 , Can someone confirm this in a newer version?
Comment 27 IL'dar Akhmetgaleev 2009-11-23 04:27:40 UTC
Why not just use pointer origin provided by X server? Why gtk shuold allow drow somewhere else but not where X pointer is?
Comment 28 troy.sobotka 2009-11-26 01:42:44 UTC
@Javier Appears the same.
Comment 29 Jennifer Elaan 2010-11-19 06:31:30 UTC
I created a new patch that works in https://bugzilla.gnome.org/show_bug.cgi?id=634977
Comment 30 Matthias Clasen 2011-01-05 14:29:41 UTC
Move input bugs to GdkDevice
Comment 31 Matthias Clasen 2015-02-18 00:56:08 UTC
I don't think this bug is no longer useful to keep open - we are now using xi2 and xrandr for a long time.