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

AlwaysOnTop options #7

Open
juliardi opened this issue Oct 2, 2017 · 3 comments
Open

AlwaysOnTop options #7

juliardi opened this issue Oct 2, 2017 · 3 comments

Comments

@juliardi
Copy link
Contributor

juliardi commented Oct 2, 2017

Can we have an options to make the message dialog appear always on top? I have a little program that works like an alarm. At a fixed time, I want it to show a message dialog. The message dialog appears, but it's burried under another application window. So it will be nice to have a dialog that will appear always on top of other application window.

@sqweek
Copy link
Owner

sqweek commented Oct 7, 2017

I'm presuming the little program doesn't have any other windows?

AFAIK there's no cross-platform way to do this, since OSX's focus model prevents "background" applications from popping up windows in front of the "foreground" application.

In linux such behaviour depends on the window manager in use and how it is configured -- you might find the "focus stealing" policy is preventing the dialog from appearing on top. You'll also probably find there's another mechanism for generating such alerts eg. via system tray balloon messages or similar.

But a best effort feature should be feasible. Preliminary research suggests:

win32: add MB_TOPMOST style https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx
osx: [window setLevel:NSFloatingWindowLevel]; https://stackoverflow.com/questions/3278208/how-do-i-to-make-a-windowosx-always-hover-on-top-of-screen/3278262#3278262
gtk: gtk_window_set_keep_above(GTK_WINDOW(win), true) or use GTK_WINDOW_POPUP https://stackoverflow.com/questions/10331394/how-to-keep-transient-window-on-top-in-gtk

(just keeping notes here for now)

@samschurter
Copy link

I tried MB_TOPMOST, MB_SYSTEMMODAL, MB_TASKMODAL, and MB_SETFOREGROUND, the only one that brought the alert box all the way to the top was MB_SYSTEMMODAL.

I added the MB_SYSTEMMODAL flag to https://github.com/TheTitanrain/w32 to keep things consistent, added a bool member to the MsgBuilder struct and a method to set it true if the dialog should be on top.

The Windows code will add the MB_SYSTEMMODAL flag if the Top flag is true, but Linux and OSX will just ignore it. I don't have experience with or access to those systems to see what works.

The file and directory dialogs don't have the same options available, looks like they will be harder to set as topmost.

@sqweek
Copy link
Owner

sqweek commented Sep 8, 2020

Sorry for not acknowledging this sooner. I started replying months ago but never finished the comment :S

I don't love the solution because MB_SYSTEMMODAL is also the most anti-social ux possible, but also based on your testing (thank you!) it doesn't seem like there's much alternative. I think I would like to better understand the circumstances in which a new dialog appears behind other windows though, in case there is a way to avoid that without adding another option to the API.

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

Successfully merging a pull request may close this issue.

3 participants