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. |