LWJGL Forum

Programming => Bug Reports / RFE => Topic started by: Simon Felix on December 29, 2011, 13:14:43

Title: [RFE] Enable maximize-window together with Display.setResizable
Post by: Simon Felix on December 29, 2011, 13:14:43
Hi everyone

It'd be nice if the window managed by LWJGL had a maximize button (WS_MAXIMIZEBOX style on Windows) when resizing is enabled.

I tested with Windows 7 (and 8 ).

Cheers,
Simon
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Simon Felix on December 30, 2011, 00:06:37
I attached a diff to fix the behavior. This works at least on Windows XP, Vista, 7 and 8. I did not test any other platforms, but I made no changes there anyway. Hope you can use it!
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Matzon on December 30, 2011, 08:36:28
aye, window looks easy enough to fix - dont know about mac / linux tho. Waiting for someone to chime in before applying.
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Simon Felix on December 30, 2011, 21:42:47
Ok. It shouldn't break anything on other platforms and improve the situation on Windows. But having a similar fix for other platforms (if they even show the same behavior) would be desirable.
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Simon Felix on January 09, 2012, 20:08:30
Anybody chiming in?
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Matzon on January 11, 2012, 20:47:54
I have applied the patch for windows. kappaOne mentioned on IRC it should be easy enough to add on linux and mac (although he did mention that mac was "different" in that regard).
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Simon Felix on January 14, 2012, 21:53:20
Cool, thanks!
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: kappa on January 22, 2012, 18:23:19
I can confirm that the maximise button already works as expected on both Linux and Mac when Display.setResizable(true) is set. So no need to make further changes for those platforms.

RFE marked as complete and implemented.
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: princec on January 22, 2012, 22:46:57
What about the "restore" functionality? And is there any API to retrieve extended window state a la AWT?

Cas :)
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: kappa on January 23, 2012, 20:58:29
What about the "restore" functionality?
If you mean the restore button once maximised (to return window to size it was before maximising), then yeh that works fine, as expected.

And is there any API to retrieve extended window state a la AWT?
Extended window state? you mean like an API to detect if the window is minimised, make it flash, etc? or something else?
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: princec on January 23, 2012, 22:15:22
Cool.

The extended state - eg query and set the iconified status of the window programmatically.

Cas :)
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: kappa on January 24, 2012, 09:51:29
The extended state - eg query and set the iconified status of the window programmatically.
Ah, as far as I'm aware there is no API currently to get the extended state of the Display window. The only API I'm aware of is Display.isActive() which will tell you if the window is focused or not (will also return false if window is minimised).
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: NateS on August 01, 2012, 03:36:54
I'm necro'ing this topic (in case the OP or others interested in maximize enabled notify on this thread) to ask for a new feature: Can Display have a feature to maximize and restore (unmaximize) the window? I need to both query and set the current maximized state. I need this for a desktop app where I want to restore the application window to the same state it was in when the app was closed.

Edit: Seems to be a related problem, if I save Display.getX/Y and use the values with Display.getLocation when the app next runs, the window is not positioned in the same location. Eg:
Code: [Select]
Display.setLocation(822, 525);
Display.create(...);
System.out.println(Display.getX() + ", " + Display.getY()); // 832, 565
That is on Windows 7 Ultimate 64-bit. I can create a new thread for either or both issues if you prefer.
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: Matzon on August 01, 2012, 17:11:13
I'm necro'ing this topic (in case the OP or others interested in maximize enabled notify on this thread) to ask for a new feature: Can Display have a feature to maximize and restore (unmaximize) the window? I need to both query and set the current maximized state. I need this for a desktop app where I want to restore the application window to the same state it was in when the app was closed.
Not sure if there are cross platform issues with this ?

Quote
Edit: Seems to be a related problem, if I save Display.getX/Y and use the values with Display.getLocation when the app next runs, the window is not positioned in the same location. Eg:
Code: [Select]
Display.setLocation(822, 525);
Display.create(...);
System.out.println(Display.getX() + ", " + Display.getY()); // 832, 565
That is on Windows 7 Ultimate 64-bit. I can create a new thread for either or both issues if you prefer.
Try nightly.
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: NateS on August 09, 2012, 13:13:18
I'm necro'ing this topic (in case the OP or others interested in maximize enabled notify on this thread) to ask for a new feature: Can Display have a feature to maximize and restore (unmaximize) the window? I need to both query and set the current maximized state. I need this for a desktop app where I want to restore the application window to the same state it was in when the app was closed.
Not sure if there are cross platform issues with this ?
I'm not sure either. I do think support for it is important. I would be fine if it worked on Windows, if only until it could be implemented for other OSes. The bad part without this feature is that when the user maximizes the window, all I know is that is has been resized. When they launch the app again, they get a huge window that isn't maximized.

Quote
Quote
Edit: Seems to be a related problem, if I save Display.getX/Y and use the values with Display.getLocation when the app next runs, the window is not positioned in the same location. Eg:
Code: [Select]
Display.setLocation(822, 525);
Display.create(...);
System.out.println(Display.getX() + ", " + Display.getY()); // 832, 565
That is on Windows 7 Ultimate 64-bit. I can create a new thread for either or both issues if you prefer.
Try nightly.
Verified it works correctly in nightly build #1757. Thanks!

