[RFE] Enable maximize-window together with Display.setResizable

Started by Simon Felix, December 29, 2011, 13:14:43

Previous topic - Next topic

NateS

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:
Display.setLocation(Display.getX(), Display.getY());

kappa

Quote from: NateS on August 09, 2012, 13:13:18
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.

Quote from: NateS on August 09, 2012, 13:13:18
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:
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 :)

kappa

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:

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).

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
}

princec

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 :)

Matzon

Quote from: 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:
Display.setLocation(Display.getX(), Display.getY());


Works for me ... http://lwjgl.org/forum/index.php/topic,4673.msg25071/topicseen.html#new

NateS

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, Linux is here (look for the setState method). Not sure that is helpful, as I haven't dug into how LWJGL creates the window.

Quote from: Matzon on August 09, 2012, 21:48:35
Quote from: 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:
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.


Liam

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

princec

Why not use an AWT Frame with Display.setParent() in the meantime?

Cas :)

Liam

Indeed a viable workaround for the time being, just nudging that it would be great to have in LWJGL's API is all ;)

NateS

Aye, I've decided to go with a JFrame so this is no longer an issue for me.