diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3a1e4a7a67..b72fa5d3d2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ [versions] checkstyle = "9.3" -lwjgl3 = "3.3.3" +lwjgl3 = "3.3.4" nifty = "1.4.3" [libraries] diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java index be78bd64c0..019e5f466c 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2023 jMonkeyEngine + * Copyright (c) 2009-2025 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -353,13 +353,27 @@ public void invoke(int error, long description) { requestWidth = videoMode.width(); requestHeight = videoMode.height(); } - + int requestX = GLFW_ANY_POSITION; + int requestY = GLFW_ANY_POSITION; + if (!settings.isFullscreen()) { + if (settings.getCenterWindow()) { + // Center the window + requestX = videoMode.width() - requestWidth; + requestY = videoMode.height() - requestWidth; + } else { + requestX = settings.getWindowXPosition(); + requestY = settings.getWindowYPosition(); + } + glfwWindowHint(GLFW_POSITION_X, requestX); + glfwWindowHint(GLFW_POSITION_Y, requestY); + } // Lets use the monitor selected from AppSettings if FullScreen is // set. - if (settings.isFullscreen()) window = - glfwCreateWindow(requestWidth, requestHeight, settings.getTitle(), monitor, NULL); else window = - glfwCreateWindow(requestWidth, requestHeight, settings.getTitle(), NULL, NULL); - + if (settings.isFullscreen()) { + window = glfwCreateWindow(requestWidth, requestHeight, settings.getTitle(), monitor, NULL); + } else { + window = glfwCreateWindow(requestWidth, requestHeight, settings.getTitle(), NULL, NULL); + } if (window == NULL) { throw new RuntimeException("Failed to create the GLFW window"); } @@ -383,17 +397,13 @@ public void invoke(final long window, final boolean focus) { } ); - if (!settings.isFullscreen()) { - if (settings.getCenterWindow()) { - // Center the window - glfwSetWindowPos( - window, - (videoMode.width() - requestWidth) / 2, - (videoMode.height() - requestHeight) / 2 - ); - } else { - glfwSetWindowPos(window, settings.getWindowXPosition(), settings.getWindowYPosition()); - } + int platformId = glfwGetPlatform(); + if (platformId != GLFW_PLATFORM_WAYLAND && !settings.isFullscreen()) { + /* + * in case the window positioning hints above were ignored, but not + * on Wayland, since Wayland doesn't support window positioning + */ + glfwSetWindowPos(window, requestX, requestY); } // Make the OpenGL context current @@ -490,6 +500,11 @@ protected void showWindow() { * @param settings settings for getting the icons */ protected void setWindowIcon(final AppSettings settings) { + if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) { + // Wayland doesn't support custom icons. + return; + } + final Object[] icons = settings.getIcons(); if (icons == null) return;