Implement Resizing Display API for OS X
This commit is contained in:
parent
1f305d514a
commit
5949d57bb1
|
@ -93,6 +93,12 @@ public final class Display {
|
|||
* unlike GL, where it is typically at the bottom of the display.
|
||||
*/
|
||||
private static int y = -1;
|
||||
|
||||
/** the width of the Display window */
|
||||
private static int width = 0;
|
||||
|
||||
/** the height of the Display window */
|
||||
private static int height = 0;
|
||||
|
||||
/** Title of the window (never null) */
|
||||
private static String title = "Game";
|
||||
|
@ -109,6 +115,10 @@ public final class Display {
|
|||
private static boolean window_created;
|
||||
|
||||
private static boolean parent_resized;
|
||||
|
||||
private static boolean window_resized;
|
||||
|
||||
private static boolean window_resizable;
|
||||
|
||||
/** Initial Background Color of Display */
|
||||
private static float r, g, b;
|
||||
|
@ -295,6 +305,9 @@ public final class Display {
|
|||
DisplayMode mode = getEffectiveMode();
|
||||
display_impl.createWindow(drawable, mode, tmp_parent, getWindowX(), getWindowY());
|
||||
window_created = true;
|
||||
|
||||
width = Display.getDisplayMode().getWidth();
|
||||
height = Display.getDisplayMode().getHeight();
|
||||
|
||||
setTitle(title);
|
||||
initControls();
|
||||
|
@ -661,6 +674,13 @@ public final class Display {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
window_resized = !isFullscreen() && parent == null && display_impl.wasResized();
|
||||
|
||||
if ( window_resized ) {
|
||||
width = display_impl.getWidth();
|
||||
height = display_impl.getHeight();
|
||||
}
|
||||
|
||||
if ( parent_resized ) {
|
||||
reshape();
|
||||
|
@ -1257,14 +1277,17 @@ public final class Display {
|
|||
* false to disable resizing on the Display window.
|
||||
*/
|
||||
public static void setResizable(boolean resizable) {
|
||||
|
||||
window_resizable = resizable;
|
||||
if ( isCreated() ) {
|
||||
display_impl.setResizable(resizable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the Display window is resizable.
|
||||
*/
|
||||
public static boolean isResizable() {
|
||||
return false;
|
||||
return window_resizable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1274,7 +1297,7 @@ public final class Display {
|
|||
* This will return false if running in fullscreen or with Display.setParent(Canvas parent)
|
||||
*/
|
||||
public static boolean wasResized() {
|
||||
return false;
|
||||
return window_resized;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1287,7 +1310,16 @@ public final class Display {
|
|||
* This value will be updated after a call to Display.update().
|
||||
*/
|
||||
public static int getWidth() {
|
||||
return 0;
|
||||
|
||||
if (Display.isFullscreen()) {
|
||||
return Display.getDisplayMode().getWidth();
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
return parent.getWidth();
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1300,6 +1332,15 @@ public final class Display {
|
|||
* This value will be updated after a call to Display.update().
|
||||
*/
|
||||
public static int getHeight() {
|
||||
return 0;
|
||||
|
||||
if (Display.isFullscreen()) {
|
||||
return Display.getDisplayMode().getHeight();
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
return parent.getHeight();
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,12 +169,7 @@ interface DisplayImplementation extends InputImplementation {
|
|||
void setResizable(boolean resizable);
|
||||
|
||||
/**
|
||||
* @return true if the Display window is resizable.
|
||||
*/
|
||||
boolean isResizable();
|
||||
|
||||
/**
|
||||
* @return true if the Display window has been resized.
|
||||
* @return true if the Display window has been resized since this method was last called.
|
||||
*/
|
||||
boolean wasResized();
|
||||
|
||||
|
|
|
@ -1361,10 +1361,6 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
|
||||
}
|
||||
|
||||
public boolean isResizable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean wasResized() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ final class MacOSXCanvasListener implements ComponentListener, HierarchyListener
|
|||
private int width;
|
||||
private int height;
|
||||
private boolean context_update;
|
||||
private boolean resized;
|
||||
|
||||
MacOSXCanvasListener(Canvas canvas) {
|
||||
this.canvas = canvas;
|
||||
|
@ -102,6 +103,7 @@ final class MacOSXCanvasListener implements ComponentListener, HierarchyListener
|
|||
|
||||
public void componentResized(ComponentEvent e) {
|
||||
setUpdate();
|
||||
resized = true;
|
||||
}
|
||||
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
|
@ -111,4 +113,13 @@ final class MacOSXCanvasListener implements ComponentListener, HierarchyListener
|
|||
public void hierarchyChanged(HierarchyEvent e) {
|
||||
setUpdate();
|
||||
}
|
||||
|
||||
public boolean wasResized() {
|
||||
if (resized) {
|
||||
resized = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -497,11 +497,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public int getWidth() {
|
||||
return Display.getDisplayMode().getWidth();
|
||||
return frame.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return Display.getDisplayMode().getHeight();
|
||||
return frame.getHeight();
|
||||
}
|
||||
|
||||
public boolean isInsideWindow() {
|
||||
|
@ -509,15 +509,11 @@ final class MacOSXDisplay implements DisplayImplementation {
|
|||
}
|
||||
|
||||
public void setResizable(boolean resizable) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isResizable() {
|
||||
return false;
|
||||
frame.setResizable(resizable);
|
||||
}
|
||||
|
||||
public boolean wasResized() {
|
||||
return false;
|
||||
return canvas_listener.wasResized();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
|||
private boolean should_release_cursor;
|
||||
|
||||
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
|
||||
setResizable(false);
|
||||
setResizable(Display.isResizable());
|
||||
addWindowListener(this);
|
||||
addComponentListener(this);
|
||||
canvas = new MacOSXGLCanvas();
|
||||
|
|
|
@ -945,10 +945,6 @@ final class WindowsDisplay implements DisplayImplementation {
|
|||
|
||||
}
|
||||
|
||||
public boolean isResizable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean wasResized() {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue