diff options
author | Sven Gothel <[email protected]> | 2011-12-02 07:54:41 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-12-02 07:54:41 +0100 |
commit | 30c959a4534bc0c6b4718ae65fd4f91d68d6eca6 (patch) | |
tree | 09d676201680f6a670385c8e5f78d23b4eea9955 /src/newt/classes/jogamp | |
parent | 4856f7800bac165c3770495b77de4a2eabcca46e (diff) |
NEWT EVENT_MOUSE_WHEEL_MOVED: Fix Bug 413 - Generate proper mouse wheel events.
> 0: UP
< 0: DOWN
See MouseEvent.getWheelRotation() for details.
OSX/Windows: Default to wheel 'button' 1
OSX: Properly report '<0'
X11: Synthesize wheel events by mapping buttons 4/5 and 6/7 to wheel 1 and 2.
Diffstat (limited to 'src/newt/classes/jogamp')
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 5 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/x11/X11Window.java | 50 |
2 files changed, 52 insertions, 3 deletions
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index e496ae4fb..f0abd9625 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1904,8 +1904,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x, int y, int button, int rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); } - private void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, int rotation) { + + protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, + int x, int y, int button, int rotation) { if(eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED) { if(eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1) { diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java index 1cff26fad..bfaf53f0d 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java @@ -44,9 +44,15 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.newt.event.MouseEvent; + public class X11Window extends WindowImpl { private static final String WINDOW_CLASS_NAME = "NewtWindow"; - + private static final int X11_WHEEL_ONE_UP_BUTTON = 4; + private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5; + private static final int X11_WHEEL_TWO_UP_BUTTON = 6; + private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; + static { X11Display.initSingleton(); } @@ -175,6 +181,48 @@ public class X11Window extends WindowImpl { // nop - using event driven insetsChange(..) } + protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, + int x, int y, int button, int rotation) { + switch(eventType) { + case MouseEvent.EVENT_MOUSE_PRESSED: + switch(button) { + case X11_WHEEL_ONE_UP_BUTTON: + case X11_WHEEL_ONE_DOWN_BUTTON: + case X11_WHEEL_TWO_UP_BUTTON: + case X11_WHEEL_TWO_DOWN_BUTTON: + // ignore wheel pressed ! + return; + } + break; + case MouseEvent.EVENT_MOUSE_RELEASED: + switch(button) { + case X11_WHEEL_ONE_UP_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 1; + rotation = 1; + break; + case X11_WHEEL_ONE_DOWN_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 1; + rotation = -1; + break; + case X11_WHEEL_TWO_UP_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 2; + rotation = 1; + break; + case X11_WHEEL_TWO_DOWN_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 2; + rotation = -1; + break; + } + break; + } + super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); + } + + //---------------------------------------------------------------------- // Internals only // |