Hi Simon,

1. The main problem is that GTK2 has no support for hotplugging input 
devices while the application is running. The list returned by 
gdk_devices_list() is constructed once at startup and never updated 
subsequently. It still contains devices that have been unplugged, and 
does not contain devices plugged after application startup.

(Xournal has to work around this to avoid some crashes, see the call to 
gdk_error_trap_push/pop() in emergency_enable_xinput() in src/xo-misc.c, 
since otherwise re-enabling the dead devices causes the program to 
crash... the latter function needed to work around more GTK2 issues, 
with a range of GTK versions from 2.17 to somewhere before 2.24 if we 
leave the drawing area we need to emergency disable all XInput devices 
so the interface won't become unresponsive. In 2.24 this is only needed 
for text box edition and not for other cases anymore. In short, it's a 
mess.)

Hacking into the internal GTK2 data structures would be theoretically 
possible but a huge mess to maintain in terms of compatibility. Without 
GTK2 being aware of the devices, the events they generate can't be 
processed the normal way either. So: in short, no hotplugging support as 
long as we rely on GTK2.  The GTK3 port of xournal that Daniel German 
has been working on would hopefully fix this.

However...

2. I'm pretty sure that the approach of emulating USB unplugs and 
reassigning devices just so you can figure what their original geometry 
was is not the best one -- especially if it causes device ids to change! 
For example, in increasing order of efficiency:

(a) your script could store in a temporary file, if not already found, 
the geometry of the device when it is first called; this way, the next 
time you run it, it could retrieve the original geometry from the 
existing file on disk (instead of querying Area which is no longer the 
default value).

(b) if your version of xsetwacom support it,
xsetwacom set "device name" ResetArea
will reset the Area parameter (assuming this is what you were modifying 
and lost) without having to hotplug/unplug.

(c) xsetwacom set "device name" MapToOutput 500x600+400+300
maps the device area to a 500x600 window located at coordinates 400,300 
  -- and can be run repeatedly safely as far as I can tell. This
is a much better way to rescale the device than to change the Area 
parameter.
(Besides a window geometry you can also specify a display name, or 
"desktop" for the whole desktop area, which has the effect of undoing a 
previous MapToOutput command; but you can do successive MapToOutput 
commands without undoing them in between.)

Also:

3. In principle there's a GDK_MODE_WINDOW mode and a GDK_MODE_SCREEN 
mode for GTK2 input devices. Xournal sets things to SCREEN (use the 
whole screen) because of its tablet origins, but you could try seeing 
what happens if you recompile the source code after changing 
GDK_MODE_SCREEN to GDK_MODE_WINDOW in both places where it occurs. On my 
Tablet PC it doesn't do the right thing at all (not to mention that just 
doing this would remap all devices, not just the wacom tablet, to the 
window), so I assume GDK_MODE_WINDOW is broken and the correct 
approaches are those in item 2 above.

Hope this helps.
Denis

------------------------------------------------------------------------------
_______________________________________________
Xournal-devel mailing list
Xournal-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xournal-devel

Reply via email to