@Override public void centerWindow(Graphics graphics) { Lwjgl3Graphics g = (Lwjgl3Graphics) graphics; Graphics.DisplayMode mode = g.getDisplayMode(); Lwjgl3Window window = g.getWindow(); window.setPosition(mode.width / 2 - g.getWidth() / 2, mode.height / 2 - g.getHeight() / 2); }
/** * @return The new windowed size for the application after applying the safe window size limits. */ public static Dim limitInitialWindowSize(Graphics graphics) { if (graphics.isFullscreen()) { // If fullscreen, we fill the entire screen already so nothing needs to be done } else { // Width/height of the window in physical pixels int w = graphics.getBackBufferWidth(); int h = graphics.getBackBufferHeight(); // Limit window size so it fits inside the current monitor (with a margin for OS bars/decorations) DisplayMode displayMode = graphics.getDisplayMode(); int maxW = displayMode.width - 100; int maxH = displayMode.height - 150; int dw = Math.min(0, maxW - w); int dh = Math.min(0, maxH - h); graphics.setWindowedMode(w + dw, h + dh); // Also change the window's position so it's centered on its previous location Lwjgl3Window window = getCurrentWindow(); window.setPosition(window.getPositionX() - dw / 2, window.getPositionY() - dh / 2); } return Dim.of(graphics.getBackBufferWidth(), graphics.getBackBufferHeight()); }
public Lwjgl3Window window(ApplicationListener listener, Lwjgl3WindowConfiguration cfg) { return app.newWindow(listener, cfg); }
public Lwjgl3Window duplicateWindow(Lwjgl3WindowConfiguration cfg) { return app.newWindow(app.getApplicationListener(), cfg); }
public Lwjgl3Window window(ApplicationListener listener) { return app.newWindow(listener, defaultCfg()); }
public DetatchableFrame(Lwjgl3Window primaryWindow) { this.primaryWindow = primaryWindow; }
private static Lwjgl3Window getCurrentWindow() { // Oddly, the only public way to get a reference to the main window is through the graphics object... Lwjgl3Graphics graphics = (Lwjgl3Graphics)Gdx.graphics; return graphics.getWindow(); }
void attach(Lwjgl3Window window);
Lwjgl3Window detatch();