GNOME Bugzilla – Bug 782029
set_keep_above has no effect
Last modified: 2018-05-02 18:26:06 UTC
I have been trying to implement a modal application launcher (like dmenu) for OSX. Neither with experimental rust bindings nor with python bindings I am able to create a window that is consistently placed above other window. set_keep_above doesn't seem to have any effect. I have also tried set_modal and present with no success. As with native Cocoa such modal windows seem to be possible, I suspect that there is something missing in the backend for this to work. Here is an example python program to test this. import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk win = Gtk.Window() win.set_keep_above(True) win.set_modal(True) win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main()
OS X/MacOS has a concept for window layering that doesn't exist on X Window or in GTK (not explicitly, anyway). Windows belong to a particular type layer. There is no way to make a window be above ALL other windows unless it is of the type that users the upper-most layer. the current implementation of set_keep_above() (assuming it is like the one I originally worked on for GTK+2) only raises a window to the top of its layer group (just like the Cocoa equivalent). If you want window to be "really on top", you have to ensure it will be on an upper layer, which in GTK terms means it needs to be a popup (for example).
Thanks for the explanations. I also tried to set the window type to popup but that just made the window appear somewhere where I couldn't find it at all.
A workaround can be done by having an Objective C code: #import <AppKit/AppKit.h> void macos_force_foreground_level() { [NSApp activateIgnoringOtherApps: YES]; } Then just compile it with cc (which is clang on OSX): cc -framework Foundation -framework AppKit your_file.m Then just call the function inside your code. We did it in gtk-rs: https://github.com/gtk-rs/gtk/pull/651
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/812.