Page 1 of 1

love.window.isVisible()

Posted: Tue Feb 03, 2015 9:16 pm
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

Re: love.window.isVisible()

Posted: Wed Feb 04, 2015 1:55 am
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:

Re: love.window.isVisible()

Posted: Wed Feb 04, 2015 3:33 am
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

Re: love.window.isVisible()

Posted: Wed Feb 04, 2015 4:09 am
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.)

Re: love.window.isVisible()

Posted: Wed Feb 04, 2015 1:18 pm
by TimWDavis84
I'm using Windows 7 SP 1 on both computers. (64 bit)

Re: love.window.isVisible()

Posted: Wed Feb 04, 2015 10:29 pm
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.

Re: love.window.isVisible()

Posted: Fri Feb 06, 2015 4:30 pm
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.

Re: love.window.isVisible()

Posted: Tue Feb 10, 2015 3:55 am
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.

Re: love.window.isVisible()

Posted: Tue Feb 10, 2015 7:02 am
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.