diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index 0033e28d..10463f00 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -1281,11 +1281,51 @@ public final class Display { return window_resized; } + /** + * @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 @@ public final class Display { * @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(). diff --git a/src/java/org/lwjgl/opengl/DisplayImplementation.java b/src/java/org/lwjgl/opengl/DisplayImplementation.java index 47d171dc..73c8741c 100644 --- a/src/java/org/lwjgl/opengl/DisplayImplementation.java +++ b/src/java/org/lwjgl/opengl/DisplayImplementation.java @@ -174,12 +174,22 @@ interface DisplayImplementation extends InputImplementation { 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(); } diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 4fbd384c..cf005676 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -473,6 +473,8 @@ final class LinuxDisplay implements DisplayImplementation { 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 @@ final class LinuxDisplay implements DisplayImplementation { 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; } diff --git a/src/java/org/lwjgl/opengl/MacOSXDisplay.java b/src/java/org/lwjgl/opengl/MacOSXDisplay.java index 465775da..c6032c72 100644 --- a/src/java/org/lwjgl/opengl/MacOSXDisplay.java +++ b/src/java/org/lwjgl/opengl/MacOSXDisplay.java @@ -495,6 +495,14 @@ final class MacOSXDisplay implements DisplayImplementation { // 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(); diff --git a/src/java/org/lwjgl/opengl/WindowsDisplay.java b/src/java/org/lwjgl/opengl/WindowsDisplay.java index d256d723..a9a16656 100644 --- a/src/java/org/lwjgl/opengl/WindowsDisplay.java +++ b/src/java/org/lwjgl/opengl/WindowsDisplay.java @@ -1013,6 +1013,14 @@ final class WindowsDisplay implements DisplayImplementation { 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;