-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gdk4-macos: manually implement native_window method
For now we need to depend on the cocoa crate in order to implement this method since it is the only decent crate implementing the cocoa api.
- Loading branch information
Showing
6 changed files
with
153 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ mod auto; | |
pub mod prelude; | ||
|
||
pub use auto::*; | ||
|
||
mod macos_surface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Take a look at the license at the top of the repository in the LICENSE file. | ||
|
||
#[cfg(feature = "v4_8")] | ||
use crate::ffi; | ||
use crate::MacosSurface; | ||
#[cfg(feature = "v4_8")] | ||
use cocoa::base::id; | ||
#[cfg(feature = "v4_8")] | ||
use glib::translate::*; | ||
|
||
impl MacosSurface { | ||
#[cfg(feature = "v4_8")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))] | ||
#[doc(alias = "gdk_macos_surface_get_native_window")] | ||
#[doc(alias = "get_native_window")] | ||
pub fn native_window(&self) -> Option<id> { | ||
unsafe { | ||
let native_window_ptr = ffi::gdk_macos_surface_get_native_window(self.to_glib_none().0); | ||
if native_window_ptr.is_null() { | ||
None | ||
} else { | ||
Some(native_window_ptr as id) | ||
} | ||
} | ||
} | ||
} |