diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/classes/com/sun/javafx/newt/NewtFactory.java | 2 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Window.java | 6 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/windows/WindowsWindow.java | 21 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/x11/X11Window.java | 4 | ||||
-rw-r--r-- | src/classes/javax/media/opengl/NativeWindow.java | 2 | ||||
-rwxr-xr-x | src/native/jogl/X11Window.c | 50 |
6 files changed, 38 insertions, 47 deletions
diff --git a/src/classes/com/sun/javafx/newt/NewtFactory.java b/src/classes/com/sun/javafx/newt/NewtFactory.java index e0281eafa..addc867d0 100755 --- a/src/classes/com/sun/javafx/newt/NewtFactory.java +++ b/src/classes/com/sun/javafx/newt/NewtFactory.java @@ -72,7 +72,7 @@ public abstract class NewtFactory { return Screen.create(getWindowType(), display, index); } - public static Window createWindow(Screen screen, long visualID) { + public static Window createWindow(Screen screen, int visualID) { return Window.create(getWindowType(), screen, visualID); } diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java index 16984d1f3..71559ede2 100755 --- a/src/classes/com/sun/javafx/newt/Window.java +++ b/src/classes/com/sun/javafx/newt/Window.java @@ -45,7 +45,7 @@ public abstract class Window implements NativeWindow public static final boolean DEBUG_KEY_EVENT = false; public static final boolean DEBUG_IMPLEMENTATION = true; - protected static Window create(String type, Screen screen, long visualID) { + protected static Window create(String type, Screen screen, int visualID) { try { Class windowClass = null; if (NewtFactory.KD.equals(type)) { @@ -89,7 +89,7 @@ public abstract class Window implements NativeWindow } protected Screen screen; - protected long visualID; + protected int visualID; protected long windowHandle; protected boolean locked; @@ -132,7 +132,7 @@ public abstract class Window implements NativeWindow return windowHandle; } - public long getVisualID() { + public int getVisualID() { return visualID; } diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java index c392cb20e..01f763f0f 100755 --- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java +++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java @@ -37,10 +37,7 @@ import com.sun.javafx.newt.*; import com.sun.opengl.impl.*; public class WindowsWindow extends Window { - private Screen screen; - private long visualID; private boolean fullscreen, visible; - private long window; // Default width and height -- will likely be re-set immediately by user private int width = 100; private int height = 100; @@ -72,12 +69,12 @@ public class WindowsWindow extends Window { public void setVisible(boolean visible) { if(this.visible!=visible) { this.visible=visible; - setVisible0(window, visible); + setVisible0(windowHandle, visible); } } public void setSize(int width, int height) { - setSize0(window, width, height); + setSize0(windowHandle, width, height); } public void setPosition(int x, int y) { @@ -106,7 +103,7 @@ public class WindowsWindow extends Window { public boolean setFullscreen(boolean fullscreen) { if(this.fullscreen!=fullscreen) { this.fullscreen=fullscreen; - return setFullScreen0(window, fullscreen); + return setFullScreen0(windowHandle, fullscreen); } return true; } @@ -124,7 +121,7 @@ public class WindowsWindow extends Window { } public void pumpMessages() { - DispatchMessages(window); + DispatchMessages(windowHandle); } //---------------------------------------------------------------------- @@ -156,12 +153,12 @@ public class WindowsWindow extends Window { private static native boolean initIDs(); private static native long LoadLibraryW(String libraryName); private static native long RegisterWindowClass(String windowClassName, long hInstance); - private native long CreateWindow(String windowClassName, long hInstance, long visualID, + private native long CreateWindow(String windowClassName, long hInstance, int visualID, int x, int y, int width, int height); - private native void setVisible0(long window, boolean visible); - private static native void DispatchMessages(long window); - private native void setSize0(long window, int width, int height); - private native boolean setFullScreen0(long window, boolean fullscreen); + private native void setVisible0(long windowHandle, boolean visible); + private static native void DispatchMessages(long windowHandle); + private native void setSize0(long windowHandle, int width, int height); + private native boolean setFullScreen0(long windowHandle, boolean fullscreen); private void sizeChanged(int newWidth, int newHeight) { width = newWidth; diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java index d89cd1169..d9a6e07ba 100755 --- a/src/classes/com/sun/javafx/newt/x11/X11Window.java +++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java @@ -144,7 +144,7 @@ public class X11Window extends Window { private static native boolean initIDs(); private native long CreateWindow(long display, long screen, int screen_index, - long visualID, int x, int y, int width, int height); + int visualID, int x, int y, int width, int height); private native void setVisible0(long display, long windowHandle, boolean visible); private native void DispatchMessages(long display, long windowHandle); private native void setSize0(long display, long windowHandle, int width, int height); @@ -170,7 +170,7 @@ public class X11Window extends Window { } } - private void windowCreated(long visualID, long windowHandle) { + private void windowCreated(int visualID, long windowHandle) { this.visualID = visualID; this.windowHandle = windowHandle; } diff --git a/src/classes/javax/media/opengl/NativeWindow.java b/src/classes/javax/media/opengl/NativeWindow.java index 98e5edc68..a93037bee 100644 --- a/src/classes/javax/media/opengl/NativeWindow.java +++ b/src/classes/javax/media/opengl/NativeWindow.java @@ -52,7 +52,7 @@ public interface NativeWindow { public long getScreenHandle(); public int getScreenIndex(); public long getWindowHandle(); - public long getVisualID(); + public int getVisualID(); public void setSize(int width, int height); public void setPosition(int x, int y); diff --git a/src/native/jogl/X11Window.c b/src/native/jogl/X11Window.c index c60fd2f9b..54f28f2a1 100755 --- a/src/native/jogl/X11Window.c +++ b/src/native/jogl/X11Window.c @@ -44,16 +44,13 @@ #include "MouseEvent.h" #include "KeyEvent.h" -// This is set by DispatchMessages, below, and cleared when it exits -static JNIEnv* env = NULL; - #define VERBOSE_ON 1 #ifdef VERBOSE_ON static void _dumpVisualInfo(const char * msg, XVisualInfo *pVisualQuery) { if(pVisualQuery!=NULL) { - fprintf(stderr, "%s: screen %d, visual: %p, visual-id: 0x%X, depth: %d, class %d, cmap sz: %d, bpp: %d, rgb 0x%X 0x%X 0x%X\n", + fprintf(stderr, "%s: screen %d, visual: %p, visual-id: 0x%X, depth: %d, class %d, cmap sz: %d, bpp: 3x%d, rgb 0x%X 0x%X 0x%X\n", msg, pVisualQuery->screen, pVisualQuery->visual, @@ -155,7 +152,7 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Window_initIDs positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(II)V"); windowClosedID = (*env)->GetMethodID(env, clazz, "windowClosed", "()V"); windowDestroyedID = (*env)->GetMethodID(env, clazz, "windowDestroyed", "()V"); - windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(JJ)V"); + windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(IJ)V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIII)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (sizeChangedID == NULL || @@ -173,11 +170,11 @@ JNIEXPORT jboolean JNICALL Java_com_sun_javafx_newt_x11_X11Window_initIDs /* * Class: com_sun_javafx_newt_x11_X11Window * Method: CreateWindow - * Signature: (JJJIIIII)J + * Signature: (JJIIIIII)J */ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow (JNIEnv *env, jobject obj, jlong display, jlong screen, jint screen_index, - jlong visualID, + jint visualID, jint x, jint y, jint width, jint height) { Display * dpy = NULL; @@ -208,7 +205,6 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow return 0; } - visualID=33; if(visualID>0) { // try given VisualID on screen memset(&visualTemplate, 0, sizeof(XVisualInfo)); @@ -224,17 +220,19 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow pVisualQuery=NULL; } #ifdef VERBOSE_ON - fprintf(stderr, "trying given (screen %d, visualID: %d) found: %d\n", scrn_idx, visualID, (visual!=NULL)); + fprintf(stderr, "trying given (screen %d, visualID: %d) found: %p\n", scrn_idx, visualID, visual); #endif } if (visual==NULL) { // try depth >=15 on screen memset(&visualTemplate, 0, sizeof(XVisualInfo)); - visualTemplate.screen = scrn_idx; - visualTemplate.depth = 15; - pVisualQuery = XGetVisualInfo(dpy, VisualScreenMask|VisualDepthMask, &visualTemplate,&n); - DUMP_VISUAL_INFO("Given VisualID,ScreenIdx", pVisualQuery); + visualTemplate.class = TrueColor; + //visualTemplate.screen = scrn_idx; + visualTemplate.depth = 16; + visualTemplate.bits_per_rgb = 5; + pVisualQuery = XGetVisualInfo(dpy, VisualClassMask|VisualDepthMask|VisualBitsPerRGBMask, &visualTemplate,&n); + DUMP_VISUAL_INFO("Given ScreenIdx, depth>=15, bpp:15", pVisualQuery); if(pVisualQuery!=NULL) { visual = pVisualQuery->visual; depth = pVisualQuery->depth; @@ -243,13 +241,13 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow pVisualQuery=NULL; } #ifdef VERBOSE_ON - fprintf(stderr, "trying (screen %d, depth >= 15) found: %d, id: %d\n", scrn_idx, (visual!=NULL), visualID); + fprintf(stderr, "trying (screen %d, depth >= 15, rgb >=15) found: %p, id: %d\n", scrn_idx, visual, visualID); #endif } if (visual==NULL) { // try default .. - Visual * visual = XDefaultVisualOfScreen(scrn); + visual = XDefaultVisualOfScreen(scrn); if(visual!=NULL) { visualID = visual->visualid; // try given VisualID on screen @@ -257,6 +255,7 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow visualTemplate.screen = scrn_idx; visualTemplate.visualid = (VisualID)visualID; pVisualQuery = XGetVisualInfo(dpy, VisualIDMask|VisualScreenMask, &visualTemplate,&n); + DUMP_VISUAL_INFO("Given ScreenIdx, Default VisualID", pVisualQuery); if(pVisualQuery!=NULL) { visual = pVisualQuery->visual; depth = pVisualQuery->depth; @@ -268,11 +267,10 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow visualID = 0; } #ifdef VERBOSE_ON - fprintf(stderr, "default visual (screen %d, visualID: %d) found: %d\n", scrn_idx, visualID, (visual!=NULL)); + fprintf(stderr, "default visual (screen %d, visualID: %d) found: %p\n", scrn_idx, visualID, visual); #endif } } - DUMP_VISUAL_INFO("Choosen", pVisualQuery); if (visual==NULL) { fprintf(stderr, "could not query any Visual, bail out!\n"); @@ -308,13 +306,9 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_x11_X11Window_CreateWindow attrMask, &xswa); XClearWindow(dpy, window); - XMapRaised(dpy, window); - (*env)->CallVoidMethod(env, obj, windowCreatedID, (jlong) visualID, (jlong) window); + (*env)->CallVoidMethod(env, obj, windowCreatedID, visualID, (jlong) window); - XSelectInput(dpy, window, ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask| - KeyPressMask|KeyReleaseMask); - XSetInputFocus(dpy, window, RevertToNone, CurrentTime); return (jlong) window; } @@ -329,14 +323,14 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_setVisible0 Display * dpy = (Display *) (intptr_t) display; Window w = (Window)window; if(visible==JNI_TRUE) { - XMapRaise(dpy, window); + XMapRaised(dpy, w); - XSelectInput(dpy, window, ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask| + XSelectInput(dpy, w, ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask| KeyPressMask|KeyReleaseMask); - XSetInputFocus(dpy, window, RevertToNone, CurrentTime); + XSetInputFocus(dpy, w, RevertToNone, CurrentTime); } else { - XSelectInput(dpy, window, 0); - XUnmapWindow(dpy, window); + XSelectInput(dpy, w, 0); + XUnmapWindow(dpy, w); } } @@ -350,10 +344,10 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_DispatchMessages { Display * dpy = (Display *) (intptr_t) display; Window w = (Window)window; + (void) w; // unused for now, might be necessary to verify the event source // Periodically take a break while( XPending(dpy)>0 ) { - int eventType; XEvent evt; KeySym keySym; char keyChar; |