@@ -298,6 +298,20 @@ public void invoke(int error, long description) {
298298 requestWidth = videoMode .width ();
299299 requestHeight = videoMode .height ();
300300 }
301+ int requestX = GLFW_ANY_POSITION ;
302+ int requestY = GLFW_ANY_POSITION ;
303+ if (!settings .isFullscreen ()) {
304+ if (settings .getCenterWindow ()) {
305+ // Center the window
306+ requestX = videoMode .width () - requestWidth ;
307+ requestY = videoMode .height () - requestWidth ;
308+ } else {
309+ requestX = settings .getWindowXPosition ();
310+ requestY = settings .getWindowYPosition ();
311+ }
312+ glfwWindowHint (GLFW_POSITION_X , requestX );
313+ glfwWindowHint (GLFW_POSITION_Y , requestY );
314+ }
301315 window = glfwCreateWindow (requestWidth , requestHeight , settings .getTitle (), monitor , NULL );
302316 if (window == NULL ) {
303317 throw new RuntimeException ("Failed to create the GLFW window" );
@@ -321,17 +335,11 @@ public void invoke(final long window, final boolean focus) {
321335
322336 int platformId = glfwGetPlatform ();
323337 if (platformId != GLFW_PLATFORM_WAYLAND && !settings .isFullscreen ()) {
324- // Wayland doesn't support window positioning.
325- if (settings .getCenterWindow ()) {
326- // Center the window
327- glfwSetWindowPos (window ,
328- (videoMode .width () - requestWidth ) / 2 ,
329- (videoMode .height () - requestHeight ) / 2 );
330- } else {
331- glfwSetWindowPos (window ,
332- settings .getWindowXPosition (),
333- settings .getWindowYPosition ());
334- }
338+ /*
339+ * in case the window positioning hints above were ignored, but not
340+ * on Wayland, since Wayland doesn't support window positioning.
341+ */
342+ glfwSetWindowPos (window , requestX , requestY );
335343 }
336344
337345 // Make the OpenGL context current
0 commit comments