From: <ka...@us...> - 2012-02-18 16:30:45
|
Revision: 3743 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3743&view=rev Author: kappa1 Date: 2012-02-18 16:30:38 +0000 (Sat, 18 Feb 2012) Log Message: ----------- Added the new public API's Display.getX() and Display.getY(). Currently implemented for Linux and Mac. Windows implementation pending. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-02-18 01:49:46 UTC (rev 3742) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2012-02-18 16:30:38 UTC (rev 3743) @@ -1282,10 +1282,50 @@ } /** + * @return this method will return the x position (top-left) of the Display window. + * + * If running in fullscreen mode it will return 0. + * If Display.setParent(Canvas parent) is being used, the x position of + * the parent will be returned. + */ + public static int getX() { + + if (Display.isFullscreen()) { + return 0; + } + + if (parent != null) { + return parent.getX(); + } + + return display_impl.getX(); + } + + /** + * @return this method will return the y position (top-left) of the Display window. + * + * If running in fullscreen mode it will return 0. + * If Display.setParent(Canvas parent) is being used, the y position of + * the parent will be returned. + */ + public static int getY() { + + if (Display.isFullscreen()) { + return 0; + } + + if (parent != null) { + return parent.getY(); + } + + return display_impl.getY(); + } + + /** * @return this method will return the width of the Display window. * * If running in fullscreen mode it will return the width of the current set DisplayMode. - * If running Display.setParent(Canvas parent) is being used, the width of the parent + * If Display.setParent(Canvas parent) is being used, the width of the parent * will be returned. * * This value will be updated after a call to Display.update(). @@ -1307,7 +1347,7 @@ * @return this method will return the height of the Display window. * * If running in fullscreen mode it will return the height of the current set DisplayMode. - * If running Display.setParent(Canvas parent) is being used, the height of the parent + * If Display.setParent(Canvas parent) is being used, the height of the parent * will be returned. * * This value will be updated after a call to Display.update(). Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2012-02-18 01:49:46 UTC (rev 3742) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayImplementation.java 2012-02-18 16:30:38 UTC (rev 3743) @@ -174,12 +174,22 @@ boolean wasResized(); /** - * @return this method will return a the width of the Display window. + * @return this method will return the width of the Display window. */ int getWidth(); /** - * @return this method will return a the height of the Display window. + * @return this method will return the height of the Display window. */ int getHeight(); + + /** + * @return this method will return the top-left x position of the Display window. + */ + int getX(); + + /** + * @return this method will return the top-left y position of the Display window. + */ + int getY(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2012-02-18 01:49:46 UTC (rev 3742) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java 2012-02-18 16:30:38 UTC (rev 3743) @@ -473,6 +473,8 @@ parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen()); resizable = Display.isResizable(); resized = false; + window_x = x; + window_y = y; window_width = mode.getWidth(); window_height = mode.getHeight(); current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window, resizable); @@ -1387,6 +1389,14 @@ private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height); + public int getX() { + return window_x; + } + + public int getY() { + return window_y; + } + public int getWidth() { return window_width; } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2012-02-18 01:49:46 UTC (rev 3742) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java 2012-02-18 16:30:38 UTC (rev 3743) @@ -495,7 +495,15 @@ // Don't use any icon, since Mac OS X windows don't have window icons return 0; } + + public int getX() { + return frame.getX(); + } + public int getY() { + return frame.getY(); + } + public int getWidth() { return frame.getWidth(); } Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2012-02-18 01:49:46 UTC (rev 3742) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2012-02-18 16:30:38 UTC (rev 3743) @@ -1013,7 +1013,15 @@ return defWindowProc(hwnd, msg, wParam, lParam); } } + + public int getX() { + return 0; // placeholder until implemented + } + public int getY() { + return 0; // placeholder until implemented + } + public int getWidth() { return width; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |