Page 1 of 1

Does anyone know how to keep the window above others?

Posted: Wed Jul 17, 2019 12:50 am
by Leonardo2450
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?

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

Posted: Wed Jul 17, 2019 1:43 am
by raidho36
SDL supports this feature but it's not currently exposed in LOVE.

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

Posted: Wed Jul 17, 2019 12:15 pm
by Leonardo2450
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?

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

Posted: Wed Jul 17, 2019 1:34 pm
by zorg
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.)

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

Posted: Wed Jul 17, 2019 2:05 pm
by NotARaptor
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

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

Posted: Wed Jul 17, 2019 2:27 pm
by pgimeno
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

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

Posted: Wed Jul 17, 2019 8:25 pm
by Leonardo2450
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?