love.window.isVisible()

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
TimWDavis84
Prole
Posts: 4
Joined: Tue Feb 03, 2015 9:01 pm

love.window.isVisible()

Post by TimWDavis84 »

Hey everyone,

I'm brand new to LÖVE and would like to first say hello. I'm really enjoying it so far.

I had a question regarding love.window.isVisible(). I have searched the forums and documentation and can't seem to solve my issue. For some reason, minimizing my window is not causing this function to switch to false. Has anyone else had this issue and have any idea on how to fix it? I'll post two ways I'm trying to get it to show up, but can post all of my code if needed. Thanks in advance!

Tim

Code: Select all

function love.update(dt)
	
	if love.window.isVisible() == false then
		print("Window minimized!")
	end
	
	checkPrices()
	checkThread()

	updateTimer = updateTimer - dt
	
	if updateTimer <= 0 then
		updateTimer = updateTime
		newThread()
	end

end
--- This never prints Window Minimized

Code: Select all

function love.visible(v)
	
	print(v)
	
end
--- This just displays true and then never triggers again
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: love.window.isVisible()

Post by HugoBDesigner »

Hello TimWDavis! Welcome to the forums!

So, the function love.window.setVisible does not exists. You can't (yet) force a window to minimize, only to close.
As for the love.window.isVisible, it returns false if the window is minimized. You can set a little timer to test this out:

Code: Select all

function love.load()
    myTimer = 0
end
function love.update(dt)
    myTimer = myTimer + dt
    if myTimer >= 1 then
        print("window visible: " .. tostring(love.window.isVisible()))
        myTimer = 0
    end
end
This will make your game print a new message every second. Try minimizing and restoring your window every now and then, with different intervals of time, to test this out. If it doesn't work, try with love.visible in the same way, and let us know if it worked or not.

I hope I helped, and good luck with your project :awesome:
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
TimWDavis84
Prole
Posts: 4
Joined: Tue Feb 03, 2015 9:01 pm

Re: love.window.isVisible()

Post by TimWDavis84 »

Hey Hugo! Thanks a lot for your quick response!

I tried testing with your timer and still got the same results. For some reason even when I minimize the window the timer still prints that the window visible = true. I actually created a new blank program with your code to see if something was wrong w/ my game, but still the same results. I also have tried this on two separate computers. I try to do all the troubleshooting I can before bugging everyone with silly questions, but this one really has me stumped. I'm thinking it's something really silly on my end. I'll keep messing with it and see if I can figure it out!

Thanks again for your help! :)
Tim
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.window.isVisible()

Post by slime »

What OS are you using? It sounds like a bug in the OS-specific backend code for window visibility in SDL (the library LÖVE uses for cross-platform window/screen and input functionality.)
User avatar
TimWDavis84
Prole
Posts: 4
Joined: Tue Feb 03, 2015 9:01 pm

Re: love.window.isVisible()

Post by TimWDavis84 »

I'm using Windows 7 SP 1 on both computers. (64 bit)
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: love.window.isVisible()

Post by HugoBDesigner »

Huh... This is weird. I just tested my own code, and it also just printed "true" for all cases. My computer is also Windows 7, but 32 bits.
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
TimWDavis84
Prole
Posts: 4
Joined: Tue Feb 03, 2015 9:01 pm

Re: love.window.isVisible()

Post by TimWDavis84 »

Yeah that is weird. Well I'm glad I'm not crazy. I did everything I could think of to get it to trigger.
Cartread
Prole
Posts: 6
Joined: Sat May 19, 2012 8:17 pm

Re: love.window.isVisible()

Post by Cartread »

I encountered this about a year ago (time of year that it's really cold :neko: ).
I posted it on the issue tracker: https://bitbucket.org/rude/love/issue/8 ... triggering
Alex Szpakowski answered basically the same as slime mentioned above (Windows and SDL interaction).

love.window.hasFocus() could be of use to you.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: love.window.isVisible()

Post by bartbes »

Cartread wrote: Alex Szpakowski answered basically the same as slime mentioned above (Windows and SDL interaction).
At least he didn't change his mind, then.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 3 guests