mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-02 23:00:05 -04:00
Add option to enable/disable WS_CLIPCHILDREN window style (#3212)
This commit is contained in:
@@ -91,6 +91,7 @@ Unreleased` header.
|
|||||||
- On macOS, send a `Resized` event after each `ScaleFactorChanged` event.
|
- On macOS, send a `Resized` event after each `ScaleFactorChanged` event.
|
||||||
- On Wayland, fix `wl_surface` being destroyed before associated objects.
|
- On Wayland, fix `wl_surface` being destroyed before associated objects.
|
||||||
- On macOS, fix assertion when pressing `Fn` key.
|
- On macOS, fix assertion when pressing `Fn` key.
|
||||||
|
- On Windows, add `WindowBuilderExtWindows::with_clip_children` to control `WS_CLIPCHILDREN` style.
|
||||||
|
|
||||||
# 0.29.3
|
# 0.29.3
|
||||||
|
|
||||||
|
|||||||
@@ -315,6 +315,9 @@ pub trait WindowBuilderExtWindows {
|
|||||||
/// Enabling the shadow causes a thin 1px line to appear on the top of the window.
|
/// Enabling the shadow causes a thin 1px line to appear on the top of the window.
|
||||||
fn with_undecorated_shadow(self, shadow: bool) -> Self;
|
fn with_undecorated_shadow(self, shadow: bool) -> Self;
|
||||||
|
|
||||||
|
/// This sets or removes `WS_CLIPCHILDREN` style.
|
||||||
|
fn with_clip_children(self, flag: bool) -> Self;
|
||||||
|
|
||||||
/// Sets the color of the window border.
|
/// Sets the color of the window border.
|
||||||
///
|
///
|
||||||
/// Supported starting with Windows 11 Build 22000.
|
/// Supported starting with Windows 11 Build 22000.
|
||||||
@@ -385,6 +388,12 @@ impl WindowBuilderExtWindows for WindowBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn with_clip_children(mut self, flag: bool) -> Self {
|
||||||
|
self.window.platform_specific.clip_children = flag;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn with_border_color(mut self, color: Option<Color>) -> Self {
|
fn with_border_color(mut self, color: Option<Color>) -> Self {
|
||||||
self.window.platform_specific.border_color = Some(color.unwrap_or(Color::NONE));
|
self.window.platform_specific.border_color = Some(color.unwrap_or(Color::NONE));
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ pub struct PlatformSpecificWindowBuilderAttributes {
|
|||||||
pub skip_taskbar: bool,
|
pub skip_taskbar: bool,
|
||||||
pub class_name: String,
|
pub class_name: String,
|
||||||
pub decoration_shadow: bool,
|
pub decoration_shadow: bool,
|
||||||
|
pub clip_children: bool,
|
||||||
pub border_color: Option<Color>,
|
pub border_color: Option<Color>,
|
||||||
pub title_background_color: Option<Color>,
|
pub title_background_color: Option<Color>,
|
||||||
pub title_text_color: Option<Color>,
|
pub title_text_color: Option<Color>,
|
||||||
@@ -54,6 +55,7 @@ impl Default for PlatformSpecificWindowBuilderAttributes {
|
|||||||
skip_taskbar: false,
|
skip_taskbar: false,
|
||||||
class_name: "Window Class".to_string(),
|
class_name: "Window Class".to_string(),
|
||||||
decoration_shadow: false,
|
decoration_shadow: false,
|
||||||
|
clip_children: true,
|
||||||
border_color: None,
|
border_color: None,
|
||||||
title_background_color: None,
|
title_background_color: None,
|
||||||
title_text_color: None,
|
title_text_color: None,
|
||||||
|
|||||||
@@ -1356,6 +1356,10 @@ unsafe fn init(
|
|||||||
// Will be changed later using `window.set_enabled_buttons` but we need to set a default here
|
// Will be changed later using `window.set_enabled_buttons` but we need to set a default here
|
||||||
// so the diffing later can work.
|
// so the diffing later can work.
|
||||||
window_flags.set(WindowFlags::CLOSABLE, true);
|
window_flags.set(WindowFlags::CLOSABLE, true);
|
||||||
|
window_flags.set(
|
||||||
|
WindowFlags::CLIP_CHILDREN,
|
||||||
|
attributes.platform_specific.clip_children,
|
||||||
|
);
|
||||||
|
|
||||||
let mut fallback_parent = || match attributes.platform_specific.owner {
|
let mut fallback_parent = || match attributes.platform_specific.owner {
|
||||||
Some(parent) => {
|
Some(parent) => {
|
||||||
|
|||||||
@@ -124,6 +124,8 @@ bitflags! {
|
|||||||
|
|
||||||
const MARKER_ACTIVATE = 1 << 21;
|
const MARKER_ACTIVATE = 1 << 21;
|
||||||
|
|
||||||
|
const CLIP_CHILDREN = 1 << 22;
|
||||||
|
|
||||||
const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits();
|
const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +255,7 @@ impl WindowFlags {
|
|||||||
|
|
||||||
pub fn to_window_styles(self) -> (WINDOW_STYLE, WINDOW_EX_STYLE) {
|
pub fn to_window_styles(self) -> (WINDOW_STYLE, WINDOW_EX_STYLE) {
|
||||||
// Required styles to properly support common window functionality like aero snap.
|
// Required styles to properly support common window functionality like aero snap.
|
||||||
let mut style = WS_CAPTION | WS_BORDER | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU;
|
let mut style = WS_CAPTION | WS_BORDER | WS_CLIPSIBLINGS | WS_SYSMENU;
|
||||||
let mut style_ex = WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES;
|
let mut style_ex = WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES;
|
||||||
|
|
||||||
if self.contains(WindowFlags::RESIZABLE) {
|
if self.contains(WindowFlags::RESIZABLE) {
|
||||||
@@ -298,6 +300,9 @@ impl WindowFlags {
|
|||||||
if self.contains(WindowFlags::IGNORE_CURSOR_EVENT) {
|
if self.contains(WindowFlags::IGNORE_CURSOR_EVENT) {
|
||||||
style_ex |= WS_EX_TRANSPARENT | WS_EX_LAYERED;
|
style_ex |= WS_EX_TRANSPARENT | WS_EX_LAYERED;
|
||||||
}
|
}
|
||||||
|
if self.contains(WindowFlags::CLIP_CHILDREN) {
|
||||||
|
style |= WS_CLIPCHILDREN;
|
||||||
|
}
|
||||||
|
|
||||||
if self.intersects(
|
if self.intersects(
|
||||||
WindowFlags::MARKER_EXCLUSIVE_FULLSCREEN | WindowFlags::MARKER_BORDERLESS_FULLSCREEN,
|
WindowFlags::MARKER_EXCLUSIVE_FULLSCREEN | WindowFlags::MARKER_BORDERLESS_FULLSCREEN,
|
||||||
|
|||||||
Reference in New Issue
Block a user