-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS regresssion: new window starts on top of fullscreen window #2051
Comments
This is really an issue with the way that use simple_logger::SimpleLogger;
use winit::{
event::{Event, WindowEvent, StartCause},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
fn main() {
SimpleLogger::new().init().unwrap();
let event_loop = EventLoop::new();
let mut window = None;
event_loop.run(move |event, event_loop, control_flow| {
*control_flow = ControlFlow::Wait;
println!("{:?}", event);
match event {
Event::NewEvents(StartCause::Init) => {
window = Some(WindowBuilder::new()
.with_title("A fantastic window!")
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.build(&event_loop)
.unwrap());
}
Event::WindowEvent {
event: WindowEvent::CloseRequested,
window_id,
} if window_id == window.as_ref().unwrap().id() => *control_flow = ControlFlow::Exit,
Event::MainEventsCleared => {
window.as_ref().unwrap().request_redraw();
}
_ => (),
}
});
} But if that is not possible, you can temporarily add the following after unsafe {
use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicy::*};
let ns_app = NSApp();
ns_app.setActivationPolicy_(NSApplicationActivationPolicyRegular);
} |
I can confirm that adding unsafe {
use cocoa::appkit::{NSApp, NSApplication, NSApplicationActivationPolicy::*};
let ns_app = NSApp();
ns_app.setActivationPolicy_(NSApplicationActivationPolicyRegular);
} to the top of the app fixes the problem! Thanks for that work-around! |
I can confirm that your sample code works on macOS and fixed the window behaviour. With regard to:
I think an update to the primary usage example would help to make this clear. See crates.io - this is where I started. Also, the idea to redraw every time
On the surface, this looks a little redundant. Can it be explained, and also added to the example. |
I think the idea of creating the window from within the loop is a good one, but other libraries (like So essentially (like the title suggests) this should most likely be marked as a type: bug and be fixed accordingly. |
I just quickly copied the
Correct. I may try to take at stab at it at some point, but others should feel welcome! |
Reproduce: Run VSCode in fullscreen mode, and in the VSCode terminal enter
cargo run --example window
(in thewinit
repo).Expected (and actual in winit 0.24):
The view changes to the desktop and the winit window opens there.
Actual:
The winit window pops up over the fullscreen VSCode, and then the view changes to the desktop (where there is no window).
When did this break?
Work-arounds
Add the following code to after you create the event loop, but before creating your window:
The text was updated successfully, but these errors were encountered: