Is there a way to tell if a window is currently maximized in GLFW3? Not fullscreen, but maximized in windowed mode.
2 Answers
From https://www.glfw.org/docs/3.3/window_guide.html#window_maximize
int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED);

- 2,881
- 2
- 27
- 36
-
1Cool! They finally implemented it! – Sam Washburn Nov 30 '20 at 20:48
I've been looking through the GLFW3 docs (http://www.glfw.org/docs/latest/) and nothing has immediatly jumped out at me which is strange because you'd think it would be a window attribute but here are a few alternatives:
Keeping Track - This is the easiest method. You could just create a boolean variable to keep track of when the user maximizes (or minimizes) the window. You could then query this to determine which state the window is currently in.
Getting the Size - This is not entirely reliable because it changes depending on your monitor resolution but it is fairly simple to implement. Simply get the size of the window using the following code:
int width, height;
glfwGetWindowSize(window, &width, &height);
Then check to see if it matches the maximum window resolutions.
OS Specifics - If you are on Windows then it might be worth checking out the microsoft documentation on how to check for these attributes using the GLFW's window handle. The specific page to look at would be this: http://msdn.microsoft.com/en-gb/library/windows/desktop/ms633518(v=vs.85).aspx

- 349
- 3
- 15
-
Keeping track might work if there is a way to tell when the maximized button has been clicked. Is there? – Sam Washburn Aug 18 '14 at 14:13
-
What is it you are trying to do when the user has maximized the window? A possible method would be to setup a resize callback and use the **getting the size** section also. – Steadi Aug 18 '14 at 14:51
-
Well, I'm trying to show the content with a letterbox border if the window is maximized, but have the window snap to a well-fitting borderless size if the window is not maximized. I'll try getting the size first, but I may go the OS Specifics route as a last course of action. – Sam Washburn Aug 18 '14 at 17:05