Move Event::RedrawRequested to WindowEvent (#3049)

This commit is contained in:
daxpedda 2023-08-27 16:15:09 +02:00 committed by GitHub
parent a3cba838ea
commit 67d3fd28f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 572 additions and 562 deletions

View file

@ -57,7 +57,13 @@ enum UserCallbackTransitionResult<'a> {
impl Event<Never> {
fn is_redraw(&self) -> bool {
matches!(self, Event::RedrawRequested(_))
matches!(
self,
Event::WindowEvent {
event: WindowEvent::RedrawRequested,
..
}
)
}
}
@ -755,7 +761,12 @@ pub unsafe fn handle_main_events_cleared() {
let redraw_events: Vec<EventWrapper> = this
.main_events_cleared_transition()
.into_iter()
.map(|window| EventWrapper::StaticEvent(Event::RedrawRequested(RootWindowId(window.id()))))
.map(|window| {
EventWrapper::StaticEvent(Event::WindowEvent {
window_id: RootWindowId(window.id()),
event: WindowEvent::RedrawRequested,
})
})
.collect();
drop(this);

View file

@ -43,9 +43,10 @@ declare_class!(
fn draw_rect(&self, rect: CGRect) {
let window = self.window().unwrap();
unsafe {
app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::RedrawRequested(
RootWindowId(window.id()),
)));
app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::WindowEvent {
window_id: RootWindowId(window.id()),
event: WindowEvent::RedrawRequested,
}));
}
let _: () = unsafe { msg_send![super(self), drawRect: rect] };
}