aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/javafx
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com/sun/javafx')
-rwxr-xr-xsrc/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java4
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Display.java42
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/NewtFactory.java80
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Screen.java44
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Window.java143
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsDisplay.java46
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsScreen.java46
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/windows/WindowsWindow.java24
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Display.java59
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Screen.java59
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/x11/X11Window.java61
11 files changed, 448 insertions, 160 deletions
diff --git a/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java b/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java
index e4ade6375..2040c55d1 100755
--- a/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java
+++ b/src/classes/com/sun/javafx/audio/windows/waveout/TestSpatialization.java
@@ -44,7 +44,9 @@ public class TestSpatialization {
try {
// FIXME: this is a hack to get the native library loaded
- GLDrawableFactory.getFactory();
+ try {
+ GLDrawableFactory.getFactory(GLDrawableFactory.PROFILE_GLES1, null);
+ } catch (Exception e) {}
// Initialize the audio subsystem
Audio audio = Audio.getInstance();
// Create a track
diff --git a/src/classes/com/sun/javafx/newt/Display.java b/src/classes/com/sun/javafx/newt/Display.java
index 7be9a1b12..5ec2c381a 100755
--- a/src/classes/com/sun/javafx/newt/Display.java
+++ b/src/classes/com/sun/javafx/newt/Display.java
@@ -33,16 +33,33 @@
package com.sun.javafx.newt;
-public class Display {
+public abstract class Display {
- public Display() {
- this(null);
+ protected static Display create(String type, String name) {
+ try {
+ Class displayClass = null;
+ if (NewtFactory.KD.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.kd.KDDisplay");
+ } else if (NewtFactory.WINDOWS.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.displays.WindowsDisplay");
+ } else if (NewtFactory.X11.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.x11.X11Display");
+ } else if (NewtFactory.MACOSX.equals(type)) {
+ displayClass = Class.forName("com.sun.javafx.newt.macosx.MacOSXDisplay");
+ } else {
+ throw new RuntimeException("Unknown display type \"" + type + "\"");
+ }
+ Display display = (Display) displayClass.newInstance();
+ display.name=name;
+ display.handle=0;
+ display.initNative();
+ return display;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
- public Display(String name) {
- this.name=name;
- this.handle=-1;
- }
+ protected abstract void initNative();
public String getName() {
return name;
@@ -52,17 +69,6 @@ public class Display {
return handle;
}
- /**
- * native handle
- *
- * write once ..
- */
- public void setHandle(long handle) {
- if(this.handle<0) {
- this.handle=handle;
- }
- }
-
protected String name;
protected long handle;
}
diff --git a/src/classes/com/sun/javafx/newt/NewtFactory.java b/src/classes/com/sun/javafx/newt/NewtFactory.java
new file mode 100755
index 000000000..e0281eafa
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/NewtFactory.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public abstract class NewtFactory {
+ /** OpenKODE window type */
+ public static final String KD = "KD";
+
+ /** Microsoft Windows window type */
+ public static final String WINDOWS = "Windows";
+
+ /** X11 window type */
+ public static final String X11 = "X11";
+
+ /** Mac OS X window type */
+ public static final String MACOSX = "MacOSX";
+
+ /** Creates a Window of the default type for the current operating system. */
+ public static String getWindowType() {
+ String osName = System.getProperty("os.name");
+ String osNameLowerCase = osName.toLowerCase();
+ String windowType;
+ if (osNameLowerCase.startsWith("wind")) {
+ windowType = WINDOWS;
+ } else if (osNameLowerCase.startsWith("mac os x")) {
+ windowType = MACOSX;
+ } else {
+ windowType = X11;
+ }
+ return windowType;
+ }
+
+ public static Display createDisplay(String name) {
+ return Display.create(getWindowType(), name);
+ }
+
+ public static Screen createScreen(Display display, int index) {
+ return Screen.create(getWindowType(), display, index);
+ }
+
+ public static Window createWindow(Screen screen, long visualID) {
+ return Window.create(getWindowType(), screen, visualID);
+ }
+
+}
+
diff --git a/src/classes/com/sun/javafx/newt/Screen.java b/src/classes/com/sun/javafx/newt/Screen.java
index b698a0248..9252b30d4 100755
--- a/src/classes/com/sun/javafx/newt/Screen.java
+++ b/src/classes/com/sun/javafx/newt/Screen.java
@@ -33,17 +33,34 @@
package com.sun.javafx.newt;
-public class Screen {
+public abstract class Screen {
- public Screen(Display display) {
- this(display, 0);
+ protected static Screen create(String type, Display display, int idx) {
+ try {
+ Class screenClass = null;
+ if (NewtFactory.KD.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.kd.KDScreen");
+ } else if (NewtFactory.WINDOWS.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.screens.WindowsScreen");
+ } else if (NewtFactory.X11.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.x11.X11Screen");
+ } else if (NewtFactory.MACOSX.equals(type)) {
+ screenClass = Class.forName("com.sun.javafx.newt.macosx.MacOSXScreen");
+ } else {
+ throw new RuntimeException("Unknown window type \"" + type + "\"");
+ }
+ Screen screen = (Screen) screenClass.newInstance();
+ screen.display = display;
+ screen.index = idx;
+ screen.handle = 0;
+ screen.initNative();
+ return screen;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
- public Screen(Display display, int idx) {
- this.display=display;
- this.index=idx;
- this.handle=-1;
- }
+ protected abstract void initNative();
public Display getDisplay() {
return display;
@@ -57,17 +74,6 @@ public class Screen {
return handle;
}
- /**
- * native handle
- *
- * write once ..
- */
- public void setHandle(long handle) {
- if(this.handle<0) {
- this.handle=handle;
- }
- }
-
protected Display display;
protected int index;
protected long handle;
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java
index 27610cdf2..16984d1f3 100755
--- a/src/classes/com/sun/javafx/newt/Window.java
+++ b/src/classes/com/sun/javafx/newt/Window.java
@@ -33,101 +33,120 @@
package com.sun.javafx.newt;
+import javax.media.opengl.NativeWindow;
+import javax.media.opengl.NativeWindowException;
+
import java.util.ArrayList;
import java.util.Iterator;
-public abstract class Window {
+public abstract class Window implements NativeWindow
+{
public static final boolean DEBUG_MOUSE_EVENT = false;
public static final boolean DEBUG_KEY_EVENT = false;
+ public static final boolean DEBUG_IMPLEMENTATION = true;
- /** OpenKODE window type */
- public static final String KD = "KD";
-
- /** Microsoft Windows window type */
- public static final String WINDOWS = "Windows";
-
- /** X11 window type */
- public static final String X11 = "X11";
-
- /** Mac OS X window type */
- public static final String MACOSX = "MacOSX";
-
- /** Creates a Window of the default type for the current operating system. */
- public static Window create(Screen screen, long visualID) {
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
- String windowType;
- if (osNameLowerCase.startsWith("wind")) {
- windowType = WINDOWS;
- } else if (osNameLowerCase.startsWith("mac os x")) {
- windowType = MACOSX;
- } else {
- windowType = X11;
- }
- Window window = create(windowType);
- window.initNative(screen, visualID);
- return window;
- }
-
-
- public static Window create(String type) {
+ protected static Window create(String type, Screen screen, long visualID) {
try {
Class windowClass = null;
- if (KD.equals(type)) {
+ if (NewtFactory.KD.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.kd.KDWindow");
- } else if (WINDOWS.equals(type)) {
+ } else if (NewtFactory.WINDOWS.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.windows.WindowsWindow");
- } else if (X11.equals(type)) {
+ } else if (NewtFactory.X11.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.x11.X11Window");
- } else if (MACOSX.equals(type)) {
+ } else if (NewtFactory.MACOSX.equals(type)) {
windowClass = Class.forName("com.sun.javafx.newt.macosx.MacOSXWindow");
} else {
throw new RuntimeException("Unknown window type \"" + type + "\"");
}
- return (Window) windowClass.newInstance();
+ Window window = (Window) windowClass.newInstance();
+ window.screen = screen;
+ window.visualID = visualID;
+ window.windowHandle = 0;
+ window.locked = false;
+ window.initNative();
+ return window;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
+ protected abstract void initNative();
- /**
- * [ display, screen, window ]
- */
- public long[] getHandles() {
- long[] handles = new long[3];
- handles[0] = getScreen().getDisplay().getHandle();
- handles[1] = getScreen().getHandle();
- handles[2] = getWindowHandle();
- return handles;
+ public Screen getScreen() {
+ return screen;
}
- protected abstract void initNative(Screen screen, long visualID);
-
- public abstract void setVisible(boolean visible);
- public abstract void setSize(int width, int height);
- public abstract void setPosition(int x, int y);
- public abstract boolean isVisible();
- public abstract int getWidth();
- public abstract int getHeight();
- public abstract int getX();
- public abstract int getY();
- public abstract boolean setFullscreen(boolean fullscreen);
- public abstract boolean isFullscreen();
public abstract int getDisplayWidth();
public abstract int getDisplayHeight();
- public abstract Screen getScreen();
- public abstract long getWindowHandle();
-
public abstract void pumpMessages();
public String toString() {
- return "Window[handle "+getWindowHandle()+
+ return "Window[handle "+windowHandle+
", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+
", visible "+isVisible()+"]";
}
+ protected Screen screen;
+ protected long visualID;
+ protected long windowHandle;
+ protected boolean locked;
+
+ //
+ // NativeWindow impl
+ //
+
+ public boolean lockSurface() throws NativeWindowException {
+ if (locked) {
+ throw new NativeWindowException("Surface already locked");
+ }
+ locked = true;
+ return true;
+ }
+
+ public void unlockSurface() {
+ if (!locked) {
+ throw new NativeWindowException("Surface already locked");
+ }
+ locked = false;
+ }
+
+ public boolean isSurfaceLocked() {
+ return locked;
+ }
+
+ public long getDisplayHandle() {
+ return screen.getDisplay().getHandle();
+ }
+
+ public long getScreenHandle() {
+ return screen.getHandle();
+ }
+
+ public int getScreenIndex() {
+ return screen.getIndex();
+ }
+
+ public long getWindowHandle() {
+ return windowHandle;
+ }
+
+ public long getVisualID() {
+ return visualID;
+ }
+
+ public abstract int getWidth();
+ public abstract int getHeight();
+ public abstract int getX();
+ public abstract int getY();
+ public abstract void setVisible(boolean visible);
+ public abstract void setSize(int width, int height);
+ public abstract void setPosition(int x, int y);
+ public abstract boolean isVisible();
+ public abstract boolean setFullscreen(boolean fullscreen);
+ public abstract boolean isFullscreen();
+
//
// MouseListener Support
//
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsDisplay.java b/src/classes/com/sun/javafx/newt/windows/WindowsDisplay.java
new file mode 100755
index 000000000..ce2ac8c4a
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsDisplay.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.windows;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class WindowsDisplay extends Display {
+ public WindowsDisplay() {
+ }
+
+ public void initNative() {
+ handle = 0;
+ }
+}
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsScreen.java b/src/classes/com/sun/javafx/newt/windows/WindowsScreen.java
new file mode 100755
index 000000000..cf163ce48
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsScreen.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.windows;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class WindowsScreen extends Screen {
+ public WindowsScreen() {
+ }
+
+ public void initNative() {
+ handle = 0;
+ }
+}
diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index e170f9b56..c392cb20e 100755
--- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -59,22 +59,14 @@ public class WindowsWindow extends Window {
public WindowsWindow() {
}
- public void initNative(Screen screen, long visualID) {
- this.screen = screen;
- this.visualID = visualID;
+ public void initNative() {
long wndClass = getWindowClass();
fullscreen=false;
visible=false;
- window = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), visualID, x, y, width, height);
- if (window == 0) {
+ windowHandle = CreateWindow(WINDOW_CLASS_NAME, getHInstance(), visualID, x, y, width, height);
+ if (windowHandle == 0) {
throw new RuntimeException("Error creating window");
}
- screen.setHandle(0); // dummy
- screen.getDisplay().setHandle(0); // dummy
- }
-
- public Screen getScreen() {
- return screen;
}
public void setVisible(boolean visible) {
@@ -131,10 +123,6 @@ public class WindowsWindow extends Window {
return 480; // FIXME
}
- public long getWindowHandle() {
- return window;
- }
-
public void pumpMessages() {
DispatchMessages(window);
}
@@ -175,12 +163,6 @@ public class WindowsWindow extends Window {
private native void setSize0(long window, int width, int height);
private native boolean setFullScreen0(long window, boolean fullscreen);
- private void keyDown(long key) {
- }
-
- private void keyUp(long key) {
- }
-
private void sizeChanged(int newWidth, int newHeight) {
width = newWidth;
height = newHeight;
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Display.java b/src/classes/com/sun/javafx/newt/x11/X11Display.java
new file mode 100755
index 000000000..5a4ed8eed
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/x11/X11Display.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.x11;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class X11Display extends Display {
+ static {
+ NativeLibLoader.loadCore();
+ }
+
+ public X11Display() {
+ }
+
+ public void initNative() {
+ handle = CreateDisplay(name);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating display: "+name);
+ }
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ private native long CreateDisplay(String name);
+}
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Screen.java b/src/classes/com/sun/javafx/newt/x11/X11Screen.java
new file mode 100755
index 000000000..279507fab
--- /dev/null
+++ b/src/classes/com/sun/javafx/newt/x11/X11Screen.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution 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 Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.sun.javafx.newt.x11;
+
+import com.sun.javafx.newt.*;
+import com.sun.opengl.impl.*;
+
+public class X11Screen extends Screen {
+ static {
+ NativeLibLoader.loadCore();
+ }
+
+ public X11Screen() {
+ }
+
+ public void initNative() {
+ handle = GetScreen(display.getHandle(), index);
+ if (handle == 0 ) {
+ throw new RuntimeException("Error creating screen: "+index);
+ }
+ }
+
+ //----------------------------------------------------------------------
+ // Internals only
+ //
+
+ private native long GetScreen(long dpy, int scrn_idx);
+}
diff --git a/src/classes/com/sun/javafx/newt/x11/X11Window.java b/src/classes/com/sun/javafx/newt/x11/X11Window.java
index 80021dca4..d89cd1169 100755
--- a/src/classes/com/sun/javafx/newt/x11/X11Window.java
+++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java
@@ -37,10 +37,6 @@ import com.sun.javafx.newt.*;
import com.sun.opengl.impl.*;
public class X11Window extends Window {
- private Screen screen;
- private long visualID;
- private long dpy, scrn, window;
- private int scrn_idx;
private static final String WINDOW_CLASS_NAME = "NewtWindow";
// Default width and height -- will likely be re-set immediately by user
private int width = 100;
@@ -62,36 +58,28 @@ public class X11Window extends Window {
public X11Window() {
}
- public void initNative(Screen screen, long visualID) {
- this.screen = screen;
- this.visualID = visualID;
+ public void initNative() {
fullscreen=false;
visible=false;
- long w = CreateWindow(visualID, x, y, width, height);
- if (w == 0 || w!=window) {
+ long w = CreateWindow(getDisplayHandle(), getScreenHandle(), getScreenIndex(), visualID, x, y, width, height);
+ if (w == 0 || w!=windowHandle) {
throw new RuntimeException("Error creating window: "+w);
}
- screen.setHandle(scrn);
- screen.getDisplay().setHandle(dpy);
- }
-
- public Screen getScreen() {
- return screen;
}
public void setVisible(boolean visible) {
if(this.visible!=visible) {
this.visible=visible;
- setVisible0(dpy, window, visible);
+ setVisible0(getDisplayHandle(), windowHandle, visible);
}
}
public void setSize(int width, int height) {
- setSize0(dpy, window, width, height);
+ setSize0(getDisplayHandle(), windowHandle, width, height);
}
public void setPosition(int x, int y) {
- setPosition0(dpy, window, x, y);
+ setPosition0(getDisplayHandle(), windowHandle, x, y);
}
public boolean isVisible() {
@@ -120,16 +108,16 @@ public class X11Window extends Window {
this.fullscreen=fullscreen;
if(this.fullscreen) {
x = 0; y = 0;
- w = getDisplayWidth0(dpy, scrn_idx)/2;
- h = getDisplayHeight0(dpy, scrn_idx)/2;
+ w = getDisplayWidth0(getDisplayHandle(), getScreenIndex())/2;
+ h = getDisplayHeight0(getDisplayHandle(), getScreenIndex())/2;
} else {
x = nfs_x;
y = nfs_y;
w = nfs_width;
h = nfs_height;
}
- setPosition0(dpy, window, x, y);
- setSize0(dpy, window, w, h);
+ setPosition0(getDisplayHandle(), windowHandle, x, y);
+ setSize0(getDisplayHandle(), windowHandle, w, h);
}
return true;
}
@@ -138,20 +126,16 @@ public class X11Window extends Window {
return fullscreen;
}
- public long getWindowHandle() {
- return window;
- }
-
public void pumpMessages() {
- DispatchMessages(dpy, window);
+ DispatchMessages(getDisplayHandle(), windowHandle);
}
public int getDisplayWidth() {
- return getDisplayWidth0(dpy, scrn_idx);
+ return getDisplayWidth0(getDisplayHandle(), getScreenIndex());
}
public int getDisplayHeight() {
- return getDisplayHeight0(dpy, scrn_idx);
+ return getDisplayHeight0(getDisplayHandle(), getScreenIndex());
}
//----------------------------------------------------------------------
@@ -159,11 +143,12 @@ public class X11Window extends Window {
//
private static native boolean initIDs();
- private native long CreateWindow(long visualID, int x, int y, int width, int height);
- private native void setVisible0(long display, long window, boolean visible);
- private native void DispatchMessages(long display, long window);
- private native void setSize0(long display, long window, int width, int height);
- private native void setPosition0(long display, long window, int x, int y);
+ private native long CreateWindow(long display, long screen, int screen_index,
+ long 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);
+ private native void setPosition0(long display, long windowHandle, int x, int y);
private native int getDisplayWidth0(long display, int scrn_idx);
private native int getDisplayHeight0(long display, int scrn_idx);
@@ -185,11 +170,9 @@ public class X11Window extends Window {
}
}
- private void windowCreated(long dpy, int scrn_idx, long scrn, long window) {
- this.dpy = dpy;
- this.scrn_idx = scrn_idx;
- this.scrn = scrn;
- this.window = window;
+ private void windowCreated(long visualID, long windowHandle) {
+ this.visualID = visualID;
+ this.windowHandle = windowHandle;
}
private void windowClosed() {