After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 782029 - set_keep_above has no effect
set_keep_above has no effect
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: Quartz
3.22.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-quartz maintainers
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-05-01 20:53 UTC by languitar
Modified: 2018-05-02 18:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description languitar 2017-05-01 20:53:10 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()
Comment 1 Paul Davis 2017-05-01 21:10:39 UTC
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).
Comment 2 languitar 2017-05-01 21:12:03 UTC
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.
Comment 3 guillaume1.gomez 2018-04-29 20:12:32 UTC
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
Comment 4 GNOME Infrastructure Team 2018-05-02 18:26:06 UTC
-- 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.