On Wayland, reduce amount of spurious wakeups
Mark it as breaking, since some clients relied on that behavior, simply because dispatching clients queue always woke up a winit, meaning that they won't be able to use user events for this sake.
This commit is contained in:
parent
3c3a863cc9
commit
cad3277550
5 changed files with 155 additions and 95 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use std::cell::RefCell;
|
||||
use std::error::Error;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use fnv::FnvHashMap;
|
||||
|
|
@ -104,6 +105,10 @@ pub struct WinitState {
|
|||
|
||||
/// Loop handle to re-register event sources, such as keyboard repeat.
|
||||
pub loop_handle: LoopHandle<'static, Self>,
|
||||
|
||||
/// Whether we have dispatched events to the user thus we want to
|
||||
/// send `AboutToWait` and normally wakeup the user.
|
||||
pub dispatched_events: bool,
|
||||
}
|
||||
|
||||
impl WinitState {
|
||||
|
|
@ -167,6 +172,8 @@ impl WinitState {
|
|||
monitors: Arc::new(Mutex::new(monitors)),
|
||||
events_sink: EventSink::new(),
|
||||
loop_handle,
|
||||
// Make it true by default.
|
||||
dispatched_events: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -328,6 +335,18 @@ impl CompositorHandler for WinitState {
|
|||
None => return,
|
||||
};
|
||||
|
||||
// In case we have a redraw requested we must indicate the wake up.
|
||||
if self
|
||||
.window_requests
|
||||
.get_mut()
|
||||
.get(&window_id)
|
||||
.unwrap()
|
||||
.redraw_requested
|
||||
.load(Ordering::Relaxed)
|
||||
{
|
||||
self.dispatched_events = true;
|
||||
}
|
||||
|
||||
window.lock().unwrap().frame_callback_received();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue