mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 14:51:30 +11:00
Implement revamped RedrawRequested
on iOS. (#1299)
* Implement revamped `RedrawRequested` on iOS * Added RedrawEventsCleared to events_cleared logic * Fixed from comments * Added RedrawEventsCleared to draw_rect handler. * Fixed out of order `RedrawEventsCleared` events. * cargo fmt
This commit is contained in:
parent
133b11fa6d
commit
530ff5420b
|
@ -12,7 +12,7 @@ use std::{
|
||||||
use objc::runtime::{BOOL, YES};
|
use objc::runtime::{BOOL, YES};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
event::{Event, StartCause, WindowEvent},
|
event::{Event, StartCause},
|
||||||
event_loop::ControlFlow,
|
event_loop::ControlFlow,
|
||||||
platform_impl::platform::{
|
platform_impl::platform::{
|
||||||
event_loop::{EventHandler, Never},
|
event_loop::{EventHandler, Never},
|
||||||
|
@ -51,11 +51,7 @@ enum UserCallbackTransitionResult<'a> {
|
||||||
|
|
||||||
impl Event<Never> {
|
impl Event<Never> {
|
||||||
fn is_redraw(&self) -> bool {
|
fn is_redraw(&self) -> bool {
|
||||||
if let Event::WindowEvent {
|
if let Event::RedrawRequested(_) = self {
|
||||||
window_id: _,
|
|
||||||
event: WindowEvent::RedrawRequested,
|
|
||||||
} = self
|
|
||||||
{
|
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -776,16 +772,18 @@ pub unsafe fn handle_main_events_cleared() {
|
||||||
|
|
||||||
// User events are always sent out at the end of the "MainEventLoop"
|
// User events are always sent out at the end of the "MainEventLoop"
|
||||||
handle_user_events();
|
handle_user_events();
|
||||||
handle_nonuser_event(Event::EventsCleared);
|
handle_nonuser_event(Event::MainEventsCleared);
|
||||||
|
|
||||||
let mut this = AppState::get_mut();
|
let mut this = AppState::get_mut();
|
||||||
let redraw_events = this
|
let mut redraw_events: Vec<Event<Never>> = this
|
||||||
.main_events_cleared_transition()
|
.main_events_cleared_transition()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|window| Event::WindowEvent {
|
.map(|window| Event::RedrawRequested(RootWindowId(window.into())))
|
||||||
window_id: RootWindowId(window.into()),
|
.collect();
|
||||||
event: WindowEvent::RedrawRequested,
|
|
||||||
});
|
if !redraw_events.is_empty() {
|
||||||
|
redraw_events.push(Event::RedrawEventsCleared);
|
||||||
|
}
|
||||||
drop(this);
|
drop(this);
|
||||||
|
|
||||||
handle_nonuser_events(redraw_events);
|
handle_nonuser_events(redraw_events);
|
||||||
|
|
|
@ -102,10 +102,10 @@ unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
||||||
unsafe {
|
unsafe {
|
||||||
let window: id = msg_send![object, window];
|
let window: id = msg_send![object, window];
|
||||||
assert!(!window.is_null());
|
assert!(!window.is_null());
|
||||||
app_state::handle_nonuser_event(Event::WindowEvent {
|
app_state::handle_nonuser_events(
|
||||||
window_id: RootWindowId(window.into()),
|
std::iter::once(Event::RedrawRequested(RootWindowId(window.into())))
|
||||||
event: WindowEvent::RedrawRequested,
|
.chain(std::iter::once(Event::RedrawEventsCleared)),
|
||||||
});
|
);
|
||||||
let superclass: &'static Class = msg_send![object, superclass];
|
let superclass: &'static Class = msg_send![object, superclass];
|
||||||
let () = msg_send![super(object, superclass), drawRect: rect];
|
let () = msg_send![super(object, superclass), drawRect: rect];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue