summaryrefslogtreecommitdiffstats
path: root/src/newt/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes')
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseEvent.java14
-rw-r--r--src/newt/classes/com/jogamp/newt/event/MouseListener.java2
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java5
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Window.java50
4 files changed, 68 insertions, 3 deletions
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
index ccc674f1d..9bc3be1e5 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -139,6 +139,20 @@ public class MouseEvent extends InputEvent
return pressure[index];
}
+ /**
+ * <i>Usually</i> a wheel rotation of <b>&gt; 0 is up</b>,
+ * and <b>&lt; 0 is down</b>.<br>
+ * <i>However</i>, on some OS this might be flipped due to the OS <i>default</i> behavior.
+ * The latter is true for OS X 10.7 (Lion) for example.
+ * <p>
+ * The events will be send usually in steps of one, ie. <i>-1</i> and <i>1</i>.
+ * Higher values may result due to fast scrolling.
+ * </p>
+ * <p>
+ * The button number refers to the wheel number.
+ * </p>
+ * @return
+ */
public int getWheelRotation() {
return wheelRotation;
}
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseListener.java b/src/newt/classes/com/jogamp/newt/event/MouseListener.java
index 5ec086b94..7668b755c 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseListener.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseListener.java
@@ -43,6 +43,8 @@ public interface MouseListener extends NEWTEventListener
public void mouseReleased(MouseEvent e);
public void mouseMoved(MouseEvent e);
public void mouseDragged(MouseEvent e);
+
+ /** See {@link MouseEvent#getWheelRotation() } */
public void mouseWheelMoved(MouseEvent e);
}
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
//