gtk/
window.rs

1// Copyright 2015-2018, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use glib::object::IsA;
6use glib::translate::*;
7use gtk_sys;
8use Window;
9
10pub trait GtkWindowExtManual: 'static {
11    fn present(&self);
12}
13
14#[cfg(target_os = "macos")]
15extern "C" {
16    fn macos_force_foreground_level();
17}
18
19impl<O: IsA<Window>> GtkWindowExtManual for O {
20    fn present(&self) {
21        unsafe {
22            gtk_sys::gtk_window_present(self.as_ref().to_glib_none().0);
23        }
24        // This is a super wonderful hack to actually make this function work as expected.
25        #[cfg(target_os = "macos")]
26        unsafe {
27            macos_force_foreground_level();
28        }
29    }
30}