mapped: Allow to query in-flight configure for resize throttling
This commit is contained in:
parent
6c7ec54bdb
commit
df74a322ab
2 changed files with 63 additions and 0 deletions
|
|
@ -489,6 +489,14 @@ impl CosmicMapped {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn latest_size_committed(&self) -> bool {
|
||||
match &self.element {
|
||||
CosmicMappedInternal::Stack(s) => s.surfaces().any(|s| s.latest_size_committed()),
|
||||
CosmicMappedInternal::Window(w) => w.surface().latest_size_committed(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn configure(&self) -> Option<Serial> {
|
||||
match &self.element {
|
||||
CosmicMappedInternal::Stack(s) => {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ use smithay::{
|
|||
},
|
||||
xwayland::{xwm::X11Relatable, X11Surface},
|
||||
};
|
||||
use tracing::trace;
|
||||
|
||||
use crate::{
|
||||
state::{State, SurfaceDmabufFeedback},
|
||||
|
|
@ -499,6 +500,60 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn serial_past(&self, serial: &Serial) -> bool {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(toplevel) => with_states(toplevel.wl_surface(), |states| {
|
||||
let attrs = states
|
||||
.data_map
|
||||
.get::<XdgToplevelSurfaceData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
attrs
|
||||
.current_serial
|
||||
.as_ref()
|
||||
.map(|s| s >= serial)
|
||||
.unwrap_or(false)
|
||||
}),
|
||||
WindowSurface::X11(_surface) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn latest_size_committed(&self) -> bool {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(toplevel) => {
|
||||
with_states(toplevel.wl_surface(), |states| {
|
||||
let attributes = states
|
||||
.data_map
|
||||
.get::<XdgToplevelSurfaceData>()
|
||||
.unwrap()
|
||||
.lock()
|
||||
.unwrap();
|
||||
|
||||
let current_server = attributes.current_server_state();
|
||||
if attributes.current.size == current_server.size {
|
||||
// The window had committed for our previous size change, so we can
|
||||
// change the size again.
|
||||
trace!(
|
||||
"current size matches server size: {:?}",
|
||||
attributes.current.size
|
||||
);
|
||||
true
|
||||
} else {
|
||||
// The window had not committed for our previous size change yet.
|
||||
// This throttling is done because some clients do not batch size requests,
|
||||
// leading to bad behavior with very fast input devices (i.e. a 1000 Hz
|
||||
// mouse). This throttling also helps interactive resize transactions
|
||||
// preserve visual consistency.
|
||||
trace!("throttling resize");
|
||||
false
|
||||
}
|
||||
})
|
||||
}
|
||||
WindowSurface::X11(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn force_configure(&self) -> Option<Serial> {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(toplevel) => Some(toplevel.send_configure()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue