Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions winit-win32/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ pub struct WindowAttributesWindows {
pub(crate) title_text_color: Option<Color>,
pub(crate) corner_preference: Option<CornerPreference>,
pub(crate) use_system_wheel_speed: bool,
pub(crate) no_activate: bool,
}

impl Default for WindowAttributesWindows {
Expand All @@ -494,6 +495,7 @@ impl Default for WindowAttributesWindows {
title_text_color: None,
corner_preference: None,
use_system_wheel_speed: true,
no_activate: false,
}
}
}
Expand Down Expand Up @@ -638,6 +640,13 @@ impl WindowAttributesWindows {
self.use_system_wheel_speed = should_use;
self
}

/// This sets or removes the WS_EX_NOACTIVATE flag
/// The default is `false`
pub fn with_no_activate(mut self, no_activate: bool) -> Self {
self.no_activate = no_activate;
self
}
}

impl PlatformWindowAttributes for WindowAttributesWindows {
Expand Down
1 change: 1 addition & 0 deletions winit-win32/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,7 @@ unsafe fn init(
// so the diffing later can work.
window_flags.set(WindowFlags::CLOSABLE, true);
window_flags.set(WindowFlags::CLIP_CHILDREN, win_attributes.clip_children);
window_flags.set(WindowFlags::NO_ACTIVATE, win_attributes.no_activate);

let mut fallback_parent = || match win_attributes.owner {
Some(parent) => {
Expand Down
11 changes: 8 additions & 3 deletions winit-win32/src/window_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use windows_sys::Win32::UI::WindowsAndMessaging::{
SWP_NOREPOSITION, SWP_NOSIZE, SWP_NOZORDER, SendMessageW, SetWindowLongW, SetWindowPos,
ShowWindow, WINDOW_EX_STYLE, WINDOW_STYLE, WINDOWPLACEMENT, WS_BORDER, WS_CAPTION, WS_CHILD,
WS_CLIPCHILDREN, WS_CLIPSIBLINGS, WS_EX_ACCEPTFILES, WS_EX_APPWINDOW, WS_EX_LAYERED,
WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOPMOST, WS_EX_TRANSPARENT, WS_EX_WINDOWEDGE, WS_MAXIMIZE,
WS_MAXIMIZEBOX, WS_MINIMIZE, WS_MINIMIZEBOX, WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX,
WS_SYSMENU, WS_VISIBLE,
WS_EX_NOACTIVATE, WS_EX_NOREDIRECTIONBITMAP, WS_EX_TOPMOST, WS_EX_TRANSPARENT,
WS_EX_WINDOWEDGE, WS_MAXIMIZE, WS_MAXIMIZEBOX, WS_MINIMIZE, WS_MINIMIZEBOX,
WS_OVERLAPPEDWINDOW, WS_POPUP, WS_SIZEBOX, WS_SYSMENU, WS_VISIBLE,
};
use winit_core::icon::Icon;
use winit_core::keyboard::ModifiersState;
Expand Down Expand Up @@ -140,6 +140,8 @@ bitflags! {

const CLIP_CHILDREN = 1 << 22;

const NO_ACTIVATE = 1 << 23;

const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits();
}
}
Expand Down Expand Up @@ -323,6 +325,9 @@ impl WindowFlags {
if self.contains(WindowFlags::CLIP_CHILDREN) {
style |= WS_CLIPCHILDREN;
}
if self.contains(WindowFlags::NO_ACTIVATE) {
style_ex |= WS_EX_NOACTIVATE;
}

if self.intersects(
WindowFlags::MARKER_EXCLUSIVE_FULLSCREEN | WindowFlags::MARKER_BORDERLESS_FULLSCREEN,
Expand Down
1 change: 1 addition & 0 deletions winit/src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ changelog entry.
### Added

- Add `keyboard` support for OpenHarmony.
- On Windows, add WindowAttributesWindows::no_activate for WS_EX_NOACTIVATE flag

### Fixed

Expand Down