Skip to content

Commit f580433

Browse files
committed
WIP fifo and commit timing
1 parent d6c1ca8 commit f580433

File tree

6 files changed

+118
-2
lines changed

6 files changed

+118
-2
lines changed

src/backend/kms/surface/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ impl SurfaceThreadState {
993993
vrr = has_active_fullscreen;
994994
}
995995

996+
// TODO commit timing `signal_until`
997+
996998
let mut elements = output_elements(
997999
Some(&render_node),
9981000
&mut renderer,
@@ -1309,6 +1311,9 @@ impl SurfaceThreadState {
13091311
// If postprocessing, use states from first render
13101312
let states = pre_postprocess_data.states.unwrap_or(frame_result.states);
13111313
self.send_dmabuf_feedback(states);
1314+
1315+
let shell = self.shell.read();
1316+
shell.signal_fifos(&self.output);
13121317
}
13131318

13141319
if x.is_ok() {

src/shell/mod.rs

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ use smithay::{
3434
space::SpaceElement,
3535
utils::{
3636
surface_presentation_feedback_flags_from_states, surface_primary_scanout_output,
37-
take_presentation_feedback_surface_tree, OutputPresentationFeedback,
37+
take_presentation_feedback_surface_tree, with_surfaces_surface_tree,
38+
OutputPresentationFeedback,
3839
},
3940
LayerSurface, PopupKind, WindowSurface, WindowSurfaceType,
4041
},
@@ -51,7 +52,8 @@ use smithay::{
5152
},
5253
utils::{IsAlive, Logical, Point, Rectangle, Serial, Size},
5354
wayland::{
54-
compositor::{with_states, SurfaceAttributes},
55+
compositor::{with_states, SurfaceAttributes, SurfaceData},
56+
fifo::FifoBarrierCachedState,
5557
seat::WaylandFocus,
5658
session_lock::LockSurface,
5759
shell::wlr_layer::{KeyboardInteractivity, Layer, LayerSurfaceCachedState},
@@ -1905,6 +1907,98 @@ impl Shell {
19051907
})
19061908
}
19071909

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

src/state.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ use smithay::{
7676
compositor::{CompositorClientState, CompositorState, SurfaceData},
7777
cursor_shape::CursorShapeManagerState,
7878
dmabuf::{DmabufFeedback, DmabufGlobal, DmabufState},
79+
fifo::FifoManagerState,
7980
fractional_scale::{with_fractional_scale, FractionalScaleManagerState},
8081
idle_inhibit::IdleInhibitManagerState,
8182
idle_notify::IdleNotifierState,
@@ -233,6 +234,7 @@ pub struct Common {
233234
pub xdg_decoration_state: XdgDecorationState,
234235
pub overlap_notify_state: OverlapNotifyState,
235236
pub a11y_state: A11yState,
237+
pub fifo_manager_state: FifoManagerState,
236238

237239
// shell-related wayland state
238240
pub xdg_shell_state: XdgShellState,
@@ -646,6 +648,8 @@ impl State {
646648
// TODO: Restrict to only specific client?
647649
let atspi_state = AtspiState::new::<State, _>(dh, |_| true);
648650

651+
let fifo_manager_state = FifoManagerState::new::<State>(dh);
652+
649653
State {
650654
common: Common {
651655
config,
@@ -700,6 +704,7 @@ impl State {
700704
xdg_foreign_state,
701705
workspace_state,
702706
a11y_state,
707+
fifo_manager_state,
703708
xwayland_scale: None,
704709
xwayland_state: None,
705710
xwayland_shell_state,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
3+
use crate::state::State;
4+
5+
smithay::delegate_commit_timing!(State);

src/wayland/handlers/fifo.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
3+
use crate::state::State;
4+
5+
smithay::delegate_fifo!(State);

src/wayland/handlers/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub mod a11y;
44
pub mod alpha_modifier;
55
pub mod atspi;
66
pub mod buffer;
7+
pub mod commit_timing;
78
pub mod compositor;
89
pub mod data_control;
910
pub mod data_device;
@@ -12,6 +13,7 @@ pub mod dmabuf;
1213
pub mod drm;
1314
pub mod drm_lease;
1415
pub mod drm_syncobj;
16+
pub mod fifo;
1517
pub mod foreign_toplevel_list;
1618
pub mod fractional_scale;
1719
pub mod idle_inhibit;

0 commit comments

Comments
 (0)