Skip to content

Commit

Permalink
Apply 'with_active' option to winit (emilk#2813)
Browse files Browse the repository at this point in the history
* feat: apply 'with_active' option to winit

* fix: remove platform specification

- winit accept this option for all platforms

* build fix

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
Dixeran and emilk authored Apr 18, 2023
1 parent af4d737 commit 8a2cfbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ pub struct NativeOptions {
/// Generally you would use this in conjunction with always_on_top
pub mouse_passthrough: bool,

/// Whether grant focus when window initially opened. True by default.
pub active: bool,

/// Turn on vertical syncing, limiting the FPS to the display refresh rate.
///
/// The default is `true`.
Expand Down Expand Up @@ -421,6 +424,9 @@ impl Default for NativeOptions {
resizable: true,
transparent: false,
mouse_passthrough: false,

active: true,

vsync: true,
multisampling: 0,
depth_buffer: 0,
Expand Down
2 changes: 2 additions & 0 deletions crates/eframe/src/native/epi_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub fn window_builder<E>(
resizable,
transparent,
centered,
active,
..
} = native_options;

Expand All @@ -104,6 +105,7 @@ pub fn window_builder<E>(
.with_resizable(*resizable)
.with_transparent(*transparent)
.with_window_icon(window_icon)
.with_active(*active)
// Keep hidden until we've painted something. See https://github.com/emilk/egui/pull/2279
// We must also keep the window hidden until AccessKit is initialized.
.with_visible(false);
Expand Down

0 comments on commit 8a2cfbd

Please sign in to comment.