diff options
Diffstat (limited to 'src/classes/com')
-rw-r--r-- | src/classes/com/sun/javafx/newt/GLWindow.java | 8 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/NewtFactory.java | 11 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Screen.java | 34 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/Window.java | 3 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/kd/KDScreen.java | 2 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/kd/KDWindow.java | 35 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/windows/WindowsWindow.java | 8 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/x11/X11Screen.java | 5 | ||||
-rwxr-xr-x | src/classes/com/sun/javafx/newt/x11/X11Window.java | 16 |
9 files changed, 71 insertions, 51 deletions
diff --git a/src/classes/com/sun/javafx/newt/GLWindow.java b/src/classes/com/sun/javafx/newt/GLWindow.java index 89886c24f..10e1f1db5 100644 --- a/src/classes/com/sun/javafx/newt/GLWindow.java +++ b/src/classes/com/sun/javafx/newt/GLWindow.java @@ -153,14 +153,6 @@ public class GLWindow extends Window implements GLAutoDrawable { window.close(); } - public int getDisplayWidth() { - return window.getDisplayWidth(); - } - - public int getDisplayHeight() { - return window.getDisplayHeight(); - } - public boolean getPerfLogEnabled() { return perfLog; } public void enablePerfLog(boolean v) { diff --git a/src/classes/com/sun/javafx/newt/NewtFactory.java b/src/classes/com/sun/javafx/newt/NewtFactory.java index d277fc65e..ffd530082 100755 --- a/src/classes/com/sun/javafx/newt/NewtFactory.java +++ b/src/classes/com/sun/javafx/newt/NewtFactory.java @@ -53,6 +53,17 @@ public abstract class NewtFactory { /** Generic AWT wrapped window type, if available */ public static final String AWT = "AWT"; + public static int getPropertyIntValue(String propname) { + int i=0; + String s = System.getProperty(propname); + if(null!=s) { + try { + i = Integer.valueOf(s).intValue(); + } catch (NumberFormatException nfe) {} + } + return i; + } + /** Creates a Window of the default type for the current operating system. */ public static String getWindowType() { String osName = System.getProperty("newt.ws.name"); diff --git a/src/classes/com/sun/javafx/newt/Screen.java b/src/classes/com/sun/javafx/newt/Screen.java index 7a4209826..4cd8ee5c3 100755 --- a/src/classes/com/sun/javafx/newt/Screen.java +++ b/src/classes/com/sun/javafx/newt/Screen.java @@ -57,6 +57,11 @@ public abstract class Screen { protected static Screen create(String type, Display display, int idx) { try { + if(usrWidth<0 || usrHeight<0) { + usrWidth = NewtFactory.getPropertyIntValue("newt.ws.swidth"); + usrHeight = NewtFactory.getPropertyIntValue("newt.ws.sheight"); + System.out.println("User screen size "+usrWidth+"x"+usrHeight); + } Class screenClass = getScreenClass(type); Screen screen = (Screen) screenClass.newInstance(); screen.display = display; @@ -96,8 +101,37 @@ public abstract class Screen { return handle; } + /** + * The actual implementation shall return the detected display value, + * if not we return 800. + * This can be overwritten with the user property 'newt.ws.swidth', + */ + public int getWidth() { + return (usrWidth>0) ? usrWidth : (width>0) ? width : 480; + } + + /** + * The actual implementation shall return the detected display value, + * if not we return 480. + * This can be overwritten with the user property 'newt.ws.sheight', + */ + public int getHeight() { + return (usrHeight>0) ? usrHeight : (height>0) ? height : 480; + } + + /** + * The actual implementation shall call this function + * to set the detected screen size + */ + public void setScreenSize(int w, int h) { + System.out.println("Detected screen size "+w+"x"+h); + width=w; height=h; + } + protected Display display; protected int index; protected long handle; + protected int width=-1, height=-1; // detected values: set using setScreenSize + protected static int usrWidth=-1, usrHeight=-1; // property values: newt.ws.swidth and newt.ws.sheight } diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java index a2db7623b..6928c3397 100755 --- a/src/classes/com/sun/javafx/newt/Window.java +++ b/src/classes/com/sun/javafx/newt/Window.java @@ -128,9 +128,6 @@ public abstract class Window implements NativeWindow return screen; } - public abstract int getDisplayWidth(); - public abstract int getDisplayHeight(); - /** * eventMask is a bitfield of EventListener event flags */ diff --git a/src/classes/com/sun/javafx/newt/kd/KDScreen.java b/src/classes/com/sun/javafx/newt/kd/KDScreen.java index f635c8757..5d576356d 100755 --- a/src/classes/com/sun/javafx/newt/kd/KDScreen.java +++ b/src/classes/com/sun/javafx/newt/kd/KDScreen.java @@ -42,5 +42,7 @@ public class KDScreen extends Screen { protected void createNative() { handle = 0; + width=-1; + height=-1; } } diff --git a/src/classes/com/sun/javafx/newt/kd/KDWindow.java b/src/classes/com/sun/javafx/newt/kd/KDWindow.java index 3ac502111..ebd8edc36 100755 --- a/src/classes/com/sun/javafx/newt/kd/KDWindow.java +++ b/src/classes/com/sun/javafx/newt/kd/KDWindow.java @@ -42,10 +42,6 @@ import javax.media.opengl.NativeWindowException; public class KDWindow extends Window { private static final String WINDOW_CLASS_NAME = "NewtWindow"; - // fullscreen size - // this will be correct _after_ setting fullscreen on, - // but KD has no method to ask for the display size - private int fs_width=800, fs_height=480; // non fullscreen dimensions .. private int nfs_width, nfs_height, nfs_x, nfs_y; @@ -79,15 +75,17 @@ public class KDWindow extends Window { chosenCaps = config.getCapabilities(); windowHandle = 0; - eglWindowHandle = CreateWindow(getDisplayHandle(), visualID, eglRenderableType); + windowID = ++_windowID; + eglWindowHandle = CreateWindow(windowID, getDisplayHandle(), visualID, eglRenderableType); if (eglWindowHandle == 0) { throw new RuntimeException("Error creating egl window: "+eglWindowHandle); } setVisible0(eglWindowHandle, false); + /* windowHandle = RealizeWindow(eglWindowHandle); if (0 == windowHandle) { throw new RuntimeException("Error native Window Handle is null"); - } + } */ windowHandleClose = eglWindowHandle; } @@ -101,6 +99,12 @@ public class KDWindow extends Window { if(this.visible!=visible) { this.visible=visible; setVisible0(eglWindowHandle, visible); + if ( 0==windowHandle ) { + windowHandle = RealizeWindow(eglWindowHandle); + if (0 == windowHandle) { + throw new RuntimeException("Error native Window Handle is null"); + } + } clearEventMask(); } } @@ -127,16 +131,8 @@ public class KDWindow extends Window { return true; } - public int getDisplayWidth() { - return fs_width; - } - - public int getDisplayHeight() { - return fs_height; - } - protected void dispatchMessages(int eventMask) { - DispatchMessages(eglWindowHandle, eventMask); + DispatchMessages(windowID, eglWindowHandle, eventMask); } //---------------------------------------------------------------------- @@ -144,13 +140,13 @@ public class KDWindow extends Window { // private static native boolean initIDs(); - private native long CreateWindow(long displayHandle, long eglConfig, int eglRenderableType); + private native long CreateWindow(int owner, long displayHandle, long eglConfig, int eglRenderableType); private native long RealizeWindow(long eglWindowHandle); private native int CloseWindow(long eglWindowHandle); private native void setVisible0(long eglWindowHandle, boolean visible); private native void setSize0(long eglWindowHandle, int width, int height); private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); - private native void DispatchMessages(long eglWindowHandle, int eventMask); + private native void DispatchMessages(int owner, long eglWindowHandle, int eventMask); private void sizeChanged(int newWidth, int newHeight) { width = newWidth; @@ -159,8 +155,7 @@ public class KDWindow extends Window { nfs_width=width; nfs_height=height; } else { - fs_width = width; - fs_height = width; + screen.setScreenSize(width, height); } sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); } @@ -170,4 +165,6 @@ public class KDWindow extends Window { private long eglWindowHandle; private long windowHandleClose; + private int windowID; + private static int _windowID = 0; } diff --git a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java index e1a1255ff..bd60402d2 100755 --- a/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java +++ b/src/classes/com/sun/javafx/newt/windows/WindowsWindow.java @@ -116,14 +116,6 @@ public class WindowsWindow extends Window { return true; } - public int getDisplayWidth() { - return 640; // FIXME - } - - public int getDisplayHeight() { - return 480; // FIXME - } - protected void dispatchMessages(int eventMask) { DispatchMessages(windowHandle, eventMask); } diff --git a/src/classes/com/sun/javafx/newt/x11/X11Screen.java b/src/classes/com/sun/javafx/newt/x11/X11Screen.java index 5920d4997..9482c09c2 100755 --- a/src/classes/com/sun/javafx/newt/x11/X11Screen.java +++ b/src/classes/com/sun/javafx/newt/x11/X11Screen.java @@ -49,6 +49,8 @@ public class X11Screen extends Screen { if (handle == 0 ) { throw new RuntimeException("Error creating screen: "+index); } + setScreenSize(getWidth0(display.getHandle(), index), + getHeight0(display.getHandle(), index)); } //---------------------------------------------------------------------- @@ -56,4 +58,7 @@ public class X11Screen extends Screen { // private native long GetScreen(long dpy, int scrn_idx); + private native int getWidth0(long display, int scrn_idx); + private native int getHeight0(long display, 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 311ba7dae..c77933f18 100755 --- a/src/classes/com/sun/javafx/newt/x11/X11Window.java +++ b/src/classes/com/sun/javafx/newt/x11/X11Window.java @@ -95,10 +95,10 @@ public class X11Window extends Window { if(this.fullscreen!=fullscreen) { int x,y,w,h; this.fullscreen=fullscreen; - if(this.fullscreen) { + if(fullscreen) { x = 0; y = 0; - w = getDisplayWidth0(getDisplayHandle(), getScreenIndex())/2; - h = getDisplayHeight0(getDisplayHandle(), getScreenIndex())/2; + w = screen.getWidth(); + h = screen.getHeight(); } else { x = nfs_x; y = nfs_y; @@ -111,14 +111,6 @@ public class X11Window extends Window { return true; } - public int getDisplayWidth() { - return getDisplayWidth0(getDisplayHandle(), getScreenIndex()); - } - - public int getDisplayHeight() { - return getDisplayHeight0(getDisplayHandle(), getScreenIndex()); - } - protected void dispatchMessages(int eventMask) { DispatchMessages(getDisplayHandle(), windowHandle, eventMask); } @@ -135,8 +127,6 @@ public class X11Window extends Window { private native void DispatchMessages(long display, long windowHandle, int eventMask); private native void setSize0(long display, long windowHandle, int width, int height, int decorationToggle, boolean isVisible); 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); private void sizeChanged(int newWidth, int newHeight) { width = newWidth; |