Skip to content
Draft
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
6 changes: 6 additions & 0 deletions winit-win32/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ unsafe fn init(
let menu = win_attributes.menu;
let fullscreen = attributes.fullscreen.clone();
let maximized = attributes.maximized;
let active = attributes.active;
let mut initdata = InitData { runner, attributes, win_attributes, window_flags, window: None };

let (style, ex_style) = window_flags.to_window_styles();
Expand Down Expand Up @@ -1700,6 +1701,11 @@ unsafe fn init(
win.set_maximized(true);
}

if !active {
win.window_state_lock()
.set_window_flags_in_place(|f| f.insert(WindowFlags::MARKER_ACTIVATE));
}

Ok(win)
}

Expand Down
11 changes: 5 additions & 6 deletions winit-win32/src/window_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,18 @@ impl WindowFlags {
}

/// Adjust the window client rectangle to the return value, if present.
fn apply_diff(mut self, window: HWND, mut new: WindowFlags) {
self = self.mask();
new = new.mask();
fn apply_diff(self, window: HWND, new: WindowFlags) {
let old = self.mask();
let new = new.mask();

let mut diff = self ^ new;
let mut diff = old ^ new;

if diff == WindowFlags::empty() {
return;
}

if new.contains(WindowFlags::VISIBLE) {
let flag = if !self.contains(WindowFlags::MARKER_ACTIVATE) {
self.set(WindowFlags::MARKER_ACTIVATE, true);
let flag = if !old.contains(WindowFlags::MARKER_ACTIVATE) {
SW_SHOWNOACTIVATE
} else {
SW_SHOW
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 @@ -51,3 +51,4 @@ changelog entry.
- Removed the `url` dependency from `winit-core`, along with `SendData::from_file_paths`,
`TypedData::try_as_file_paths` and `impl From<Vec<url::Url>> for SendData`. Use `SendData::Uris`
/ `TypedData::try_as_uris` with `file:` URIs instead.
- On Windows, if the window is created through `with_active(false)`, subsequent `window.set_visible(true)` calls will now focus the window (the current behavior is the window only gets focus if you call `window.set_focus()` or `window.set_maximized(true)`) this is consistent with the other platforms.
Loading