mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Fix events not being emitted during modal loops on macOS (#1173)
This commit is contained in:
parent
d35ee0d580
commit
695547f4ca
|
@ -12,6 +12,8 @@
|
||||||
- On Windows, fix handling of surrogate pairs when dispatching `ReceivedCharacter`.
|
- On Windows, fix handling of surrogate pairs when dispatching `ReceivedCharacter`.
|
||||||
- On macOS 10.15, fix freeze upon exiting exclusive fullscreen mode.
|
- On macOS 10.15, fix freeze upon exiting exclusive fullscreen mode.
|
||||||
- On iOS, fix null window on initial `HiDpiFactorChanged` event.
|
- On iOS, fix null window on initial `HiDpiFactorChanged` event.
|
||||||
|
- On macOS, fix events not being emitted during modal loops, such as when windows are being resized
|
||||||
|
by the user.
|
||||||
- On Windows, fix hovering the mouse over the active window creating an endless stream of CursorMoved events.
|
- On Windows, fix hovering the mouse over the active window creating an endless stream of CursorMoved events.
|
||||||
|
|
||||||
# 0.20.0 Alpha 3 (2019-08-14)
|
# 0.20.0 Alpha 3 (2019-08-14)
|
||||||
|
|
|
@ -84,7 +84,6 @@ struct Handler {
|
||||||
start_time: Mutex<Option<Instant>>,
|
start_time: Mutex<Option<Instant>>,
|
||||||
callback: Mutex<Option<Box<dyn EventHandler>>>,
|
callback: Mutex<Option<Box<dyn EventHandler>>>,
|
||||||
pending_events: Mutex<VecDeque<Event<Never>>>,
|
pending_events: Mutex<VecDeque<Event<Never>>>,
|
||||||
deferred_events: Mutex<VecDeque<Event<Never>>>,
|
|
||||||
pending_redraw: Mutex<Vec<WindowId>>,
|
pending_redraw: Mutex<Vec<WindowId>>,
|
||||||
waker: Mutex<EventLoopWaker>,
|
waker: Mutex<EventLoopWaker>,
|
||||||
}
|
}
|
||||||
|
@ -97,10 +96,6 @@ impl Handler {
|
||||||
self.pending_events.lock().unwrap()
|
self.pending_events.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deferred<'a>(&'a self) -> MutexGuard<'a, VecDeque<Event<Never>>> {
|
|
||||||
self.deferred_events.lock().unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn redraw<'a>(&'a self) -> MutexGuard<'a, Vec<WindowId>> {
|
fn redraw<'a>(&'a self) -> MutexGuard<'a, Vec<WindowId>> {
|
||||||
self.pending_redraw.lock().unwrap()
|
self.pending_redraw.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -145,10 +140,6 @@ impl Handler {
|
||||||
mem::replace(&mut *self.events(), Default::default())
|
mem::replace(&mut *self.events(), Default::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_deferred(&self) -> VecDeque<Event<Never>> {
|
|
||||||
mem::replace(&mut *self.deferred(), Default::default())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn should_redraw(&self) -> Vec<WindowId> {
|
fn should_redraw(&self) -> Vec<WindowId> {
|
||||||
mem::replace(&mut *self.redraw(), Default::default())
|
mem::replace(&mut *self.redraw(), Default::default())
|
||||||
}
|
}
|
||||||
|
@ -264,20 +255,6 @@ impl AppState {
|
||||||
HANDLER.events().append(&mut events);
|
HANDLER.events().append(&mut events);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_event_immediately(event: Event<Never>) {
|
|
||||||
if !unsafe { msg_send![class!(NSThread), isMainThread] } {
|
|
||||||
panic!("Event sent from different thread: {:#?}", event);
|
|
||||||
}
|
|
||||||
HANDLER.deferred().push_back(event);
|
|
||||||
if !HANDLER.get_in_callback() {
|
|
||||||
HANDLER.set_in_callback(true);
|
|
||||||
for event in HANDLER.take_deferred() {
|
|
||||||
HANDLER.handle_nonuser_event(event);
|
|
||||||
}
|
|
||||||
HANDLER.set_in_callback(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cleared() {
|
pub fn cleared() {
|
||||||
if !HANDLER.is_ready() {
|
if !HANDLER.is_ready() {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,7 +4,6 @@ use crate::platform_impl::platform::{app_state::AppState, ffi};
|
||||||
|
|
||||||
#[link(name = "CoreFoundation", kind = "framework")]
|
#[link(name = "CoreFoundation", kind = "framework")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub static kCFRunLoopDefaultMode: CFRunLoopMode;
|
|
||||||
pub static kCFRunLoopCommonModes: CFRunLoopMode;
|
pub static kCFRunLoopCommonModes: CFRunLoopMode;
|
||||||
|
|
||||||
pub fn CFRunLoopGetMain() -> CFRunLoopRef;
|
pub fn CFRunLoopGetMain() -> CFRunLoopRef;
|
||||||
|
@ -162,7 +161,7 @@ impl RunLoop {
|
||||||
handler,
|
handler,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
);
|
||||||
CFRunLoopAddObserver(self.0, observer, kCFRunLoopDefaultMode);
|
CFRunLoopAddObserver(self.0, observer, kCFRunLoopCommonModes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,11 +84,7 @@ impl WindowDelegateState {
|
||||||
pub fn emit_resize_event(&mut self) {
|
pub fn emit_resize_event(&mut self) {
|
||||||
let rect = unsafe { NSView::frame(*self.ns_view) };
|
let rect = unsafe { NSView::frame(*self.ns_view) };
|
||||||
let size = LogicalSize::new(rect.size.width as f64, rect.size.height as f64);
|
let size = LogicalSize::new(rect.size.width as f64, rect.size.height as f64);
|
||||||
let event = Event::WindowEvent {
|
self.emit_event(WindowEvent::Resized(size));
|
||||||
window_id: WindowId(get_window_id(*self.ns_window)),
|
|
||||||
event: WindowEvent::Resized(size),
|
|
||||||
};
|
|
||||||
AppState::send_event_immediately(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_move_event(&mut self) {
|
fn emit_move_event(&mut self) {
|
||||||
|
|
Loading…
Reference in a new issue