You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
|
8
(1) |
9
|
10
|
11
(3) |
12
|
13
|
14
|
|
15
|
16
|
17
|
18
|
19
|
20
(6) |
21
|
|
22
|
23
(8) |
24
(6) |
25
|
26
(10) |
27
(3) |
28
(1) |
|
29
|
30
(2) |
31
(1) |
|
|
|
|
|
From: <eli...@us...> - 2006-10-26 21:39:48
|
Revision: 2613
http://svn.sourceforge.net/java-game-lib/?rev=2613&view=rev
Author: elias_naur
Date: 2006-10-26 14:39:37 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Mac OS X: Implemented AWTInputAdapter
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 21:15:50 UTC (rev 2612)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613)
@@ -37,7 +37,6 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
-import java.awt.event.FocusListener;
import java.awt.Cursor;
/**
@@ -49,16 +48,18 @@
abstract class AbstractAWTInput implements AWTCanvasInputImplementation {
private AWTGLCanvas canvas;
- private volatile int current_height;
- private volatile int current_width;
private KeyboardEventQueue keyboard_queue;
private MouseEventQueue mouse_queue;
private volatile boolean grab;
- protected AbstractAWTInput(AWTGLCanvas canvas) throws LWJGLException {
+ protected AbstractAWTInput(AWTGLCanvas canvas) {
this.canvas = canvas;
}
+ protected synchronized MouseEventQueue getMouseEventQueue() {
+ return mouse_queue;
+ }
+
public synchronized void grabMouse(boolean grab) {
this.grab = grab;
if (mouse_queue != null)
@@ -83,18 +84,13 @@
}
public final int getWidth() {
- return current_width;
+ return canvas.getWidth();
}
public final int getHeight() {
- return current_height;
+ return canvas.getHeight();
}
- public synchronized void processInput(PeerInfo peer_info) {
- current_width = canvas.getWidth();
- current_height = canvas.getHeight();
- }
-
public boolean hasWheel() {
return AWTUtil.hasWheel();
}
@@ -104,10 +100,14 @@
}
public void createMouse() throws LWJGLException {
- mouse_queue = new MouseEventQueue(canvas);
+ mouse_queue = createMouseQueue();
mouse_queue.register();
}
+ protected MouseEventQueue createMouseQueue() {
+ return new MouseEventQueue(getCanvas());
+ }
+
public void destroyMouse() {
mouse_queue.unregister();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 21:15:50 UTC (rev 2612)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613)
@@ -113,7 +113,6 @@
}
public synchronized void processInput(PeerInfo peer_info) {
- super.processInput(peer_info);
LinuxDisplay.lockAWT();
try {
LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info;
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2002-2004 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+import java.nio.IntBuffer;
+import java.nio.ByteBuffer;
+
+import org.lwjgl.LWJGLException;
+import org.lwjgl.LWJGLUtil;
+
+/**
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2586 $
+ * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $
+ */
+final class MacOSXAWTInput extends AbstractAWTInput {
+ private boolean had_focus;
+
+ MacOSXAWTInput(AWTGLCanvas canvas) {
+ super(canvas);
+ }
+
+ protected MouseEventQueue createMouseQueue() {
+ return new MacOSXMouseEventQueue(getCanvas());
+ }
+
+ public synchronized void processInput(PeerInfo peer_info) {
+ boolean has_focus = getCanvas().isFocusOwner();
+ if (!had_focus && has_focus)
+ ((MacOSXMouseEventQueue)getMouseEventQueue()).warpCursor();
+ had_focus = has_focus;
+ }
+
+ public void destroy() {
+ }
+
+ public void update() {
+ }
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 21:15:50 UTC (rev 2612)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 21:39:37 UTC (rev 2613)
@@ -64,6 +64,6 @@
}
public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException {
- throw new UnsupportedOperationException();
+ return new MacOSXAWTInput(canvas);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 21:15:59
|
Revision: 2612
http://svn.sourceforge.net/java-game-lib/?rev=2612&view=rev
Author: elias_naur
Date: 2006-10-26 14:15:50 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Linux: Replaced obsolete hasFocus with isFocusOwner
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 20:49:07 UTC (rev 2611)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 21:15:50 UTC (rev 2612)
@@ -37,8 +37,6 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
-import java.awt.event.FocusEvent;
-
/**
*
* @author elias_naur <eli...@us...>
@@ -141,7 +139,7 @@
}
private void checkFocus() {
- if (getCanvas().hasFocus()) {
+ if (getCanvas().isFocusOwner()) {
input_released = false;
} else {
input_released = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 20:49:21
|
Revision: 2611
http://svn.sourceforge.net/java-game-lib/?rev=2611&view=rev
Author: elias_naur
Date: 2006-10-26 13:49:07 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Mac OS X: Moved mouse handling from MacOSXDisplay to MacOSXMouseEventQueue
Modified Paths:
--------------
trunk/LWJGL/build.xml
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2006-10-26 20:33:40 UTC (rev 2610)
+++ trunk/LWJGL/build.xml 2006-10-26 20:49:07 UTC (rev 2611)
@@ -524,6 +524,7 @@
</javah>
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
+ <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
<class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" />
<class name="org.lwjgl.opengl.MacOSXPeerInfo" />
<class name="org.lwjgl.opengl.MacOSXPbufferPeerInfo" />
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 20:33:40 UTC (rev 2610)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 20:49:07 UTC (rev 2611)
@@ -69,7 +69,7 @@
private static final int GAMMA_LENGTH = 256;
private MacOSXFrame frame;
- private MouseEventQueue mouse_queue;
+ private MacOSXMouseEventQueue mouse_queue;
private KeyboardEventQueue keyboard_queue;
private java.awt.DisplayMode requested_mode;
@@ -256,20 +256,11 @@
GL11.glGetInteger(GL11.GL_VIEWPORT, current_viewport);
GL11.glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
}
- if (frame.syncShouldWarpCursor()) {
- warpCursor();
+ if (frame.syncShouldWarpCursor() && mouse_queue != null) {
+ mouse_queue.warpCursor();
}
}
- private void warpCursor() {
- if (mouse_queue != null && mouse_queue.isGrabbed()) {
- Rectangle bounds = frame.syncGetBounds();
- int x = bounds.x + bounds.width/2;
- int y = bounds.y + bounds.height/2;
- nWarpCursor(x, y);
- }
- }
-
/**
* This is an interface to the native Carbon call
* SetSystemUIMode. It is used to hide the dock in a way
@@ -286,8 +277,6 @@
private native void nHideUI(boolean hide);
- native void getMouseDeltas(IntBuffer delta_buffer);
-
public void reshape(int x, int y, int width, int height) {
frame.resize(x, y, width, height);
}
@@ -323,14 +312,8 @@
public void grabMouse(boolean grab) {
mouse_queue.setGrabbed(grab);
- warpCursor();
- nGrabMouse(grab);
}
- private native void nWarpCursor(int x, int y);
-
- private native void nGrabMouse(boolean grab);
-
public int getNativeCursorCapabilities() {
return AWTUtil.getNativeCursorCapabilities();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-26 20:33:40 UTC (rev 2610)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-26 20:49:07 UTC (rev 2611)
@@ -42,6 +42,7 @@
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.Component;
+import java.awt.Rectangle;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@@ -55,16 +56,22 @@
super(component);
}
+ public void setGrabbed(boolean grab) {
+ super.setGrabbed(grab);
+ warpCursor();
+ nGrabMouse(grab);
+ }
+
protected void resetCursorToCenter() {
super.resetCursorToCenter();
/* Clear accumulated deltas */
- ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
+ getMouseDeltas(delta_buffer);
}
protected void updateDeltas(long nanos) {
super.updateDeltas(nanos);
synchronized ( this ) {
- ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
+ getMouseDeltas(delta_buffer);
int dx = delta_buffer.get(0);
int dy = -delta_buffer.get(1);
if ( dx != 0 || dy != 0 ) {
@@ -73,4 +80,19 @@
}
}
}
+
+ void warpCursor() {
+ if (isGrabbed()) {
+ Rectangle bounds = getComponent().getBounds();
+ int x = bounds.x + bounds.width/2;
+ int y = bounds.y + bounds.height/2;
+ nWarpCursor(x, y);
+ }
+ }
+
+ private static native void getMouseDeltas(IntBuffer delta_buffer);
+
+ private static native void nWarpCursor(int x, int y);
+
+ private static native void nGrabMouse(boolean grab);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:33:40 UTC (rev 2610)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:49:07 UTC (rev 2611)
@@ -56,7 +56,6 @@
private boolean grabbed;
-
/** The accumulated mouse deltas returned by poll() */
private int accum_dx;
private int accum_dy;
@@ -93,6 +92,10 @@
component.removeMouseWheelListener(this);
}
+ protected Component getComponent() {
+ return component;
+ }
+
public synchronized void setGrabbed(boolean grabbed) {
this.grabbed = grabbed;
resetCursorToCenter();
Modified: trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c
===================================================================
--- trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c 2006-10-26 20:33:40 UTC (rev 2610)
+++ trunk/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.c 2006-10-26 20:49:07 UTC (rev 2611)
@@ -41,11 +41,12 @@
#include <jni.h>
#include <ApplicationServices/ApplicationServices.h>
+#include "org_lwjgl_opengl_MacOSXMouseEventQueue.h"
#include "common_tools.h"
static bool is_grabbed;
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nGrabMouse(JNIEnv *env, jobject this, jboolean grab) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nGrabMouse(JNIEnv *env, jclass unused, jboolean grab) {
bool new_grabbed = grab == JNI_TRUE;
if (is_grabbed != new_grabbed) {
is_grabbed = new_grabbed;
@@ -57,14 +58,14 @@
}
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_nWarpCursor(JNIEnv *env, jobject this, jint x, jint y) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_nWarpCursor(JNIEnv *env, jclass unused, jint x, jint y) {
CGPoint p;
p.x = x;
p.y = y;
CGWarpMouseCursorPosition(p);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_getMouseDeltas(JNIEnv *env, jobject this, jobject delta_buffer) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXMouseEventQueue_getMouseDeltas(JNIEnv *env, jclass unused, jobject delta_buffer) {
CGMouseDelta dx, dy;
CGGetLastMouseDelta(&dx, &dy);
int buffer_length = (*env)->GetDirectBufferCapacity(env, delta_buffer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 20:33:49
|
Revision: 2610
http://svn.sourceforge.net/java-game-lib/?rev=2610&view=rev
Author: elias_naur
Date: 2006-10-26 13:33:40 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Mac OS X: Fixed null delta_buffer in MacOSXMouseEventQueue
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:19:40 UTC (rev 2609)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:33:40 UTC (rev 2610)
@@ -78,10 +78,10 @@
MouseEventQueue(Component component) {
super(Mouse.EVENT_SIZE);
this.component = component;
- resetCursorToCenter();
}
public void register() {
+ resetCursorToCenter();
component.addMouseListener(this);
component.addMouseMotionListener(this);
component.addMouseWheelListener(this);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 20:20:14
|
Revision: 2609
http://svn.sourceforge.net/java-game-lib/?rev=2609&view=rev
Author: elias_naur
Date: 2006-10-26 13:19:40 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Added org.lwjgl.opengl.AWTInputAdapter which enabled use of Mouse and
Keyboard with AWTGLCanvases. Programs can now avoid implementing AWT input processing and access the mouse grabbing features from both Display and AWTGLCanvas. See org.lwjgl.test.opengl.awt.AWTInputAdapterTest for an example.
Note: This commit is the linux and generic AWT imlementation and can still
change a lot while implementing windows and mac os x.
Modified Paths:
--------------
trunk/LWJGL/build.xml
trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java
trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java
trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxPeerInfo.c
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java
trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxAWTInput.c
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/build.xml 2006-10-26 20:19:40 UTC (rev 2609)
@@ -494,6 +494,7 @@
<target name="headers" description="invokes javah on java classes" depends="compile">
<!-- platform specific classes -->
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
+ <class name="org.lwjgl.opengl.LinuxAWTInput" />
<class name="org.lwjgl.opengl.LinuxEvent" />
<class name="org.lwjgl.opengl.LinuxMouse" />
<class name="org.lwjgl.opengl.LinuxKeyboard" />
Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -42,7 +42,7 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;
-import org.lwjgl.opengl.DisplayImplementation;
+import org.lwjgl.opengl.InputImplementation;
/**
* <br>
@@ -264,7 +264,7 @@
/** One time initialization */
private static boolean initialized;
- private static DisplayImplementation implementation;
+ private static InputImplementation implementation;
/**
* Keyboard cannot be constructed.
@@ -283,25 +283,33 @@
}
/**
- * "Create" the keyboard. The display must first have been created. The
- * reason for this is so the keyboard has a window to "focus" in.
+ * "Create" the keyboard with the given implementation. This is used
+ * reflectively from AWTInputAdapter.
*
* @throws LWJGLException if the keyboard could not be created for any reason
*/
- public static void create() throws LWJGLException {
- if (!Display.isCreated())
- throw new IllegalStateException("Display must be created before you can create Keyboard");
+ private static void create(InputImplementation impl) throws LWJGLException {
+ if (created)
+ throw new IllegalStateException("Destroy the Keyboard first.");
if (!initialized)
initialize();
- if (created)
- return;
- implementation = Mouse.getImplementation();
+ implementation = impl;
implementation.createKeyboard();
created = true;
readBuffer = ByteBuffer.allocate(EVENT_SIZE*BUFFER_SIZE);
reset();
}
+ /**
+ * "Create" the keyboard. The display must first have been created. The
+ * reason for this is so the keyboard has a window to "focus" in.
+ *
+ * @throws LWJGLException if the keyboard could not be created for any reason
+ */
+ public static void create() throws LWJGLException {
+ create(Mouse.createImplementation());
+ }
+
private static void reset() {
readBuffer.limit(0);
for (int i = 0; i < keyDownBuffer.remaining(); i++)
Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -40,8 +40,8 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys;
-import org.lwjgl.opengl.DisplayImplementation;
import org.lwjgl.opengl.Display;
+import org.lwjgl.opengl.InputImplementation;
import java.lang.reflect.Method;
import java.security.AccessController;
@@ -57,7 +57,7 @@
* n buttons supported, n being a native limit. A scrolly wheel is also
* supported, if one such is available. Movement is reported as delta from
* last position or as an absolute position. If the window has been created
- * the absolute position will be clamped to 0 - Display (width | height)
+ * the absolute position will be clamped to 0 - width | height.
*
* @author cix_foo <ci...@us...>
* @author elias_naur <eli...@us...>
@@ -134,10 +134,10 @@
private static boolean isGrabbed;
- private static DisplayImplementation implementation;
+ private static InputImplementation implementation;
- /** Whether we're running windows - which need to manually update cursor animation */
- private static final boolean isWindows = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS;
+ /** Whether we're running windows - which need to manually update cursor animation */
+ private static final boolean isWindows = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS;
/**
* Mouse cannot be constructed.
@@ -220,13 +220,19 @@
readBuffer.position(readBuffer.limit());
}
- static DisplayImplementation getImplementation() {
+ static InputImplementation getImplementation() {
+ return implementation;
+ }
+
+ static InputImplementation createImplementation() {
+ if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
+
/* Use reflection since we can't make Display.getImplementation
* public
*/
try {
- return (DisplayImplementation)AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception{
+ return (InputImplementation)AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null);
getImplementation_method.setAccessible(true);
return getImplementation_method.invoke(null, null);
@@ -238,19 +244,17 @@
}
/**
- * "Create" the mouse. The display must first have been created.
- * Initially, the mouse is not grabbed and the delta values are reported
- * with respect to the center of the display.
+ * "Create" the mouse with the given custom implementation. This is used
+ * reflectively by AWTInputAdapter.
*
* @throws LWJGLException if the mouse could not be created for any reason
*/
- public static void create() throws LWJGLException {
- if (!Display.isCreated()) throw new IllegalStateException("Display must be created prior to creating mouse");
-
+ private static void create(InputImplementation impl) throws LWJGLException {
+ if (created)
+ throw new IllegalStateException("Destroy the mouse first.");
if (!initialized)
initialize();
- if (created) return;
- implementation = getImplementation();
+ implementation = impl;
implementation.createMouse();
hasWheel = implementation.hasWheel();
created = true;
@@ -259,7 +263,7 @@
buttonCount = implementation.getButtonCount();
buttons = BufferUtils.createByteBuffer(buttonCount);
coord_buffer = BufferUtils.createIntBuffer(3);
- if (currentCursor != null)
+ if (currentCursor != null && implementation.getNativeCursorCapabilities() != 0)
setNativeCursor(currentCursor);
readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE);
readBuffer.limit(0);
@@ -267,6 +271,17 @@
}
/**
+ * "Create" the mouse. The display must first have been created.
+ * Initially, the mouse is not grabbed and the delta values are reported
+ * with respect to the center of the display.
+ *
+ * @throws LWJGLException if the mouse could not be created for any reason
+ */
+ public static void create() throws LWJGLException {
+ create(createImplementation());
+ }
+
+ /**
* @return true if the mouse has been created
*/
public static boolean isCreated() {
@@ -327,8 +342,8 @@
x = poll_coord1;
y = poll_coord2;
}
- x = Math.min(Display.getDisplayMode().getWidth() - 1, Math.max(0, x));
- y = Math.min(Display.getDisplayMode().getHeight() - 1, Math.max(0, y));
+ x = Math.min(implementation.getWidth() - 1, Math.max(0, x));
+ y = Math.min(implementation.getHeight() - 1, Math.max(0, y));
dwheel += poll_dwheel;
read();
}
@@ -404,8 +419,8 @@
event_x = new_event_x;
event_y = new_event_y;
}
- event_x = Math.min(Display.getDisplayMode().getWidth() - 1, Math.max(0, event_x));
- event_y = Math.min(Display.getDisplayMode().getHeight() - 1, Math.max(0, event_y));
+ event_x = Math.min(implementation.getWidth() - 1, Math.max(0, event_x));
+ event_y = Math.min(implementation.getHeight() - 1, Math.max(0, event_y));
event_dwheel = readBuffer.getInt();
event_nanos = readBuffer.getLong();
return true;
@@ -476,8 +491,8 @@
}
/**
- * Retrieves the absolute position. If the Display has been created
- * x will be clamped to 0...width-1.
+ * Retrieves the absolute position. It will be clamped to
+ * 0...width-1.
*
* @return Absolute x axis position of mouse
*/
@@ -486,8 +501,8 @@
}
/**
- * Retrieves the absolute position. If the Display has been created
- * y will be clamped to 0...height-1.
+ * Retrieves the absolute position. It will be clamped to
+ * 0...height-1.
*
* @return Absolute y axis position of mouse
*/
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -46,7 +46,7 @@
/**
* Return an opaque handle to the canvas peer information required to create a context from it.
*/
- public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException;
+ PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException;
/**
* Find a proper GraphicsConfiguration from the given GraphicsDevice and PixelFormat.
@@ -54,5 +54,13 @@
* @return A GraphicsConfiguration matching the given GraphicsConfiguration and PixelFormat.
* @throws LWJGLException if no suitable configuration could be found.
*/
- public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException;
+ GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException;
+
+ /**
+ * Create an AWTCanvasInputImplementation for a specified AWTGLCanvas.
+ *
+ * @return A platform specific AWTCanvasInputImplementation.
+ * @param canvas An AWTGLCanvas
+ */
+ AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException;
}
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTCanvasInputImplementation.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2002-2006 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+import org.lwjgl.LWJGLException;
+
+/**
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2286 $
+ * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $
+ */
+interface AWTCanvasInputImplementation extends InputImplementation {
+ void processInput(PeerInfo peer_info);
+ void update();
+ void init();
+ void destroy();
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -81,6 +81,9 @@
/** Tracks whether initGL() needs to be called */
private boolean first_run;
+ /** Track the input adapter, if any */
+ private volatile AWTCanvasInputImplementation awt_input;
+
static {
Sys.initialize();
String class_name;
@@ -109,7 +112,17 @@
}
}
+ /**
+ * Used from AWTInputAdapter
+ */
+ static AWTCanvasImplementation getImplementation() {
+ return implementation;
+ }
+ void setInput(AWTCanvasInputImplementation awt_input) {
+ this.awt_input = awt_input;
+ }
+
private void setUpdate() {
synchronized(SYNC_LOCK) {
update_context = true;
@@ -271,8 +284,9 @@
*/
public final void paint(Graphics g) {
try {
- if (peer_info == null)
+ if (peer_info == null) {
this.peer_info = implementation.createPeerInfo(this, pixel_format);
+ }
peer_info.lockAndGetHandle();
try {
if (context == null) {
@@ -288,6 +302,9 @@
context.update();
update_context = false;
}
+ AWTCanvasInputImplementation current_input = awt_input;
+ if (current_input != null)
+ current_input.processInput(peer_info);
if (first_run) {
first_run = false;
initGL();
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTInputAdapter.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2002-2006 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+import org.lwjgl.LWJGLException;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.input.Keyboard;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
+
+import java.lang.reflect.Method;
+
+import java.awt.Canvas;
+
+/**
+ * This is the static class for using LWJGL input (Mouse and Keyboard)
+ * with an AWTGLCanvas.
+ *
+ * @author Elias Naur
+ * @version $Revision: 2286 $
+ * $Id: AWTCanvasImplementation.java 2286 2006-03-23 19:32:21Z matzon $
+ */
+public final class AWTInputAdapter {
+ private static AWTCanvasInputImplementation awt_input;
+
+ /**
+ * Create AWTInputAdapter with the specified AWTGLCanvas. Use
+ * update() to receive input.
+ *
+ * @param canvas The canvas to receive input from.
+ */
+ public static synchronized void create(AWTGLCanvas canvas) throws LWJGLException {
+ if (awt_input != null)
+ throw new IllegalStateException("You need to destroy() the adapter.");
+ awt_input = AWTGLCanvas.getImplementation().createInput(canvas);
+ // Invoke Mouse.create(awt_input) and Keyboard.create(awt_input)
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ private void invokeCreate(Class input_class) throws Exception {
+ Method create_method = input_class.getDeclaredMethod("create", new Class[]{InputImplementation.class});
+ create_method.setAccessible(true);
+ create_method.invoke(null, new Object[]{awt_input});
+ }
+
+ public Object run() throws Exception {
+ invokeCreate(Mouse.class);
+ invokeCreate(Keyboard.class);
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof LWJGLException)
+ throw (LWJGLException)cause;
+ else
+ throw new Error(cause);
+ }
+ awt_input.init();
+ }
+
+ public static synchronized void destroy() {
+ if (awt_input != null) {
+ awt_input.destroy();
+ awt_input = null;
+ }
+ }
+
+ public static synchronized void update() {
+ if (awt_input == null)
+ throw new IllegalStateException("You need to create() the adapter.");
+ awt_input.update();
+ Display.pollDevices();
+ }
+}
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2002-2004 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+import java.nio.IntBuffer;
+import java.nio.ByteBuffer;
+
+import org.lwjgl.LWJGLException;
+import org.lwjgl.LWJGLUtil;
+
+import java.awt.event.FocusListener;
+import java.awt.Cursor;
+
+/**
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2586 $
+ * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $
+ */
+abstract class AbstractAWTInput implements AWTCanvasInputImplementation {
+ private AWTGLCanvas canvas;
+
+ private volatile int current_height;
+ private volatile int current_width;
+ private KeyboardEventQueue keyboard_queue;
+ private MouseEventQueue mouse_queue;
+ private volatile boolean grab;
+
+ protected AbstractAWTInput(AWTGLCanvas canvas) throws LWJGLException {
+ this.canvas = canvas;
+ }
+
+ public synchronized void grabMouse(boolean grab) {
+ this.grab = grab;
+ if (mouse_queue != null)
+ mouse_queue.setGrabbed(grab);
+ }
+
+ protected boolean isGrabbed() {
+ return grab;
+ }
+
+ protected final AWTGLCanvas getCanvas() {
+ return canvas;
+ }
+
+ public final void init() {
+ canvas.setInput(this);
+ }
+
+ public synchronized void destroy() {
+ canvas.setInput(null);
+ canvas = null;
+ }
+
+ public final int getWidth() {
+ return current_width;
+ }
+
+ public final int getHeight() {
+ return current_height;
+ }
+
+ public synchronized void processInput(PeerInfo peer_info) {
+ current_width = canvas.getWidth();
+ current_height = canvas.getHeight();
+ }
+
+ public boolean hasWheel() {
+ return AWTUtil.hasWheel();
+ }
+
+ public int getButtonCount() {
+ return AWTUtil.getButtonCount();
+ }
+
+ public void createMouse() throws LWJGLException {
+ mouse_queue = new MouseEventQueue(canvas);
+ mouse_queue.register();
+ }
+
+ public void destroyMouse() {
+ mouse_queue.unregister();
+ }
+
+ public int getNativeCursorCapabilities() {
+ return AWTUtil.getNativeCursorCapabilities();
+ }
+
+ public void setCursorPosition(int x, int y) {
+ AWTUtil.setCursorPosition(canvas, x, y);
+ }
+
+ public void setNativeCursor(Object handle) throws LWJGLException {
+ canvas.setCursor((Cursor)handle);
+ }
+
+ public int getMinCursorSize() {
+ return AWTUtil.getMinCursorSize();
+ }
+
+ public int getMaxCursorSize() {
+ return AWTUtil.getMaxCursorSize();
+ }
+
+ public synchronized void createKeyboard() throws LWJGLException {
+ keyboard_queue = new KeyboardEventQueue(canvas);
+ keyboard_queue.register();
+ }
+
+ public synchronized void destroyKeyboard() {
+ if (keyboard_queue != null)
+ keyboard_queue.unregister();
+ }
+
+ public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
+ return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
+ }
+
+ public void destroyCursor(Object cursor_handle) {
+ }
+
+ public synchronized void readMouse(ByteBuffer buffer) {
+ mouse_queue.copyEvents(buffer);
+ }
+
+ public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
+ mouse_queue.poll(coord_buffer, buttons);
+ }
+
+ public synchronized void readKeyboard(ByteBuffer buffer) {
+ keyboard_queue.copyEvents(buffer);
+ }
+
+ public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) {
+ keyboard_queue.poll(keyDownBuffer);
+ }
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -44,7 +44,7 @@
import org.lwjgl.LWJGLException;
-public interface DisplayImplementation {
+interface DisplayImplementation extends InputImplementation {
void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
@@ -124,88 +124,6 @@
*/
DisplayMode[] getAvailableDisplayModes() throws LWJGLException;
- /*
- * Mouse methods
- */
- /** Query of wheel support */
- boolean hasWheel();
-
- /** Query of button count */
- int getButtonCount();
-
- /**
- * Method to create the mouse.
- */
- void createMouse() throws LWJGLException;
-
- /**
- * Method the destroy the mouse
- */
- void destroyMouse();
-
- /**
- * Method to poll the mouse
- */
- void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
-
- /**
- * Method to read the keyboard buffer
- */
- void readMouse(ByteBuffer buffer);
-
- void grabMouse(boolean grab);
-
- /**
- * Function to determine native cursor support
- */
- int getNativeCursorCapabilities();
-
- /** Method to set the native cursor position */
- void setCursorPosition(int x, int y);
-
- /** Method to set the native cursor */
- void setNativeCursor(Object handle) throws LWJGLException;
-
- /** Method returning the minimum cursor size */
- int getMinCursorSize();
-
- /** Method returning the maximum cursor size */
- int getMaxCursorSize();
-
- /*
- * Keyboard methods
- */
-
- /**
- * Method to create the keyboard
- */
- void createKeyboard() throws LWJGLException;
-
- /**
- * Method to destroy the keyboard
- */
- void destroyKeyboard();
-
- /**
- * Method to poll the keyboard.
- *
- * @param keyDownBuffer the address of a 256-byte buffer to place
- * key states in.
- */
- void pollKeyboard(ByteBuffer keyDownBuffer);
-
- /**
- * Method to read the keyboard buffer
- */
- void readKeyboard(ByteBuffer buffer);
-
-// int isStateKeySet(int key);
-
- /** Native cursor handles */
- Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException;
-
- void destroyCursor(Object cursor_handle);
-
/* Pbuffer */
int getPbufferCapabilities();
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/InputImplementation.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2002-2004 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+/**
+ * This is the input implementation interface. Mouse and Keyboard delegates
+ * to implementors of this interface. There is one InputImplementation
+ * for each supported platform.
+ * @author elias_naur
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+
+import org.lwjgl.LWJGLException;
+
+public interface InputImplementation {
+ /*
+ * Mouse methods
+ */
+ /** Query of wheel support */
+ boolean hasWheel();
+
+ /** Query of button count */
+ int getButtonCount();
+
+ /**
+ * Method to create the mouse.
+ */
+ void createMouse() throws LWJGLException;
+
+ /**
+ * Method the destroy the mouse
+ */
+ void destroyMouse();
+
+ /**
+ * Method to poll the mouse
+ */
+ void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
+
+ /**
+ * Method to read the keyboard buffer
+ */
+ void readMouse(ByteBuffer buffer);
+
+ void grabMouse(boolean grab);
+
+ /**
+ * Function to determine native cursor support
+ */
+ int getNativeCursorCapabilities();
+
+ /** Method to set the native cursor position */
+ void setCursorPosition(int x, int y);
+
+ /** Method to set the native cursor */
+ void setNativeCursor(Object handle) throws LWJGLException;
+
+ /** Method returning the minimum cursor size */
+ int getMinCursorSize();
+
+ /** Method returning the maximum cursor size */
+ int getMaxCursorSize();
+
+ /*
+ * Keyboard methods
+ */
+
+ /**
+ * Method to create the keyboard
+ */
+ void createKeyboard() throws LWJGLException;
+
+ /**
+ * Method to destroy the keyboard
+ */
+ void destroyKeyboard();
+
+ /**
+ * Method to poll the keyboard.
+ *
+ * @param keyDownBuffer the address of a 256-byte buffer to place
+ * key states in.
+ */
+ void pollKeyboard(ByteBuffer keyDownBuffer);
+
+ /**
+ * Method to read the keyboard buffer
+ */
+ void readKeyboard(ByteBuffer buffer);
+
+// int isStateKeySet(int key);
+
+ /** Native cursor handles */
+ Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException;
+
+ void destroyCursor(Object cursor_handle);
+
+ int getWidth();
+
+ int getHeight();
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -32,8 +32,7 @@
package org.lwjgl.opengl;
/**
- * A java implementation of a LWJGL compatible Keyboard event queue.
- * Currently only used by the Mac OS X implementation.
+ * An AWT implementation of a LWJGL compatible Keyboard event queue.
* @author elias_naur
*/
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2002-2004 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+import java.nio.IntBuffer;
+import java.nio.ByteBuffer;
+
+import org.lwjgl.LWJGLException;
+import org.lwjgl.LWJGLUtil;
+
+import java.awt.event.FocusEvent;
+
+/**
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2586 $
+ * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $
+ */
+final class LinuxAWTInput extends AbstractAWTInput {
+ private final long display;
+ private final long input_window;
+ private final LinuxEvent event = new LinuxEvent();
+
+ private long cached_window;
+ private LinuxMouse cached_mouse;
+// private LinuxKeyboard cached_keyboard;
+ private long blank_cursor = LinuxDisplay.None;
+ private boolean input_grabbed;
+ private boolean input_released;
+
+ public LinuxAWTInput(AWTGLCanvas canvas) throws LWJGLException {
+ super(canvas);
+ LinuxDisplay.lockAWT();
+ try {
+ this.display = LinuxDisplay.openDisplay();
+ this.input_window = createInputOnlyWindow(display, LinuxDisplay.nGetDefaultScreen(display));
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ }
+ private static native long createInputOnlyWindow(long display, int screen);
+
+ public synchronized void destroy() {
+ super.destroy();
+ LinuxDisplay.lockAWT();
+ try {
+ destroyCursor();
+ LinuxDisplay.nDestroyWindow(display, input_window);
+ LinuxDisplay.closeDisplay(display);
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ }
+
+ private void ungrabInputLocked() {
+ LinuxDisplay.lockAWT();
+ try {
+ ungrabInput();
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ }
+
+ private void ungrabInput() {
+ if (input_grabbed) {
+// LinuxDisplay.nUngrabKeyboard(display);
+ LinuxDisplay.nUngrabPointer(display);
+ LinuxDisplay.nSetRepeatMode(display, LinuxDisplay.AutoRepeatModeDefault);
+ input_grabbed = false;
+ }
+ }
+
+ private void grabInput(long window) {
+ if (!input_grabbed) {
+// int res1 = LinuxDisplay.nGrabKeyboard(display, window);
+ LinuxDisplay.nSetRepeatMode(display, LinuxDisplay.AutoRepeatModeOff);
+ int res2 = LinuxDisplay.nGrabPointer(display, window, blank_cursor);
+ if (/*res1 == LinuxDisplay.GrabSuccess && */res2 == LinuxDisplay.GrabSuccess)
+ input_grabbed = true;
+ }
+ }
+
+ private final void destroyCursor() {
+ if (blank_cursor != LinuxDisplay.None)
+ LinuxDisplay.nDestroyCursor(display, blank_cursor);
+ }
+
+ public synchronized void processInput(PeerInfo peer_info) {
+ super.processInput(peer_info);
+ LinuxDisplay.lockAWT();
+ try {
+ LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info;
+ long new_window = linux_peer_info.getDrawable();
+ if (new_window != cached_window) {
+ ungrabInput();
+ cached_window = new_window;
+ try {
+ cached_mouse = new LinuxMouse(display, new_window, input_window);
+// cached_keyboard = new LinuxKeyboard(display, new_window);
+ } catch (LWJGLException e) {
+ LWJGLUtil.log("Failed to create input devices: " + e);
+ }
+ destroyCursor();
+ this.blank_cursor = LinuxDisplay.nCreateBlankCursor(display, new_window);
+ }
+ checkFocus();
+ if (!input_grabbed && shouldGrab())
+ grabInput(new_window);
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ }
+
+ private void checkFocus() {
+ if (getCanvas().hasFocus()) {
+ input_released = false;
+ } else {
+ input_released = true;
+ ungrabInput();
+ }
+ }
+
+ private boolean shouldGrab() {
+ return !input_released && isGrabbed();
+ }
+
+ public synchronized void update() {
+ LinuxDisplay.lockAWT();
+ try {
+ while (LinuxEvent.getPending(display) > 0) {
+ event.nextEvent(display);
+ if (shouldGrab()) {
+ long event_window = event.getWindow();
+ boolean processed = event.filterEvent(event_window) ||
+ cached_mouse.filterEvent(isGrabbed(), shouldGrab(), event)/* ||
+ cached_keyboard.filterEvent(event)*/;
+ }
+ }
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ }
+
+ public synchronized void grabMouse(boolean grab) {
+ if (grab != isGrabbed()) {
+ super.grabMouse(grab);
+ if (cached_mouse != null)
+ cached_mouse.changeGrabbed(grab, shouldGrab());
+ ungrabInputLocked();
+ }
+ }
+
+/* public synchronized void pollKeyboard(ByteBuffer keyDownBuffer) {
+ if (isGrabbed()) {
+ LinuxDisplay.lockAWT();
+ try {
+ if (cached_keyboard != null)
+ cached_keyboard.poll(keyDownBuffer);
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ } else
+ super.pollKeyboard(keyDownBuffer);
+ }
+
+ public synchronized void readKeyboard(ByteBuffer buffer) {
+ if (isGrabbed()) {
+ LinuxDisplay.lockAWT();
+ try {
+ if (cached_keyboard != null)
+ cached_keyboard.read(buffer);
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ } else
+ super.readKeyboard(buffer);
+ }
+*/
+ public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
+ if (isGrabbed()) {
+ LinuxDisplay.lockAWT();
+ try {
+ if (cached_mouse != null)
+ cached_mouse.poll(isGrabbed(), coord_buffer, buttons);
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ } else
+ super.pollMouse(coord_buffer, buttons);
+ }
+
+ public synchronized void readMouse(ByteBuffer buffer) {
+ if (isGrabbed()) {
+ LinuxDisplay.lockAWT();
+ try {
+ if (cached_mouse != null)
+ cached_mouse.read(buffer);
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
+ } else
+ super.readMouse(buffer);
+ }
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -119,4 +119,8 @@
}
}
private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException;
+
+ public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException {
+ return new LinuxAWTInput(canvas);
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -50,9 +50,9 @@
final class LinuxDisplay implements DisplayImplementation {
/* X11 constants */
public final static int GrabSuccess = 0;
- private final static int AutoRepeatModeOff = 0;
- private final static int AutoRepeatModeOn = 1;
- private final static int AutoRepeatModeDefault = 2;
+ public final static int AutoRepeatModeOff = 0;
+ public final static int AutoRepeatModeOn = 1;
+ public final static int AutoRepeatModeDefault = 2;
public final static int None = 0;
/** Window mode enum */
@@ -754,7 +754,7 @@
releaseInput();
}
}
- private static native long nGetInputFocus(long display);
+ static native long nGetInputFocus(long display);
private void releaseInput() {
if (isLegacyFullscreen() || input_released)
@@ -789,7 +789,7 @@
}
}
}
- private static native void nSetRepeatMode(long display, int mode);
+ static native void nSetRepeatMode(long display, int mode);
public void grabMouse(boolean new_grab) {
lockAWT();
@@ -1054,4 +1054,12 @@
}
private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height);
+
+ public int getWidth() {
+ return Display.getDisplayMode().getWidth();
+ }
+
+ public int getHeight() {
+ return Display.getDisplayMode().getHeight();
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPeerInfo.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -44,4 +44,14 @@
super(createHandle());
}
private static native ByteBuffer createHandle();
+
+ public final long getDisplay() {
+ return nGetDisplay(getHandle());
+ }
+ private static native long nGetDisplay(ByteBuffer handle);
+
+ public final long getDrawable() {
+ return nGetDrawable(getHandle());
+ }
+ private static native long nGetDrawable(ByteBuffer handle);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -62,4 +62,8 @@
*/
return null;
}
+
+ public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException {
+ throw new UnsupportedOperationException();
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -303,7 +303,7 @@
public void createMouse() throws LWJGLException {
MacOSXGLCanvas canvas = frame.getCanvas();
- this.mouse_queue = new MouseEventQueue(canvas);
+ this.mouse_queue = new MacOSXMouseEventQueue(canvas);
mouse_queue.register();
}
@@ -520,4 +520,12 @@
return 1;
}
+
+ public int getWidth() {
+ return Display.getDisplayMode().getWidth();
+ }
+
+ public int getHeight() {
+ return Display.getDisplayMode().getHeight();
+ }
}
Copied: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java (from rev 2607, trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java)
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2002-2004 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+/**
+ * An AWT implementation of a LWJGL compatible Mouse event queue.
+ * @author elias_naur
+ */
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.Component;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+
+import org.lwjgl.BufferUtils;
+import org.lwjgl.input.Mouse;
+
+final class MacOSXMouseEventQueue extends MouseEventQueue {
+ private final IntBuffer delta_buffer = BufferUtils.createIntBuffer(2);
+
+ MacOSXMouseEventQueue(Component component) {
+ super(component);
+ }
+
+ protected void resetCursorToCenter() {
+ super.resetCursorToCenter();
+ /* Clear accumulated deltas */
+ ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
+ }
+
+ protected void updateDeltas(long nanos) {
+ super.updateDeltas(nanos);
+ synchronized ( this ) {
+ ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
+ int dx = delta_buffer.get(0);
+ int dy = -delta_buffer.get(1);
+ if ( dx != 0 || dy != 0 ) {
+ putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos);
+ addDelta(dx, dy);
+ }
+ }
+ }
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -48,7 +48,7 @@
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Mouse;
-final class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener {
+class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionListener, MouseWheelListener {
private static final int WHEEL_SCALE = 120;
public static final int NUM_BUTTONS = 3;
@@ -56,7 +56,6 @@
private boolean grabbed;
- private final IntBuffer delta_buffer = BufferUtils.createIntBuffer(2);
/** The accumulated mouse deltas returned by poll() */
private int accum_dx;
@@ -107,11 +106,9 @@
return component.getHeight() - 1 - y;
}
- private void resetCursorToCenter() {
+ protected void resetCursorToCenter() {
clearEvents();
accum_dx = accum_dy = 0;
- /* Clear accumulated deltas */
- ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
}
private void putMouseEvent(byte button, byte state, int dz, long nanos) {
@@ -121,7 +118,7 @@
putMouseEventWithCoords(button, state, last_x, last_y, dz, nanos);
}
- private void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
+ protected void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
event.clear();
event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos);
event.flip();
@@ -149,13 +146,17 @@
return;
int dx = x - last_x;
int dy = y - last_y;
- accum_dx += dx;
- accum_dy += dy;
+ addDelta(dx, dy);
last_x = x;
last_y = y;
putMouseEventWithCoords((byte)-1, (byte)0, x, y, 0, nanos);
}
+ protected void addDelta(int dx, int dy) {
+ accum_dx += dx;
+ accum_dy += dy;
+ }
+
public void mouseClicked(MouseEvent e) {
}
@@ -242,19 +243,7 @@
putMouseEvent((byte)-1, (byte)0, amount, nanos);
}
- private void updateDeltas(long nanos) {
- if (!grabbed)
- return;
- synchronized ( this ) {
- ((MacOSXDisplay)Display.getImplementation()).getMouseDeltas(delta_buffer);
- int dx = delta_buffer.get(0);
- int dy = -delta_buffer.get(1);
- if ( dx != 0 || dy != 0 ) {
- putMouseEventWithCoords((byte)-1, (byte)0, dx, dy, 0, nanos);
- accum_dx += dx;
- accum_dy += dy;
- }
- }
+ protected void updateDeltas(long nanos) {
}
public void mouseWheelMoved(MouseWheelEvent e) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -65,6 +65,10 @@
});
}
+ public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException {
+ throw new UnsupportedOperationException();
+ }
+
public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException {
return new WindowsAWTGLCanvasPeerInfo(canvas, pixel_format);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-26 19:41:15 UTC (rev 2608)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -589,4 +589,12 @@
return new WindowsDirectInput3(getDllInstance());
}
}
+
+ public int getWidth() {
+ return Display.getDisplayMode().getWidth();
+ }
+
+ public int getHeight() {
+ return Display.getDisplayMode().getHeight();
+ }
}
Added: trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTInputAdapterTest.java 2006-10-26 20:19:40 UTC (rev 2609)
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2002-2005 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.test.opengl.awt;
+
+import java.awt.Frame;
+import java.awt.Color;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.nio.FloatBuffer;
+
+import org.lwjgl.BufferUtils;
+import org.lwjgl.LWJGLException;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.opengl.ARBTransposeMatrix;
+import org.lwjgl.opengl.AWTGLCanvas;
+import org.lwjgl.opengl.AWTInputAdapter;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GLContext;
+
+/**
+ * <p>
+ * Gears demo using AWTInputAdapter input
+ * <p>
+ * @version $Revision$
+ * @author Brian Matzon <br...@ma...>
+ * @author Elias Naur <eli...@us...>
+ * $Id$
+ */
+public class AWTInputAdapterTest extends Frame {
+ /** AWT GL canvas */
+ private AWTGLCanvas canvas0;
+
+ private float view_rotx = 20.0f;
+
+ private float view_roty = 30.0f;
+
+ private float view_rotz = 0.0f;
+
+ private int gear1;
+
+ private int gear2;
+
+ private int gear3;
+
+ private float angle = 0.0f;
+
+ /**
+ * C'tor
+ */
+ public AWTInputAdapterTest() throws LWJGLException {
+ setTitle("Gears");
+ setSize(300, 300);
+ setBackground(Color.BLACK);
+ add(canvas0 = new AWTGLCanvas() {
+ long startTime = 0;
+ long fps = 0;
+ int current_width;
+ int current_height;
+ public void paintGL() {
+
+ if(startTime == 0) {
+ setup();
+ startTime = System.currentTimeMillis() + 5000;
+ }
+
+ try {
+ angle += 2.0f;
+ if (getWidth() != current_width || getHeight() != current_height) {
+ current_width = getWidth();
+ current_height = getHeight();
+ GL11.glViewport(0, 0, current_width, current_height);
+ }
+ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
+
+ GL11.glPushMatrix();
+ GL11.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
+ GL11.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
+ GL11.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(-3.0f, -2.0f, 0.0f);
+ GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
+ GL11.glCallList(gear1);
+ GL11.glPopMatrix();
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(3.1f, -2.0f, 0.0f);
+ GL11.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
+ GL11.glCallList(gear2);
+ GL11.glPopMatrix();
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(-3.1f, 4.2f, 0.0f);
+ GL11.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
+ GL11.glCallList(gear3);
+ GL11.glPopMatrix();
+
+ GL11.glPopMatrix();
+ swapBuffers();
+ repaint();
+ } catch (LWJGLException e) {
+ throw new RuntimeException(e);
+ }
+ if (startTime > System.currentTimeMillis()) {
+ fps++;
+ } else {
+ long timeUsed = 5000 + (startTime - System.currentTimeMillis());
+ startTime = System.currentTimeMillis() + 5000;
+ System.out.println(fps + " frames in " + (float) (timeUsed / 1000f) + " seconds = "
+ + (fps / (timeUsed / 1000f)));
+ fps = 0;
+ }
+ AWTInputAdapter.update();
+ while (Mouse.next()) {
+ view_roty += Mouse.getEventDX()*.1;
+ view_rotx -= Mouse.getEventDY()*.1;
+ }
+ while (Keyboard.next()) {
+ if (Keyboard.getEventKeyState()) {
+ switch (Keyboard.getEventKey()) {
+ case Keyboard.KEY_ESCAPE:
+ System.exit(0);
+ break;
+ case Keyboard.KEY_G:
+ Mouse.setGrabbed(!Mouse.isGrabbed());
+ break;
+ default:
+ break;
+ }
+ }
+ if (Keyboard.getEventCharacter() != Keyboard.CHAR_NONE)
+ System.out.println("Typed: " + Keyboard.getEventCharacter());
+ }
+ if (Keyboard.isKeyDown(Keyboard.KEY_UP))
+ view_rotx -= .1;
+ else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN))
+ view_rotx += .1;
+ if (Keyboard.isKeyDown(Keyboard.KEY_LEFT))
+ view_roty -= .1;
+ else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
+ view_roty += .1;
+ }
+ });
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ dispose();
+ System.exit(0);
+ }
+ });
+ AWTInputAdapter.create(canvas0);
+ canvas0.setFocusable(true);
+ canvas0.requestFocus();
+ setResizable(true);
+ setVisible(true);
+ }
+
+ private void setup() {
+ // setup ogl
+ FloatBuffer pos = BufferUtils.createFloatBuffer(4).put(new float[] { 5.0f, 5.0f, 10.0f, 0.0f});
+ FloatBuffer red = BufferUtils.createFloatBuffer(4).put(new float[] { 0.8f, 0.1f, 0.0f, 1.0f});
+ FloatBuffer green = BufferUtils.createFloatBuffer(4).put(new float[] { 0.0f, 0.8f, 0.2f, 1.0f});
+ FloatBuffer blue = BufferUtils.createFloatBuffer(4).put(new float[] { 0.2f, 0.2f, 1.0f, 1.0f});
+ pos.flip();
+ red.flip();
+ green.flip();
+ blue.flip();
+
+ GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, pos);
+ GL11.glEnable(GL11.GL_CULL_FACE);
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glEnable(GL11.GL_LIGHT0);
+ GL11.glEnable(GL11.GL_DEPTH_TEST);
+
+ /* make the gears */
+ gear1 = GL11.glGenLists(1);
+ GL11.glNewList(gear1, GL11.GL_COMPILE);
+ GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, red);
+ gear(1.0f, 4.0f, 1.0f, 20, 0.7f);
+ GL11.glEndList();
+
+ gear2 = GL11.glGenLists(1);
+ GL11.glNewList(gear2, GL11.GL_COMPILE);
+ GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, green);
+ gear(0.5f, 2.0f, 2.0f, 10, 0.7f);
+ GL11.glEndList();
+
+ gear3 = GL11.glGenLists(1);
+ GL11.glNewList(gear3, GL11.GL_COMPILE);
+ GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT_AND_DIFFUSE, blue);
+ gear(1.3f, 2.0f, 0.5f, 10, 0.7f);
+ GL11.glEndList();
+
+ GL11.glEnable(GL11.GL_NORMALIZE);
+
+ GL11.glMatrixMode(GL11.GL_PROJECTION);
+
+ System.err.println("Use the arrow keys and the mouse to rotate the gears. Press 'G' to toggle mouse grabbing.");
+ System.err.println("GL_VENDOR: " + GL11.glGetString(GL11.GL_VENDOR));
+ System.err.println("GL_RENDERER: " + GL11.glGetString(GL11.GL_RENDERER));
+ System.err.println("GL_VERSION: " + GL11.glGetString(GL11.GL_VERSION));
+ System.err.println();
+ System.err.println("glLoadTransposeMatrixfARB() supported: " + GLContext.getCapabilities().GL_ARB_transpose_matrix);
+ if (!GLContext.getCapabilities().GL_ARB_transpose_matrix) {
+ // --- not using extensions
+ GL11.glLoadIdentity();
+ } else {
+ // --- using extensions
+ final FloatBuffer identityTranspose = BufferUtils.createFloatBuffer(16).put(
+ new float[] { 1, 0, 0, 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0, 0, 0, 1});
+ identityTranspose.fli...
[truncated message content] |
|
From: <eli...@us...> - 2006-10-26 19:41:27
|
Revision: 2608
http://svn.sourceforge.net/java-game-lib/?rev=2608&view=rev
Author: elias_naur
Date: 2006-10-26 12:41:15 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Don't register the Display shutdown hook in the static initializer. Register it at create() and remove it at destroy(). This avoids unnecessary conflicts when only using AWT stuff
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-10-26 15:03:47 UTC (rev 2607)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-10-26 19:41:15 UTC (rev 2608)
@@ -59,6 +59,11 @@
import org.lwjgl.input.Mouse;
public final class Display {
+ private static final Thread shutdown_hook = new Thread() {
+ public void run() {
+ reset();
+ }
+ };
/** The display implementor */
private static final DisplayImplementation display_impl;
@@ -105,16 +110,6 @@
try {
current_mode = initial_mode = display_impl.init();
LWJGLUtil.log("Initial mode: " + initial_mode);
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- reset();
- }
- });
- return null;
- }
- });
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
@@ -589,7 +584,10 @@
}
processMessages();
+ pollDevices();
+ }
+ static void pollDevices() {
// Poll the input devices while we're here
if (Mouse.isCreated()) {
Mouse.poll();
@@ -677,6 +675,12 @@
throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time.");
if (pixel_format == null)
throw new NullPointerException("pixel_format cannot be null");
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ Runtime.getRuntime().addShutdownHook(shutdown_hook);
+ return null;
+ }
+ });
if (fullscreen)
switchDisplayMode();
try {
@@ -777,6 +781,12 @@
x = y = -1;
cached_icons = null;
reset();
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ Runtime.getRuntime().removeShutdownHook(shutdown_hook);
+ return null;
+ }
+ });
}
private static void destroyPeerInfo() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 15:03:55
|
Revision: 2607
http://svn.sourceforge.net/java-game-lib/?rev=2607&view=rev
Author: elias_naur
Date: 2006-10-26 08:03:47 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Mac OS X: Moved registering and unregistering of AWT listeners from MacOSXDisplay to the input handlers
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 14:47:02 UTC (rev 2606)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/KeyboardEventQueue.java 2006-10-26 15:03:47 UTC (rev 2607)
@@ -39,6 +39,7 @@
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
+import java.awt.Component;
import java.nio.ByteBuffer;
import org.lwjgl.input.Keyboard;
@@ -51,6 +52,8 @@
/** Event scratch array */
private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
+ private final Component component;
+
static {
KEY_MAP[KeyEvent.VK_0] = Keyboard.KEY_0;
KEY_MAP[KeyEvent.VK_1] = Keyboard.KEY_1;
@@ -238,10 +241,23 @@
KEY_MAP[KeyEvent.VK_Z] = Keyboard.KEY_Z;
}
- public KeyboardEventQueue() {
+ public KeyboardEventQueue(Component component) {
super(Keyboard.EVENT_SIZE);
+ this.component = component;
}
+ public void register() {
+ component.addKeyListener(this);
+ }
+
+ public void unregister() {
+ /*
+ * This line is commented out to work around AWT bug 4867453:
+ * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4867453
+ */
+ //component.removeKeyListener(this);
+ }
+
private void putKeyboardEvent(int key_code, byte state, int character, long nanos) {
event.clear();
event.putInt(key_code).put(state).putInt(character).putLong(nanos);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 14:47:02 UTC (rev 2606)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 15:03:47 UTC (rev 2607)
@@ -303,17 +303,13 @@
public void createMouse() throws LWJGLException {
MacOSXGLCanvas canvas = frame.getCanvas();
- this.mouse_queue = new MouseEventQueue(canvas.getWidth(), canvas.getHeight());
- canvas.addMouseListener(mouse_queue);
- canvas.addMouseMotionListener(mouse_queue);
- canvas.addMouseWheelListener(mouse_queue);
+ this.mouse_queue = new MouseEventQueue(canvas);
+ mouse_queue.register();
}
public void destroyMouse() {
- MacOSXGLCanvas canvas = frame.getCanvas();
- canvas.removeMouseListener(mouse_queue);
- canvas.removeMouseWheelListener(mouse_queue);
- canvas.removeMouseMotionListener(mouse_queue);
+ if (mouse_queue != null)
+ mouse_queue.unregister();
this.mouse_queue = null;
}
@@ -359,17 +355,13 @@
/* Keyboard */
public void createKeyboard() throws LWJGLException {
MacOSXGLCanvas canvas = frame.getCanvas();
- this.keyboard_queue = new KeyboardEventQueue();
- canvas.addKeyListener(keyboard_queue);
+ this.keyboard_queue = new KeyboardEventQueue(canvas);
+ keyboard_queue.register();
}
public void destroyKeyboard() {
- /*
- * This line is commented out to work around AWT bug 4867453:
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4867453
- */
-// frame.getCanvas().removeKeyListener(keyboard_queue);
-
+ if (keyboard_queue != null)
+ keyboard_queue.unregister();
this.keyboard_queue = null;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 14:47:02 UTC (rev 2606)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MouseEventQueue.java 2006-10-26 15:03:47 UTC (rev 2607)
@@ -32,8 +32,7 @@
package org.lwjgl.opengl;
/**
- * A java implementation of a LWJGL compatible Mouse event queue.
- * Currently only used by the Mac OS X implementation.
+ * An AWT implementation of a LWJGL compatible Mouse event queue.
* @author elias_naur
*/
@@ -42,6 +41,7 @@
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
+import java.awt.Component;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@@ -52,8 +52,7 @@
private static final int WHEEL_SCALE = 120;
public static final int NUM_BUTTONS = 3;
- private final int width;
- private final int height;
+ private final Component component;
private boolean grabbed;
@@ -77,13 +76,24 @@
/** Buttons array */
private final byte[] buttons = new byte[NUM_BUTTONS];
- MouseEventQueue(int width, int height) {
+ MouseEventQueue(Component component) {
super(Mouse.EVENT_SIZE);
- this.width = width;
- this.height = height;
+ this.component = component;
resetCursorToCenter();
}
+ public void register() {
+ component.addMouseListener(this);
+ component.addMouseMotionListener(this);
+ component.addMouseWheelListener(this);
+ }
+
+ public void unregister() {
+ component.removeMouseListener(this);
+ component.removeMouseMotionListener(this);
+ component.removeMouseWheelListener(this);
+ }
+
public synchronized void setGrabbed(boolean grabbed) {
this.grabbed = grabbed;
resetCursorToCenter();
@@ -94,7 +104,7 @@
}
private int transformY(int y) {
- return height - 1 - y;
+ return component.getHeight() - 1 - y;
}
private void resetCursorToCenter() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 14:47:12
|
Revision: 2606
http://svn.sourceforge.net/java-game-lib/?rev=2606&view=rev
Author: elias_naur
Date: 2006-10-26 07:47:02 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Mac OS X: Moved AWT input handling to separate AWTUtil.java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-26 14:47:02 UTC (rev 2606)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2002-2004 LWJGL Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'LWJGL' nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.lwjgl.opengl;
+
+/**
+ * @author elias_naur
+ */
+
+import java.awt.Cursor;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.KeyEvent;
+import java.awt.image.BufferedImage;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.lwjgl.BufferUtils;
+import org.lwjgl.LWJGLException;
+import org.lwjgl.LWJGLUtil;
+import org.lwjgl.input.Keyboard;
+
+final class AWTUtil {
+ public static boolean hasWheel() {
+ return true;
+ }
+
+ public static int getButtonCount() {
+ return MouseEventQueue.NUM_BUTTONS;
+ }
+
+ public static int getNativeCursorCapabilities() {
+ if (LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX || LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) {
+ int cursor_colors = Toolkit.getDefaultToolkit().getMaximumCursorColors();
+ boolean supported = cursor_colors >= Short.MAX_VALUE && getMaxCursorSize() > 0;
+ int caps = supported ? org.lwjgl.input.Cursor.CURSOR_8_BIT_ALPHA | org.lwjgl.input.Cursor.CURSOR_ONE_BIT_TRANSPARENCY: 0;
+ return caps;
+ } else {
+ /* Return no capability in Mac OS X 10.3 and earlier , as there are two unsolved bugs (both reported to apple along with
+ minimal test case):
+ 1. When a custom cursor (or some standard) java.awt.Cursor is assigned to a
+ Componennt, it is reset to the default pointer cursor when the window is de-
+ activated and the re-activated. The Cursor can not be reset to the custom cursor,
+ with another setCursor.
+ 2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen
+ mode, no mouse moved events are reported, even though mouse pressed/released and dragged
+ events are reported
+ */
+ return 0;
+ }
+ }
+
+ public static void setCursorPosition(final Component component, int x, int y) {
+ try {
+ Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
+ return new Robot(component.getGraphicsConfiguration().getDevice());
+ }
+ });
+ int transformed_x = component.getX() + x;
+ int transformed_y = component.getY() + component.getHeight() - 1 - y;
+ robot.mouseMove(transformed_x, transformed_y);
+ } catch (PrivilegedActionException e) {
+ LWJGLUtil.log("Got exception while setting mouse cursor position: " + e);
+ }
+ }
+
+ public static int getMinCursorSize() {
+ Dimension min_size = Toolkit.getDefaultToolkit().getBestCursorSize(0, 0);
+ return Math.max(min_size.width, min_size.height);
+ }
+
+ public static int getMaxCursorSize() {
+ Dimension max_size = Toolkit.getDefaultToolkit().getBestCursorSize(10000, 10000);
+ return Math.min(max_size.width, max_size.height);
+ }
+
+ /** Native cursor handles */
+ public static Cursor createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
+ BufferedImage cursor_image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ int[] pixels = new int[images.remaining()];
+ int old_position = images.position();
+ images.get(pixels);
+ images.position(old_position);
+ cursor_image.setRGB(0, 0, width, height, pixels, 0, width);
+ return Toolkit.getDefaultToolkit().createCustomCursor(cursor_image, new Point(xHotspot, yHotspot), "LWJGL Custom cursor");
+ }
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 12:15:46 UTC (rev 2605)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 14:47:02 UTC (rev 2606)
@@ -294,11 +294,11 @@
/* Mouse */
public boolean hasWheel() {
- return true;
+ return AWTUtil.hasWheel();
}
public int getButtonCount() {
- return MouseEventQueue.NUM_BUTTONS;
+ return AWTUtil.getButtonCount();
}
public void createMouse() throws LWJGLException {
@@ -336,39 +336,11 @@
private native void nGrabMouse(boolean grab);
public int getNativeCursorCapabilities() {
- if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4)) {
- int cursor_colors = Toolkit.getDefaultToolkit().getMaximumCursorColors();
- boolean supported = cursor_colors >= Short.MAX_VALUE && getMaxCursorSize() > 0;
- int caps = supported ? org.lwjgl.input.Cursor.CURSOR_8_BIT_ALPHA | org.lwjgl.input.Cursor.CURSOR_ONE_BIT_TRANSPARENCY: 0;
- return caps;
- } else {
- /* Return no capability in Mac OS X 10.3 and earlier , as there are two unsolved bugs (both reported to apple along with
- minimal test case):
- 1. When a custom cursor (or some standard) java.awt.Cursor is assigned to a
- Componennt, it is reset to the default pointer cursor when the window is de-
- activated and the re-activated. The Cursor can not be reset to the custom cursor,
- with another setCursor.
- 2. When the cursor is moving in the top pixel row (y = 0 in AWT coordinates) in fullscreen
- mode, no mouse moved events are reported, even though mouse pressed/released and dragged
- events are reported
- */
- return 0;
- }
+ return AWTUtil.getNativeCursorCapabilities();
}
public void setCursorPosition(int x, int y) {
- try {
- Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- return new Robot(frame.getGraphicsConfiguration().getDevice());
- }
- });
- int transformed_x = frame.getX() + x;
- int transformed_y = frame.getY() + frame.getHeight() - 1 - y;
- robot.mouseMove(transformed_x, transformed_y);
- } catch (PrivilegedActionException e) {
- LWJGLUtil.log("Got exception while setting mouse cursor position: " + e);
- }
+ AWTUtil.setCursorPosition(frame, x, y);
}
public void setNativeCursor(Object handle) throws LWJGLException {
@@ -377,13 +349,11 @@
}
public int getMinCursorSize() {
- Dimension min_size = Toolkit.getDefaultToolkit().getBestCursorSize(0, 0);
- return Math.max(min_size.width, min_size.height);
+ return AWTUtil.getMinCursorSize();
}
public int getMaxCursorSize() {
- Dimension max_size = Toolkit.getDefaultToolkit().getBestCursorSize(10000, 10000);
- return Math.min(max_size.width, max_size.height);
+ return AWTUtil.getMaxCursorSize();
}
/* Keyboard */
@@ -437,13 +407,7 @@
*/
/** Native cursor handles */
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
- BufferedImage cursor_image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
- int[] pixels = new int[images.remaining()];
- int old_position = images.position();
- images.get(pixels);
- images.position(old_position);
- cursor_image.setRGB(0, 0, width, height, pixels, 0, width);
- return Toolkit.getDefaultToolkit().createCustomCursor(cursor_image, new Point(xHotspot, yHotspot), "LWJGL Custom cursor");
+ return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
}
public void destroyCursor(Object cursor_handle) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 12:15:58
|
Revision: 2605
http://svn.sourceforge.net/java-game-lib/?rev=2605&view=rev
Author: elias_naur
Date: 2006-10-26 05:15:46 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Removed redundant import
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java
Modified: trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2006-10-26 12:14:37 UTC (rev 2604)
+++ trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2006-10-26 12:15:46 UTC (rev 2605)
@@ -38,7 +38,6 @@
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys;
-import org.lwjgl.opengl.DisplayImplementation;
/**
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-26 12:14:52
|
Revision: 2604
http://svn.sourceforge.net/java-game-lib/?rev=2604&view=rev
Author: elias_naur
Date: 2006-10-26 05:14:37 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Linux: Made cursor handles longs instead of ByteBuffers
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 11:17:44 UTC (rev 2603)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-26 12:14:37 UTC (rev 2604)
@@ -49,10 +49,11 @@
final class LinuxDisplay implements DisplayImplementation {
/* X11 constants */
- private final static int GrabSuccess = 0;
+ public final static int GrabSuccess = 0;
private final static int AutoRepeatModeOff = 0;
private final static int AutoRepeatModeOn = 1;
private final static int AutoRepeatModeDefault = 2;
+ public final static int None = 0;
/** Window mode enum */
private static final int FULLSCREEN_LEGACY = 1;
@@ -109,8 +110,8 @@
private boolean minimized;
private boolean dirty;
private boolean close_requested;
- private ByteBuffer current_cursor;
- private ByteBuffer blank_cursor;
+ private long current_cursor;
+ private long blank_cursor;
private LinuxKeyboard keyboard;
private LinuxMouse mouse;
@@ -296,7 +297,7 @@
static int getDefaultScreen() {
return nGetDefaultScreen(getDisplay());
}
- private static native int nGetDefaultScreen(long display);
+ static native int nGetDefaultScreen(long display);
static long getWindow() {
return current_window;
@@ -308,7 +309,7 @@
keyboard_grabbed = false;
}
}
- private static native int nUngrabKeyboard(long display);
+ static native int nUngrabKeyboard(long display);
private void grabKeyboard() {
if (!keyboard_grabbed) {
@@ -317,11 +318,11 @@
keyboard_grabbed = true;
}
}
- private static native int nGrabKeyboard(long display, long window);
+ static native int nGrabKeyboard(long display, long window);
private void grabPointer() {
if (!pointer_grabbed) {
- int result = nGrabPointer(getDisplay(), getWindow());
+ int result = nGrabPointer(getDisplay(), getWindow(), None);
if (result == GrabSuccess) {
pointer_grabbed = true;
// make sure we have a centered window
@@ -331,7 +332,7 @@
}
}
}
- private static native int nGrabPointer(long display, long window);
+ static native int nGrabPointer(long display, long window, long cursor);
private static native void nSetViewPort(long display, long window, int screen);
private void ungrabPointer() {
@@ -340,7 +341,7 @@
nUngrabPointer(getDisplay());
}
}
- private static native int nUngrabPointer(long display);
+ static native int nUngrabPointer(long display);
private boolean isFullscreen() {
return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM;
@@ -360,7 +361,7 @@
}
private void updateCursor() {
- ByteBuffer cursor;
+ long cursor;
if (shouldGrab()) {
cursor = blank_cursor;
} else {
@@ -368,7 +369,7 @@
}
nDefineCursor(getDisplay(), getWindow(), cursor);
}
- private static native void nDefineCursor(long display, long window, ByteBuffer cursor_handle);
+ private static native void nDefineCursor(long display, long window, long cursor_handle);
private boolean isLegacyFullscreen() {
return current_window_mode == FULLSCREEN_LEGACY;
@@ -391,7 +392,7 @@
current_window_mode = getWindowMode(fullscreen);
current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y);
blank_cursor = createBlankCursor();
- current_cursor = null;
+ current_cursor = None;
focused = true;
input_released = false;
pointer_grabbed = false;
@@ -429,7 +430,7 @@
LWJGLUtil.log("Failed to reset cursor: " + e.getMessage());
}
nDestroyCursor(getDisplay(), blank_cursor);
- blank_cursor = null;
+ blank_cursor = None;
ungrabKeyboard();
nDestroyWindow(getDisplay(), getWindow());
nSetRepeatMode(getDisplay(), AutoRepeatModeDefault);
@@ -438,7 +439,7 @@
unlockAWT();
}
}
- private static native void nDestroyWindow(long display, long window);
+ static native void nDestroyWindow(long display, long window);
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
lockAWT();
@@ -706,7 +707,7 @@
public void createMouse() throws LWJGLException {
lockAWT();
try {
- mouse = new LinuxMouse(getDisplay(), getWindow());
+ mouse = new LinuxMouse(getDisplay(), getWindow(), getWindow());
} finally {
unlockAWT();
}
@@ -825,7 +826,7 @@
private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException;
public void setNativeCursor(Object handle) throws LWJGLException {
- current_cursor = (ByteBuffer)handle;
+ current_cursor = getCursorHandle(handle);
lockAWT();
try {
updateCursor();
@@ -914,19 +915,20 @@
return Keyboard.STATE_UNKNOWN;
}
*/
- private static native ByteBuffer nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
+ private static native long nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
- private static ByteBuffer createBlankCursor() {
+ private static long createBlankCursor() {
return nCreateBlankCursor(getDisplay(), getWindow());
}
- private static native ByteBuffer nCreateBlankCursor(long display, long window);
+ static native long nCreateBlankCursor(long display, long window);
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
lockAWT();
try {
incDisplay();
try {
- return nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
+ long cursor = nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
+ return new Long(cursor);
} catch (LWJGLException e) {
decDisplay();
throw e;
@@ -936,16 +938,20 @@
}
}
+ private static long getCursorHandle(Object cursor_handle) {
+ return cursor_handle != null ? ((Long)cursor_handle).longValue() : None;
+ }
+
public void destroyCursor(Object cursorHandle) {
lockAWT();
try {
- nDestroyCursor(getDisplay(), cursorHandle);
+ nDestroyCursor(getDisplay(), getCursorHandle(cursorHandle));
decDisplay();
} finally {
unlockAWT();
}
}
- private static native void nDestroyCursor(long display, Object cursorHandle);
+ static native void nDestroyCursor(long display, long cursorHandle);
public int getPbufferCapabilities() {
lockAWT();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 11:17:44 UTC (rev 2603)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-26 12:14:37 UTC (rev 2604)
@@ -64,6 +64,7 @@
private final long display;
private final long window;
+ private final long input_window;
private final long warp_atom;
private final IntBuffer query_pointer_buffer = BufferUtils.createIntBuffer(4);
private final ByteBuffer event_buffer = ByteBuffer.allocate(Mouse.EVENT_SIZE);
@@ -77,15 +78,11 @@
private EventQueue event_queue;
private long last_event_nanos;
- public LinuxMouse(long display, long window) throws LWJGLException {
+ public LinuxMouse(long display, long window, long input_window) throws LWJGLException {
this.display = display;
this.window = window;
- LinuxDisplay.lockAWT();
- try {
- this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
- } finally {
- LinuxDisplay.unlockAWT();
- }
+ this.input_window = input_window;
+ this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
reset();
}
@@ -138,7 +135,7 @@
}
private void doWarpPointer(int center_x, int center_y) {
- nSendWarpEvent(display, window, warp_atom, center_x, center_y);
+ nSendWarpEvent(display, input_window, warp_atom, center_x, center_y);
nWarpCursor(display, window, center_x, center_y);
}
private static native void nSendWarpEvent(long display, long window, long warp_atom, int center_x, int center_y);
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-24 11:17:44 UTC (rev 2603)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-26 12:14:37 UTC (rev 2604)
@@ -81,15 +81,10 @@
return width_return > height_return ? height_return : width_return;
}
-JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
(JNIEnv *env, jclass clazz, jlong display, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset)
{
Display *disp = (Display *)(intptr_t)display;
- jobject handle_buffer = newJavaManagedByteBuffer(env, sizeof(Cursor));
- if (handle_buffer == NULL) {
- throwException(env, "Could not allocate handle buffer");
- return NULL;
- }
const int *delays = NULL;
if (delay_buffer != NULL)
delays = (const int *)(*env)->GetDirectBufferAddress(env, delay_buffer) + delays_offset;
@@ -98,7 +93,7 @@
XcursorImages *cursor_images = XcursorImagesCreate(num_images);
if (cursor_images == NULL) {
throwException(env, "Could not allocate cursor.");
- return NULL;
+ return None;
}
cursor_images->nimage = num_images;
int i;
@@ -111,16 +106,15 @@
cursor_image->delay = delays[i];
cursor_images->images[i] = cursor_image;
}
- Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, handle_buffer);
- *cursor = XcursorImagesLoadCursor(disp, cursor_images);
+ Cursor cursor = XcursorImagesLoadCursor(disp, cursor_images);
XcursorImagesDestroy(cursor_images);
- return handle_buffer;
+ return cursor;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor
- (JNIEnv *env, jclass clazz, jlong display, jobject cursor_handle_buffer)
+ (JNIEnv *env, jclass clazz, jlong display, jlong cursor_ptr)
{
Display *disp = (Display *)(intptr_t)display;
- Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, cursor_handle_buffer);
- XFreeCursor(disp, *cursor);
+ Cursor cursor = (Cursor)cursor_ptr;
+ XFreeCursor(disp, cursor);
}
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-24 11:17:44 UTC (rev 2603)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-26 12:14:37 UTC (rev 2604)
@@ -423,11 +423,12 @@
return XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
}
-JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
Display *disp = (Display *)(intptr_t)display_ptr;
Window win = (Window)window_ptr;
+ Cursor cursor = (Cursor)cursor_ptr;
int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
- return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
+ return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, cursor, CurrentTime);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
@@ -444,25 +445,16 @@
return XUngrabPointer(disp, CurrentTime);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jobject cursor_handle) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
Display *disp = (Display *)(intptr_t)display_ptr;
Window win = (Window)window_ptr;
- Cursor cursor;
- if (cursor_handle != NULL)
- cursor = *((Cursor *)(*env)->GetDirectBufferAddress(env, cursor_handle));
- else
- cursor = None;
+ Cursor cursor = (Cursor)cursor_ptr;
XDefineCursor(disp, win, cursor);
}
-JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
Display *disp = (Display *)(intptr_t)display_ptr;
Window win = (Window)window_ptr;
- jobject handle_buffer = newJavaManagedByteBuffer(env, sizeof(Cursor));
- if (handle_buffer == NULL) {
- return NULL;
- }
- Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, handle_buffer);
unsigned int best_width, best_height;
if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) {
throwException(env, "Could not query best cursor size");
@@ -475,9 +467,9 @@
XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height);
XFreeGC(disp, gc);
XColor dummy_color;
- *cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0);
+ Cursor cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0);
XFreePixmap(disp, mask);
- return handle_buffer;
+ return cursor;
}
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|