/**
* @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());
}
DesktopGraphicsUtil.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:nvlist
作者:
评论列表
文章目录