Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Feature]Always on top #68

Open
Fran-Rg opened this issue Nov 30, 2015 · 5 comments
Open

[New Feature]Always on top #68

Fran-Rg opened this issue Nov 30, 2015 · 5 comments

Comments

@Fran-Rg
Copy link

Fran-Rg commented Nov 30, 2015

That would be great to add an option "always on top" that would keep the item tracker windows at the top of the windows.
It would be even better if it could be on top of the game when fullscreen, but I don't think this is feasible.

@Zamiell
Copy link
Contributor

Zamiell commented Dec 9, 2015

There's no real need to add this to the tracker, as this can be accomplished in literally one line using AutoHotkey:

; A hotkey of Windows Key + x
#x::
    ; Set the currently active window to "AlwaysOnTop" mode, or disable it if it was already set that way
    Winset, AlwaysOnTop, Toggle, A

    ; Play a sound so that I know the hotkey was pressed
    SoundPlay, C:\Windows\Media\Windows Logoff Sound.wav
return

@Zamiell
Copy link
Contributor

Zamiell commented Jan 21, 2016

This lists how to add this option:

http://stackoverflow.com/questions/1482565/how-to-make-python-window-run-as-always-on-top

It seems it would only take adding 2 additional lines? Something like:

if option.alwaysontop:
    SetWindowPos(pygame.display.get_wm_info()['window'], -1, x, y, 0, 0, 0x0001)

@Hyphen-ated
Copy link
Owner

when i call that function, it can successfully set the size and position, but it doesn't do the always-on-top

@viroulep
Copy link
Contributor

I forgot to post it there, when looking for a platform independent solution I found this :
http://pygame.org/project-Window+Manager+Extensions-515-.html

If using a pygame extension is fine I could take a look at this in like 2 weeks.

@viroulep
Copy link
Contributor

I forgot to say that I looked into it.
tl;dr: Zam's lines "should" have worked, and please make this a Windows-specific option.

Long version :

Windows

The extension is pretty straightforward, basically it does what Zam said :
SetWindowPos(getSDLWindow(), zorder, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE)
Which translates to :

from ctypes import windll
windll.user32.SetWindowPos(pygame.display.get_wm_info()['window'], -1, 0, 0, 0, 0, 0x0003)

(the SWP_NOMOVE flag tells no to modify the window position, so x/y would be ignored)
So if Hyphen tested it and it didn't work then idk...
Both the extension and the SO question are quite old, pygame and/or windows may have changed stuff in between. I can't be very helpful with this.

Linux

It's... complicated.
First of all there is not only one window manager.
The program can set a bunch of predefined "hints" that may, or may not, be handled by the window manager (in this case the _NET_WM_STATE_ABOVE, from the Extended Window Manager Hints).
I use a tiling window manager, floating windows support is here only for edge cases like "print" or "save as" popups, or specific app like inkscape/gimp (and in my case Isaac windowed+tracker+timer, which do not overlap). In the context of such a WM, there is not much use-case for a z-order on floating windows, and i3 just doesn't support it.
Still, I could extract a minimal set of changes from the extension and run it. It obviously doesn't work for me, but the most popular desktop environments (gnome/kde) have support for this, so I believe it would work.
However I actually don't have a use for this feature, and I'm not setting up a VM to test this :p
If someone else want to bring the linux support for this feature, I can push a rough draft of the changes needed somewhere. Maybe @Nandicre would be interested to do this, he mentioned he was using arch and I think he uses xfce, which claims having support for EWMH.
Not sure it's worth it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants