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-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.
|
|
From: <eli...@us...> - 2006-10-23 19:51:46
|
Revision: 2595
http://svn.sourceforge.net/java-game-lib/?rev=2595&view=rev
Author: elias_naur
Date: 2006-10-23 12:51:22 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Moved the pointer warp X11 atom from native to java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:22:27 UTC (rev 2594)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 19:51:22 UTC (rev 2595)
@@ -84,6 +84,9 @@
/** Current mode swithcing API */
private int current_displaymode_extension = NONE;
+ /** Atom used for the pointer warp messages */
+ private long warp_atom;
+
private PeerInfo peer_info;
/** Saved gamma used to restore display settings */
@@ -447,6 +450,20 @@
}
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 {
+ return nInternAtom(getDisplay(), atom_name, only_if_exists);
+ } finally {
+ decDisplay();
+ }
+ }
+ private static native long nInternAtom(long display, String atom_name, boolean only_if_exists);
+
public void resetDisplayMode() {
lockAWT();
try {
@@ -527,6 +544,7 @@
public DisplayMode init() throws LWJGLException {
lockAWT();
try {
+ warp_atom = getWarpAtom();
current_displaymode_extension = getBestDisplayModeExtension();
if (current_displaymode_extension == NONE)
throw new LWJGLException("No display mode extension is available");
@@ -607,7 +625,7 @@
public void update() {
lockAWT();
try {
- nUpdate(getDisplay());
+ nUpdate(getDisplay(), warp_atom);
checkInput();
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while processing messages: " + e);
@@ -615,7 +633,7 @@
unlockAWT();
}
}
- private native void nUpdate(long display) throws LWJGLException;
+ private native void nUpdate(long display, long warp_atom) throws LWJGLException;
public void reshape(int x, int y, int width, int height) {
lockAWT();
@@ -655,7 +673,7 @@
public void createMouse() {
lockAWT();
try {
- mouse = new LinuxMouse(getDisplay(), getWindow());
+ mouse = new LinuxMouse(getDisplay(), getWindow(), warp_atom);
} finally {
unlockAWT();
}
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 14:22:27 UTC (rev 2594)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 19:51:22 UTC (rev 2595)
@@ -81,7 +81,6 @@
static int current_screen;
static bool async_x_error;
static char error_message[ERR_MSG_SIZE];
-static Atom warp_atom;
int getCurrentScreen(void) {
return current_screen;
@@ -119,12 +118,18 @@
return (intptr_t)NULL;
}
current_screen = XDefaultScreen(display_connection);
- warp_atom = XInternAtom(display_connection, "_LWJGL_WARP", False);
return (intptr_t)display_connection;
}
-Atom getWarpAtom(void) {
- return warp_atom;
+
+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;
+ char *atom_name = GetStringNativeChars(env, atom_name_obj);
+ if (atom_name == NULL)
+ return 0;
+ Atom atom = XInternAtom(disp, atom_name, only_if_exists ? True : False);
+ free(atom_name);
+ return atom;
}
static void waitMapped(Display *disp, Window win) {
@@ -157,7 +162,7 @@
return window_mode == org_lwjgl_opengl_LinuxDisplay_FULLSCREEN_LEGACY;
}
-static void handleMessages(JNIEnv *env, Display *disp, jobject disp_obj) {
+static void handleMessages(JNIEnv *env, Display *disp, jobject disp_obj, Atom warp_atom) {
XEvent event;
jclass disp_class = (*env)->GetObjectClass(env, disp_obj);
if (disp_class == NULL)
@@ -375,9 +380,10 @@
return current_win;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate(JNIEnv *env, jobject disp_obj, jlong display) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate(JNIEnv *env, jobject disp_obj, jlong display, jlong warp_atom_ptr) {
Display *disp = (Display *)(intptr_t)display;
- handleMessages(env, disp, disp_obj);
+ Atom warp_atom = (Atom)warp_atom_ptr;
+ 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) {
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c 2006-10-23 14:22:27 UTC (rev 2594)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxMouse.c 2006-10-23 19:51:22 UTC (rev 2595)
@@ -91,13 +91,14 @@
return root_return;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nSendWarpEvent(JNIEnv *env, jclass unusued, jlong display_ptr, jlong window_ptr, jint x, jint y) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxMouse_nSendWarpEvent(JNIEnv *env, jclass unusued, jlong display_ptr, jlong window_ptr, jlong warp_atom_ptr, jint x, jint y) {
+ Atom warp_atom = (Atom)warp_atom_ptr;
Display *disp = (Display *)(intptr_t)display_ptr;
Window win = (Window)window_ptr;
XEvent warp_event;
warp_event.type = ClientMessage;
warp_event.xclient.window = win;
- warp_event.xclient.message_type = getWarpAtom();
+ warp_event.xclient.message_type = warp_atom;
warp_event.xclient.format = 32;
warp_event.xclient.data.l[0] = x;
warp_event.xclient.data.l[1] = y;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-23 14:23:22
|
Revision: 2594
http://svn.sourceforge.net/java-game-lib/?rev=2594&view=rev
Author: elias_naur
Date: 2006-10-23 07:22:27 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Moved another Display instance to java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/native/linux/display.c
trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
Removed Paths:
-------------
trunk/LWJGL/src/native/linux/display.h
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:16:40 UTC (rev 2593)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:22:27 UTC (rev 2594)
@@ -430,14 +430,23 @@
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
lockAWT();
try {
- nSwitchDisplayMode(getScreen(), current_displaymode_extension, mode);
+ switchDisplayModeOnTmpDisplay(mode);
current_mode = mode;
} finally {
unlockAWT();
}
}
- private static native void nSwitchDisplayMode(int screen, int extension, DisplayMode mode) throws LWJGLException;
+ private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException {
+ long tmp_display = openDisplay();
+ try {
+ nSwitchDisplayMode(tmp_display, getScreen(), current_displaymode_extension, mode);
+ } finally {
+ closeDisplay(tmp_display);
+ }
+ }
+ private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException;
+
public void resetDisplayMode() {
lockAWT();
try {
@@ -704,7 +713,7 @@
if (current_window_mode == FULLSCREEN_NETWM) {
nIconifyWindow(getDisplay(), getWindow(), getScreen());
try {
- nSwitchDisplayMode(getScreen(), current_displaymode_extension, saved_mode);
+ switchDisplayModeOnTmpDisplay(saved_mode);
setGammaRampOnTmpDisplay(saved_gamma);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage());
@@ -721,7 +730,7 @@
updateInputGrab();
if (current_window_mode == FULLSCREEN_NETWM) {
try {
- nSwitchDisplayMode(getScreen(), current_displaymode_extension, current_mode);
+ switchDisplayModeOnTmpDisplay(current_mode);
setGammaRampOnTmpDisplay(current_gamma);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to restore mode: " + e.getMessage());
Modified: trunk/LWJGL/src/native/linux/display.c
===================================================================
--- trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:16:40 UTC (rev 2593)
+++ trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:22:27 UTC (rev 2594)
@@ -47,7 +47,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include "display.h"
#include "common_tools.h"
#include "Window.h"
#include "org_lwjgl_opengl_LinuxDisplay.h"
@@ -319,7 +318,7 @@
}
}
-bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) {
+static bool switchDisplayMode(JNIEnv * env, Display *disp, int screen, jint extension, jobject mode) {
if (mode == NULL) {
throwException(env, "mode must be non-null");
return false;
@@ -331,17 +330,11 @@
int width = (*env)->GetIntField(env, mode, fid_width);
int height = (*env)->GetIntField(env, mode, fid_height);
int freq = (*env)->GetIntField(env, mode, fid_freq);
- Display *disp = XOpenDisplay(NULL);
- if (disp == NULL) {
- throwException(env, "Could not open display");
- return false;
- }
if (!setMode(env, disp, screen, extension, width, height, freq)) {
XCloseDisplay(disp);
throwException(env, "Could not switch mode.");
return false;
}
- XCloseDisplay(disp);
return true;
}
@@ -403,8 +396,9 @@
return getAvailableDisplayModes(env, disp, getCurrentScreen(), extension);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint screen, jint extension, jobject mode) {
- switchDisplayMode(env, screen, extension, mode);
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jlong display, jint screen, jint extension, jobject mode) {
+ Display *disp = (Display *)(intptr_t)display;
+ switchDisplayMode(env, disp, screen, extension, mode);
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jclass clazz, jlong display_ptr, jint screen) {
Deleted: trunk/LWJGL/src/native/linux/display.h
===================================================================
--- trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:16:40 UTC (rev 2593)
+++ trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:22:27 UTC (rev 2594)
@@ -1,50 +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$
- *
- * Linux specific library for display handling.
- *
- * @author elias_naur <eli...@us...>
- * @version $Revision$
- */
-
-#ifndef _DISPLAY_H
-#define _DISPLAY_H
-
-#include <jni.h>
-#include "common_tools.h"
-
-extern bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode);
-
-#endif
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 14:16:40 UTC (rev 2593)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 14:22:27 UTC (rev 2594)
@@ -53,7 +53,6 @@
#include "extgl_glx.h"
#include "Window.h"
#include "context.h"
-#include "display.h"
#include "org_lwjgl_opengl_LinuxDisplay.h"
#include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-23 14:16:51
|
Revision: 2593
http://svn.sourceforge.net/java-game-lib/?rev=2593&view=rev
Author: elias_naur
Date: 2006-10-23 07:16:40 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Moved another Display instance to java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
trunk/LWJGL/src/native/linux/display.c
trunk/LWJGL/src/native/linux/display.h
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:05:40 UTC (rev 2592)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:16:40 UTC (rev 2593)
@@ -485,14 +485,23 @@
private void doSetGamma(ByteBuffer native_gamma) throws LWJGLException {
lockAWT();
try {
- nSetGammaRamp(getScreen(), native_gamma);
+ setGammaRampOnTmpDisplay(native_gamma);
current_gamma = native_gamma;
} finally {
unlockAWT();
}
}
- private static native void nSetGammaRamp(int screen, ByteBuffer gammaRamp) throws LWJGLException;
+ private void setGammaRampOnTmpDisplay(ByteBuffer native_gamma) throws LWJGLException {
+ long tmp_display = openDisplay();
+ try {
+ nSetGammaRamp(tmp_display, getScreen(), native_gamma);
+ } finally {
+ closeDisplay(tmp_display);
+ }
+ }
+ private static native void nSetGammaRamp(long display, int screen, ByteBuffer gammaRamp) throws LWJGLException;
+
private static ByteBuffer convertToNativeRamp(FloatBuffer ramp) throws LWJGLException {
return nConvertToNativeRamp(ramp, ramp.position(), ramp.remaining());
}
@@ -696,7 +705,7 @@
nIconifyWindow(getDisplay(), getWindow(), getScreen());
try {
nSwitchDisplayMode(getScreen(), current_displaymode_extension, saved_mode);
- nSetGammaRamp(getScreen(), saved_gamma);
+ setGammaRampOnTmpDisplay(saved_gamma);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to restore saved mode: " + e.getMessage());
}
@@ -713,7 +722,7 @@
if (current_window_mode == FULLSCREEN_NETWM) {
try {
nSwitchDisplayMode(getScreen(), current_displaymode_extension, current_mode);
- nSetGammaRamp(getScreen(), current_gamma);
+ setGammaRampOnTmpDisplay(current_gamma);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to restore mode: " + e.getMessage());
}
Modified: trunk/LWJGL/src/native/linux/display.c
===================================================================
--- trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:05:40 UTC (rev 2592)
+++ trunk/LWJGL/src/native/linux/display.c 2006-10-23 14:16:40 UTC (rev 2593)
@@ -319,16 +319,6 @@
}
}
-void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer) {
- Display * disp = XOpenDisplay(NULL);
- if (disp == NULL) {
- throwException(env, "Could not open display");
- return;
- }
- setGamma(env, disp, screen, gamma_ramp_buffer);
- XCloseDisplay(disp);
-}
-
bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode) {
if (mode == NULL) {
throwException(env, "mode must be non-null");
@@ -422,7 +412,8 @@
return (jint)getGammaRampLengthOfDisplay(env, disp, screen);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jint screen, jobject gamma_buffer) {
- setGammaRamp(env, screen, gamma_buffer);
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject gamma_buffer) {
+ Display *disp = (Display *)(intptr_t)display;
+ setGamma(env, disp, screen, gamma_buffer);
}
Modified: trunk/LWJGL/src/native/linux/display.h
===================================================================
--- trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:05:40 UTC (rev 2592)
+++ trunk/LWJGL/src/native/linux/display.h 2006-10-23 14:16:40 UTC (rev 2593)
@@ -46,6 +46,5 @@
#include "common_tools.h"
extern bool switchDisplayMode(JNIEnv * env, int screen, jint extension, jobject mode);
-extern void setGammaRamp(JNIEnv *env, int screen, jobject gamma_ramp_buffer);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-23 14:05:47
|
Revision: 2592
http://svn.sourceforge.net/java-game-lib/?rev=2592&view=rev
Author: elias_naur
Date: 2006-10-23 07:05:40 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Added sanity check to LinuxDisplay.getDisplay()
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-23 13:58:33 UTC (rev 2591)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 14:05:40 UTC (rev 2592)
@@ -258,7 +258,7 @@
if (display_connection_usage_count < 0)
throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count);
if (display_connection_usage_count == 0) {
- closeDisplay(getDisplay());
+ closeDisplay(display);
display = 0;
GLContext.unloadOpenGLLibrary();
}
@@ -281,6 +281,8 @@
}
static long getDisplay() {
+ if (display_connection_usage_count <= 0)
+ throw new InternalError("display_connection_usage_count = " + display_connection_usage_count);
return display;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <eli...@us...> - 2006-10-23 13:58:58
|
Revision: 2591
http://svn.sourceforge.net/java-game-lib/?rev=2591&view=rev
Author: elias_naur
Date: 2006-10-23 06:58:33 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Moved Display pointer from native to java
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/Sys.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/LinuxDisplayPeerInfo.java
trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java
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_Pbuffer.c
Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-10-23 13:58:33 UTC (rev 2591)
@@ -57,7 +57,7 @@
private static final String VERSION = "1.0beta3";
/** Current version of the JNI library */
- static final int JNI_VERSION = 4;
+ static final int JNI_VERSION = 5;
/** The implementation instance to delegate platform specific behavior to */
private final static SysImplementation implementation;
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java 2006-10-23 13:58:33 UTC (rev 2591)
@@ -107,7 +107,7 @@
GLContext.loadOpenGLLibrary();
try {
LinuxDisplay.incDisplay();
- return nFindVisualIDFromFormat(screen, pixel_format);
+ return nFindVisualIDFromFormat(LinuxDisplay.getDisplay(), screen, pixel_format);
} finally {
LinuxDisplay.decDisplay();
}
@@ -118,5 +118,5 @@
LinuxDisplay.unlockAWT();
}
}
- private static native int nFindVisualIDFromFormat(int screen, PixelFormat pixel_format) throws LWJGLException;
+ private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException;
}
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 13:58:33 UTC (rev 2591)
@@ -75,6 +75,9 @@
*/
private static Thread current_awt_lock_owner;
private static int awt_lock_count;
+
+ /** Current X11 Display pointer */
+ private static long display;
private static int display_connection_usage_count = 0;
@@ -111,7 +114,7 @@
incDisplay();
try {
if (isXF86VidModeSupported())
- return nGetCurrentGammaRamp();
+ return nGetCurrentGammaRamp(getDisplay());
else
return null;
} finally {
@@ -121,7 +124,7 @@
unlockAWT();
}
}
- private static native ByteBuffer nGetCurrentGammaRamp() throws LWJGLException;
+ private static native ByteBuffer nGetCurrentGammaRamp(long display) throws LWJGLException;
private static int getBestDisplayModeExtension() {
int result;
@@ -145,7 +148,7 @@
try {
incDisplay();
try {
- return nIsXrandrSupported();
+ return nIsXrandrSupported(getDisplay());
} finally {
decDisplay();
}
@@ -156,14 +159,14 @@
unlockAWT();
}
}
- private static native boolean nIsXrandrSupported() throws LWJGLException;
+ private static native boolean nIsXrandrSupported(long display) throws LWJGLException;
private static boolean isXF86VidModeSupported() {
lockAWT();
try {
incDisplay();
try {
- return nIsXF86VidModeSupported();
+ return nIsXF86VidModeSupported(getDisplay());
} finally {
decDisplay();
}
@@ -174,7 +177,7 @@
unlockAWT();
}
}
- private static native boolean nIsXF86VidModeSupported() throws LWJGLException;
+ private static native boolean nIsXF86VidModeSupported(long display) throws LWJGLException;
private static boolean isNetWMFullscreenSupported() throws LWJGLException {
if (Display.getPrivilegedBoolean("LWJGL_DISABLE_NETWM"))
@@ -183,7 +186,7 @@
try {
incDisplay();
try {
- return nIsNetWMFullscreenSupported();
+ return nIsNetWMFullscreenSupported(getDisplay());
} finally {
decDisplay();
}
@@ -194,7 +197,7 @@
unlockAWT();
}
}
- private static native boolean nIsNetWMFullscreenSupported() throws LWJGLException;
+ private static native boolean nIsNetWMFullscreenSupported(long display) 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
@@ -245,7 +248,7 @@
static void incDisplay() throws LWJGLException {
if (display_connection_usage_count == 0) {
GLContext.loadOpenGLLibrary();
- openDisplay();
+ display = openDisplay();
}
display_connection_usage_count++;
}
@@ -255,13 +258,14 @@
if (display_connection_usage_count < 0)
throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count);
if (display_connection_usage_count == 0) {
- closeDisplay();
+ closeDisplay(getDisplay());
+ display = 0;
GLContext.unloadOpenGLLibrary();
}
}
- private static native void openDisplay() throws LWJGLException;
- private static native void closeDisplay();
+ private static native long openDisplay() throws LWJGLException;
+ private static native void closeDisplay(long display);
private int getWindowMode(boolean fullscreen) throws LWJGLException {
if (fullscreen) {
@@ -276,7 +280,10 @@
return WINDOWED;
}
- private static native long getDisplay();
+ static long getDisplay() {
+ return display;
+ }
+
private static native int getScreen();
private static native long getWindow();
@@ -367,7 +374,7 @@
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
current_window_mode = getWindowMode(fullscreen);
- nCreateWindow(handle, mode, current_window_mode, x, y);
+ nCreateWindow(getDisplay(), handle, mode, current_window_mode, x, y);
blank_cursor = createBlankCursor();
current_cursor = null;
focused = true;
@@ -391,7 +398,7 @@
unlockAWT();
}
}
- private static native void nCreateWindow(ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException;
+ private static native void nCreateWindow(long display, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y) throws LWJGLException;
private void updateInputGrab() {
updatePointerGrab();
@@ -406,17 +413,17 @@
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to reset cursor: " + e.getMessage());
}
- nDestroyCursor(blank_cursor);
+ nDestroyCursor(getDisplay(), blank_cursor);
blank_cursor = null;
ungrabKeyboard();
- nDestroyWindow();
+ nDestroyWindow(getDisplay());
nSetRepeatMode(getDisplay(), AutoRepeatModeDefault);
decDisplay();
} finally {
unlockAWT();
}
}
- private static native void nDestroyWindow();
+ private static native void nDestroyWindow(long display);
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
lockAWT();
@@ -530,7 +537,7 @@
try {
incDisplay();
try {
- return nGetCurrentXRandrMode();
+ return nGetCurrentXRandrMode(getDisplay());
} finally {
decDisplay();
}
@@ -540,17 +547,17 @@
}
/** Assumes extension == XRANDR */
- private static native DisplayMode nGetCurrentXRandrMode() throws LWJGLException;
+ private static native DisplayMode nGetCurrentXRandrMode(long display) throws LWJGLException;
public void setTitle(String title) {
lockAWT();
try {
- nSetTitle(title);
+ nSetTitle(getDisplay(), title);
} finally {
unlockAWT();
}
}
- private static native void nSetTitle(String title);
+ private static native void nSetTitle(long display, String title);
public boolean isCloseRequested() {
boolean result = close_requested;
@@ -580,7 +587,7 @@
public void update() {
lockAWT();
try {
- nUpdate();
+ nUpdate(getDisplay());
checkInput();
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while processing messages: " + e);
@@ -588,24 +595,24 @@
unlockAWT();
}
}
- private native void nUpdate() throws LWJGLException;
+ private native void nUpdate(long display) throws LWJGLException;
public void reshape(int x, int y, int width, int height) {
lockAWT();
try {
- nReshape(x, y, width, height);
+ nReshape(getDisplay(), x, y, width, height);
} finally {
unlockAWT();
}
}
- private static native void nReshape(int x, int y, int width, int height);
+ private static native void nReshape(long display, int x, int y, int width, int height);
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
lockAWT();
try {
incDisplay();
try {
- DisplayMode[] modes = nGetAvailableDisplayModes(current_displaymode_extension);
+ DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), current_displaymode_extension);
return modes;
} finally {
decDisplay();
@@ -614,7 +621,7 @@
unlockAWT();
}
}
- private static native DisplayMode[] nGetAvailableDisplayModes(int extension) throws LWJGLException;
+ private static native DisplayMode[] nGetAvailableDisplayModes(long display, int extension) throws LWJGLException;
/* Mouse */
public boolean hasWheel() {
@@ -734,7 +741,7 @@
try {
incDisplay();
try {
- return nGetNativeCursorCapabilities();
+ return nGetNativeCursorCapabilities(getDisplay());
} finally {
decDisplay();
}
@@ -744,7 +751,7 @@
unlockAWT();
}
}
- private static native int nGetNativeCursorCapabilities() throws LWJGLException;
+ private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException;
public void setNativeCursor(Object handle) throws LWJGLException {
current_cursor = (ByteBuffer)handle;
@@ -761,7 +768,7 @@
try {
incDisplay();
try {
- return nGetMinCursorSize();
+ return nGetMinCursorSize(getDisplay());
} finally {
decDisplay();
}
@@ -772,14 +779,14 @@
unlockAWT();
}
}
- private static native int nGetMinCursorSize();
+ private static native int nGetMinCursorSize(long display);
public int getMaxCursorSize() {
lockAWT();
try {
incDisplay();
try {
- return nGetMaxCursorSize();
+ return nGetMaxCursorSize(getDisplay());
} finally {
decDisplay();
}
@@ -790,7 +797,7 @@
unlockAWT();
}
}
- private static native int nGetMaxCursorSize();
+ private static native int nGetMaxCursorSize(long display);
/* Keyboard */
public void createKeyboard() throws LWJGLException {
@@ -836,7 +843,7 @@
return Keyboard.STATE_UNKNOWN;
}
*/
- private static native ByteBuffer nCreateCursor(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 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 ByteBuffer createBlankCursor() {
return nCreateBlankCursor(getDisplay(), getWindow());
@@ -848,7 +855,7 @@
try {
incDisplay();
try {
- return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
+ return nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
} catch (LWJGLException e) {
decDisplay();
throw e;
@@ -861,20 +868,20 @@
public void destroyCursor(Object cursorHandle) {
lockAWT();
try {
- nDestroyCursor(cursorHandle);
+ nDestroyCursor(getDisplay(), cursorHandle);
decDisplay();
} finally {
unlockAWT();
}
}
- private static native void nDestroyCursor(Object cursorHandle);
+ private static native void nDestroyCursor(long display, Object cursorHandle);
public int getPbufferCapabilities() {
lockAWT();
try {
incDisplay();
try {
- return nGetPbufferCapabilities();
+ return nGetPbufferCapabilities(getDisplay());
} finally {
decDisplay();
}
@@ -885,7 +892,7 @@
unlockAWT();
}
}
- private static native int nGetPbufferCapabilities();
+ private static native int nGetPbufferCapabilities(long display);
public boolean isBufferLost(PeerInfo handle) {
return false;
@@ -954,7 +961,7 @@
int size = icons[i].limit() / 4;
int dimension = (int)Math.sqrt(size);
ByteBuffer icon = convertIcon(icons[i], dimension, dimension);
- nSetWindowIcon(icon, icon.capacity(), dimension, dimension);
+ nSetWindowIcon(getDisplay(), icon, icon.capacity(), dimension, dimension);
return 1;
}
return 0;
@@ -969,7 +976,7 @@
}
}
- private static native void nSetWindowIcon(ByteBuffer icon, int icons_size, int width, int height);
+ private static native void nSetWindowIcon(long display, 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 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java 2006-10-23 13:58:33 UTC (rev 2591)
@@ -49,7 +49,7 @@
try {
LinuxDisplay.incDisplay();
try {
- initDefaultPeerInfo(getHandle(), pixel_format);
+ initDefaultPeerInfo(LinuxDisplay.getDisplay(), getHandle(), pixel_format);
} catch (LWJGLException e) {
LinuxDisplay.decDisplay();
throw e;
@@ -62,7 +62,7 @@
LinuxDisplay.unlockAWT();
}
}
- private static native void initDefaultPeerInfo(ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException;
+ private static native void initDefaultPeerInfo(long display, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException;
protected void doLockAndInitHandle() throws LWJGLException {
LinuxDisplay.lockAWT();
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java 2006-10-23 13:58:33 UTC (rev 2591)
@@ -49,7 +49,7 @@
try {
LinuxDisplay.incDisplay();
try {
- nInitHandle(getHandle(), width, height, pixel_format);
+ nInitHandle(LinuxDisplay.getDisplay(), getHandle(), width, height, pixel_format);
} catch (LWJGLException e) {
LinuxDisplay.decDisplay();
throw e;
@@ -62,7 +62,7 @@
LinuxDisplay.unlockAWT();
}
}
- private static native void nInitHandle(ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException;
+ private static native void nInitHandle(long display, ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException;
public void destroy() {
LinuxDisplay.lockAWT();
Modified: trunk/LWJGL/src/native/linux/display.c
===================================================================
--- trunk/LWJGL/src/native/linux/display.c 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/native/linux/display.c 2006-10-23 13:58:33 UTC (rev 2591)
@@ -108,13 +108,15 @@
return major_ver >= 2;
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXrandrSupported(JNIEnv *env, jclass unused) {
- jboolean result = isXrandrSupported(env, getDisplay()) ? JNI_TRUE : JNI_FALSE;
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXrandrSupported(JNIEnv *env, jclass unused, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ jboolean result = isXrandrSupported(env, disp) ? JNI_TRUE : JNI_FALSE;
return result;
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXF86VidModeSupported(JNIEnv *env, jclass unused) {
- jboolean result = isXF86VidModeSupported(env, getDisplay()) ? JNI_TRUE : JNI_FALSE;
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsXF86VidModeSupported(JNIEnv *env, jclass unused, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ jboolean result = isXF86VidModeSupported(env, disp) ? JNI_TRUE : JNI_FALSE;
return result;
}
@@ -287,15 +289,16 @@
return native_ramp;
}
-JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused) {
- int ramp_size = getGammaRampLengthOfDisplay(env, getDisplay(), getCurrentScreen());
+JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentGammaRamp(JNIEnv *env, jclass unused, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ int ramp_size = getGammaRampLengthOfDisplay(env, disp, getCurrentScreen());
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(getDisplay(), getCurrentScreen(), ramp_size, ramp,
+ if (!XF86VidModeGetGammaRamp(disp, getCurrentScreen(), ramp_size, ramp,
ramp + ramp_size, ramp + ramp_size*2)) {
throwException(env, "Could not get the current gamma ramp");
return NULL;
@@ -400,12 +403,14 @@
return displayMode;
}
-JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode(JNIEnv *env, jclass unused) {
- return getCurrentXRandrMode(env, getDisplay(), getCurrentScreen());
+JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetCurrentXRandrMode(JNIEnv *env, jclass unused, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ return getCurrentXRandrMode(env, disp, getCurrentScreen());
}
-JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jint extension) {
- return getAvailableDisplayModes(env, getDisplay(), getCurrentScreen(), extension);
+JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jclass clazz, jlong display, jint extension) {
+ Display *disp = (Display *)(intptr_t)display;
+ return getAvailableDisplayModes(env, disp, getCurrentScreen(), extension);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jint screen, jint extension, jobject mode) {
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_input_Cursor.c 2006-10-23 13:58:33 UTC (rev 2591)
@@ -48,10 +48,11 @@
#include "common_tools.h"
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetNativeCursorCapabilities
- (JNIEnv *env, jclass clazz) {
+ (JNIEnv *env, jclass clazz, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
int caps = 0;
- XcursorBool argb_supported = XcursorSupportsARGB(getDisplay());
- XcursorBool anim_supported = XcursorSupportsAnim(getDisplay());
+ XcursorBool argb_supported = XcursorSupportsARGB(disp);
+ XcursorBool anim_supported = XcursorSupportsAnim(disp);
if (argb_supported)
caps |= org_lwjgl_input_Cursor_CURSOR_8_BIT_ALPHA | org_lwjgl_input_Cursor_CURSOR_ONE_BIT_TRANSPARENCY;
if (anim_supported)
@@ -60,26 +61,29 @@
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMinCursorSize
- (JNIEnv *env, jclass clazz)
+ (JNIEnv *env, jclass clazz, jlong display)
{
+ Display *disp = (Display *)(intptr_t)display;
unsigned int width_return = 0;
unsigned int height_return = 0;
- XQueryBestCursor(getDisplay(), getCurrentWindow(), 1, 1, &width_return, &height_return);
+ XQueryBestCursor(disp, getCurrentWindow(), 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)
+ (JNIEnv *env, jclass clazz, jlong display)
{
+ Display *disp = (Display *)(intptr_t)display;
unsigned int width_return = 0;
unsigned int height_return = 0;
- XQueryBestCursor(getDisplay(), getCurrentWindow(), 0xffffffff, 0xffffffff, &width_return, &height_return);
+ XQueryBestCursor(disp, getCurrentWindow(), 0xffffffff, 0xffffffff, &width_return, &height_return);
return width_return > height_return ? height_return : width_return;
}
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
- (JNIEnv *env, jclass clazz, 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)
+ (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");
@@ -107,14 +111,15 @@
cursor_images->images[i] = cursor_image;
}
Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, handle_buffer);
- *cursor = XcursorImagesLoadCursor(getDisplay(), cursor_images);
+ *cursor = XcursorImagesLoadCursor(disp, cursor_images);
XcursorImagesDestroy(cursor_images);
return handle_buffer;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor
- (JNIEnv *env, jclass clazz, jobject cursor_handle_buffer)
+ (JNIEnv *env, jclass clazz, jlong display, jobject cursor_handle_buffer)
{
+ Display *disp = (Display *)(intptr_t)display;
Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, cursor_handle_buffer);
- XFreeCursor(getDisplay(), *cursor);
+ 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-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c 2006-10-23 13:58:33 UTC (rev 2591)
@@ -80,7 +80,6 @@
static Visual *current_visual;
static int current_screen;
-static Display *display_connection = NULL;
static bool async_x_error;
static char error_message[ERR_MSG_SIZE];
static Atom warp_atom;
@@ -112,35 +111,27 @@
return 0;
}
-Display *getDisplay(void) {
- return display_connection;
-}
-
-static void openDisplay(JNIEnv *env) {
+static jlong openDisplay(JNIEnv *env) {
async_x_error = false;
XSetErrorHandler(errorHandler);
- display_connection = XOpenDisplay(NULL);
+ Display *display_connection = XOpenDisplay(NULL);
if (display_connection == NULL) {
throwException(env, "Could not open X display connection");
- return;
+ return (intptr_t)NULL;
}
- current_screen = XDefaultScreen(getDisplay());
+ current_screen = XDefaultScreen(display_connection);
warp_atom = XInternAtom(display_connection, "_LWJGL_WARP", False);
+ return (intptr_t)display_connection;
}
Atom getWarpAtom(void) {
return warp_atom;
}
-static void closeDisplay(void) {
- XCloseDisplay(display_connection);
- display_connection = NULL;
-}
-
-static void waitMapped(Window win) {
+static void waitMapped(Display *disp, Window win) {
XEvent event;
do {
- XMaskEvent(getDisplay(), StructureNotifyMask, &event);
+ XMaskEvent(disp, StructureNotifyMask, &event);
} while ((event.type != MapNotify) || (event.xmap.event != win));
}
@@ -155,19 +146,19 @@
XCloseDisplay(disp);
}
-static void setDecorations(int dec) {
- Atom motif_hints_atom = XInternAtom(getDisplay(), "_MOTIF_WM_HINTS", False);
+static void setDecorations(Display *disp, 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 (getDisplay(), getCurrentWindow(), motif_hints_atom, motif_hints_atom, 32, PropModeReplace, (unsigned char *)&motif_hints, sizeof(MotifWmHints)/sizeof(long));
+ XChangeProperty(disp, getCurrentWindow(), 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, jobject disp_obj) {
+static void handleMessages(JNIEnv *env, Display *disp, jobject disp_obj) {
XEvent event;
jclass disp_class = (*env)->GetObjectClass(env, disp_obj);
if (disp_class == NULL)
@@ -196,8 +187,8 @@
jmethodID handleCloseEvent_method = (*env)->GetMethodID(env, disp_class, "handleCloseEvent", "()V");
if (handleCloseEvent_method == NULL)
return;
- while (!(*env)->ExceptionOccurred(env) && XPending(getDisplay()) > 0) {
- XNextEvent(getDisplay(), &event);
+ while (!(*env)->ExceptionOccurred(env) && XPending(disp) > 0) {
+ XNextEvent(disp, &event);
if (XFilterEvent(&event, None) == True)
continue;
// Ignore events from old windows
@@ -234,16 +225,17 @@
}
}
-static void setWindowTitle(const char *title) {
- XStoreName(getDisplay(), current_win, title);
+static void setWindowTitle(Display *disp, const char *title) {
+ XStoreName(disp, current_win, title);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) {
- openDisplay(env);
+JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) {
+ return openDisplay(env);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_closeDisplay(JNIEnv *env, jclass clazz) {
- closeDisplay();
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_closeDisplay(JNIEnv *env, jclass clazz, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ XCloseDisplay(disp);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDrawable(JNIEnv *env, jclass clazz, jobject peer_info_handle) {
@@ -254,46 +246,48 @@
peer_info->drawable = getCurrentWindow();
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jobject peer_info_handle, jobject pixel_format) {
- initPeerInfo(env, peer_info_handle, getDisplay(), getCurrentScreen(), pixel_format, true, GLX_WINDOW_BIT, true, false);
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplayPeerInfo_initDefaultPeerInfo(JNIEnv *env, jclass clazz, jlong display, 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);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jstring title_obj) {
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jclass clazz, jlong display, jstring title_obj) {
+ Display *disp = (Display *)(intptr_t)display;
char * title = GetStringNativeChars(env, title_obj);
- setWindowTitle(title);
+ setWindowTitle(disp, title);
free(title);
}
-static void freeIconPixmap() {
+static void freeIconPixmap(Display *disp) {
if (current_icon_pixmap != 0) {
- XFreePixmap(getDisplay(), current_icon_pixmap);
+ XFreePixmap(disp, current_icon_pixmap);
current_icon_pixmap = 0;
}
}
-static void destroyWindow(JNIEnv *env) {
+static void destroyWindow(JNIEnv *env, Display *disp) {
if (glx_window != None) {
- lwjgl_glXDestroyWindow(getDisplay(), glx_window);
+ lwjgl_glXDestroyWindow(disp, glx_window);
glx_window = None;
}
- XDestroyWindow(getDisplay(), current_win);
- XFreeColormap(getDisplay(), cmap);
- freeIconPixmap();
+ XDestroyWindow(disp, current_win);
+ XFreeColormap(disp, cmap);
+ freeIconPixmap(disp);
}
-static bool isNetWMFullscreenSupported(JNIEnv *env) {
+static bool isNetWMFullscreenSupported(JNIEnv *env, Display *disp) {
unsigned long nitems;
Atom actual_type;
int actual_format;
unsigned long bytes_after;
Atom *supported_list;
- Atom netwm_supported_atom = XInternAtom(getDisplay(), "_NET_SUPPORTED", False);
- int result = XGetWindowProperty(getDisplay(), RootWindow(getDisplay(), getCurrentScreen()), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&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);
if (result != Success) {
throwException(env, "Unable to query _NET_SUPPORTED window property");
return false;
}
- Atom fullscreen_atom = XInternAtom(getDisplay(), "_NET_WM_STATE_FULLSCREEN", False);
+ Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
bool supported = false;
unsigned long i;
for (i = 0; i < nitems; i++) {
@@ -306,26 +300,28 @@
return supported;
}
-JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused) {
- return isNetWMFullscreenSupported(env) ? JNI_TRUE : JNI_FALSE;
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsNetWMFullscreenSupported(JNIEnv *env, jclass unused, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ return isNetWMFullscreenSupported(env, disp) ? JNI_TRUE : JNI_FALSE;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jint x, jint y, jint width, jint height) {
- XMoveWindow(getDisplay(), getCurrentWindow(), x, y);
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jlong display, jint x, jint y, jint width, jint height) {
+ Display *disp = (Display *)(intptr_t)display;
+ XMoveWindow(disp, getCurrentWindow(), x, y);
}
-static bool createWindow(JNIEnv* env, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
+static bool createWindow(JNIEnv* env, Display *disp, 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(getDisplay(), getCurrentScreen());
+ root_win = RootWindow(disp, getCurrentScreen());
XVisualInfo *vis_info = getVisualInfoFromPeerInfo(env, peer_info);
if (vis_info == NULL)
return false;
- cmap = XCreateColormap(getDisplay(), root_win, vis_info->visual, AllocNone);
+ cmap = XCreateColormap(disp, root_win, vis_info->visual, AllocNone);
attribs.colormap = cmap;
attribs.event_mask = ExposureMask | /*FocusChangeMask | */VisibilityChangeMask | StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
attribs.background_pixel = 0xFF000000;
@@ -335,21 +331,21 @@
attribmask |= CWOverrideRedirect;
attribs.override_redirect = True;
}
- win = XCreateWindow(getDisplay(), root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
+ win = XCreateWindow(disp, root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs);
current_depth = vis_info->depth;
current_visual = vis_info->visual;
XFree(vis_info);
- if (!checkXError(env, getDisplay())) {
- XFreeColormap(getDisplay(), cmap);
+ if (!checkXError(env, disp)) {
+ XFreeColormap(disp, cmap);
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(0);
+ setDecorations(disp, 0);
}
XSizeHints * size_hints = XAllocSizeHints();
size_hints->flags = PMinSize | PMaxSize;
@@ -357,20 +353,20 @@
size_hints->max_width = width;
size_hints->min_height = height;
size_hints->max_height = height;
- XSetWMNormalHints(getDisplay(), win, size_hints);
+ XSetWMNormalHints(disp, win, size_hints);
XFree(size_hints);
- delete_atom = XInternAtom(getDisplay(), "WM_DELETE_WINDOW", False);
- XSetWMProtocols(getDisplay(), win, &delete_atom, 1);
+ 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(getDisplay(), "_NET_WM_STATE_FULLSCREEN", False);
- XChangeProperty(getDisplay(), getCurrentWindow(), XInternAtom(getDisplay(), "_NET_WM_STATE", False),
- XInternAtom(getDisplay(), "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
+ Atom fullscreen_atom = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
+ XChangeProperty(disp, getCurrentWindow(), XInternAtom(disp, "_NET_WM_STATE", False),
+ XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1);
}
- XMapRaised(getDisplay(), win);
- waitMapped(win);
- XClearWindow(getDisplay(), win);
- if (!checkXError(env, getDisplay())) {
- destroyWindow(env);
+ XMapRaised(disp, win);
+ waitMapped(disp, win);
+ XClearWindow(disp, win);
+ if (!checkXError(env, disp)) {
+ destroyWindow(env, disp);
return false;
}
return true;
@@ -380,12 +376,13 @@
return current_win;
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate
- (JNIEnv *env, jobject disp_obj) {
- handleMessages(env, disp_obj);
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate(JNIEnv *env, jobject disp_obj, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ handleMessages(env, disp, disp_obj);
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, 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, 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) {
@@ -398,22 +395,23 @@
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, window_mode, peer_info, x, y, width, height);
+ bool window_created = createWindow(env, disp, window_mode, peer_info, x, y, width, height);
if (!window_created) {
return;
}
if (peer_info->glx13) {
- glx_window = lwjgl_glXCreateWindow(getDisplay(), *fb_config, getCurrentWindow(), NULL);
+ glx_window = lwjgl_glXCreateWindow(disp, *fb_config, getCurrentWindow(), NULL);
XFree(fb_config);
}
- if (!checkXError(env, getDisplay())) {
- lwjgl_glXDestroyWindow(getDisplay(), glx_window);
- destroyWindow(env);
+ if (!checkXError(env, disp)) {
+ lwjgl_glXDestroyWindow(disp, glx_window);
+ destroyWindow(env, disp);
}
}
-JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz) {
- destroyWindow(env);
+JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jclass clazz, jlong display) {
+ Display *disp = (Display *)(intptr_t)display;
+ destroyWindow(env, disp);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
@@ -436,10 +434,10 @@
jawt.Unlock(env);
}
-static void setIcon(JNIEnv *env, char *data, int icon_size, int width,int height) {
+static void setIcon(JNIEnv *env, Display *disp, char *data, int icon_size, int width,int height) {
XWMHints* win_hints;
- freeIconPixmap();
- current_icon_pixmap = XCreatePixmap(getDisplay(), getCurrentWindow(), width, height, current_depth);
+ freeIconPixmap(disp);
+ current_icon_pixmap = XCreatePixmap(disp, getCurrentWindow(), 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)
*/
@@ -450,17 +448,17 @@
return;
}
memcpy(icon_copy, data, icon_size);
- XImage *image = XCreateImage(getDisplay(), current_visual, current_depth, ZPixmap, 0, icon_copy, width, height, 32, 0);
+ XImage *image = XCreateImage(disp, current_visual, current_depth, ZPixmap, 0, icon_copy, width, height, 32, 0);
if (image == NULL) {
- freeIconPixmap();
+ freeIconPixmap(disp);
free(icon_copy);
throwException(env, "XCreateImage failed");
return;
}
- GC gc = XCreateGC(getDisplay(), current_icon_pixmap, 0, NULL);
- XPutImage(getDisplay(), current_icon_pixmap, gc, image, 0, 0, 0, 0, width, height);
- XFreeGC(getDisplay(), gc);
+ GC gc = XCreateGC(disp, current_icon_pixmap, 0, NULL);
+ XPutImage(disp, current_icon_pixmap, gc, image, 0, 0, 0, 0, width, height);
+ XFreeGC(disp, gc);
XDestroyImage(image);
// We won't free icon_copy because it is freed by XDestroyImage
@@ -473,23 +471,20 @@
win_hints->flags = IconPixmapHint;
win_hints->icon_pixmap = current_icon_pixmap;
- XSetWMHints(getDisplay(), getCurrentWindow(), win_hints);
+ XSetWMHints(disp, getCurrentWindow(), win_hints);
XFree(win_hints);
- XFlush(getDisplay());
+ XFlush(disp);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon
- (JNIEnv *env, jclass clazz, jobject iconBuffer, jint icon_size, jint width, jint height)
+ (JNIEnv *env, jclass clazz, jlong display, jobject iconBuffer, jint icon_size, jint width, jint height)
{
+ Display *disp = (Display *)(intptr_t)display;
char *imgData = (char *)(*env)->GetDirectBufferAddress(env, iconBuffer);
- setIcon(env, imgData, icon_size, width, height);
+ setIcon(env, disp, imgData, icon_size, width, height);
}
-JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getDisplay(JNIEnv *env, jclass unused) {
- return (intptr_t)getDisplay();
-}
-
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getWindow(JNIEnv *env, jclass unused) {
return getCurrentWindow();
}
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_LinuxCanvasImplementation.c 2006-10-23 13:58:33 UTC (rev 2591)
@@ -47,13 +47,14 @@
#include "Window.h"
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxCanvasImplementation_nFindVisualIDFromFormat
- (JNIEnv *env, jclass clazz, jint screen, jobject pixel_format) {
+ (JNIEnv *env, jclass clazz, jlong display, jint screen, jobject pixel_format) {
+ Display *disp = (Display *)(intptr_t)display;
GLXExtensions extension_flags;
- if (!extgl_InitGLX(getDisplay(), screen, &extension_flags)) {
+ if (!extgl_InitGLX(disp, screen, &extension_flags)) {
throwException(env, "Could not initialize GLX");
return -1;
}
- XVisualInfo *vis_info = chooseVisualGLX(env, getDisplay(), screen, pixel_format, true, true);
+ XVisualInfo *vis_info = chooseVisualGLX(env, disp, screen, pixel_format, true, true);
if (vis_info == NULL) {
throwException(env, "Could not choose a VisualInfo");
return -1;
Modified: trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c
===================================================================
--- trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c 2006-10-23 10:24:03 UTC (rev 2590)
+++ trunk/LWJGL/src/native/linux/org_lwjgl_opengl_Pbuffer.c 2006-10-23 13:58:33 UTC (rev 2591)
@@ -48,23 +48,25 @@
#include "common_tools.h"
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCapabilities
- (JNIEnv *env, jclass clazz)
+ (JNIEnv *env, jclass clazz, jlong display)
{
+ Display *disp = (Display *)(intptr_t)display;
GLXExtensions extension_flags;
- if (!extgl_InitGLX(getDisplay(), getCurrentScreen(), &extension_flags))
+ if (!extgl_InitGLX(disp, getCurrentScreen(), &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, jobject peer_info_handle, jint width, jint height, jobject pixel_format) {
+ (JNIEnv *env, jclass clazz, jlong display, jobject peer_info_handle, jint width, jint height, jobject pixel_format) {
+ Display *disp = (Display *)(intptr_t)display;
GLXExtensions extension_flags;
- if (!extgl_InitGLX(getDisplay(), getCurrentScreen(), &extension_flags) || !extension_flags.GLX13) {
+ if (!extgl_InitGLX(disp, getCurrentScreen(), &extension_flags) || !extension_flags.GLX13) {
throwException(env, "No Pbuffer support");
return;
}
- bool result = initPeerInfo(env, peer_info_handle, getDisplay(), getCurrentScreen(), pixel_format, false, GLX_PBUFFER_BIT, false, true);
+ bool result = initPeerInfo(env, peer_info_handle, disp, getCurrentScreen(), 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.
|
|
From: <eli...@us...> - 2006-10-23 10:24:13
|
Revision: 2590
http://svn.sourceforge.net/java-game-lib/?rev=2590&view=rev
Author: elias_naur
Date: 2006-10-23 03:24:03 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Linux: Simplified 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-20 12:55:01 UTC (rev 2589)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2006-10-23 10:24:03 UTC (rev 2590)
@@ -718,12 +718,16 @@
if (new_grab != grab) {
grab = new_grab;
updateInputGrab();
- mouse.changeGrabbed(grab, pointer_grabbed, shouldGrab());
+ mouse.changeGrabbed(grab, shouldWarpPointer());
}
} finally {
unlockAWT();
}
}
+
+ private boolean shouldWarpPointer() {
+ return pointer_grabbed && shouldGrab();
+ }
public int getNativeCursorCapabilities() {
lockAWT();
@@ -980,7 +984,7 @@
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, pointer_grabbed, shouldGrab(), millis, root_window, x_root, y_root, x, y);
+ mouse.handlePointerMotion(grab, shouldWarpPointer(), millis, root_window, x_root, y_root, x, y);
}
private void handleWarpEvent(int x, int y) {
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-20 12:55:01 UTC (rev 2589)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java 2006-10-23 10:24:03 UTC (rev 2590)
@@ -135,9 +135,9 @@
}
private static native void nSendWarpEvent(long display, long window, int center_x, int center_y);
- private void doHandlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long root_window, int root_x, int root_y, int win_x, int win_y, long nanos) {
+ 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);
- if (!pointer_grabbed || !should_grab)
+ if (!warp_pointer)
return;
int root_window_height = nGetWindowHeight(display, root_window);
int root_window_width = nGetWindowWidth(display, root_window);
@@ -165,10 +165,10 @@
}
}
- public void changeGrabbed(boolean grab, boolean pointer_grabbed, boolean should_grab) {
+ public void changeGrabbed(boolean grab, boolean warp_pointer) {
reset();
long root_window = nQueryPointer(display, window, query_pointer_buffer);
- doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, query_pointer_buffer.get(0), query_pointer_buffer.get(1), query_pointer_buffer.get(2), query_pointer_buffer.get(3), last_event_nanos);
+ doHandlePointerMotion(grab, warp_pointer, root_window, query_pointer_buffer.get(0), query_pointer_buffer.get(1), query_pointer_buffer.get(2), query_pointer_buffer.get(3), last_event_nanos);
}
public int getButtonCount() {
@@ -188,8 +188,8 @@
}
private static native void nWarpCursor(long display, long window, int x, int y);
- public void handlePointerMotion(boolean grab, boolean pointer_grabbed, boolean should_grab, long millis, long root_window, int x_root, int y_root, int x, int y) {
- doHandlePointerMotion(grab, pointer_grabbed, should_grab, root_window, x_root, y_root, x, y, millis*1000000);
+ public 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);
}
private void handleButton(boolean grab, int button, byte state, long nanos) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|