Merge pull request #654 from atbentley/hide-titlebar-macos

Hide titlebar on macos
This commit is contained in:
Héctor Ramón 2021-08-12 21:04:20 +07:00 committed by GitHub
commit 0f5242a728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 8 deletions

View file

@ -2,8 +2,13 @@
#[cfg(target_os = "windows")]
#[path = "settings/windows.rs"]
mod platform;
#[cfg(not(target_os = "windows"))]
#[path = "settings/not_windows.rs"]
#[cfg(target_os = "macos")]
#[path = "settings/macos.rs"]
mod platform;
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
#[path = "settings/other.rs"]
mod platform;
pub use platform::PlatformSpecific;
@ -137,6 +142,20 @@ impl Window {
.with_drag_and_drop(self.platform_specific.drag_and_drop);
}
#[cfg(target_os = "macos")]
{
use winit::platform::macos::WindowBuilderExtMacOS;
window_builder = window_builder
.with_title_hidden(self.platform_specific.title_hidden)
.with_titlebar_transparent(
self.platform_specific.titlebar_transparent,
)
.with_fullsize_content_view(
self.platform_specific.fullsize_content_view,
);
}
window_builder = window_builder
.with_fullscreen(conversion::fullscreen(primary_monitor, mode));

View file

@ -0,0 +1,13 @@
#![cfg(target_os = "macos")]
//! Platform specific settings for macOS.
/// The platform specific window settings of an application.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct PlatformSpecific {
/// Hides the window title.
pub title_hidden: bool,
/// Makes the titlebar transparent and allows the content to appear behind it.
pub titlebar_transparent: bool,
/// Makes the window content appear behind the titlebar.
pub fullsize_content_view: bool,
}

View file

@ -1,6 +0,0 @@
#![cfg(not(target_os = "windows"))]
//! Platform specific settings for not Windows.
/// The platform specific window settings of an application.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct PlatformSpecific {}

View file

@ -0,0 +1,3 @@
/// The platform specific window settings of an application.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct PlatformSpecific;