From 18a5d40ba3ed196ee44142f4d6eda787f8e17428 Mon Sep 17 00:00:00 2001 From: Rodrigo Rivas Costa Date: Sun, 14 Sep 2025 19:49:31 +0200 Subject: [PATCH] Fix 'no-decorations' in Windows. In Windows, an overlapped window that used `with_decorations(false)` didn't have the proper styles. --- winit-win32/src/window_state.rs | 13 +++++++------ winit/src/changelog/unreleased.md | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/winit-win32/src/window_state.rs b/winit-win32/src/window_state.rs index 78b36e5221..31c51fa385 100644 --- a/winit-win32/src/window_state.rs +++ b/winit-win32/src/window_state.rs @@ -295,12 +295,13 @@ impl WindowFlags { } if self.contains(WindowFlags::CHILD) { style |= WS_CHILD; // This is incompatible with WS_POPUP if that gets added eventually. - - // Remove decorations window styles for child - if !self.contains(WindowFlags::MARKER_DECORATIONS) { - style &= !(WS_CAPTION | WS_BORDER); - style_ex &= !WS_EX_WINDOWEDGE; - } + } + if !self.contains(WindowFlags::MARKER_DECORATIONS) { + // WS_CAPTION is equal to (WS_BORDER | WS_DLGFRAME) + // The former is intended for overlapped windows, + // the latter are for child windows. + style &= !(WS_CAPTION | WS_SIZEBOX); + style_ex &= !WS_EX_WINDOWEDGE; } if self.contains(WindowFlags::POPUP) { style |= WS_POPUP; diff --git a/winit/src/changelog/unreleased.md b/winit/src/changelog/unreleased.md index c59decc82a..79622c67ce 100644 --- a/winit/src/changelog/unreleased.md +++ b/winit/src/changelog/unreleased.md @@ -264,3 +264,4 @@ changelog entry. - On Windows, `Window::theme` will return the correct theme after setting it through `Window::set_theme`. - On Windows, `Window::set_theme` will change the title bar color immediately now. - On Windows 11, prevent incorrect shifting when dragging window onto a monitor with different DPI. +- On Windows, `with_decoration(false)` works for overlapped (non child) windows.