Does anyone know how to keep the window above others?

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.
Post Reply
User avatar
Leonardo2450
Prole
Posts: 13
Joined: Wed Jul 17, 2019 12:45 am
Location: Esta xd

Does anyone know how to keep the window above others?

Post by Leonardo2450 » Wed Jul 17, 2019 12:50 am

I'm using Love2D and currently I need to make my window always the first one to be displayed. Does anyone have any idea how to do it?
-Leonardo2450-
[DATA EXPUNGED] Argentinian looking for something to do in his spare time. :awesome:

User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Does anyone know how to keep the window above others?

Post by raidho36 » Wed Jul 17, 2019 1:43 am

SDL supports this feature but it's not currently exposed in LOVE.

User avatar
Leonardo2450
Prole
Posts: 13
Joined: Wed Jul 17, 2019 12:45 am
Location: Esta xd

Re: Does anyone know how to keep the window above others?

Post by Leonardo2450 » Wed Jul 17, 2019 12:15 pm

raidho36 wrote:
Wed Jul 17, 2019 1:43 am
SDL supports this feature but it's not currently exposed in LOVE.
So what should I do?
-Leonardo2450-
[DATA EXPUNGED] Argentinian looking for something to do in his spare time. :awesome:

User avatar
zorg
Party member
Posts: 2936
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Does anyone know how to keep the window above others?

Post by zorg » Wed Jul 17, 2019 1:34 pm

You can't do anything in löve itself, unless you want to compile it yourself after modifying its source. (Edit: I forgot about FFI as the post below this pointed out)
You could also open an issue on bitbucket and try your luck that way, whether the devs think it's an option worthy of adding or not.

One more solution, but only if you're using windows and are only making your project for yourself; nirsoft has an utility called WinLister that can set the topmost mode on any window... note that you can mess your OS up in suprising ways with it (making invisible windows topmost, making it impossible to click on anything anymore, for example) so the tool's not for novices... but apart from that, it is safe; the guy has a good reputation. (Just google nirsoft winlister if the scenario i said previously applies to you.)
Last edited by zorg on Wed Jul 17, 2019 6:20 pm, edited 1 time in total.
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
NotARaptor
Citizen
Posts: 59
Joined: Thu Feb 22, 2018 3:15 pm

Re: Does anyone know how to keep the window above others?

Post by NotARaptor » Wed Jul 17, 2019 2:05 pm

If you're only targeting Windows, you can use ffi to call the relevant WinApi functions directly - you'd need FindWindow and SetWindowPos:

- Set the title of the window to some unique string (in love)
- Call FindWindow [ffi] with that string to retrieve the HWND of the main window
- Call SetWindowPos [ffi] with HWND_TOPMOST (-1) as second argument and the flags to ignore the other arguments
- Set your window title back to the original one

User avatar
pgimeno
Party member
Posts: 2211
Joined: Sun Oct 18, 2015 2:58 pm

Re: Does anyone know how to keep the window above others?

Post by pgimeno » Wed Jul 17, 2019 2:27 pm

Since SDL has that function, wouldn't it be simpler, and more cross-platform compatible, to call the SDL function via FFI?

Edit: Hm, apparently not, as it seems SDL only allows that at window creation. https://discourse.libsdl.org/t/can-i-ch ... ehow/24030

User avatar
Leonardo2450
Prole
Posts: 13
Joined: Wed Jul 17, 2019 12:45 am
Location: Esta xd

Re: Does anyone know how to keep the window above others?

Post by Leonardo2450 » Wed Jul 17, 2019 8:25 pm

NotARaptor wrote:
Wed Jul 17, 2019 2:05 pm
If you're only targeting Windows, you can use ffi to call the relevant WinApi functions directly - you'd need FindWindow and SetWindowPos:

- Set the title of the window to some unique string (in love)
- Call FindWindow [ffi] with that string to retrieve the HWND of the main window
- Call SetWindowPos [ffi] with HWND_TOPMOST (-1) as second argument and the flags to ignore the other arguments
- Set your window title back to the original one
I guess the winApi I have to download or not?
-Leonardo2450-
[DATA EXPUNGED] Argentinian looking for something to do in his spare time. :awesome:

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests