Skip to content

Commit fef7060

Browse files
committed
WIP commit timing
1 parent 4c94721 commit fef7060

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed

src/backend/kms/surface/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,11 @@ impl SurfaceThreadState {
992992
}
993993

994994
// TODO commit timing `signal_until`
995+
{
996+
let shell = self.shell.read();
997+
// XXX correct way to set time?
998+
shell.signal_commit_timing(&self.output, self.clock.now() + estimated_presentation);
999+
}
9951000

9961001
let mut elements = output_elements(
9971002
Some(&render_node),

src/shell/mod.rs

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ use smithay::{
5050
wayland_protocols::ext::session_lock::v1::server::ext_session_lock_v1::ExtSessionLockV1,
5151
wayland_server::{protocol::wl_surface::WlSurface, Client},
5252
},
53-
utils::{IsAlive, Logical, Point, Rectangle, Serial, Size},
53+
utils::{IsAlive, Logical, Monotonic, Point, Rectangle, Serial, Size, Time},
5454
wayland::{
55+
commit_timing::CommitTimerBarrierStateUserData,
5556
compositor::{with_states, SurfaceAttributes, SurfaceData},
5657
fifo::FifoBarrierCachedState,
5758
seat::WaylandFocus,
@@ -1907,6 +1908,96 @@ impl Shell {
19071908
})
19081909
}
19091910

1911+
pub fn signal_commit_timing(&self, output: &Output, until: Time<Monotonic>) {
1912+
let processor = |_surface: &WlSurface, states: &SurfaceData| {
1913+
if let Some(mut commit_timer_state) = states
1914+
.data_map
1915+
.get::<CommitTimerBarrierStateUserData>()
1916+
.map(|commit_timer| commit_timer.lock().unwrap())
1917+
{
1918+
commit_timer_state.signal_until(until);
1919+
}
1920+
};
1921+
1922+
if let Some(session_lock) = self.session_lock.as_ref() {
1923+
if let Some(lock_surface) = session_lock.surfaces.get(output) {
1924+
with_surfaces_surface_tree(lock_surface.wl_surface(), processor);
1925+
}
1926+
}
1927+
1928+
self.workspaces
1929+
.sets
1930+
.get(output)
1931+
.unwrap()
1932+
.sticky_layer
1933+
.mapped()
1934+
.for_each(|mapped| {
1935+
for (window, _) in mapped.windows() {
1936+
window.0.with_surfaces(processor);
1937+
}
1938+
});
1939+
1940+
for workspace in self.workspaces.spaces_for_output(output) {
1941+
if let Some(window) = workspace.get_fullscreen() {
1942+
window.0.with_surfaces(processor);
1943+
}
1944+
workspace.mapped().for_each(|mapped| {
1945+
for (window, _) in mapped.windows() {
1946+
window.0.with_surfaces(processor);
1947+
}
1948+
});
1949+
workspace.minimized_windows.iter().for_each(|m| {
1950+
for window in m.windows() {
1951+
window.0.with_surfaces(processor);
1952+
}
1953+
});
1954+
}
1955+
1956+
let map = smithay::desktop::layer_map_for_output(output);
1957+
for layer_surface in map.layers() {
1958+
layer_surface.with_surfaces(processor);
1959+
}
1960+
1961+
self.override_redirect_windows.iter().for_each(|or| {
1962+
// Find output the override redirect window overlaps the most with
1963+
let or_geo = or.geometry().as_global();
1964+
let max_intersect_output = self
1965+
.outputs()
1966+
.filter_map(|o| Some((o, o.geometry().intersection(or_geo)?)))
1967+
.max_by_key(|(_, intersection)| intersection.size.w * intersection.size.h)
1968+
.map(|(o, _)| o);
1969+
if max_intersect_output == Some(output) {
1970+
if let Some(wl_surface) = or.wl_surface() {
1971+
with_surfaces_surface_tree(&wl_surface, processor);
1972+
}
1973+
}
1974+
});
1975+
1976+
for seat in self
1977+
.seats
1978+
.iter()
1979+
.filter(|seat| &seat.active_output() == output)
1980+
{
1981+
let cursor_status = seat.cursor_image_status();
1982+
1983+
if let CursorImageStatus::Surface(wl_surface) = cursor_status {
1984+
with_surfaces_surface_tree(&wl_surface, processor);
1985+
}
1986+
1987+
if let Some(move_grab) = seat.user_data().get::<SeatMoveGrabState>() {
1988+
if let Some(grab_state) = move_grab.lock().unwrap().as_ref() {
1989+
for (window, _) in grab_state.element().windows() {
1990+
window.0.with_surfaces(processor);
1991+
}
1992+
}
1993+
}
1994+
1995+
if let Some(icon) = get_dnd_icon(seat) {
1996+
with_surfaces_surface_tree(&icon.surface, processor);
1997+
}
1998+
}
1999+
}
2000+
19102001
pub fn signal_fifos(&self, output: &Output) {
19112002
fn processor(_surface: &WlSurface, states: &SurfaceData) {
19122003
let fifo_barrier = states

0 commit comments

Comments
 (0)