Starting window maximized (GLFW)

Started by cypherdare, November 07, 2016, 15:54:09

Previous topic - Next topic

cypherdare

Anyone successfully get a window opened in maximized state? When I try this, the window starts with the size of a maximized window, but it's top left corner is near the center of the screen. Windows 10 seems a bit confused--once I drag the title bar, it pops back to the width and height I used to create the window. I've tried setting the position to (0, 0), but setting the position has no effect on where the pseudo maximized window appears.

GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
GLFW.glfwWindowHint(GLFW.GLFW_MAXIMIZED, GLFW.GLFW_TRUE);

//snip (color, alpha, depth, stencil hints)

GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, GLFW.GLFW_TRUE);
windowHandle = GLFW.glfwCreateWindow(800, 600, "title", 0, 0);   
GLFW.glfwMakeContextCurrent(windowHandle);
GLFW.glfwShowWindow(windowHandle);   


Kai

Yes, I have that exact problem with the exact symptoms (near center and popping back to default size when dragged), too, on Windows 7. To solve it, show the window in normal (not maximized) mode first, and immediately after the call to glfwShowWindow() do a call to glfwMaximizeWindow(window). This fixed it for me.

spasi

I just tried the above code and it works fine for me (Windows 10, LWJGL 3.1.0).

Could you share more information about your systems? Do you have multiple monitors? Is the taskbar autohidden? Any weird setting in your GPU drivers? Using a custom window manager? Using multiple virtual desktops?

Kai

For me it's:
- Stock Nvidia driver 375.63 on Windows 7 x64 (as well as older 369.26, I just upgraded, but issue persists)
- issue happens on integrated laptop display as well as external monitor (both operated in "show only on that monitor" mode, respectively)
- default graphics driver settings (by installation)
- no custom settings to the Windows desktop environment (taskbar stays put)

EDIT: With GLFW natively (git commit 8210f89b127a7c085ec38ba4342602da6b298244) everything runs fine and there is no issue with the window not being maximized.

spasi

How do you launch the LWJGL app? If from an IDE, could you try from the command line?

Kai

I just "patched" the lwjgl-glfw-3.1.1-SNAPSHOT-natives-windows.jar with the glfw3.dll (renamed to glfw.dll) built from the latest GLFW with:
- cmake -DUSE_MSVC_RUNTIME_LIBRARY_DLL=OFF -DBUILD_SHARED_LIBS=ON .. -G "Visual Studio 14 2015 Win64"
- MSBuild /p:Configuration=MinSizeRel /p:Platform=x64 GLFW.sln

And also tried to run a single jar containing everything with the Getting Started example from the lwjgl.org site from the command line via:
- java -jar out.jar

No luck. When using Java, it persistently shows the (supposedly maximized) window always near the center of the screen and (somewhat grown towards the lower right out of the screen).

When I just modify a native GLFW example program, it works. Just not with Java.

Kai

Oh, stupid me.... I was having this code in it:
// Get the resolution of the primary monitor
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
// Center our window
glfwSetWindowPos(
	window,
	(vidmode.width() - WIDTH) / 2,
	(vidmode.height() - HEIGHT) / 2
);

Without it, everything's fine, obviously. :)

I'm pretty sure this is the same for cypherdare.

cypherdare

I didn't think I was doing that, but on third look, yes I was.  :-[

Thanks for the help.