mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-28 07:33:14 -04:00
[macos] add NSWindow.hasShadow support (#1637)
* [macos] add NSWindow.hasShadow * change log * cargo fmt * Update CHANGELOG.md * Update src/platform_impl/macos/window.rs * Update src/platform/macos.rs * set_has_shadow() with cuter format * adjust code * cargo fmt * changelog
This commit is contained in:
@@ -60,7 +60,7 @@ pub fn get_window_id(window_cocoa_id: id) -> Id {
|
||||
Id(window_cocoa_id as *const Object as _)
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
#[derive(Clone)]
|
||||
pub struct PlatformSpecificWindowBuilderAttributes {
|
||||
pub activation_policy: ActivationPolicy,
|
||||
pub movable_by_window_background: bool,
|
||||
@@ -71,6 +71,25 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
||||
pub fullsize_content_view: bool,
|
||||
pub resize_increments: Option<LogicalSize<f64>>,
|
||||
pub disallow_hidpi: bool,
|
||||
pub has_shadow: bool,
|
||||
}
|
||||
|
||||
impl Default for PlatformSpecificWindowBuilderAttributes {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
activation_policy: Default::default(),
|
||||
movable_by_window_background: false,
|
||||
titlebar_transparent: false,
|
||||
title_hidden: false,
|
||||
titlebar_hidden: false,
|
||||
titlebar_buttons_hidden: false,
|
||||
fullsize_content_view: false,
|
||||
resize_increments: None,
|
||||
disallow_hidpi: false,
|
||||
has_shadow: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_app(activation_policy: ActivationPolicy) -> Option<id> {
|
||||
@@ -224,6 +243,10 @@ fn create_window(
|
||||
}
|
||||
}
|
||||
|
||||
if !pl_attrs.has_shadow {
|
||||
ns_window.setHasShadow_(NO);
|
||||
}
|
||||
|
||||
ns_window.center();
|
||||
ns_window
|
||||
});
|
||||
@@ -1094,6 +1117,19 @@ impl WindowExtMacOS for UnownedWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn has_shadow(&self) -> bool {
|
||||
unsafe { self.ns_window.hasShadow() == YES }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_has_shadow(&self, has_shadow: bool) {
|
||||
unsafe {
|
||||
self.ns_window
|
||||
.setHasShadow_(if has_shadow { YES } else { NO })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for UnownedWindow {
|
||||
|
||||
Reference in New Issue
Block a user