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-31 09:52:44
|
Revision: 2620
http://svn.sourceforge.net/java-game-lib/?rev=2620&view=rev
Author: elias_naur
Date: 2006-10-31 01:52:38 -0800 (Tue, 31 Oct 2006)
Log Message:
-----------
Don't include binary native files from bin/ in lwjgl.jar (oops\!)
Modified Paths:
--------------
trunk/LWJGL/build.xml
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2006-10-30 15:49:02 UTC (rev 2619)
+++ trunk/LWJGL/build.xml 2006-10-31 09:52:38 UTC (rev 2620)
@@ -22,8 +22,7 @@
<!-- Files to include in the lwjgl.jar file -->
<fileset id="lwjgl.fileset" dir="${lwjgl.bin}">
- <include name="**" />
- <exclude name="**.*" />
+ <include name="org/**/*" />
<exclude name="org/lwjgl/fmod3/**" />
<exclude name="org/lwjgl/test/**" />
<exclude name="org/lwjgl/util/**" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-30 15:49:20
|
Revision: 2619
http://svn.sourceforge.net/java-game-lib/?rev=2619&view=rev
Author: elias_naur
Date: 2006-10-30 07:49:02 -0800 (Mon, 30 Oct 2006)
Log Message:
-----------
Windows: Fix compiler warning
Modified Paths:
--------------
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-10-30 15:46:42 UTC (rev 2618)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-10-30 15:49:02 UTC (rev 2619)
@@ -61,5 +61,5 @@
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) {
WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
- return peer_info->u.hwnd;
+ return (intptr_t)peer_info->u.hwnd;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-30 15:47:06
|
Revision: 2618
http://svn.sourceforge.net/java-game-lib/?rev=2618&view=rev
Author: elias_naur
Date: 2006-10-30 07:46:42 -0800 (Mon, 30 Oct 2006)
Log Message:
-----------
Windows: Implemented AWTInputAdapter.
Modified Paths:
--------------
trunk/LWJGL/build.xml
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java
trunk/LWJGL/src/native/windows/context.h
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/build.xml 2006-10-30 15:46:42 UTC (rev 2618)
@@ -508,6 +508,7 @@
</javah>
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
+ <class name="org.lwjgl.opengl.WindowsAWTInput" />
<class name="org.lwjgl.opengl.WindowsKeyboard" />
<class name="org.lwjgl.opengl.WindowsDirectInput8" />
<class name="org.lwjgl.opengl.WindowsDirectInputDevice8" />
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTInput.java 2006-10-30 15:46:42 UTC (rev 2618)
@@ -0,0 +1,150 @@
+/*
+ * 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 org.lwjgl.BufferUtils;
+
+import java.awt.Cursor;
+import java.awt.Point;
+
+/**
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2586 $
+ * $Id: LinuxAWTGLCanvasPeerInfo.java 2586 2006-10-20 11:51:34Z elias_naur $
+ */
+final class WindowsAWTInput extends AbstractAWTInput {
+ private final static int WS_CHILD = 0x40000000;
+ private final Cursor blank_cursor;
+ private Cursor cached_cursor;
+
+ private long cached_hwnd;
+ private WindowsMouse cached_mouse;
+ private boolean has_grabbed;
+
+ public WindowsAWTInput(AWTGLCanvas canvas) throws LWJGLException {
+ super(canvas);
+ int w = AWTUtil.getMinCursorSize();
+ int h = AWTUtil.getMinCursorSize();
+ blank_cursor = AWTUtil.createCursor(w, h, 0, 0, 1, BufferUtils.createIntBuffer(w*h), null);
+ }
+
+ public synchronized void destroy() {
+ super.destroy();
+ if (cached_mouse != null) {
+ grab(false);
+ cached_mouse.destroy();
+ }
+ }
+
+ public synchronized void processInput(PeerInfo peer_info) {
+ WindowsPeerInfo windows_peerinfo = (WindowsPeerInfo)peer_info;
+ long hwnd = windows_peerinfo.getHwnd();
+ try {
+ hwnd = findTopLevelWindow(hwnd);
+ if (cached_mouse == null || hwnd != cached_hwnd) {
+ has_grabbed = false;
+ cached_hwnd = hwnd;
+ if (cached_mouse != null)
+ cached_mouse.destroy();
+ cached_mouse = new WindowsMouse(WindowsDisplay.createDirectInput(), hwnd);
+ }
+ if (isGrabbed() && getCanvas().getCursor() != blank_cursor) {
+ cached_cursor = getCanvas().getCursor();
+ /**
+ * For some reason, DirectInput won't let us blank the cursor
+ * with the EXCLUSIVE access mode, so we'll work around it with a
+ * custom blank cursor
+ */
+ getCanvas().setCursor(blank_cursor);
+ }
+ grab(isGrabbed());
+ } catch (LWJGLException e) {
+ LWJGLUtil.log("Failed to create windows mouse: " + e);
+ }
+ }
+ private static native int getWindowStyles(long hwnd) throws LWJGLException;
+ private static native long getParentWindow(long hwnd);
+
+ private static long findTopLevelWindow(long hwnd) throws LWJGLException {
+ int window_styles = getWindowStyles(hwnd);
+ while ((window_styles & WS_CHILD) != 0) {
+ hwnd = getParentWindow(hwnd);
+ window_styles = getWindowStyles(hwnd);
+ }
+ return hwnd;
+ }
+
+ private void grab(boolean grab) {
+ if (has_grabbed != grab) {
+ cached_mouse.grab(grab);
+ has_grabbed = grab;
+ if (!grab)
+ getCanvas().setCursor(cached_cursor);
+ }
+ }
+
+ public synchronized void grabMouse(boolean grab) {
+ if (grab != isGrabbed()) {
+ super.grabMouse(grab);
+ /* Only ungrab since grabbing can only occur in processInput
+ * when the hwnd is guaranteed valid
+ */
+ if (cached_mouse != null && !grab)
+ grab(grab);
+ }
+ }
+
+ public void update() {
+ }
+
+ public synchronized void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
+ if (isGrabbed()) {
+ if (cached_mouse != null)
+ cached_mouse.poll(coord_buffer, buttons);
+ } else
+ super.pollMouse(coord_buffer, buttons);
+ }
+
+ public synchronized void readMouse(ByteBuffer buffer) {
+ if (isGrabbed()) {
+ if (cached_mouse != null)
+ cached_mouse.read(buffer);
+ } else
+ super.readMouse(buffer);
+ }
+}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java 2006-10-30 15:46:42 UTC (rev 2618)
@@ -66,7 +66,7 @@
}
public AWTCanvasInputImplementation createInput(AWTGLCanvas canvas) throws LWJGLException {
- throw new UnsupportedOperationException();
+ return new WindowsAWTInput(canvas);
}
public PeerInfo createPeerInfo(AWTGLCanvas canvas, PixelFormat pixel_format) throws LWJGLException {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDirectInputDevice.java 2006-10-30 15:46:42 UTC (rev 2618)
@@ -76,14 +76,14 @@
public void setDataFormat(int type) throws LWJGLException {
int ret = setDataFormat(di_device, type);
if (ret != WindowsDirectInput.DI_OK)
- throw new LWJGLException("Failed to set data format (" + ret + ")");
+ throw new LWJGLException("Failed to set data format (" + Integer.toHexString(ret) + ")");
}
protected abstract int setDataFormat(long di_device, int type);
public void setCooperateLevel(long hwnd, int flags) throws LWJGLException {
int ret = setCooperativeLevel(di_device, hwnd, flags);
if (ret != WindowsDirectInput.DI_OK)
- throw new LWJGLException("Failed to set cooperative level (" + ret + ")");
+ throw new LWJGLException("Failed to set cooperative level (" + Integer.toHexString(ret) + ")");
}
protected abstract int setCooperativeLevel(long di_device, long hwnd, int flags);
@@ -95,7 +95,7 @@
public void setBufferSize(int buffer_size) throws LWJGLException {
int ret = setBufferSize(di_device, buffer_size);
if (ret != WindowsDirectInput.DI_OK && ret != WindowsDirectInput.DI_PROPNOEFFECT && ret != WindowsDirectInput.DI_POLLEDDEVICE)
- throw new LWJGLException("Failed to set buffer size (" + ret + ")");
+ throw new LWJGLException("Failed to set buffer size (" + Integer.toHexString(ret) + ")");
int event_buffer_size = getEventSize()*buffer_size;
event_buffer = BufferUtils.createByteBuffer(event_buffer_size);
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2006-10-30 15:46:42 UTC (rev 2618)
@@ -289,6 +289,7 @@
peer_info = new WindowsDisplayPeerInfo(pixel_format);
return peer_info;
}
+
public void update() {
nUpdate();
if (did_maximize) {
@@ -581,7 +582,7 @@
}
}
- private static WindowsDirectInput createDirectInput() throws LWJGLException {
+ static WindowsDirectInput createDirectInput() throws LWJGLException {
try {
return new WindowsDirectInput8(getDllInstance());
} catch (LWJGLException e) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsPeerInfo.java 2006-10-30 15:46:42 UTC (rev 2618)
@@ -52,4 +52,9 @@
nChoosePixelFormat(getHandle(), origin_x, origin_y, pixel_format, pixel_format_caps, use_hdc_bpp, support_window, support_pbuffer, double_buffered);
}
private static native void nChoosePixelFormat(ByteBuffer peer_info_handle, int origin_x, int origin_y, PixelFormat pixel_format, IntBuffer pixel_format_caps, boolean use_hdc_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException;
+
+ public final long getHwnd() {
+ return nGetHwnd(getHandle());
+ }
+ private static native long nGetHwnd(ByteBuffer handle);
}
Modified: trunk/LWJGL/src/native/windows/context.h
===================================================================
--- trunk/LWJGL/src/native/windows/context.h 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/native/windows/context.h 2006-10-30 15:46:42 UTC (rev 2618)
@@ -47,12 +47,15 @@
#include "extgl_wgl.h"
typedef struct {
- struct {
- HPBUFFERARB pbuffer;
- // Contains the function pointers that
- // created the pbuffer
- WGLExtensions extensions;
- } pbuffer;
+ union {
+ HWND hwnd;
+ struct {
+ HPBUFFERARB pbuffer;
+ // Contains the function pointers that
+ // created the pbuffer
+ WGLExtensions extensions;
+ } pbuffer;
+ } u;
HDC drawable_hdc;
} WindowsPeerInfo;
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Pbuffer.c 2006-10-30 15:46:42 UTC (rev 2618)
@@ -169,23 +169,23 @@
throwException(env, "Could not get Pbuffer DC");
return;
}
- peer_info->pbuffer.extensions = extensions;
- peer_info->pbuffer.pbuffer = Pbuffer;
+ peer_info->u.pbuffer.extensions = extensions;
+ peer_info->u.pbuffer.pbuffer = Pbuffer;
peer_info->drawable_hdc = Pbuffer_dc;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nDestroy
(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
- peer_info->pbuffer.extensions.wglReleasePbufferDCARB(peer_info->pbuffer.pbuffer, peer_info->drawable_hdc);
- peer_info->pbuffer.extensions.wglDestroyPbufferARB(peer_info->pbuffer.pbuffer);
+ peer_info->u.pbuffer.extensions.wglReleasePbufferDCARB(peer_info->u.pbuffer.pbuffer, peer_info->drawable_hdc);
+ peer_info->u.pbuffer.extensions.wglDestroyPbufferARB(peer_info->u.pbuffer.pbuffer);
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nIsBufferLost
(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
BOOL buffer_lost;
- peer_info->pbuffer.extensions.wglQueryPbufferARB(peer_info->pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost);
+ peer_info->u.pbuffer.extensions.wglQueryPbufferARB(peer_info->u.pbuffer.pbuffer, WGL_PBUFFER_LOST_ARB, &buffer_lost);
return buffer_lost ? JNI_TRUE : JNI_FALSE;
}
@@ -198,17 +198,17 @@
attribs[1] = value;
attribs[2] = 0;
- peer_info->pbuffer.extensions.wglSetPbufferAttribARB(peer_info->pbuffer.pbuffer, attribs);
+ peer_info->u.pbuffer.extensions.wglSetPbufferAttribARB(peer_info->u.pbuffer.pbuffer, attribs);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nBindTexImageToPbuffer
(JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) {
WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
- peer_info->pbuffer.extensions.wglBindTexImageARB(peer_info->pbuffer.pbuffer, buffer);
+ peer_info->u.pbuffer.extensions.wglBindTexImageARB(peer_info->u.pbuffer.pbuffer, buffer);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsPbufferPeerInfo_nReleaseTexImageFromPbuffer
(JNIEnv *env, jclass clazz, jobject peer_info_handle, jint buffer) {
WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
- peer_info->pbuffer.extensions.wglReleaseTexImageARB(peer_info->pbuffer.pbuffer, buffer);
+ peer_info->u.pbuffer.extensions.wglReleaseTexImageARB(peer_info->u.pbuffer.pbuffer, buffer);
}
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2006-10-30 15:46:42 UTC (rev 2618)
@@ -51,4 +51,5 @@
AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle);
JAWT_Win32DrawingSurfaceInfo *win32_dsi = (JAWT_Win32DrawingSurfaceInfo *)surface->dsi->platformInfo;
peer_info->drawable_hdc = win32_dsi->hdc;
+ peer_info->u.hwnd = win32_dsi->hwnd;
}
Added: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c (rev 0)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsAWTInput.c 2006-10-30 15:46:42 UTC (rev 2618)
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/**
+ * $Id: org_lwjgl_opengl_WindowsAWTGLCanvasPeerInfo.c 2575 2006-09-19 14:17:13Z elias_naur $
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2575 $
+ */
+
+#include <jni.h>
+#include "context.h"
+#include "org_lwjgl_opengl_WindowsAWTInput.h"
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getWindowStyles(JNIEnv *env, jclass unused, jlong hwnd_ptr) {
+ HWND hwnd = (HWND)(intptr_t)hwnd_ptr;
+ WINDOWINFO window_info;
+ if (!GetWindowInfo(hwnd, &window_info)) {
+ throwFormattedException(env, "Failed to get window info (%d).", GetLastError());
+ return 0;
+ }
+ return window_info.dwStyle;
+}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsAWTInput_getParentWindow(JNIEnv *env, jclass unused, jlong hwnd_ptr) {
+ HWND hwnd = (HWND)(intptr_t)hwnd_ptr;
+ return (intptr_t)GetParent(hwnd);
+}
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsDisplayPeerInfo.c 2006-10-30 15:46:42 UTC (rev 2618)
@@ -47,4 +47,5 @@
(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
peer_info->drawable_hdc = getCurrentHDC();
+ peer_info->u.hwnd = getCurrentHWND();
}
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-10-28 22:06:24 UTC (rev 2617)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_WindowsPeerInfo.c 2006-10-30 15:46:42 UTC (rev 2618)
@@ -58,3 +58,8 @@
// Let it throw
applyPixelFormat(env, peer_info->drawable_hdc, pixel_format_id);
}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsPeerInfo_nGetHwnd(JNIEnv *env, jclass unused, jobject peer_info_handle) {
+ WindowsPeerInfo *peer_info = (WindowsPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle);
+ return peer_info->u.hwnd;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-28 22:06:37
|
Revision: 2617
http://svn.sourceforge.net/java-game-lib/?rev=2617&view=rev
Author: elias_naur
Date: 2006-10-28 15:06:24 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Fixed AWTUtil.setCursorPosition. Added check to LinuxAWTInput.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-27 08:15:31 UTC (rev 2616)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-28 22:06:24 UTC (rev 2617)
@@ -108,8 +108,9 @@
public static void setCursorPosition(Component component, Robot robot, int x, int y) {
if (robot != null) {
- int transformed_x = component.getX() + x;
- int transformed_y = component.getY() + component.getHeight() - 1 - y;
+ Point location = component.getLocationOnScreen();
+ int transformed_x = location.x + x;
+ int transformed_y = location.y + component.getHeight() - 1 - y;
robot.mouseMove(transformed_x, transformed_y);
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-27 08:15:31 UTC (rev 2616)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTInput.java 2006-10-28 22:06:24 UTC (rev 2617)
@@ -117,7 +117,7 @@
try {
LinuxPeerInfo linux_peer_info = (LinuxPeerInfo)peer_info;
long new_window = linux_peer_info.getDrawable();
- if (new_window != cached_window) {
+ if (cached_mouse == null || new_window != cached_window) {
ungrabInput();
cached_window = new_window;
try {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-27 08:15:31 UTC (rev 2616)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-28 22:06:24 UTC (rev 2617)
@@ -321,7 +321,7 @@
}
public void setCursorPosition(int x, int y) {
- AWTUtil.setCursorPosition(frame, robot, x, y);
+ AWTUtil.setCursorPosition(frame.getCanvas(), robot, x, y);
}
public void setNativeCursor(Object handle) throws LWJGLException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-27 08:15:41
|
Revision: 2616
http://svn.sourceforge.net/java-game-lib/?rev=2616&view=rev
Author: elias_naur
Date: 2006-10-27 01:15:31 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
Mac OS X: Fixed cursor warping coordinates
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-27 06:27:58 UTC (rev 2615)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXMouseEventQueue.java 2006-10-27 08:15:31 UTC (rev 2616)
@@ -43,6 +43,7 @@
import java.awt.event.MouseWheelListener;
import java.awt.Component;
import java.awt.Rectangle;
+import java.awt.Point;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@@ -84,8 +85,9 @@
void warpCursor() {
if (isGrabbed()) {
Rectangle bounds = getComponent().getBounds();
- int x = bounds.x + bounds.width/2;
- int y = bounds.y + bounds.height/2;
+ Point location_on_screen = getComponent().getLocationOnScreen();
+ int x = location_on_screen.x + bounds.width/2;
+ int y = location_on_screen.y + bounds.height/2;
nWarpCursor(x, y);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-27 06:28:12
|
Revision: 2615
http://svn.sourceforge.net/java-game-lib/?rev=2615&view=rev
Author: elias_naur
Date: 2006-10-26 23:27:58 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Fixed potential NPE from Cursor.getCapabilities()
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java
trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java
trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java
Modified: trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2006-10-27 06:04:55 UTC (rev 2614)
+++ trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2006-10-27 06:27:58 UTC (rev 2615)
@@ -141,7 +141,10 @@
* @return A bit mask with native cursor capabilities.
*/
public static int getCapabilities() {
- return Mouse.getImplementation().getNativeCursorCapabilities();
+ if (Mouse.getImplementation() != null)
+ return Mouse.getImplementation().getNativeCursorCapabilities();
+ else
+ return Mouse.createImplementation().getNativeCursorCapabilities();
}
/**
Modified: trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-10-27 06:04:55 UTC (rev 2614)
+++ trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java 2006-10-27 06:27:58 UTC (rev 2615)
@@ -307,6 +307,8 @@
* @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.");
+
create(Mouse.createImplementation());
}
Modified: trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-10-27 06:04:55 UTC (rev 2614)
+++ trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java 2006-10-27 06:27:58 UTC (rev 2615)
@@ -225,8 +225,6 @@
}
static InputImplementation createImplementation() {
- if (!Display.isCreated()) throw new IllegalStateException("Display must be created.");
-
/* Use reflection since we can't make Display.getImplementation
* public
*/
@@ -278,6 +276,8 @@
* @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.");
+
create(createImplementation());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-27 06:05:03
|
Revision: 2614
http://svn.sourceforge.net/java-game-lib/?rev=2614&view=rev
Author: elias_naur
Date: 2006-10-26 23:04:55 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Made the AWT setCursorPosition garbage free
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java
trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java
trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-26 21:39:37 UTC (rev 2613)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java 2006-10-27 06:04:55 UTC (rev 2614)
@@ -92,18 +92,25 @@
}
}
- public static void setCursorPosition(final Component component, int x, int y) {
+ public static Robot createRobot(final Component component) {
try {
Robot robot = (Robot)AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
return new Robot(component.getGraphicsConfiguration().getDevice());
}
});
+ return robot;
+ } catch (PrivilegedActionException e) {
+ LWJGLUtil.log("Got exception while creating robot: " + e.getCause());
+ return null;
+ }
+ }
+
+ public static void setCursorPosition(Component component, Robot robot, int x, int y) {
+ if (robot != null) {
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);
}
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-26 21:39:37 UTC (rev 2613)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/AbstractAWTInput.java 2006-10-27 06:04:55 UTC (rev 2614)
@@ -38,6 +38,7 @@
import org.lwjgl.LWJGLUtil;
import java.awt.Cursor;
+import java.awt.Robot;
/**
*
@@ -47,6 +48,7 @@
*/
abstract class AbstractAWTInput implements AWTCanvasInputImplementation {
private AWTGLCanvas canvas;
+ private Robot robot;
private KeyboardEventQueue keyboard_queue;
private MouseEventQueue mouse_queue;
@@ -54,6 +56,7 @@
protected AbstractAWTInput(AWTGLCanvas canvas) {
this.canvas = canvas;
+ this.robot = AWTUtil.createRobot(canvas);
}
protected synchronized MouseEventQueue getMouseEventQueue() {
@@ -117,7 +120,7 @@
}
public void setCursorPosition(int x, int y) {
- AWTUtil.setCursorPosition(canvas, x, y);
+ AWTUtil.setCursorPosition(canvas, robot, x, y);
}
public void setNativeCursor(Object handle) throws LWJGLException {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-26 21:39:37 UTC (rev 2613)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2006-10-27 06:04:55 UTC (rev 2614)
@@ -69,6 +69,7 @@
private static final int GAMMA_LENGTH = 256;
private MacOSXFrame frame;
+ private Robot robot;
private MacOSXMouseEventQueue mouse_queue;
private KeyboardEventQueue keyboard_queue;
private java.awt.DisplayMode requested_mode;
@@ -85,6 +86,7 @@
close_requested = false;
try {
frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y);
+ robot = AWTUtil.createRobot(frame);
} catch (LWJGLException e) {
destroyWindow();
throw e;
@@ -319,7 +321,7 @@
}
public void setCursorPosition(int x, int y) {
- AWTUtil.setCursorPosition(frame, x, y);
+ AWTUtil.setCursorPosition(frame, robot, x, y);
}
public void setNativeCursor(Object handle) throws LWJGLException {
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: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.
|
|
From: <eli...@us...> - 2006-10-24 11:17:52
|
Revision: 2603
http://svn.sourceforge.net/java-game-lib/?rev=2603&view=rev
Author: elias_naur
Date: 2006-10-24 04:17:44 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Linux: Added locking to LinuxMouse
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 10:43:52 UTC (rev 2602)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 11:17:44 UTC (rev 2603)
@@ -80,7 +80,12 @@
public LinuxMouse(long display, long window) throws LWJGLException {
this.display = display;
this.window = window;
- this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
+ LinuxDisplay.lockAWT();
+ try {
+ this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
+ } finally {
+ LinuxDisplay.unlockAWT();
+ }
reset();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-24 10:43:58
|
Revision: 2602
http://svn.sourceforge.net/java-game-lib/?rev=2602&view=rev
Author: elias_naur
Date: 2006-10-24 03:43:52 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Linux: Moved warp Atom from LinuxDisplay to LinuxMouse
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 10:39:14 UTC (rev 2601)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 10:43:52 UTC (rev 2602)
@@ -89,7 +89,6 @@
private int current_displaymode_extension = NONE;
/** Atom used for the pointer warp messages */
- private long warp_atom;
private long delete_atom;
private PeerInfo peer_info;
@@ -461,10 +460,6 @@
}
private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException;
- static long getWarpAtom() throws LWJGLException {
- return internAtom("_LWJGL", false);
- }
-
private static long internAtom(String atom_name, boolean only_if_exists) throws LWJGLException {
incDisplay();
try {
@@ -473,7 +468,7 @@
decDisplay();
}
}
- private static native long nInternAtom(long display, String atom_name, boolean only_if_exists);
+ static native long nInternAtom(long display, String atom_name, boolean only_if_exists);
public void resetDisplayMode() {
lockAWT();
@@ -555,7 +550,6 @@
public DisplayMode init() throws LWJGLException {
lockAWT();
try {
- warp_atom = getWarpAtom();
delete_atom = internAtom("WM_DELETE_WINDOW", false);
current_displaymode_extension = getBestDisplayModeExtension();
if (current_displaymode_extension == NONE)
@@ -709,10 +703,10 @@
return mouse.getButtonCount();
}
- public void createMouse() {
+ public void createMouse() throws LWJGLException {
lockAWT();
try {
- mouse = new LinuxMouse(getDisplay(), getWindow(), warp_atom);
+ mouse = new LinuxMouse(getDisplay(), getWindow());
} finally {
unlockAWT();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 10:39:14 UTC (rev 2601)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 10:43:52 UTC (rev 2602)
@@ -40,6 +40,7 @@
import java.nio.CharBuffer;
import org.lwjgl.BufferUtils;
+import org.lwjgl.LWJGLException;
import org.lwjgl.input.Mouse;
import java.nio.charset.CharsetDecoder;
@@ -76,10 +77,10 @@
private EventQueue event_queue;
private long last_event_nanos;
- public LinuxMouse(long display, long window, long warp_atom) {
+ public LinuxMouse(long display, long window) throws LWJGLException {
this.display = display;
this.window = window;
- this.warp_atom = warp_atom;
+ this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
reset();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-24 10:39:24
|
Revision: 2601
http://svn.sourceforge.net/java-game-lib/?rev=2601&view=rev
Author: elias_naur
Date: 2006-10-24 03:39:14 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Linux: Moved input event processing to LinuxKeyboard and LinuxMouse
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 09:59:00 UTC (rev 2600)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 10:39:14 UTC (rev 2601)
@@ -638,16 +638,13 @@
while (LinuxEvent.getPending(getDisplay()) > 0) {
event_buffer.nextEvent(getDisplay());
long event_window = event_buffer.getWindow();
- if (event_window != getWindow())
+ if (event_window != getWindow() || event_buffer.filterEvent(event_window) ||
+ (mouse != null && mouse.filterEvent(grab, shouldWarpPointer(), event_buffer)) ||
+ (keyboard != null && keyboard.filterEvent(event_buffer)))
continue;
- if (event_buffer.filterEvent(event_window))
- continue;
switch (event_buffer.getType()) {
case LinuxEvent.ClientMessage:
- if (event_buffer.getClientMessageType() == warp_atom) {
- if (mouse != null)
- mouse.handleWarpEvent(event_buffer.getClientData(0), event_buffer.getClientData(1));
- } else if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom))
+ if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom))
close_requested = true;
break;
case LinuxEvent.MapNotify:
@@ -661,20 +658,6 @@
case LinuxEvent.Expose:
dirty = true;
break;
- case LinuxEvent.ButtonPress: /* Fall through */
- case LinuxEvent.ButtonRelease:
- if (mouse != null)
- mouse.handleButtonEvent(grab, event_buffer.getButtonTime(), event_buffer.getButtonType(), (byte)event_buffer.getButtonButton());
- break;
- case LinuxEvent.MotionNotify:
- if (mouse != null)
- mouse.handlePointerMotion(grab, shouldWarpPointer(), event_buffer.getButtonTime(), event_buffer.getButtonRoot(), event_buffer.getButtonXRoot(), event_buffer.getButtonYRoot(), event_buffer.getButtonX(), event_buffer.getButtonY());
- break;
- case LinuxEvent.KeyPress: /* Fall through */
- case LinuxEvent.KeyRelease:
- if (keyboard != null)
- keyboard.handleKeyEvent(event_buffer.getKeyAddress(), event_buffer.getKeyTime(), event_buffer.getKeyType(), event_buffer.getKeyKeyCode(), event_buffer.getKeyState());
- break;
default:
break;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-10-24 09:59:00 UTC (rev 2600)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeyboard.java 2006-10-24 10:39:14 UTC (rev 2601)
@@ -296,10 +296,22 @@
}
}
- public void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) {
+ private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) {
int keycode = getKeycode(event_ptr, event_state);
byte key_state = getKeyState(event_type);
key_down_buffer[keycode] = key_state;
translateEvent(event_ptr, event_type, keycode, key_state, millis*1000000);
}
+
+ public boolean filterEvent(LinuxEvent event) {
+ switch (event.getType()) {
+ case LinuxEvent.KeyPress: /* Fall through */
+ case LinuxEvent.KeyRelease:
+ handleKeyEvent(event.getKeyAddress(), event.getKeyTime(), event.getKeyType(), event.getKeyKeyCode(), event.getKeyState());
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 09:59:00 UTC (rev 2600)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-24 10:39:14 UTC (rev 2601)
@@ -190,7 +190,7 @@
}
private static native void nWarpCursor(long display, long window, int x, int y);
- public void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) {
+ private void handlePointerMotion(boolean grab, boolean warp_pointer, long millis, long root_window, int x_root, int y_root, int x, int y) {
doHandlePointerMotion(grab, warp_pointer, root_window, x_root, y_root, x, y, millis*1000000);
}
@@ -239,7 +239,7 @@
}
}
- public void handleButtonEvent(boolean grab, long millis, int type, byte button) {
+ private void handleButtonEvent(boolean grab, long millis, int type, byte button) {
long nanos = millis*1000000;
switch (type) {
case ButtonRelease:
@@ -258,7 +258,28 @@
last_y = transformY(y);
}
- public void handleWarpEvent(int x, int y) {
+ private void handleWarpEvent(int x, int y) {
resetCursor(x, y);
}
+
+ public boolean filterEvent(boolean grab, boolean warp_pointer, LinuxEvent event) {
+ switch (event.getType()) {
+ case LinuxEvent.ClientMessage:
+ if (event.getClientMessageType() == warp_atom) {
+ handleWarpEvent(event.getClientData(0), event.getClientData(1));
+ return true;
+ }
+ break;
+ case LinuxEvent.ButtonPress: /* Fall through */
+ case LinuxEvent.ButtonRelease:
+ handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton());
+ return true;
+ case LinuxEvent.MotionNotify:
+ handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY());
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-24 09:59:12
|
Revision: 2600
http://svn.sourceforge.net/java-game-lib/?rev=2600&view=rev
Author: elias_naur
Date: 2006-10-24 02:59:00 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Linux: Removed redundant methods from LinuxDisplay.java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 09:52:12 UTC (rev 2599)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 09:59:00 UTC (rev 2600)
@@ -645,29 +645,35 @@
switch (event_buffer.getType()) {
case LinuxEvent.ClientMessage:
if (event_buffer.getClientMessageType() == warp_atom) {
- handleWarpEvent(event_buffer.getClientData(0), event_buffer.getClientData(1));
+ if (mouse != null)
+ mouse.handleWarpEvent(event_buffer.getClientData(0), event_buffer.getClientData(1));
} else if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom))
- handleCloseEvent();
+ close_requested = true;
break;
case LinuxEvent.MapNotify:
- handleMapNotifyEvent();
+ dirty = true;
+ minimized = false;
break;
case LinuxEvent.UnmapNotify:
- handleUnmapNotifyEvent();
+ dirty = true;
+ minimized = true;
break;
case LinuxEvent.Expose:
- handleExposeEvent();
+ dirty = true;
break;
case LinuxEvent.ButtonPress: /* Fall through */
case LinuxEvent.ButtonRelease:
- handleButtonEvent(event_buffer.getButtonTime(), event_buffer.getButtonType(), event_buffer.getButtonButton(), event_buffer.getButtonState());
+ if (mouse != null)
+ mouse.handleButtonEvent(grab, event_buffer.getButtonTime(), event_buffer.getButtonType(), (byte)event_buffer.getButtonButton());
break;
case LinuxEvent.MotionNotify:
- handlePointerMotionEvent(event_buffer.getButtonTime(), event_buffer.getButtonRoot(), event_buffer.getButtonXRoot(), event_buffer.getButtonYRoot(), event_buffer.getButtonX(), event_buffer.getButtonY(), event_buffer.getButtonState());
+ if (mouse != null)
+ mouse.handlePointerMotion(grab, shouldWarpPointer(), event_buffer.getButtonTime(), event_buffer.getButtonRoot(), event_buffer.getButtonXRoot(), event_buffer.getButtonYRoot(), event_buffer.getButtonX(), event_buffer.getButtonY());
break;
case LinuxEvent.KeyPress: /* Fall through */
case LinuxEvent.KeyRelease:
- handleKeyEvent(event_buffer.getKeyAddress(), event_buffer.getKeyTime(), event_buffer.getKeyType(), event_buffer.getKeyKeyCode(), event_buffer.getKeyState());
+ if (keyboard != null)
+ keyboard.handleKeyEvent(event_buffer.getKeyAddress(), event_buffer.getKeyTime(), event_buffer.getKeyType(), event_buffer.getKeyKeyCode(), event_buffer.getKeyState());
break;
default:
break;
@@ -1065,42 +1071,4 @@
}
private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height);
-
- private void handleButtonEvent(long millis, int type, int button, int state) {
- if (mouse != null)
- mouse.handleButtonEvent(grab, millis, type, (byte)button);
- }
-
- private void handleKeyEvent(long event_ptr, long millis, int type, int keycode, int state) {
- if (keyboard != null)
- keyboard.handleKeyEvent(event_ptr, millis, type, keycode, state);
- }
-
- private void handlePointerMotionEvent(long millis, long root_window, int x_root, int y_root, int x, int y, int state) {
- if (mouse != null)
- mouse.handlePointerMotion(grab, shouldWarpPointer(), millis, root_window, x_root, y_root, x, y);
- }
-
- private void handleWarpEvent(int x, int y) {
- if (mouse != null)
- mouse.handleWarpEvent(x, y);
- }
-
- private void handleExposeEvent() {
- dirty = true;
- }
-
- private void handleUnmapNotifyEvent() {
- dirty = true;
- minimized = true;
- }
-
- private void handleMapNotifyEvent() {
- dirty = true;
- minimized = false;
- }
-
- private void handleCloseEvent() {
- close_requested = true;
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-24 09:52:26
|
Revision: 2599
http://svn.sourceforge.net/java-game-lib/?rev=2599&view=rev
Author: elias_naur
Date: 2006-10-24 02:52:12 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Linux: Moved more event handling logic to java
Modified Paths:
--------------
trunk/LWJGL/build.xml
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Added Paths:
-----------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c
Modified: trunk/LWJGL/build.xml
===================================================================
--- trunk/LWJGL/build.xml 2006-10-24 08:33:09 UTC (rev 2598)
+++ trunk/LWJGL/build.xml 2006-10-24 09:52:12 UTC (rev 2599)
@@ -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.LinuxEvent" />
<class name="org.lwjgl.opengl.LinuxMouse" />
<class name="org.lwjgl.opengl.LinuxKeyboard" />
<class name="org.lwjgl.opengl.LinuxDisplay" />
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 08:33:09 UTC (rev 2598)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-24 09:52:12 UTC (rev 2599)
@@ -82,11 +82,15 @@
private static int display_connection_usage_count = 0;
+ /** Event buffer */
+ private final LinuxEvent event_buffer = new LinuxEvent();
+
/** Current mode swithcing API */
private int current_displaymode_extension = NONE;
/** Atom used for the pointer warp messages */
private long warp_atom;
+ private long delete_atom;
private PeerInfo peer_info;
@@ -268,8 +272,8 @@
}
}
- private static native long openDisplay() throws LWJGLException;
- private static native void closeDisplay(long display);
+ static native long openDisplay() throws LWJGLException;
+ static native void closeDisplay(long display);
private int getWindowMode(boolean fullscreen) throws LWJGLException {
if (fullscreen) {
@@ -552,6 +556,7 @@
lockAWT();
try {
warp_atom = getWarpAtom();
+ delete_atom = internAtom("WM_DELETE_WINDOW", false);
current_displaymode_extension = getBestDisplayModeExtension();
if (current_displaymode_extension == NONE)
throw new LWJGLException("No display mode extension is available");
@@ -629,18 +634,56 @@
return peer_info;
}
+ private void processEvents() {
+ while (LinuxEvent.getPending(getDisplay()) > 0) {
+ event_buffer.nextEvent(getDisplay());
+ long event_window = event_buffer.getWindow();
+ if (event_window != getWindow())
+ continue;
+ if (event_buffer.filterEvent(event_window))
+ continue;
+ switch (event_buffer.getType()) {
+ case LinuxEvent.ClientMessage:
+ if (event_buffer.getClientMessageType() == warp_atom) {
+ handleWarpEvent(event_buffer.getClientData(0), event_buffer.getClientData(1));
+ } else if ((event_buffer.getClientFormat() == 32) && (event_buffer.getClientData(0) == delete_atom))
+ handleCloseEvent();
+ break;
+ case LinuxEvent.MapNotify:
+ handleMapNotifyEvent();
+ break;
+ case LinuxEvent.UnmapNotify:
+ handleUnmapNotifyEvent();
+ break;
+ case LinuxEvent.Expose:
+ handleExposeEvent();
+ break;
+ case LinuxEvent.ButtonPress: /* Fall through */
+ case LinuxEvent.ButtonRelease:
+ handleButtonEvent(event_buffer.getButtonTime(), event_buffer.getButtonType(), event_buffer.getButtonButton(), event_buffer.getButtonState());
+ break;
+ case LinuxEvent.MotionNotify:
+ handlePointerMotionEvent(event_buffer.getButtonTime(), event_buffer.getButtonRoot(), event_buffer.getButtonXRoot(), event_buffer.getButtonYRoot(), event_buffer.getButtonX(), event_buffer.getButtonY(), event_buffer.getButtonState());
+ break;
+ case LinuxEvent.KeyPress: /* Fall through */
+ case LinuxEvent.KeyRelease:
+ handleKeyEvent(event_buffer.getKeyAddress(), event_buffer.getKeyTime(), event_buffer.getKeyType(), event_buffer.getKeyKeyCode(), event_buffer.getKeyState());
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
public void update() {
lockAWT();
try {
- nUpdate(getDisplay(), getWindow(), warp_atom);
+ processEvents();
checkInput();
- } catch (LWJGLException e) {
- LWJGLUtil.log("Caught exception while processing messages: " + e);
} finally {
unlockAWT();
}
}
- private native void nUpdate(long display, long window, long warp_atom) throws LWJGLException;
public void reshape(int x, int y, int width, int height) {
lockAWT();
@@ -1023,7 +1066,6 @@
private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height);
- /* Callbacks from nUpdate() */
private void handleButtonEvent(long millis, int type, int button, int state) {
if (mouse != null)
mouse.handleButtonEvent(grab, millis, type, (byte)button);
Added: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java (rev 0)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java 2006-10-24 09:52:12 UTC (rev 2599)
@@ -0,0 +1,173 @@
+/*
+ * 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.ByteBuffer;
+
+/**
+ * Wrapper class for X11 events.
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2286 $
+ * $Id: LinuxPeerInfo.java 2286 2006-03-23 19:32:21Z matzon $
+ */
+final class LinuxEvent {
+ public final static int KeyPress = 2;
+ public final static int KeyRelease = 3;
+ public final static int ButtonPress = 4;
+ public final static int ButtonRelease = 5;
+ public final static int MotionNotify = 6;
+ public final static int UnmapNotify = 18;
+ public final static int MapNotify = 19;
+ public final static int Expose = 12;
+ public final static int ClientMessage = 33;
+
+ private final ByteBuffer event_buffer;
+
+ public LinuxEvent() {
+ this.event_buffer = createEventBuffer();
+ }
+ private static native ByteBuffer createEventBuffer();
+
+ public final static native int getPending(long display);
+
+ public final boolean filterEvent(long window) {
+ return nFilterEvent(event_buffer, window);
+ }
+ private static native boolean nFilterEvent(ByteBuffer event_buffer, long window);
+
+ public final void nextEvent(long display) {
+ nNextEvent(display, event_buffer);
+ }
+ private static native void nNextEvent(long display, ByteBuffer event_buffer);
+
+ public final int getType() {
+ return nGetType(event_buffer);
+ }
+ private static native int nGetType(ByteBuffer event_buffer);
+
+ public final long getWindow() {
+ return nGetWindow(event_buffer);
+ }
+ private static native long nGetWindow(ByteBuffer event_buffer);
+
+ /* ClientMessage methods */
+
+ public final long getClientMessageType() {
+ return nGetClientMessageType(event_buffer);
+ }
+ private static native long nGetClientMessageType(ByteBuffer event_buffer);
+
+ public final int getClientData(int index) {
+ return nGetClientData(event_buffer, index);
+ }
+ private static native int nGetClientData(ByteBuffer event_buffer, int index);
+
+ public final int getClientFormat() {
+ return nGetClientFormat(event_buffer);
+ }
+ private static native int nGetClientFormat(ByteBuffer event_buffer);
+
+ /* Button methods */
+
+ public final long getButtonTime() {
+ return nGetButtonTime(event_buffer);
+ }
+ private static native long nGetButtonTime(ByteBuffer event_buffer);
+
+ public final int getButtonState() {
+ return nGetButtonState(event_buffer);
+ }
+ private static native int nGetButtonState(ByteBuffer event_buffer);
+
+ public final int getButtonType() {
+ return nGetButtonType(event_buffer);
+ }
+ private static native int nGetButtonType(ByteBuffer event_buffer);
+
+ public final int getButtonButton() {
+ return nGetButtonButton(event_buffer);
+ }
+ private static native int nGetButtonButton(ByteBuffer event_buffer);
+
+ public final long getButtonRoot() {
+ return nGetButtonRoot(event_buffer);
+ }
+ private static native long nGetButtonRoot(ByteBuffer event_buffer);
+
+ public final int getButtonXRoot() {
+ return nGetButtonXRoot(event_buffer);
+ }
+ private static native int nGetButtonXRoot(ByteBuffer event_buffer);
+
+ public final int getButtonYRoot() {
+ return nGetButtonYRoot(event_buffer);
+ }
+ private static native int nGetButtonYRoot(ByteBuffer event_buffer);
+
+ public final int getButtonX() {
+ return nGetButtonX(event_buffer);
+ }
+ private static native int nGetButtonX(ByteBuffer event_buffer);
+
+ public final int getButtonY() {
+ return nGetButtonY(event_buffer);
+ }
+ private static native int nGetButtonY(ByteBuffer event_buffer);
+
+ /* Key methods */
+
+ public final long getKeyAddress() {
+ return nGetKeyAddress(event_buffer);
+ }
+ private static native int nGetKeyAddress(ByteBuffer event_buffer);
+
+ public final long getKeyTime() {
+ return nGetKeyTime(event_buffer);
+ }
+ private static native int nGetKeyTime(ByteBuffer event_buffer);
+
+ public final int getKeyType() {
+ return nGetKeyType(event_buffer);
+ }
+ private static native int nGetKeyType(ByteBuffer event_buffer);
+
+ public final int getKeyKeyCode() {
+ return nGetKeyKeyCode(event_buffer);
+ }
+ private static native int nGetKeyKeyCode(ByteBuffer event_buffer);
+
+ public final int getKeyState() {
+ return nGetKeyState(event_buffer);
+ }
+ private static native int nGetKeyState(ByteBuffer event_buffer);
+}
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-24 08:33:09 UTC (rev 2598)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-24 09:52:12 UTC (rev 2599)
@@ -69,7 +69,6 @@
static GLXWindow glx_window = None;
-static Atom delete_atom;
static Colormap cmap;
static int current_depth;
static Pixmap current_icon_pixmap;
@@ -158,73 +157,6 @@
return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY;
}
-static void handleMessages(JNIEnv *env, jobject disp_obj, Display *disp, Window window, Atom warp_atom) {
- XEvent event;
- jclass disp_class = (*env)->GetObjectClass(env, disp_obj);
- if (disp_class == NULL)
- return;
- jmethodID handleKeyEvent_method = (*env)->GetMethodID(env, disp_class, "handleKeyEvent", "(JJIII)V");
- if (handleKeyEvent_method == NULL)
- return;
- jmethodID handleButtonEvent_method = (*env)->GetMethodID(env, disp_class, "handleButtonEvent", "(JIII)V");
- if (handleButtonEvent_method == NULL)
- return;
- jmethodID handlePointerMotionEvent_method = (*env)->GetMethodID(env, disp_class, "handlePointerMotionEvent", "(JJIIIII)V");
- if (handlePointerMotionEvent_method == NULL)
- return;
- jmethodID handleWarpEvent_method = (*env)->GetMethodID(env, disp_class, "handleWarpEvent", "(II)V");
- if (handleWarpEvent_method == NULL)
- return;
- jmethodID handleMapNotifyEvent_method = (*env)->GetMethodID(env, disp_class, "handleMapNotifyEvent", "()V");
- if (handleMapNotifyEvent_method == NULL)
- return;
- jmethodID handleUnmapNotifyEvent_method = (*env)->GetMethodID(env, disp_class, "handleUnmapNotifyEvent", "()V");
- if (handleUnmapNotifyEvent_method == NULL)
- return;
- jmethodID handleExposeEvent_method = (*env)->GetMethodID(env, disp_class, "handleExposeEvent", "()V");
- if (handleExposeEvent_method == NULL)
- return;
- jmethodID handleCloseEvent_method = (*env)->GetMethodID(env, disp_class, "handleCloseEvent", "()V");
- if (handleCloseEvent_method == NULL)
- return;
- while (!(*env)->ExceptionOccurred(env) && XPending(disp) > 0) {
- XNextEvent(disp, &event);
- if (XFilterEvent(&event, None) == True)
- continue;
- // Ignore events from old windows
- if (event.xany.window != window)
- continue;
- switch (event.type) {
- case ClientMessage:
- if (event.xclient.message_type == warp_atom) {
- (*env)->CallVoidMethod(env, disp_obj, handleWarpEvent_method, (jint)event.xclient.data.l[0], (jint)event.xclient.data.l[1]);
- } else if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom))
- (*env)->CallVoidMethod(env, disp_obj, handleCloseEvent_method);
- break;
- case MapNotify:
- (*env)->CallVoidMethod(env, disp_obj, handleMapNotifyEvent_method);
- break;
- case UnmapNotify:
- (*env)->CallVoidMethod(env, disp_obj, handleUnmapNotifyEvent_method);
- break;
- case Expose:
- (*env)->CallVoidMethod(env, disp_obj, handleExposeEvent_method);
- break;
- case ButtonPress: /* Fall through */
- case ButtonRelease:
- (*env)->CallVoidMethod(env, disp_obj, handleButtonEvent_method, (jlong)event.xbutton.time, (jint)event.xbutton.type, (jint)event.xbutton.button, (jint)event.xbutton.state);
- break;
- case MotionNotify:
- (*env)->CallVoidMethod(env, disp_obj, handlePointerMotionEvent_method, (jlong)event.xbutton.time, (jlong)event.xbutton.root, (jint)event.xbutton.x_root, (jint)event.xbutton.y_root, (jint)event.xbutton.x, (jint)event.xbutton.y, (jint)event.xbutton.state);
- break;
- case KeyPress:
- case KeyRelease:
- (*env)->CallVoidMethod(env, disp_obj, handleKeyEvent_method, (jlong)(intptr_t)&(event.xkey), (jlong)event.xkey.time, (jint)event.xkey.type, (jint)event.xkey.keycode, (jint)event.xkey.state);
- break;
- }
- }
-}
-
static void setWindowTitle(Display *disp, Window window, const char *title) {
XStoreName(disp, window, title);
}
@@ -356,7 +288,7 @@
size_hints->max_height = height;
XSetWMNormalHints(disp, win, size_hints);
XFree(size_hints);
- delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False);
+ Atom delete_atom = XInternAtom(disp, "WM_DELETE_WINDOW", False);
XSetWMProtocols(disp, win, &delete_atom, 1);
if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) {
Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
@@ -373,13 +305,6 @@
return win;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate(JNIEnv *env, jobject disp_obj, jlong display, jlong window_ptr, jlong warp_atom_ptr) {
- Display *disp = (Display *)(intptr_t)display;
- Window window = (Window)window_ptr;
- Atom warp_atom = (Atom)warp_atom_ptr;
- handleMessages(env, disp_obj, disp, window, warp_atom);
-}
-
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) {
Display *disp = (Display *)(intptr_t)display;
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
Added: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c (rev 0)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxEvent.c 2006-10-24 09:52:12 UTC (rev 2599)
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+
+/**
+ * $Id: org_lwjgl_opengl_LinuxEvent.c 2598 2006-10-24 08:33:09Z elias_naur $
+ *
+ * @author elias_naur <eli...@us...>
+ * @version $Revision: 2598 $
+ */
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <jni.h>
+#include "common_tools.h"
+#include "org_lwjgl_opengl_LinuxEvent.h"
+
+JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxEvent_createEventBuffer(JNIEnv *env, jclass unused) {
+ return newJavaManagedByteBuffer(env, sizeof(XEvent));
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_getPending(JNIEnv *env, jclass unused, jlong display_ptr) {
+ Display *disp = (Display *)(intptr_t)display_ptr;
+ return XPending(disp);
+}
+
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxEvent_nFilterEvent(JNIEnv *env, jclass unused, jobject event_buffer, jlong window_ptr) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ Window window = (Window)window_ptr;
+ return XFilterEvent(event, window) == True ? JNI_TRUE : JNI_FALSE;
+}
+
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxEvent_nNextEvent(JNIEnv *env, jclass unused, jlong display_ptr, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ Display *disp = (Display *)(intptr_t)display_ptr;
+ XNextEvent(disp, event);
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetType(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->type;
+}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetWindow(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xany.window;
+}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientMessageType(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xclient.message_type;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientData(JNIEnv *env, jclass unused, jobject event_buffer, jint index) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xclient.data.l[index];
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetClientFormat(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xclient.format;
+}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonTime(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.time;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonState(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.state;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonType(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.type;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonButton(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.button;
+}
+
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonRoot(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.root;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonXRoot(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.x_root;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonYRoot(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.y_root;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonX(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.x;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetButtonY(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xbutton.y;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyAddress(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return (jlong)(intptr_t)&(event->xkey);
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyTime(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xkey.time;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyType(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xkey.type;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyKeyCode(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xkey.keycode;
+}
+
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxEvent_nGetKeyState(JNIEnv *env, jclass unused, jobject event_buffer) {
+ XEvent *event = (XEvent *)(*env)->GetDirectBufferAddress(env, event_buffer);
+ return event->xkey.state;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-24 08:33:24
|
Revision: 2598
http://svn.sourceforge.net/java-game-lib/?rev=2598&view=rev
Author: elias_naur
Date: 2006-10-24 01:33:09 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
Linux: Removed redundant include statements
Modified Paths:
--------------
trunk/LWJGL/src/native/linux/display.c
trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c
Modified: trunk/LWJGL/src/native/linux/display.c
===================================================================
--- trunk/LWJGL/src/native/linux/display.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/display.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -48,7 +48,6 @@
#include <stdlib.h>
#include <math.h>
#include "common_tools.h"
-#include "Window.h"
#include "org_lwjgl_opengl_LinuxDisplay.h"
#define NUM_XRANDR_RETRIES 5
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -44,7 +44,6 @@
#include <X11/Xcursor/Xcursor.h>
#include "org_lwjgl_input_Cursor.h"
#include "org_lwjgl_opengl_LinuxDisplay.h"
-#include "Window.h"
#include "common_tools.h"
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetNativeCursorCapabilities
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -51,7 +51,6 @@
#include "common_tools.h"
#include "extgl.h"
#include "extgl_glx.h"
-#include "Window.h"
#include "context.h"
#include "org_lwjgl_opengl_LinuxDisplay.h"
#include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h"
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -44,7 +44,6 @@
#include "org_lwjgl_opengl_LinuxCanvasImplementation.h"
#include "extgl_glx.h"
#include "context.h"
-#include "Window.h"
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxCanvasImplementation_nFindVisualIDFromFormat
(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject pixel_format) {
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxContextImplementation.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -45,7 +45,6 @@
#include "extgl_glx.h"
#include "context.h"
#include "common_tools.h"
-#include "Window.h"
typedef struct {
GLXExtensions extension_flags;
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxKeyboard.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -43,7 +43,6 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
-#include "Window.h"
#include "common_tools.h"
#include "org_lwjgl_opengl_LinuxKeyboard.h"
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -42,7 +42,6 @@
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include "Window.h"
#include "common_tools.h"
#include "org_lwjgl_opengl_LinuxMouse.h"
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c 2006-10-23 20:40:48 UTC (rev 2597)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c 2006-10-24 08:33:09 UTC (rev 2598)
@@ -44,7 +44,6 @@
#include "org_lwjgl_opengl_Pbuffer.h"
#include "extgl.h"
#include "context.h"
-#include "Window.h"
#include "common_tools.h"
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-23 20:41:22
|
Revision: 2597
http://svn.sourceforge.net/java-game-lib/?rev=2597&view=rev
Author: elias_naur
Date: 2006-10-23 13:40:48 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Moved current_win to java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java
trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Removed Paths:
-------------
trunk/LWJGL/src/native/linux/Window.h
Modified: trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2006-10-23 20:14:45 UTC (rev 2596)
+++ trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java 2006-10-23 20:40:48 UTC (rev 2597)
@@ -115,6 +115,8 @@
* @return the maximum size of a native cursor
*/
public static int getMinCursorSize() {
+ if (!Mouse.isCreated())
+ throw new IllegalStateException("Mouse must be created.");
return Mouse.getImplementation().getMinCursorSize();
}
@@ -126,6 +128,8 @@
* @return the maximum size of a native cursor
*/
public static int getMaxCursorSize() {
+ if (!Mouse.isCreated())
+ throw new IllegalStateException("Mouse must be created.");
return Mouse.getImplementation().getMaxCursorSize();
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 20:14:45 UTC (rev 2596)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 20:40:48 UTC (rev 2597)
@@ -78,6 +78,7 @@
/** Current X11 Display pointer */
private static long display;
+ private static long current_window;
private static int display_connection_usage_count = 0;
@@ -294,7 +295,9 @@
}
private static native int nGetDefaultScreen(long display);
- private static native long getWindow();
+ static long getWindow() {
+ return current_window;
+ }
private void ungrabKeyboard() {
if (keyboard_grabbed) {
@@ -383,7 +386,7 @@
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
current_window_mode = getWindowMode(fullscreen);
- nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y);
+ current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y);
blank_cursor = createBlankCursor();
current_cursor = null;
focused = true;
@@ -407,7 +410,7 @@
unlockAWT();
}
}
- private static native void nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException;
+ private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException;
private void updateInputGrab() {
updatePointerGrab();
@@ -425,14 +428,14 @@
nDestroyCursor(getDisplay(), blank_cursor);
blank_cursor = null;
ungrabKeyboard();
- nDestroyWindow(getDisplay());
+ nDestroyWindow(getDisplay(), getWindow());
nSetRepeatMode(getDisplay(), AutoRepeatModeDefault);
decDisplay();
} finally {
unlockAWT();
}
}
- private static native void nDestroyWindow(long display);
+ private static native void nDestroyWindow(long display, long window);
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
lockAWT();
@@ -594,12 +597,12 @@
public void setTitle(String title) {
lockAWT();
try {
- nSetTitle(getDisplay(), title);
+ nSetTitle(getDisplay(), getWindow(), title);
} finally {
unlockAWT();
}
}
- private static native void nSetTitle(long display, String title);
+ private static native void nSetTitle(long display, long window, String title);
public boolean isCloseRequested() {
boolean result = close_requested;
@@ -629,7 +632,7 @@
public void update() {
lockAWT();
try {
- nUpdate(getDisplay(), warp_atom);
+ nUpdate(getDisplay(), getWindow(), warp_atom);
checkInput();
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while processing messages: " + e);
@@ -637,17 +640,17 @@
unlockAWT();
}
}
- private native void nUpdate(long display, long warp_atom) throws LWJGLException;
+ private native void nUpdate(long display, long window, long warp_atom) throws LWJGLException;
public void reshape(int x, int y, int width, int height) {
lockAWT();
try {
- nReshape(getDisplay(), x, y, width, height);
+ nReshape(getDisplay(), getWindow(), x, y, width, height);
} finally {
unlockAWT();
}
}
- private static native void nReshape(long display, int x, int y, int width, int height);
+ private static native void nReshape(long display, long window, int x, int y, int width, int height);
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
lockAWT();
@@ -810,7 +813,7 @@
try {
incDisplay();
try {
- return nGetMinCursorSize(getDisplay());
+ return nGetMinCursorSize(getDisplay(), getWindow());
} finally {
decDisplay();
}
@@ -821,14 +824,14 @@
unlockAWT();
}
}
- private static native int nGetMinCursorSize(long display);
+ private static native int nGetMinCursorSize(long display, long window);
public int getMaxCursorSize() {
lockAWT();
try {
incDisplay();
try {
- return nGetMaxCursorSize(getDisplay());
+ return nGetMaxCursorSize(getDisplay(), getWindow());
} finally {
decDisplay();
}
@@ -839,7 +842,7 @@
unlockAWT();
}
}
- private static native int nGetMaxCursorSize(long display);
+ private static native int nGetMaxCursorSize(long display, long window);
/* Keyboard */
public void createKeyboard() throws LWJGLException {
@@ -1003,7 +1006,7 @@
int size = icons[i].limit() / 4;
int dimension = (int)Math.sqrt(size);
ByteBuffer icon = convertIcon(icons[i], dimension, dimension);
- nSetWindowIcon(getDisplay(), icon, icon.capacity(), dimension, dimension);
+ nSetWindowIcon(getDisplay(), getWindow(), icon, icon.capacity(), dimension, dimension);
return 1;
}
return 0;
@@ -1018,7 +1021,7 @@
}
}
- private static native void nSetWindowIcon(long display, ByteBuffer icon, int icons_size, int width, int height);
+ private static native void nSetWindowIcon(long display, long window, ByteBuffer icon, int icons_size, int width, int height);
/* Callbacks from nUpdate() */
private void handleButtonEvent(long millis, int type, int button, int state) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java 2006-10-23 20:14:45 UTC (rev 2596)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java 2006-10-23 20:40:48 UTC (rev 2597)
@@ -67,12 +67,12 @@
protected void doLockAndInitHandle() throws LWJGLException {
LinuxDisplay.lockAWT();
try {
- initDrawable(getHandle());
+ initDrawable(LinuxDisplay.getWindow(), getHandle());
} finally {
LinuxDisplay.unlockAWT();
}
}
- private static native void initDrawable(ByteBuffer peer_info_handle);
+ private static native void initDrawable(long window, ByteBuffer peer_info_handle);
protected void doUnlock() throws LWJGLException {
// NO-OP
Deleted: trunk/LWJGL/src/native/linux/Window.h
===================================================================
--- trunk/LWJGL/src/native/linux/Window.h 2006-10-23 20:14:45 UTC (rev 2596)
+++ trunk/LWJGL/src/native/linux/Window.h 2006-10-23 20:40:48 UTC (rev 2597)
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * $Id$
- *
- * Include file to access public window features
- *
- * @author elias_naur <eli...@us...>
- * @version $Revision$
- */
-
-#ifndef _LWJGL_WINDOW_H_INCLUDED_
- #define _LWJGL_WINDOW_H_INCLUDED_
-
- #include <jni.h>
- #include <X11/X.h>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include "extgl.h"
- #include "extgl_glx.h"
-
- extern bool checkXError(JNIEnv *, Display *);
-
- /*
- * get the current window
- */
- extern Window getCurrentWindow(void);
-
-#endif /* _LWJGL_WINDOW_H_INCLUDED_ */
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-23 20:14:45 UTC (rev 2596)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-23 20:40:48 UTC (rev 2597)
@@ -61,22 +61,24 @@
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMinCursorSize
- (JNIEnv *env, jclass clazz, jlong display)
+ (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr)
{
Display *disp = (Display *)(intptr_t)display;
+ Window window = (Window)window_ptr;
unsigned int width_return = 0;
unsigned int height_return = 0;
- XQueryBestCursor(disp, getCurrentWindow(), 1, 1, &width_return, &height_return);
+ XQueryBestCursor(disp, window, 1, 1, &width_return, &height_return);
return width_return > height_return ? width_return : height_return;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMaxCursorSize
- (JNIEnv *env, jclass clazz, jlong display)
+ (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr)
{
Display *disp = (Display *)(intptr_t)display;
+ Window window = (Window)window_ptr;
unsigned int width_return = 0;
unsigned int height_return = 0;
- XQueryBestCursor(disp, getCurrentWindow(), 0xffffffff, 0xffffffff, &width_return, &height_return);
+ XQueryBestCursor(disp, window, 0xffffffff, 0xffffffff, &width_return, &height_return);
return width_return > height_return ? height_return : width_return;
}
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 20:14:45 UTC (rev 2596)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 20:40:48 UTC (rev 2597)
@@ -72,7 +72,6 @@
static Atom delete_atom;
static Colormap cmap;
-static Window current_win;
static int current_depth;
static Pixmap current_icon_pixmap;
@@ -148,19 +147,19 @@
XCloseDisplay(disp);
}
-static void setDecorations(Display *disp, int dec) {
+static void setDecorations(Display *disp, Window window, int dec) {
Atom motif_hints_atom = XInternAtom(disp, "_MOTIF_WM_HINTS", False);
MotifWmHints motif_hints;
motif_hints.flags = MWM_HINTS_DECORATIONS;
motif_hints.decorations = dec;
- XChangeProperty(disp, getCurrentWindow(), motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long));
+ XChangeProperty(disp, window, motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long));
}
static bool isLegacyFullscreen(jint window_mode) {
return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY;
}
-static void handleMessages(JNIEnv *env, Display *disp, jobject disp_obj, Atom warp_atom) {
+static void handleMessages(JNIEnv *env, jobject disp_obj, Display *disp, Window window, Atom warp_atom) {
XEvent event;
jclass disp_class = (*env)->GetObjectClass(env, disp_obj);
if (disp_class == NULL)
@@ -194,7 +193,7 @@
if (XFilterEvent(&event, None) == True)
continue;
// Ignore events from old windows
- if (event.xany.window != getCurrentWindow())
+ if (event.xany.window != window)
continue;
switch (event.type) {
case ClientMessage:
@@ -227,8 +226,8 @@
}
}
-static void setWindowTitle(Display *disp, const char *title) {
- XStoreName(disp, current_win, title);
+static void setWindowTitle(Display *disp, Window window, const char *title) {
+ XStoreName(disp, window, title);
}
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) {
@@ -240,12 +239,12 @@
XCloseDisplay(disp);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable(JNIEnv *env, jclass clazz, jlong window, jobject peer_info_handle) {
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
if (peer_info->glx13)
peer_info->drawable = glx_window;
else
- peer_info->drawable = getCurrentWindow();
+ peer_info->drawable = window;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject pixel_format) {
@@ -253,10 +252,11 @@
initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, true, GLX_WINDOW_BIT, true, false);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jstring title_obj) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jlong window_ptr, jstring title_obj) {
Display *disp = (Display *)(intptr_t)display;
+ Window window = (Window)window_ptr;
char * title = GetStringNativeChars(env, title_obj);
- setWindowTitle(disp, title);
+ setWindowTitle(disp, window, title);
free(title);
}
@@ -267,12 +267,12 @@
}
}
-static void destroyWindow(JNIEnv *env, Display *disp) {
+static void destroyWindow(JNIEnv *env, Display *disp, Window window) {
if (glx_window != None) {
lwjgl_glXDestroyWindow(disp, glx_window);
glx_window = None;
}
- XDestroyWindow(disp, current_win);
+ XDestroyWindow(disp, window);
XFreeColormap(disp, cmap);
freeIconPixmap(disp);
}
@@ -307,12 +307,13 @@
return isNetWMFullscreenSupported(env, disp, screen) ? JNI_TRUE : JNI_FALSE;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jlong display, jint x, jint y, jint width, jint height) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jint x, jint y, jint width, jint height) {
Display *disp = (Display *)(intptr_t)display;
- XMoveWindow(disp, getCurrentWindow(), x, y);
+ Window window = (Window)window_ptr;
+ XMoveWindow(disp, window, x, y);
}
-static bool createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
+static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
Window root_win;
Window win;
@@ -344,10 +345,9 @@
return false;
}
printfDebugJava(env, "Created window");
- current_win = win;
if (window_mode != org_lwjgl_opengl_LinuxDisplay_WINDOWED || undecorated) {
// Use Motif decoration hint property and hope the window manager respects them
- setDecorations(disp, 0);
+ setDecorations(disp, win, 0);
}
XSizeHints * size_hints = XAllocSizeHints();
size_hints->flags = PMinSize | PMaxSize;
@@ -361,60 +361,59 @@
XSetWMProtocols(disp, win, &delete_atom, 1);
if (window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_NETWM) {
Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
- XChangeProperty(disp, getCurrentWindow(), XInternAtom(disp, "_NET_WM_STATE", False),
+ XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_STATE", False),
XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
}
XMapRaised(disp, win);
waitMapped(disp, win);
XClearWindow(disp, win);
if (!checkXError(env, disp)) {
- destroyWindow(env, disp);
- return false;
+ destroyWindow(env, disp, win);
+ return 0;
}
- return true;
+ return win;
}
-Window getCurrentWindow(void) {
- return current_win;
-}
-
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate(JNIEnv *env, jobject disp_obj, jlong display, jlong warp_atom_ptr) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate(JNIEnv *env, jobject disp_obj, jlong display, jlong window_ptr, jlong warp_atom_ptr) {
Display *disp = (Display *)(intptr_t)display;
+ Window window = (Window)window_ptr;
Atom warp_atom = (Atom)warp_atom_ptr;
- handleMessages(env, disp, disp_obj, warp_atom);
+ handleMessages(env, disp_obj, disp, window, warp_atom);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) {
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) {
Display *disp = (Display *)(intptr_t)display;
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
GLXFBConfig *fb_config = NULL;
if (peer_info->glx13) {
fb_config = getFBConfigFromPeerInfo(env, peer_info);
if (fb_config == NULL)
- return;
+ return 0;
}
jclass cls_displayMode = (*env)->GetObjectClass(env, mode);
jfieldID fid_width = (*env)->GetFieldID(env, cls_displayMode, "width", "I");
jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
int width = (*env)->GetIntField(env, mode, fid_width);
int height = (*env)->GetIntField(env, mode, fid_height);
- bool window_created = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height);
- if (!window_created) {
- return;
+ Window win = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height);
+ if ((*env)->ExceptionOccurred(env)) {
+ return 0;
}
if (peer_info->glx13) {
- glx_window = lwjgl_glXCreateWindow(disp, *fb_config, getCurrentWindow(), NULL);
+ glx_window = lwjgl_glXCreateWindow(disp, *fb_config, win, NULL);
XFree(fb_config);
}
if (!checkXError(env, disp)) {
lwjgl_glXDestroyWindow(disp, glx_window);
- destroyWindow(env, disp);
+ destroyWindow(env, disp, win);
}
+ return win;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong display) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) {
Display *disp = (Display *)(intptr_t)display;
- destroyWindow(env, disp);
+ Window window = (Window)window_ptr;
+ destroyWindow(env, disp, window);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
@@ -437,10 +436,10 @@
jawt.Unlock(env);
}
-static void setIcon(JNIEnv *env, Display *disp, char *data, int icon_size, int width,int height) {
+static void setIcon(JNIEnv *env, Display *disp, Window window, char *data, int icon_size, int width,int height) {
XWMHints* win_hints;
freeIconPixmap(disp);
- current_icon_pixmap = XCreatePixmap(disp, getCurrentWindow(), width, height, current_depth);
+ current_icon_pixmap = XCreatePixmap(disp, window, width, height, current_depth);
/* We need to copy the image data since XDestroyImage will also free its data buffer, which can't be allowed
* since the data buffer is managed by the jvm (it's the storage for the direct ByteBuffer)
*/
@@ -474,24 +473,21 @@
win_hints->flags = IconPixmapHint;
win_hints->icon_pixmap = current_icon_pixmap;
- XSetWMHints(disp, getCurrentWindow(), win_hints);
+ XSetWMHints(disp, window, win_hints);
XFree(win_hints);
XFlush(disp);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
- (JNIEnv *env, jclass clazz, jlong display, jobject iconBuffer, jint icon_size, jint width, jint height)
+ (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject iconBuffer, jint icon_size, jint width, jint height)
{
Display *disp = (Display *)(intptr_t)display;
+ Window window = (Window)window_ptr;
char *imgData = (char *)(*env)->GetDirectBufferAddress(env, iconBuffer);
- setIcon(env, disp, imgData, icon_size, width, height);
+ setIcon(env, disp, window, imgData, icon_size, width, height);
}
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getWindow(JNIEnv *env, jclass unused) {
- return getCurrentWindow();
-}
-
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) {
Display *disp = (Display *)(intptr_t)display_ptr;
return XUngrabKeyboard(disp, CurrentTime);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-23 20:30:39
|
Revision: 2596
http://svn.sourceforge.net/java-game-lib/?rev=2596&view=rev
Author: elias_naur
Date: 2006-10-23 13:14:45 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Moved screen from native to java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java
trunk/LWJGL/src/native/linux/Window.h
trunk/LWJGL/src/native/linux/display.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 20:14:45 UTC (rev 2596)
@@ -117,7 +117,7 @@
incDisplay();
try {
if (isXF86VidModeSupported())
- return nGetCurrentGammaRamp(getDisplay());
+ return nGetCurrentGammaRamp(getDisplay(), getDefaultScreen());
else
return null;
} finally {
@@ -127,7 +127,7 @@
unlockAWT();
}
}
- private static native ByteBuffer nGetCurrentGammaRamp(long display) throws LWJGLException;
+ private static native ByteBuffer nGetCurrentGammaRamp(long display, int screen) throws LWJGLException;
private static int getBestDisplayModeExtension() {
int result;
@@ -189,7 +189,7 @@
try {
incDisplay();
try {
- return nIsNetWMFullscreenSupported(getDisplay());
+ return nIsNetWMFullscreenSupported(getDisplay(), getDefaultScreen());
} finally {
decDisplay();
}
@@ -200,7 +200,7 @@
unlockAWT();
}
}
- private static native boolean nIsNetWMFullscreenSupported(long display) throws LWJGLException;
+ private static native boolean nIsNetWMFullscreenSupported(long display, int screen) throws LWJGLException;
/* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
* Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to
@@ -289,7 +289,11 @@
return display;
}
- private static native int getScreen();
+ static int getDefaultScreen() {
+ return nGetDefaultScreen(getDisplay());
+ }
+ private static native int nGetDefaultScreen(long display);
+
private static native long getWindow();
private void ungrabKeyboard() {
@@ -316,7 +320,7 @@
pointer_grabbed = true;
// make sure we have a centered window
if (isLegacyFullscreen()) {
- nSetViewPort(getDisplay(), getWindow(), getScreen());
+ nSetViewPort(getDisplay(), getWindow(), getDefaultScreen());
}
}
}
@@ -379,7 +383,7 @@
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
current_window_mode = getWindowMode(fullscreen);
- nCreateWindow(getDisplay(), handle, mode, current_window_mode, x, y);
+ nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y);
blank_cursor = createBlankCursor();
current_cursor = null;
focused = true;
@@ -403,7 +407,7 @@
unlockAWT();
}
}
- private static native void nCreateWindow(long display, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException;
+ private static native void nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException;
private void updateInputGrab() {
updatePointerGrab();
@@ -443,7 +447,7 @@
private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException {
long tmp_display = openDisplay();
try {
- nSwitchDisplayMode(tmp_display, getScreen(), current_displaymode_extension, mode);
+ nSwitchDisplayMode(tmp_display, nGetDefaultScreen(tmp_display), current_displaymode_extension, mode);
} finally {
closeDisplay(tmp_display);
}
@@ -485,7 +489,7 @@
try {
incDisplay();
try {
- return nGetGammaRampLength(getDisplay(), getScreen());
+ return nGetGammaRampLength(getDisplay(), getDefaultScreen());
} catch (LWJGLException e) {
LWJGLUtil.log("Got exception while querying gamma length: " + e);
return 0;
@@ -521,7 +525,7 @@
private void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException {
long tmp_display = openDisplay();
try {
- nSetGammaRamp(tmp_display, getScreen(), native_gamma);
+ nSetGammaRamp(tmp_display, nGetDefaultScreen(tmp_display), native_gamma);
} finally {
closeDisplay(tmp_display);
}
@@ -575,7 +579,7 @@
try {
incDisplay();
try {
- return nGetCurrentXRandrMode(getDisplay());
+ return nGetCurrentXRandrMode(getDisplay(), getDefaultScreen());
} finally {
decDisplay();
}
@@ -585,7 +589,7 @@
}
/** Assumes extension == XRANDR */
- private static native DisplayMode nGetCurrentXRandrMode(long display) throws LWJGLException;
+ private static native DisplayMode nGetCurrentXRandrMode(long display, int screen) throws LWJGLException;
public void setTitle(String title) {
lockAWT();
@@ -650,7 +654,7 @@
try {
incDisplay();
try {
- DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), current_displaymode_extension);
+ DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
return modes;
} finally {
decDisplay();
@@ -659,7 +663,7 @@
unlockAWT();
}
}
- private static native DisplayMode[] nGetAvailableDisplayModes(long display, int extension) throws LWJGLException;
+ private static native DisplayMode[] nGetAvailableDisplayModes(long display, int screen, int extension) throws LWJGLException;
/* Mouse */
public boolean hasWheel() {
@@ -729,7 +733,7 @@
nSetRepeatMode(getDisplay(), AutoRepeatModeDefault);
updateInputGrab();
if (current_window_mode == FULLSCREEN_NETWM) {
- nIconifyWindow(getDisplay(), getWindow(), getScreen());
+ nIconifyWindow(getDisplay(), getWindow(), getDefaultScreen());
try {
switchDisplayModeOnTmpDisplay(saved_mode);
setGammaRampOnTmpDisplay(saved_gamma);
@@ -919,7 +923,7 @@
try {
incDisplay();
try {
- return nGetPbufferCapabilities(getDisplay());
+ return nGetPbufferCapabilities(getDisplay(), getDefaultScreen());
} finally {
decDisplay();
}
@@ -930,7 +934,7 @@
unlockAWT();
}
}
- private static native int nGetPbufferCapabilities(long display);
+ private static native int nGetPbufferCapabilities(long display, int screen);
public boolean isBufferLost(PeerInfo handle) {
return false;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java 2006-10-23 20:14:45 UTC (rev 2596)
@@ -49,7 +49,7 @@
try {
LinuxDisplay.incDisplay();
try {
- initDefaultPeerInfo(LinuxDisplay.getDisplay(), getHandle(), pixel_format);
+ initDefaultPeerInfo(LinuxDisplay.getDisplay(), LinuxDisplay.getDefaultScreen(), getHandle(), pixel_format);
} catch (LWJGLException e) {
LinuxDisplay.decDisplay();
throw e;
@@ -62,7 +62,7 @@
LinuxDisplay.unlockAWT();
}
}
- private static native void initDefaultPeerInfo(long display, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException;
+ private static native void initDefaultPeerInfo(long display, int screen, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException;
protected void doLockAndInitHandle() throws LWJGLException {
LinuxDisplay.lockAWT();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-23 20:14:45 UTC (rev 2596)
@@ -63,6 +63,7 @@
private final long display;
private final long 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);
@@ -75,9 +76,10 @@
private EventQueue event_queue;
private long last_event_nanos;
- public LinuxMouse(long display, long window) {
+ public LinuxMouse(long display, long window, long warp_atom) {
this.display = display;
this.window = window;
+ this.warp_atom = warp_atom;
reset();
}
@@ -130,10 +132,10 @@
}
private void doWarpPointer(int center_x, int center_y) {
- nSendWarpEvent(display, window, center_x, center_y);
+ nSendWarpEvent(display, window, warp_atom, center_x, center_y);
nWarpCursor(display, window, center_x, center_y);
}
- private static native void nSendWarpEvent(long display, long window, int center_x, int center_y);
+ private static native void nSendWarpEvent(long display, long window, long warp_atom, int center_x, int center_y);
private void doHandlePointerMotion(boolean grab, boolean warp_pointer, long root_window, int root_x, int root_y, int win_x, int win_y, long nanos) {
setCursorPos(grab, win_x, win_y, nanos);
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java 2006-10-23 20:14:45 UTC (rev 2596)
@@ -49,7 +49,7 @@
try {
LinuxDisplay.incDisplay();
try {
- nInitHandle(LinuxDisplay.getDisplay(), getHandle(), width, height, pixel_format);
+ nInitHandle(LinuxDisplay.getDisplay(), LinuxDisplay.getDefaultScreen(), getHandle(), width, height, pixel_format);
} catch (LWJGLException e) {
LinuxDisplay.decDisplay();
throw e;
@@ -62,7 +62,7 @@
LinuxDisplay.unlockAWT();
}
}
- private static native void nInitHandle(long display, ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException;
+ private static native void nInitHandle(long display, int screen, ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException;
public void destroy() {
LinuxDisplay.lockAWT();
Modified: trunk/LWJGL/src/native/linux/Window.h
===================================================================
--- trunk/LWJGL/src/native/linux/Window.h 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/native/linux/Window.h 2006-10-23 20:14:45 UTC (rev 2596)
@@ -50,19 +50,8 @@
#include "extgl_glx.h"
extern bool checkXError(JNIEnv *, Display *);
- extern Atom getWarpAtom(void);
-
- /*
- * get the current display
- */
- extern Display *getDisplay(void);
/*
- * get the current screen
- */
- extern int getCurrentScreen(void);
-
- /*
* get the current window
*/
extern Window getCurrentWindow(void);
Modified: trunk/LWJGL/src/native/linux/display.c
===================================================================
--- trunk/LWJGL/src/native/linux/display.c 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/native/linux/display.c 2006-10-23 20:14:45 UTC (rev 2596)
@@ -288,16 +288,16 @@
return native_ramp;
}
-JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused, jlong display) {
+JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused, jlong display, jint screen) {
Display *disp = (Display *)(intptr_t)display;
- int ramp_size = getGammaRampLengthOfDisplay(env, disp, getCurrentScreen());
+ int ramp_size = getGammaRampLengthOfDisplay(env, disp, screen);
jobject ramp_buffer = newJavaManagedByteBuffer(env, sizeof(unsigned short)*3*ramp_size);
if (ramp_buffer == NULL) {
throwException(env, "Could not allocate gamma ramp buffer");
return NULL;
}
unsigned short *ramp = (unsigned short *)(*env)->GetDirectBufferAddress(env, ramp_buffer);
- if (!XF86VidModeGetGammaRamp(disp, getCurrentScreen(), ramp_size, ramp,
+ if (!XF86VidModeGetGammaRamp(disp, screen, ramp_size, ramp,
ramp + ramp_size, ramp + ramp_size*2)) {
throwException(env, "Could not get the current gamma ramp");
return NULL;
@@ -386,14 +386,14 @@
return displayMode;
}
-JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode(JNIEnv *env, jclass unused, jlong display) {
+JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode(JNIEnv *env, jclass unused, jlong display, jint screen) {
Display *disp = (Display *)(intptr_t)display;
- return getCurrentXRandrMode(env, disp, getCurrentScreen());
+ return getCurrentXRandrMode(env, disp, screen);
}
-JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jlong display, jint extension) {
+JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension) {
Display *disp = (Display *)(intptr_t)display;
- return getAvailableDisplayModes(env, disp, getCurrentScreen(), extension);
+ return getAvailableDisplayModes(env, disp, screen, extension);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension, jobject mode) {
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 20:14:45 UTC (rev 2596)
@@ -78,14 +78,9 @@
static Visual *current_visual;
-static int current_screen;
static bool async_x_error;
static char error_message[ERR_MSG_SIZE];
-int getCurrentScreen(void) {
- return current_screen;
-}
-
bool checkXError(JNIEnv *env, Display *disp) {
XSync(disp, False);
if (async_x_error) {
@@ -117,10 +112,13 @@
throwException(env, "Could not open X display connection");
return (intptr_t)NULL;
}
- current_screen = XDefaultScreen(display_connection);
return (intptr_t)display_connection;
}
+JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetDefaultScreen(JNIEnv *env, jclass unused, jlong display_ptr) {
+ Display *disp = (Display *)(intptr_t)display_ptr;
+ return XDefaultScreen(disp);
+}
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInternAtom(JNIEnv *env, jclass unused, jlong display_ptr, jstring atom_name_obj, jboolean only_if_exists) {
Display *disp = (Display *)(intptr_t)display_ptr;
@@ -250,9 +248,9 @@
peer_info->drawable = getCurrentWindow();
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, jobject peer_info_handle, jobject pixel_format) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject pixel_format) {
Display *disp = (Display *)(intptr_t)display;
- initPeerInfo(env, peer_info_handle, disp, getCurrentScreen(), pixel_format, true, GLX_WINDOW_BIT, true, false);
+ initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, true, GLX_WINDOW_BIT, true, false);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jstring title_obj) {
@@ -279,14 +277,14 @@
freeIconPixmap(disp);
}
-static bool isNetWMFullscreenSupported(JNIEnv *env, Display *disp) {
+static bool isNetWMFullscreenSupported(JNIEnv *env, Display *disp, int screen) {
unsigned long nitems;
Atom actual_type;
int actual_format;
unsigned long bytes_after;
Atom *supported_list;
Atom netwm_supported_atom = XInternAtom(disp, "_NET_SUPPORTED", False);
- int result = XGetWindowProperty(disp, RootWindow(disp, getCurrentScreen()), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list);
+ int result = XGetWindowProperty(disp, RootWindow(disp, screen), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list);
if (result != Success) {
throwException(env, "Unable to query _NET_SUPPORTED window property");
return false;
@@ -304,9 +302,9 @@
return supported;
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused, jlong display) {
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused, jlong display, jint screen) {
Display *disp = (Display *)(intptr_t)display;
- return isNetWMFullscreenSupported(env, disp) ? JNI_TRUE : JNI_FALSE;
+ return isNetWMFullscreenSupported(env, disp, screen) ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jlong display, jint x, jint y, jint width, jint height) {
@@ -314,14 +312,14 @@
XMoveWindow(disp, getCurrentWindow(), x, y);
}
-static bool createWindow(JNIEnv* env, Display *disp, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
+static bool createWindow(JNIEnv* env, Display *disp, int screen, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
Window root_win;
Window win;
XSetWindowAttributes attribs;
int attribmask;
- root_win = RootWindow(disp, getCurrentScreen());
+ root_win = RootWindow(disp, screen);
XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
if (vis_info == NULL)
return false;
@@ -386,7 +384,7 @@
handleMessages(env, disp, disp_obj, warp_atom);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y) {
Display *disp = (Display *)(intptr_t)display;
X11PeerInfo *peer_info = (*env)->GetDirectBufferAddress(env, peer_info_handle);
GLXFBConfig *fb_config = NULL;
@@ -400,7 +398,7 @@
jfieldID fid_height = (*env)->GetFieldID(env, cls_displayMode, "height", "I");
int width = (*env)->GetIntField(env, mode, fid_width);
int height = (*env)->GetIntField(env, mode, fid_height);
- bool window_created = createWindow(env, disp, window_mode, peer_info, x, y, width, height);
+ bool window_created = createWindow(env, disp, screen, window_mode, peer_info, x, y, width, height);
if (!window_created) {
return;
}
@@ -562,10 +560,6 @@
return handle_buffer;
}
-JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getScreen(JNIEnv *env, jclass unsused) {
- return getCurrentScreen();
-}
-
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) {
Display *disp = (Display *)(intptr_t)display_ptr;
int revert_mode;
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c 2006-10-23 19:51:22 UTC (rev 2595)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c 2006-10-23 20:14:45 UTC (rev 2596)
@@ -48,25 +48,25 @@
#include "common_tools.h"
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities
- (JNIEnv *env, jclass clazz, jlong display)
+ (JNIEnv *env, jclass clazz, jlong display, jint screen)
{
Display *disp = (Display *)(intptr_t)display;
GLXExtensions extension_flags;
- if (!extgl_InitGLX(disp, getCurrentScreen(), &extension_flags))
+ if (!extgl_InitGLX(disp, screen, &extension_flags))
return 0;
// Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension
return extension_flags.GLX13 ? org_lwjgl_opengl_Pbuffer_PBUFFER_SUPPORTED : 0;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxPbufferPeerInfo_nInitHandle
- (JNIEnv *env, jclass clazz, jlong display, jobject peer_info_handle, jint width, jint height, jobject pixel_format) {
+ (JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jint width, jint height, jobject pixel_format) {
Display *disp = (Display *)(intptr_t)display;
GLXExtensions extension_flags;
- if (!extgl_InitGLX(disp, getCurrentScreen(), &extension_flags) || !extension_flags.GLX13) {
+ if (!extgl_InitGLX(disp, screen, &extension_flags) || !extension_flags.GLX13) {
throwException(env, "No Pbuffer support");
return;
}
- bool result = initPeerInfo(env, peer_info_handle, disp, getCurrentScreen(), pixel_format, false, GLX_PBUFFER_BIT, false, true);
+ bool result = initPeerInfo(env, peer_info_handle, disp, screen, pixel_format, false, GLX_PBUFFER_BIT, false, true);
if (!result)
return;
const int buffer_attribs[] = {GLX_PBUFFER_WIDTH, width,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|