Getting the usable screen dimension

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
VectorNormal
Prole
Posts: 8
Joined: Sun Oct 02, 2016 5:58 am

Getting the usable screen dimension

Post 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!
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Getting the usable screen dimension

Post 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.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Getting the usable screen dimension

Post 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.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Getting the usable screen dimension

Post by Nixola »

You could also just use [wiki]love.window.getDesktopDimensions[/wiki]
EDIT: Nevermind, it includes the taskbar.
Last edited by Nixola on Sun Oct 02, 2016 12:55 pm, edited 1 time in total.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Getting the usable screen dimension

Post 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)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Getting the usable screen dimension

Post by Nixola »

Oh true, it does include that. Sorry.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
pgimeno
Party member
Posts: 3641
Joined: Sun Oct 18, 2015 2:58 pm

Re: Getting the usable screen dimension

Post by pgimeno »

[wiki]love.window.maximize[/wiki]?
VectorNormal
Prole
Posts: 8
Joined: Sun Oct 02, 2016 5:58 am

Re: Getting the usable screen dimension

Post 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!
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: Getting the usable screen dimension

Post 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
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Getting the usable screen dimension

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests