Last active
August 31, 2023 14:24
-
-
Save rparrett/02bf3221b5eabf3d019b8c301d58e580 to your computer and use it in GitHub Desktop.
(macos) Make new windows from bevy's example-showcase --screenshot not steal focus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs | |
index 8c79494de..7bd737744 100644 | |
--- a/crates/bevy_winit/src/lib.rs | |
+++ b/crates/bevy_winit/src/lib.rs | |
@@ -47,6 +47,9 @@ use bevy_window::{ | |
#[cfg(target_os = "android")] | |
pub use winit::platform::android::activity::AndroidApp; | |
+#[cfg(target_os = "macos")] | |
+use winit::platform::macos::EventLoopBuilderExtMacOS; | |
+ | |
use winit::{ | |
event::{self, DeviceEvent, Event, StartCause, WindowEvent}, | |
event_loop::{ControlFlow, EventLoop, EventLoopBuilder, EventLoopWindowTarget}, | |
@@ -75,6 +78,9 @@ pub struct WinitPlugin; | |
impl Plugin for WinitPlugin { | |
fn build(&self, app: &mut App) { | |
let mut event_loop_builder = EventLoopBuilder::<()>::with_user_event(); | |
+ | |
+ event_loop_builder.with_activate_ignoring_other_apps(false); | |
+ | |
#[cfg(target_os = "android")] | |
{ | |
use winit::platform::android::EventLoopBuilderExtAndroid; | |
diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs | |
index 4c7f30df6..46d8b2616 100644 | |
--- a/crates/bevy_winit/src/winit_windows.rs | |
+++ b/crates/bevy_winit/src/winit_windows.rs | |
@@ -97,7 +97,8 @@ impl WinitWindows { | |
.with_enabled_buttons(convert_enabled_buttons(window.enabled_buttons)) | |
.with_decorations(window.decorations) | |
.with_transparent(window.transparent) | |
- .with_visible(window.visible); | |
+ .with_visible(window.visible) | |
+ .with_active(false); | |
let constraints = window.resize_constraints.check_constraints(); | |
let min_inner_size = LogicalSize { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment