Page 1 of 2

Getting the usable screen dimension

Posted: Sun Oct 02, 2016 6:13 am
by VectorNormal
Is there any way to get the dimensions of the desktop minus the size of the taskbar? I thought maybe

Code: Select all

love.window.setMode(0, 0)
would set the rez and then I could just grab it. Unfortunately this gives me a window which displays far below the task bar. In a desktop environment where the taskbar can be multiple heights or even custom in some cases (lxde, windows, etc) I'm hoping to find a way to get exactly the height of the usable "real estate."
It doesn't have to be purely love2D. I could use other lua techniques or modules/libraries.
Thanks for your time!

Re: Getting the usable screen dimension

Posted: Sun Oct 02, 2016 12:02 pm
by raidho36
Or, you can set the window to be resizable and then window manager will also include auto-resize such as to fill whole desktop or to put it on the left-hand side, etc.

Re: Getting the usable screen dimension

Posted: Sun Oct 02, 2016 12:21 pm
by MadByte
Or you could simply use fullscreen or windowed-fullscreen. It could help if you tell us why you need it. I can't think of any reason why a game should need the exact size of the screen without the taskbar.

Re: Getting the usable screen dimension

Posted: Sun Oct 02, 2016 12:42 pm
by Nixola
You could also just use [wiki]love.window.getDesktopDimensions[/wiki]
EDIT: Nevermind, it includes the taskbar.

Re: Getting the usable screen dimension

Posted: Sun Oct 02, 2016 12:45 pm
by zorg
Nixola wrote:You could also just use [wiki]love.window.getDesktopDimensions[/wiki]
This also includes the taskbar's area, if i'm not mistaken. (At least it does on multi-monitor setups and/or if you have the taskbar set to auto-vanish)

Re: Getting the usable screen dimension

Posted: Sun Oct 02, 2016 12:55 pm
by Nixola
Oh true, it does include that. Sorry.

Re: Getting the usable screen dimension

Posted: Sun Oct 02, 2016 3:32 pm
by pgimeno
[wiki]love.window.maximize[/wiki]?

Re: Getting the usable screen dimension

Posted: Sun Oct 09, 2016 3:15 am
by VectorNormal
@MadByte I'm making a casual puzzle game. There's no reason a player should feel like their entire computer experience is being overtaken by a casual game that you just fire up for a few minutes to play a few levels.
Worth noting is that when in windowed mode if you maximize the screen, the reported size of the window does not change. This is because resizing and maximizing are completely separate concepts.
In the end, I did not really find a solution in pure lua/love2D. It seems that python could answer the call in a platform independent way but it turns out this question is a tough one for the OS to answer.
For now, I'm just going with an offset from the reported screen height that makes sense, like 64 pixels. Then the user can resize from there if they wish.
Thanks for all the input, everyone!

Re: Getting the usable screen dimension

Posted: Sun Oct 09, 2016 3:31 am
by Positive07
VectorNormal wrote:when in windowed mode if you maximize the screen, the reported size of the window does not change. This is because resizing and maximizing are completely separate concepts
Huh? What do you mean? If you perform [wiki]love.window.maximize[/wiki] your screen should take all the available space. [wiki]love.resize[/wiki] should be called with the new width and height, and [wiki]love.graphics.getDimensions[/wiki] should return appropiate dimensions. This is also true for resizable windows that are maximized by the user. And even works with borderless windows. Of course you have to call [wiki]love.graphics.getDimensions[/wiki] after [wiki]love.window.maximize[/wiki] and currently there is no way to restore to an unmaximized state through code

Re: Getting the usable screen dimension

Posted: Sun Oct 09, 2016 5:55 am
by zorg
VectorNormal wrote:@MadByte I'm making a casual puzzle game. There's no reason a player should feel like their entire computer experience is being overtaken by a casual game that you just fire up for a few minutes to play a few levels.
VectorNormal wrote:Is there any way to get the dimensions of the desktop minus the size of the taskbar? ...
So you don't want to burden users by covering the entire screen, just the entire screen minus the taskbar. Makes sense. :awesome:
Do note that desktop fullscreen is still the better solution than exclusive fullscreen, since it doesn't muck with multi-screen setups, for example.
VectorNormal wrote:Worth noting is that when in windowed mode if you maximize the screen, the reported size of the window does not change. This is because resizing and maximizing are completely separate concepts.
Positive07 wrote:Huh? What do you mean? If you perform love.window.maximize your screen should take all the available space. love.resize should be called with the new width and height, and love.graphics.getDimensions should return appropiate dimensions. This is also true for resizable windows that are maximized by the user. And even works with borderless windows. Of course you have to call love.graphics.getDimensions after love.window.maximize and currently there is no way to restore to an unmaximized state through code
Worth noting that the love.resize callback won't be called if maximize succeeds, as per wiki documentation that +7 linked. Though that shouldn't affect löve setting the new resolution internally, that's retrievable by lg.getDimensions; that i haven't tested though.