A related feature would be to know when the application is minimized. I don't want to stop rendering if the window is not active but still visible, but if it is minimized then I do want to stop rendering.
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: NateS on August 09, 2012, 14:07:13
Actually I lied. The window seems to show up in different locations each time I run my app. To see the problem, put this in your render loop and enjoy:
Code: [Select]
Display.setLocation(Display.getX(), Display.getY());
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: kappa on August 09, 2012, 14:14:59
I'm not sure either. I do think support for it is important. I would be fine if it worked on Windows, if only until it could be implemented for other OSes.
I think AWT allows you to query and set the iconified status of the window programmatically so should be possible to implement crossplatfrom. However not sure how much work it'll be since each platform will have to have its own implementation.

The bad part without this feature is that when the user maximizes the window, all I know is that is has been resized. When they launch the app again, they get a huge window that isn't maximized.
A proper API is preferable but in the mean time you could try a hack to guess if the window is maximised:
Code: [Select]
if ((Display.getX() == 0 || Display.getY() == 0) &&
    (Display.getWidth() == Display.getDesktopDisplayMode().getWidth() ||
    Display.getHeight() == Display.getDesktopDisplayMode().getHeight())) {
        // window likely maximised
}
The above tries to take into account the various positions the taskbar could be but I might have missed other conditions that would cause the above not to detect a maximised window :)
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: kappa on August 09, 2012, 14:29:06
hmm, thinking about that a little further that code would fail when using Windows's drag snap left or drag snap right feature. So the following would likely work better:

Code: [Select]
if ((Display.getX() == 0 && Display.getWidth() == Display.getDesktopDisplayMode().getWidth()) ||
    (Display.getY() == 0 && Display.getHeight() == Display.getDesktopDisplayMode().getHeight())) {
        // window likely maximised
}

or for a bit more robustness maybe add another check as below (provided the taskbar isn't larger than half the screen, could probably bump up the check to 2/3 the screen or more).

Code: [Select]
if ((Display.getX() == 0 && Display.getWidth() == Display.getDesktopDisplayMode().getWidth() &&
    Display.getHeight() > Display.getDesktopDisplayMode().getHeight()/2) ||
    (Display.getY() == 0 && Display.getDesktopDisplayMode().getHeight() &&
    Display.getWidth() > Display.getDesktopDisplayMode().getWidth()/2)) {
        // window likely maximised
}
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: princec on August 09, 2012, 15:51:01
Adding a simple API to get the iconification state of the window would do what you wanted. AWT has it so it's probably reasonably safe to assume it's cross-platform.

Cas :)
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: Matzon on August 09, 2012, 21:48:35
Actually I lied. The window seems to show up in different locations each time I run my app. To see the problem, put this in your render loop and enjoy:
Code: [Select]
Display.setLocation(Display.getX(), Display.getY());

Works for me ... http://lwjgl.org/forum/index.php/topic,4673.msg25071/topicseen.html#new
Title: Re: [FIXED] Enable maximize-window together with Display.setResizable
Post by: NateS on August 11, 2012, 19:26:58
Thanks for the ideas kappa. I'll probably go with not saving the window size if it is a good percentage of the screen size. I still think it is an important ability to be able to query for isMinimized and isMaximized, as well as being able maximize the window (and maybe for completeness, being able to restore/unmaximize and minimize it).

Good point about AWT, Cas. It seems AWT uses Toolkit#isFrameStateSupported(int) to see if extended window flags are supported. States are normal, iconified (minimized), maximized horiz, maximized vert, and maximized both. Windows and Linux seem to support only normal, iconified, and maximized both. Not sure about Mac. Windows Harmony source is here (http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/awt/src/main/java/windows/org/apache/harmony/awt/wtk/windows/WinWindow.java?revision=929253&view=markup), Linux is here (http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWindow.java?view=markup) (look for the setState method). Not sure that is helpful, as I haven't dug into how LWJGL creates the window.

Actually I lied. The window seems to show up in different locations each time I run my app. To see the problem, put this in your render loop and enjoy:
Code: [Select]
Display.setLocation(Display.getX(), Display.getY());

Works for me ... http://lwjgl.org/forum/index.php/topic,4673.msg25071/topicseen.html#new
Aye, I got the nightlies again and verified it again. It does seem to work correctly. Sometimes I think I'm going nuts.

Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Liam on September 01, 2012, 19:47:19
Hi there,

My request is apt for this thread but slightly different, could we please have the ability to maximize the window programatically as my application requires full screen real estate but is impractical without the start bar etc accessible. Setting the height and width to the screen resolution is messy and it would just be a lot tidier if I could start it maximized.

The first thing my users pointed out was 'why do i always have to maximize it?' so I think this is a fairly obvious feature to have.

I don't know what work would be involved in this but it would make me one happy chappy :)

Thanks for your time,
Liam
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: princec on September 02, 2012, 08:46:13
Why not use an AWT Frame with Display.setParent() in the meantime?

Cas :)
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: Liam on September 02, 2012, 16:25:50
Indeed a viable workaround for the time being, just nudging that it would be great to have in LWJGL's API is all ;)
Title: Re: [RFE] Enable maximize-window together with Display.setResizable
Post by: NateS on September 04, 2012, 13:45:14
Aye, I've decided to go with a JFrame so this is no longer an issue for me.