12

How do I bring any new GTK 3 window to the foreground on OSX sierra? Any window I open (using gtk-rs or python) ends up in the background first. I tried:

  • set_modal(true)
  • set_keep_above(true)
  • present()

Nothing seems to help and I couldn't find any bug report in that direction. Any idea how to achieve this?

GTK is installed via homebrew:

languitar@miles ~/code/rust (master)> brew info gtk+3
gtk+3: stable 3.22.4 (bottled)
Toolkit for creating graphical user interfaces
http://gtk.org/
/usr/local/Cellar/gtk+3/3.22.4 (1,395 files, 70.0M) *
  Poured from bottle on 2016-11-26 at 17:11:24
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gtk+3.rb
==> Dependencies
Build: pkg-config ✔
Required: gdk-pixbuf ✔, atk ✔, gobject-introspection ✔, libepoxy ✔, pango ✔, glib ✔, hicolor-icon-theme ✔
Recommended: gsettings-desktop-schemas ✔
Optional: jasper ✔
languitar
  • 6,554
  • 2
  • 37
  • 62
  • Did you check if your code is working on another platform like Linux? – oldtechaa Nov 26 '16 at 22:53
  • The main player is your window manager, who decides where new windows will appear. Did you check the WM's settings? – jcoppens Nov 27 '16 at 14:02
  • @jcoppens well, that is OSX. I don't know how to configure anything like that for OSX. – languitar Nov 27 '16 at 14:19
  • I'm completely unfamiliar with OSX. I heard/read somewhere, that, by default, the window system is Quartz. One of my students told me that it is possible to install X11 (which is the native environment for GTK, and where you can select many window managers). But I might be completely wrong here... Anyway, `set_keep_above` and other commands are suggestions from GTK to the WM. – jcoppens Nov 27 '16 at 14:33
  • 1
    Gtk 3 uses the native cocoa toolkit in the background. No need for X11 emulation here. – languitar Nov 27 '16 at 15:05
  • 1
    I assume you are using `show_all()` to show the window for sure. How about `raise()` ? – theGtknerd Dec 17 '16 at 01:29
  • I have opened a bug report for this: https://bugzilla.gnome.org/show_bug.cgi?id=782029 – languitar May 01 '17 at 20:56

1 Answers1

-1

Going out on a limb and this question ends soon with no code shown. So I will post what code should look like. Not to say you have not tried this. Just trying to help.

use gtk::prelude::*;

fn configure_window(window: &gtk::Window) {
    window.set_title("Phoronix Reader");
    let (width, height) = (600, 500);
    window.set_default_size(width, height);
    window.connect_delete_event(|_,_| {
        gtk::main_quit();
        Inhibit(true)
    });
}

pub fn main() {
    gtk::init().unwrap_or_else(|_| panic!("Failed to initialize GTK."));

    let window = gtk::Window::new(gtk::WindowType::Toplevel);
    configure_window(&window);

    window.show_all();

    gtk::main();
}
izidor
  • 4,068
  • 5
  • 33
  • 43
norcal johnny
  • 2,050
  • 2
  • 13
  • 17