diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 654c0f01..968a810a 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -949,7 +949,7 @@ async fn run_instance
( ); actions += 1; } - Event::Winit(window_id, event) => { + Event::Winit(window_id, event::WindowEvent::RedrawRequested) => { let Some(mut current_compositor) = compositor.as_mut() else { continue; }; @@ -959,6 +959,8 @@ async fn run_instance
( else { continue; }; + // TODO only redraw when requested by event... + window.redraw_requested = false; let physical_size = window.state.physical_size(); let mut logical_size = window.state.logical_size(); @@ -1203,7 +1205,8 @@ async fn run_instance
(
}
},
}
-
+ }
+ Event::Winit(window_id, event) => {
if !is_daemon
&& matches!(event, winit::event::WindowEvent::Destroyed)
&& !is_window_opening
diff --git a/winit/src/platform_specific/mod.rs b/winit/src/platform_specific/mod.rs
index 1ea388d1..2ddaaa22 100644
--- a/winit/src/platform_specific/mod.rs
+++ b/winit/src/platform_specific/mod.rs
@@ -72,13 +72,6 @@ impl PlatformSpecific {
}
}
- pub(crate) fn send_ready(&mut self) {
- #[cfg(all(feature = "wayland", target_os = "linux"))]
- {
- self.send_wayland(wayland::Action::Ready);
- }
- }
-
pub(crate) fn update_subsurfaces(
&mut self,
id: window::Id,
diff --git a/winit/src/platform_specific/wayland/event_loop/mod.rs b/winit/src/platform_specific/wayland/event_loop/mod.rs
index 9b8891d1..6bc148f0 100644
--- a/winit/src/platform_specific/wayland/event_loop/mod.rs
+++ b/winit/src/platform_specific/wayland/event_loop/mod.rs
@@ -101,50 +101,51 @@ impl SctkEventLoop {
_ = loop_handle
.insert_source(action_rx, |event, _, state| {
match event {
- calloop::channel::Event::Msg(e) => match e {
- crate::platform_specific::Action::Action(a) => {
- if let Err(err) = state.handle_action(a) {
- log::warn!("{err:?}");
+ calloop::channel::Event::Msg(e) => match e {
+ crate::platform_specific::Action::Action(a) => {
+ if let Err(err) = state.handle_action(a) {
+ log::warn!("{err:?}");
+ }
}
- }
- crate::platform_specific::Action::TrackWindow(
- window,
- id,
- ) => {
- state.windows.push(SctkWindow { window, id });
- }
- crate::platform_specific::Action::RemoveWindow(id) => {
- // TODO clean up popups matching the window.
- state.windows.retain(|window| id != window.id);
- }
- crate::platform_specific::Action::SetCursor(icon) => {
- if let Some(seat) = state.seats.get_mut(0) {
- seat.icon = Some(icon);
- seat.set_cursor(&state.connection, icon);
+ crate::platform_specific::Action::TrackWindow(
+ window,
+ id,
+ ) => {
+ state.windows.push(SctkWindow { window, id });
}
- }
- crate::platform_specific::Action::RequestRedraw(id) => {
- let e = state.frame_status.entry(id).or_insert(FrameStatus::RequestedRedraw);
- if matches!(e, FrameStatus::Received) {
- *e = FrameStatus::Ready;
+ crate::platform_specific::Action::RemoveWindow(
+ id,
+ ) => {
+ // TODO clean up popups matching the window.
+ state.windows.retain(|window| id != window.id);
}
+ crate::platform_specific::Action::SetCursor(
+ icon,
+ ) => {
+ if let Some(seat) = state.seats.get_mut(0) {
+ seat.icon = Some(icon);
+ seat.set_cursor(&state.connection, icon);
+ }
+ }
+ crate::platform_specific::Action::RequestRedraw(
+ id,
+ ) => {
+ let e = state
+ .frame_status
+ .entry(id)
+ .or_insert(FrameStatus::RequestedRedraw);
+ if matches!(e, FrameStatus::Received) {
+ *e = FrameStatus::Ready;
+ }
+ }
+ crate::platform_specific::Action::Dropped(id) => {
+ _ = state.destroyed.remove(&id.inner());
+ }
+ },
+ calloop::channel::Event::Closed => {
+ log::info!("Calloop channel closed.");
}
- crate::platform_specific::Action::PrePresentNotify(
- _,
- ) => {
- // TODO
- }
- crate::platform_specific::Action::Ready => {
- state.ready = true;
- }
- crate::platform_specific::Action::Dropped(id) => {
- _ = state.destroyed.remove(&id.inner());
- }
- },
- calloop::channel::Event::Closed => {
- log::info!("Calloop channel closed.");
}
- }
})
.unwrap();
let wayland_source =
@@ -225,7 +226,6 @@ impl SctkEventLoop {
proxy,
id_map: Default::default(),
to_commit: HashMap::new(),
- ready: true,
destroyed: HashSet::new(),
pending_popup: Default::default(),
activation_token_ctr: 0,
@@ -303,9 +303,6 @@ impl SctkEventLoop {
}
}
}
- if !state.state.ready {
- continue;
- }
if let Err(err) =
state.event_loop.dispatch(None, &mut state.state)
@@ -370,7 +367,6 @@ impl SctkEventLoop {
);
}
}
-
if wake_up {
state.state.proxy.wake_up();
}
diff --git a/winit/src/platform_specific/wayland/event_loop/state.rs b/winit/src/platform_specific/wayland/event_loop/state.rs
index d999be20..bd5375fc 100644
--- a/winit/src/platform_specific/wayland/event_loop/state.rs
+++ b/winit/src/platform_specific/wayland/event_loop/state.rs
@@ -377,7 +377,6 @@ pub struct SctkState {
pub(crate) id_map: HashMap Window
@@ -219,11 +221,15 @@ where
pub fn request_redraw(&mut self, redraw_request: RedrawRequest) {
match redraw_request {
RedrawRequest::NextFrame => {
- self.raw.request_redraw();
+ if !self.redraw_requested {
+ self.redraw_requested = true;
+ self.raw.request_redraw();
+ }
self.redraw_at = None;
}
RedrawRequest::At(at) => {
self.redraw_at = Some(at);
+ self.redraw_requested = false;
}
RedrawRequest::Wait => {}
}