Bug 525 - GLWindow.warpPointer() does not work on Linux
Summary: GLWindow.warpPointer() does not work on Linux
Status: VERIFIED WORKSFORME
Alias: None
Product: Newt
Classification: JogAmp
Component: x11 (show other bugs)
Version: 1
Hardware: All linux
: --- major
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2011-11-09 12:56 CET by Julien Gouesse
Modified: 2011-12-05 21:39 CET (History)
0 users

See Also:
Type: ---
SCM Refs:
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Gouesse 2011-11-09 12:56:23 CET
GLWindow.warpPointer() does not work on Linux, it has absolutely no effect. I use Mageia Linux 1, KDE 4.6, the dev build 535 of JOGL 2.0, OpenJDK 1.6, AMD Sempron 2600+ (32 bits), NVIDIA Geforce 7600 GT. The bug is reproducible on Cent OS Linux 5.3 with Intel core duo and NVIDIA Quadro FX 3600.

A possible root cause and its fix are here:
http://forum.jogamp.org/JOGL-Update-New-NEWT-Mouse-Features-tp3420099p3453058.html

I cannot provide a JUnit test because there is no way of retrieving the abscissa and the ordinate of the mouse cursor in pure NEWT. Anyway, you can reproduce this bug by adding a call to warpPointer(20,20) into https://github.com/sgothel/jogl/blob/master/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java and by using java.awt.MouseInfo.getPointerInfo().getLocation() (which won't work on embedded platforms with no support of AWT of course).
Comment 1 Julien Gouesse 2011-11-09 12:57:57 CET
I've just marked this bug as major because it is problematic for the JOGL 2.0 renderer of Ardor3D.
Comment 2 Sven Gothel 2011-11-21 06:52:36 CET
Manual test works on all X11/xorg machines as desired:
  bash scripts/tests-x64.sh -time 10000000 -vsync
  java com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -time 10000000 -vsync

Ubuntu 11.04
Ubuntu 11.10
CentOS 6.0
Solaris 10

+++

Julien's post:

warpPointer() does not work on my machine, I have just tested it with TUER, it does not throw any exception, it just does nothing :( I use Mageia Linux 1, KDE 4.6, the latest dev build of JOGL 2 (535), OpenJDK 1.6. I will have to investigate.

Edit.: There is something wrong here:

<snip/>

JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_warpPointer0
  (JNIEnv *env, jclass clazz, jlong display, jlong window, jint x, jint y)
{
    Display * dpy = (Display *) (intptr_t) display;
    Window w = (Window)window;

    DBG_PRINT( "X11: warpPointer0: %d/%d\n", x, y);

    XWarpPointer(dpy, None, w, 0, 0, 0, 0, x, y);
}

I would rather call XWarpPointer(dpy, w, None, 0, 0, 0, 0, x, y); because XWarpPointer needs the source window to get its width and its height (when src_width and src_height are set to zero). If you pass None, it cannot "know" them. Ok I'm falling asleep, good night. 

+++

According to: http://tronche.com/gui/x/xlib/input/XWarpPointer.html

If dest_w is None, XWarpPointer() moves the pointer by the offsets (dest_x, dest_y) relative to the current position of the pointer. If dest_w is a window, XWarpPointer() moves the pointer to the offsets (dest_x, dest_y) relative to the origin of dest_w. However, if src_w is a window, the move only takes place if the window src_w contains the pointer and if the specified rectangle of src_w contains the pointer.

The src_x and src_y coordinates are relative to the origin of src_w. If src_height is zero, it is replaced with the current height of src_w minus src_y. If src_width is zero, it is replaced with the current width of src_w minus src_x. 

+++

Hence we use it as advertised, ie. we only pass the destination window and it's client space 
(relative window coordinates). 

We don't want to move the mouse position relative from it's current position (src_w given, dest_w NULL)
nor want we to restrict this function to the case where the mouse is within the window (both given and current mouse shall reside within src rectangular).

Besides .. the manual test works.
I may add a unit test utilizing a mouse listener.


The
Comment 3 Julien Gouesse 2011-11-24 14:29:23 CET
Is it intended to work like AWT Robot? I will test it again.
Comment 4 Sven Gothel 2011-11-25 03:31:04 CET
Re: CentOS, see bug 451, comment 3
Comment 5 Julien Gouesse 2011-12-01 13:29:58 CET
Hi

I confirm it works fine on CentOS 5.3, I have just used TestGearsES2NEWT by pressing 'w'. I have to perform this test on Mageia Linux 1.
Comment 6 Julien Gouesse 2011-12-05 21:39:49 CET
I confirm it works fine on Mageia Linux 1, the mistake came from my source code, see JoglNewtMouseManager and JoglNewtMouseWrapper.