aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Zechner <contact@badlogicgames.com>2016-05-11 10:20:41 +0200
committerMario Zechner <contact@badlogicgames.com>2016-05-11 10:20:41 +0200
commit76807c8941d1f5ece27017a4898c81e02b6431fc (patch)
treed9c9dd7ac91b5d36e6fa631ffef29d93ed0f31bf
parent4b6b2f5dc5cef21e94698ba401dcd1f71d7baf8a (diff)
parent83eaa11f607c202b66bb866b8dc76cccf3252ace (diff)
downloadlibgdx-76807c8941d1f5ece27017a4898c81e02b6431fc.tar.gz
Merge pull request #4075 from cypherdare/windowLimits
Add window size limits to LWJGL 3 app and window configurations.
-rwxr-xr-xCHANGES1
-rw-r--r--backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java12
-rw-r--r--backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3ApplicationConfiguration.java16
-rw-r--r--backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3WindowConfiguration.java14
4 files changed, 41 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 13c70f973..31bdaba00 100755
--- a/CHANGES
+++ b/CHANGES
@@ -19,6 +19,7 @@
- Fixed Gdx.input.getCurrentEventTime() not being set on LWJGL3, fixes GestureDetector and flick scroll not working
- Fixed not being able to select non-latin characters in TextFields
- Bullet: added CustomActionInterface, see https://github.com/libgdx/libgdx/pull/4025
+- Add window size limits option to LWJGL3 app and window configurations
[1.9.2]
- Added TextureArray wrapper see https://github.com/libgdx/libgdx/pull/3807
diff --git a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java
index fca89db05..94f0c7617 100644
--- a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java
+++ b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java
@@ -315,6 +315,7 @@ public class Lwjgl3Application implements Application {
Lwjgl3ApplicationConfiguration appConfig = Lwjgl3ApplicationConfiguration.copy(this.config);
appConfig.setWindowedMode(config.windowWidth, config.windowHeight);
appConfig.setWindowPosition(config.windowX, config.windowY);
+ appConfig.setWindowSizeLimits(config.windowMinWidth, config.windowMinHeight, config.windowMaxWidth, config.windowMaxHeight);
appConfig.setResizable(config.windowResizable);
appConfig.setDecorated(config.windowDecorated);
appConfig.setWindowListener(config.windowListener);
@@ -372,10 +373,19 @@ public class Lwjgl3Application implements Application {
if (windowHandle == 0) {
throw new GdxRuntimeException("Couldn't create window");
}
+ GLFW.glfwSetWindowSizeLimits(windowHandle,
+ config.windowMinWidth > -1 ? config.windowMinWidth : GLFW.GLFW_DONT_CARE,
+ config.windowMinHeight > -1 ? config.windowMinHeight : GLFW.GLFW_DONT_CARE,
+ config.windowMaxWidth > -1 ? config.windowMaxWidth : GLFW.GLFW_DONT_CARE,
+ config.windowMaxHeight> -1 ? config.windowMaxHeight : GLFW.GLFW_DONT_CARE);
if (config.fullscreenMode == null) {
if (config.windowX == -1 && config.windowY == -1) {
+ int windowWidth = Math.max(config.windowWidth, config.windowMinWidth);
+ int windowHeight = Math.max(config.windowHeight, config.windowMinHeight);
+ if (config.windowMaxWidth > -1) windowWidth = Math.min(windowWidth, config.windowMaxWidth);
+ if (config.windowMaxHeight > -1) windowHeight = Math.min(windowHeight, config.windowMaxHeight);
GLFWVidMode vidMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
- GLFW.glfwSetWindowPos(windowHandle, vidMode.width() / 2 - config.windowWidth / 2, vidMode.height() / 2 - config.windowHeight / 2);
+ GLFW.glfwSetWindowPos(windowHandle, vidMode.width() / 2 - windowWidth / 2, vidMode.height() / 2 - windowHeight / 2);
} else {
GLFW.glfwSetWindowPos(windowHandle, config.windowX, config.windowY);
}
diff --git a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3ApplicationConfiguration.java b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3ApplicationConfiguration.java
index fcb979f46..08ae39898 100644
--- a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3ApplicationConfiguration.java
+++ b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3ApplicationConfiguration.java
@@ -57,6 +57,7 @@ public class Lwjgl3ApplicationConfiguration {
int windowY = -1;
int windowWidth = 640;
int windowHeight = 480;
+ int windowMinWidth = -1, windowMinHeight = -1, windowMaxWidth = -1, windowMaxHeight = -1;
boolean windowResizable = true;
boolean windowDecorated = true;
Lwjgl3WindowListener windowListener;
@@ -91,6 +92,10 @@ public class Lwjgl3ApplicationConfiguration {
copy.windowY = config.windowY;
copy.windowWidth = config.windowWidth;
copy.windowHeight = config.windowHeight;
+ copy.windowMinWidth = config.windowMinWidth;
+ copy.windowMinHeight = config.windowMinHeight;
+ copy.windowMaxWidth = config.windowMaxWidth;
+ copy.windowMaxHeight = config.windowMaxHeight;
copy.windowResizable = config.windowResizable;
copy.windowDecorated = config.windowDecorated;
copy.windowListener = config.windowListener;
@@ -222,6 +227,17 @@ public class Lwjgl3ApplicationConfiguration {
}
/**
+ * Sets minimum and maximum size limits for the window. If the window is full screen or not resizable, these
+ * limits are ignored. The default for all four parameters is -1, which means unrestricted.
+ */
+ public void setWindowSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) {
+ windowMinWidth = minWidth;
+ windowMinHeight = minHeight;
+ windowMaxWidth = maxWidth;
+ windowMaxHeight = maxHeight;
+ }
+
+ /**
* Sets the {@link Lwjgl3WindowListener} which will be informed about
* iconficiation, focus loss and window close events.
*/
diff --git a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3WindowConfiguration.java b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3WindowConfiguration.java
index edbac858c..16eaecfbe 100644
--- a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3WindowConfiguration.java
+++ b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3WindowConfiguration.java
@@ -25,6 +25,7 @@ public class Lwjgl3WindowConfiguration {
int windowY = -1;
int windowWidth = 640;
int windowHeight = 480;
+ int windowMinWidth = -1, windowMinHeight = -1, windowMaxWidth = -1, windowMaxHeight = -1;
boolean windowResizable = true;
boolean windowDecorated = true;
Lwjgl3WindowListener windowListener;
@@ -61,7 +62,7 @@ public class Lwjgl3WindowConfiguration {
/**
* Sets the position of the window in windowed mode on the
- * primary monitor. Default -1 for booth coordinates for centered.
+ * primary monitor. Default -1 for both coordinates for centered.
*/
public void setWindowPosition(int x, int y) {
windowX = x;
@@ -69,6 +70,17 @@ public class Lwjgl3WindowConfiguration {
}
/**
+ * Sets minimum and maximum size limits for the window. If the window is full screen or not resizable, these
+ * limits are ignored. The default for all four parameters is -1, which means unrestricted.
+ */
+ public void setWindowSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) {
+ windowMinWidth = minWidth;
+ windowMinHeight = minHeight;
+ windowMaxWidth = maxWidth;
+ windowMaxHeight = maxHeight;
+ }
+
+ /**
* Sets the {@link Lwjgl3WindowListener} which will be informed about
* iconficiation, focus loss and window close events.
*/