Update Smithay (last_acked refactor, Qt layer-shell popup grab fix, popup ordering fix)
Browse files at this commit4808ba2b2055a09008be17d3e9eeae2d592b7b18Parent: 35cbab49 changed files +116 -97
- Cargo.lock +2 -2
- src/handlers/compositor.rs +9 -8
- src/handlers/layer_shell.rs +1 -17
- src/handlers/mod.rs +1 -11
- src/handlers/xdg_shell.rs +3 -2
- src/protocols/foreign_toplevel.rs +20 -7
- src/tests/window_opening.rs +1 -13
- src/utils/mod.rs +21 -1
- src/window/mapped.rs +58 -36
Cargo.lockmodified+2 -2
| @@ -3602,7 +3602,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" | |||
| 3602 | [[package]] | 3602 | [[package]] |
| 3603 | name = "smithay" | 3603 | name = "smithay" |
| 3604 | version = "0.7.0" | 3604 | version = "0.7.0" |
| 3605 | -source = "git+https://github.com/Smithay/smithay.git#20d2dacd71394b5f96f6ace0a70a6f20dc62c0c6" | 3605 | +source = "git+https://github.com/Smithay/smithay.git#47c2d2de18697a63ddf9e828212510e0349c9d27" |
| 3606 | dependencies = [ | 3606 | dependencies = [ |
| 3607 | "aliasable", | 3607 | "aliasable", |
| 3608 | "appendlist", | 3608 | "appendlist", |
| @@ -3676,7 +3676,7 @@ dependencies = [ | |||
| 3676 | [[package]] | 3676 | [[package]] |
| 3677 | name = "smithay-drm-extras" | 3677 | name = "smithay-drm-extras" |
| 3678 | version = "0.1.0" | 3678 | version = "0.1.0" |
| 3679 | -source = "git+https://github.com/Smithay/smithay.git#20d2dacd71394b5f96f6ace0a70a6f20dc62c0c6" | 3679 | +source = "git+https://github.com/Smithay/smithay.git#47c2d2de18697a63ddf9e828212510e0349c9d27" |
| 3680 | dependencies = [ | 3680 | dependencies = [ |
| 3681 | "drm", | 3681 | "drm", |
| 3682 | "libdisplay-info", | 3682 | "libdisplay-info", |
src/handlers/compositor.rsmodified+9 -8
| @@ -14,7 +14,7 @@ use smithay::wayland::compositor::{ | |||
| 14 | SurfaceAttributes, | 14 | SurfaceAttributes, |
| 15 | }; | 15 | }; |
| 16 | use smithay::wayland::dmabuf::get_dmabuf; | 16 | use smithay::wayland::dmabuf::get_dmabuf; |
| 17 | -use smithay::wayland::shell::xdg::XdgToplevelSurfaceData; | 17 | +use smithay::wayland::shell::xdg::ToplevelCachedState; |
| 18 | use smithay::wayland::shm::{ShmHandler, ShmState}; | 18 | use smithay::wayland::shm::{ShmHandler, ShmState}; |
| 19 | use smithay::{delegate_compositor, delegate_shm}; | 19 | use smithay::{delegate_compositor, delegate_shm}; |
| 20 | 20 | ||
| @@ -286,13 +286,14 @@ impl CompositorHandler for State { | |||
| 286 | .buffer_delta | 286 | .buffer_delta |
| 287 | .take(); | 287 | .take(); |
| 288 | 288 | ||
| 289 | - let role = states | 289 | + let serial = states |
| 290 | - .data_map | 290 | + .cached_state |
| 291 | - .get::<XdgToplevelSurfaceData>() | 291 | + .get::<ToplevelCachedState>() |
| 292 | - .unwrap() | 292 | + .current() |
| 293 | - .lock() | 293 | + .last_acked |
| 294 | - .unwrap(); | 294 | + .as_ref() |
| 295 | - (role.configure_serial, buffer_delta) | 295 | + .map(|c| c.serial); |
| 296 | + (serial, buffer_delta) | ||
| 296 | }); | 297 | }); |
| 297 | if serial.is_none() { | 298 | if serial.is_none() { |
| 298 | error!("commit on a mapped surface without a configured serial"); | 299 | error!("commit on a mapped surface without a configured serial"); |
src/handlers/layer_shell.rsmodified+1 -17
| @@ -174,24 +174,8 @@ impl State { | |||
| 174 | self.niri.layer_shell_on_demand_focus = Some(layer.clone()); | 174 | self.niri.layer_shell_on_demand_focus = Some(layer.clone()); |
| 175 | } | 175 | } |
| 176 | } else { | 176 | } else { |
| 177 | - let was_mapped = self.niri.mapped_layer_surfaces.remove(layer).is_some(); | 177 | + self.niri.mapped_layer_surfaces.remove(layer); |
| 178 | self.niri.unmapped_layer_surfaces.insert(surface.clone()); | 178 | self.niri.unmapped_layer_surfaces.insert(surface.clone()); |
| 179 | - | ||
| 180 | - // After layer surface unmaps it has to perform the initial commit-configure | ||
| 181 | - // sequence again. This is a workaround until Smithay properly resets | ||
| 182 | - // initial_configure_sent upon the surface unmapping itself as it does for | ||
| 183 | - // toplevels. | ||
| 184 | - if was_mapped { | ||
| 185 | - with_states(surface, |states| { | ||
| 186 | - let mut data = states | ||
| 187 | - .data_map | ||
| 188 | - .get::<LayerSurfaceData>() | ||
| 189 | - .unwrap() | ||
| 190 | - .lock() | ||
| 191 | - .unwrap(); | ||
| 192 | - data.initial_configure_sent = false; | ||
| 193 | - }); | ||
| 194 | - } | ||
| 195 | } | 179 | } |
| 196 | } else { | 180 | } else { |
| 197 | let scale = output.current_scale(); | 181 | let scale = output.current_scale(); |
src/handlers/mod.rsmodified+1 -11
| @@ -19,7 +19,6 @@ use smithay::input::pointer::{ | |||
| 19 | use smithay::input::{keyboard, Seat, SeatHandler, SeatState}; | 19 | use smithay::input::{keyboard, Seat, SeatHandler, SeatState}; |
| 20 | use smithay::output::Output; | 20 | use smithay::output::Output; |
| 21 | use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags}; | 21 | use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags}; |
| 22 | -use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; | ||
| 23 | use smithay::reexports::wayland_protocols_wlr::screencopy::v1::server::zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1; | 22 | use smithay::reexports::wayland_protocols_wlr::screencopy::v1::server::zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1; |
| 24 | use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource; | 23 | use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource; |
| 25 | use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; | 24 | use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; |
| @@ -92,7 +91,7 @@ use crate::protocols::virtual_pointer::{ | |||
| 92 | VirtualPointerInputBackend, VirtualPointerManagerState, VirtualPointerMotionAbsoluteEvent, | 91 | VirtualPointerInputBackend, VirtualPointerManagerState, VirtualPointerMotionAbsoluteEvent, |
| 93 | VirtualPointerMotionEvent, | 92 | VirtualPointerMotionEvent, |
| 94 | }; | 93 | }; |
| 95 | -use crate::utils::{output_size, send_scale_transform, with_toplevel_role}; | 94 | +use crate::utils::{output_size, send_scale_transform}; |
| 96 | use crate::{ | 95 | use crate::{ |
| 97 | delegate_ext_workspace, delegate_foreign_toplevel, delegate_gamma_control, | 96 | delegate_ext_workspace, delegate_foreign_toplevel, delegate_gamma_control, |
| 98 | delegate_mutter_x11_interop, delegate_output_management, delegate_screencopy, | 97 | delegate_mutter_x11_interop, delegate_output_management, delegate_screencopy, |
| @@ -543,15 +542,6 @@ impl ForeignToplevelHandler for State { | |||
| 543 | fn set_fullscreen(&mut self, wl_surface: WlSurface, wl_output: Option<WlOutput>) { | 542 | fn set_fullscreen(&mut self, wl_surface: WlSurface, wl_output: Option<WlOutput>) { |
| 544 | if let Some((mapped, current_output)) = self.niri.layout.find_window_and_output(&wl_surface) | 543 | if let Some((mapped, current_output)) = self.niri.layout.find_window_and_output(&wl_surface) |
| 545 | { | 544 | { |
| 546 | - let has_fullscreen_cap = with_toplevel_role(mapped.toplevel(), |role| { | ||
| 547 | - role.current | ||
| 548 | - .capabilities | ||
| 549 | - .contains(xdg_toplevel::WmCapabilities::Fullscreen) | ||
| 550 | - }); | ||
| 551 | - if !has_fullscreen_cap { | ||
| 552 | - return; | ||
| 553 | - } | ||
| 554 | - | ||
| 555 | let window = mapped.window.clone(); | 545 | let window = mapped.window.clone(); |
| 556 | 546 | ||
| 557 | if let Some(requested_output) = wl_output.as_ref().and_then(Output::from_resource) { | 547 | if let Some(requested_output) = wl_output.as_ref().and_then(Output::from_resource) { |
src/handlers/xdg_shell.rsmodified+3 -2
| @@ -1259,8 +1259,9 @@ pub fn add_mapped_toplevel_pre_commit_hook(toplevel: &ToplevelSurface) -> HookId | |||
| 1259 | .unwrap() | 1259 | .unwrap() |
| 1260 | .lock() | 1260 | .lock() |
| 1261 | .unwrap(); | 1261 | .unwrap(); |
| 1262 | + let serial = role.last_acked.as_ref().map(|c| c.serial); | ||
| 1262 | 1263 | ||
| 1263 | - (got_unmapped, dmabuf, role.configure_serial) | 1264 | + (got_unmapped, dmabuf, serial) |
| 1264 | }); | 1265 | }); |
| 1265 | 1266 | ||
| 1266 | let mut transaction_for_dmabuf = None; | 1267 | let mut transaction_for_dmabuf = None; |
| @@ -1305,7 +1306,7 @@ pub fn add_mapped_toplevel_pre_commit_hook(toplevel: &ToplevelSurface) -> HookId | |||
| 1305 | } | 1306 | } |
| 1306 | 1307 | ||
| 1307 | animate = mapped.should_animate_commit(serial); | 1308 | animate = mapped.should_animate_commit(serial); |
| 1308 | - } else { | 1309 | + } else if !got_unmapped { |
| 1309 | error!("commit on a mapped surface without a configured serial"); | 1310 | error!("commit on a mapped surface without a configured serial"); |
| 1310 | }; | 1311 | }; |
| 1311 | 1312 | ||
src/protocols/foreign_toplevel.rsmodified+20 -7
| @@ -11,7 +11,9 @@ use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; | |||
| 11 | use smithay::reexports::wayland_server::{ | 11 | use smithay::reexports::wayland_server::{ |
| 12 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, | 12 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, |
| 13 | }; | 13 | }; |
| 14 | -use smithay::wayland::shell::xdg::{ToplevelStateSet, XdgToplevelSurfaceRoleAttributes}; | 14 | +use smithay::wayland::shell::xdg::{ |
| 15 | + ToplevelState, ToplevelStateSet, XdgToplevelSurfaceRoleAttributes, | ||
| 16 | +}; | ||
| 15 | use wayland_protocols_wlr::foreign_toplevel::v1::server::{ | 17 | use wayland_protocols_wlr::foreign_toplevel::v1::server::{ |
| 16 | zwlr_foreign_toplevel_handle_v1, zwlr_foreign_toplevel_manager_v1, | 18 | zwlr_foreign_toplevel_handle_v1, zwlr_foreign_toplevel_manager_v1, |
| 17 | }; | 19 | }; |
| @@ -19,7 +21,7 @@ use zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1; | |||
| 19 | use zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1; | 21 | use zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1; |
| 20 | 22 | ||
| 21 | use crate::niri::State; | 23 | use crate::niri::State; |
| 22 | -use crate::utils::with_toplevel_role; | 24 | +use crate::utils::with_toplevel_role_and_current; |
| 23 | 25 | ||
| 24 | const VERSION: u32 = 3; | 26 | const VERSION: u32 = 3; |
| 25 | 27 | ||
| @@ -96,11 +98,16 @@ pub fn refresh(state: &mut State) { | |||
| 96 | state.niri.layout.with_windows(|mapped, output, _, _| { | 98 | state.niri.layout.with_windows(|mapped, output, _, _| { |
| 97 | let toplevel = mapped.toplevel(); | 99 | let toplevel = mapped.toplevel(); |
| 98 | let wl_surface = toplevel.wl_surface(); | 100 | let wl_surface = toplevel.wl_surface(); |
| 99 | - with_toplevel_role(toplevel, |role| { | 101 | + with_toplevel_role_and_current(toplevel, |role, cur| { |
| 102 | + let Some(cur) = cur else { | ||
| 103 | + error!("mapped must have had initial commit"); | ||
| 104 | + return; | ||
| 105 | + }; | ||
| 106 | + | ||
| 100 | if state.niri.keyboard_focus.surface() == Some(wl_surface) { | 107 | if state.niri.keyboard_focus.surface() == Some(wl_surface) { |
| 101 | focused = Some((mapped.window.clone(), output.cloned())); | 108 | focused = Some((mapped.window.clone(), output.cloned())); |
| 102 | } else { | 109 | } else { |
| 103 | - refresh_toplevel(protocol_state, wl_surface, role, output, false); | 110 | + refresh_toplevel(protocol_state, wl_surface, role, cur, output, false); |
| 104 | } | 111 | } |
| 105 | }); | 112 | }); |
| 106 | }); | 113 | }); |
| @@ -109,8 +116,13 @@ pub fn refresh(state: &mut State) { | |||
| 109 | if let Some((window, output)) = focused { | 116 | if let Some((window, output)) = focused { |
| 110 | let toplevel = window.toplevel().expect("no X11 support"); | 117 | let toplevel = window.toplevel().expect("no X11 support"); |
| 111 | let wl_surface = toplevel.wl_surface(); | 118 | let wl_surface = toplevel.wl_surface(); |
| 112 | - with_toplevel_role(toplevel, |role| { | 119 | + with_toplevel_role_and_current(toplevel, |role, cur| { |
| 113 | - refresh_toplevel(protocol_state, wl_surface, role, output.as_ref(), true); | 120 | + let Some(cur) = cur else { |
| 121 | + error!("mapped must have had initial commit"); | ||
| 122 | + return; | ||
| 123 | + }; | ||
| 124 | + | ||
| 125 | + refresh_toplevel(protocol_state, wl_surface, role, cur, output.as_ref(), true); | ||
| 114 | }); | 126 | }); |
| 115 | } | 127 | } |
| 116 | } | 128 | } |
| @@ -144,10 +156,11 @@ fn refresh_toplevel( | |||
| 144 | protocol_state: &mut ForeignToplevelManagerState, | 156 | protocol_state: &mut ForeignToplevelManagerState, |
| 145 | wl_surface: &WlSurface, | 157 | wl_surface: &WlSurface, |
| 146 | role: &XdgToplevelSurfaceRoleAttributes, | 158 | role: &XdgToplevelSurfaceRoleAttributes, |
| 159 | + current: &ToplevelState, | ||
| 147 | output: Option<&Output>, | 160 | output: Option<&Output>, |
| 148 | has_focus: bool, | 161 | has_focus: bool, |
| 149 | ) { | 162 | ) { |
| 150 | - let states = to_state_vec(&role.current.states, has_focus); | 163 | + let states = to_state_vec(¤t.states, has_focus); |
| 151 | 164 | ||
| 152 | match protocol_state.toplevels.entry(wl_surface.clone()) { | 165 | match protocol_state.toplevels.entry(wl_surface.clone()) { |
| 153 | Entry::Occupied(entry) => { | 166 | Entry::Occupied(entry) => { |
src/tests/window_opening.rsmodified+1 -13
| @@ -65,6 +65,7 @@ fn simple() { | |||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | #[test] | 67 | #[test] |
| 68 | +#[should_panic(expected = "Protocol error 3 on object xdg_surface")] | ||
| 68 | fn dont_ack_initial_configure() { | 69 | fn dont_ack_initial_configure() { |
| 69 | let mut f = Fixture::new(); | 70 | let mut f = Fixture::new(); |
| 70 | f.add_output(1, (1920, 1080)); | 71 | f.add_output(1, (1920, 1080)); |
| @@ -80,19 +81,6 @@ fn dont_ack_initial_configure() { | |||
| 80 | // Don't ack the configure. | 81 | // Don't ack the configure. |
| 81 | window.commit(); | 82 | window.commit(); |
| 82 | f.double_roundtrip(id); | 83 | f.double_roundtrip(id); |
| 83 | - | ||
| 84 | - // FIXME: Technically this is a protocol violation but uh. Smithay currently doesn't check it, | ||
| 85 | - // and I'm not sure if it can be done generically in Smithay (because a compositor may not use | ||
| 86 | - // its rendering helpers). I might add a check in niri itself sometime; I'm just not sure if | ||
| 87 | - // there might be clients that this could break. | ||
| 88 | - let window = f.client(id).window(&surface); | ||
| 89 | - assert_snapshot!( | ||
| 90 | - window.format_recent_configures(), | ||
| 91 | - @r" | ||
| 92 | - size: 936 × 1048, bounds: 1888 × 1048, states: [] | ||
| 93 | - size: 936 × 1048, bounds: 1888 × 1048, states: [Activated] | ||
| 94 | - " | ||
| 95 | - ); | ||
| 96 | } | 84 | } |
| 97 | 85 | ||
| 98 | #[derive(Clone, Copy)] | 86 | #[derive(Clone, Copy)] |
src/utils/mod.rsmodified+21 -1
| @@ -25,7 +25,8 @@ use smithay::utils::{Coordinate, Logical, Point, Rectangle, Size, Transform}; | |||
| 25 | use smithay::wayland::compositor::{send_surface_state, with_states, SurfaceData}; | 25 | use smithay::wayland::compositor::{send_surface_state, with_states, SurfaceData}; |
| 26 | use smithay::wayland::fractional_scale::with_fractional_scale; | 26 | use smithay::wayland::fractional_scale::with_fractional_scale; |
| 27 | use smithay::wayland::shell::xdg::{ | 27 | use smithay::wayland::shell::xdg::{ |
| 28 | - ToplevelSurface, XdgToplevelSurfaceData, XdgToplevelSurfaceRoleAttributes, | 28 | + ToplevelCachedState, ToplevelState, ToplevelSurface, XdgToplevelSurfaceData, |
| 29 | + XdgToplevelSurfaceRoleAttributes, | ||
| 29 | }; | 30 | }; |
| 30 | use wayland_backend::server::Credentials; | 31 | use wayland_backend::server::Credentials; |
| 31 | 32 | ||
| @@ -279,6 +280,25 @@ pub fn with_toplevel_role<T>( | |||
| 279 | }) | 280 | }) |
| 280 | } | 281 | } |
| 281 | 282 | ||
| 283 | +pub fn with_toplevel_role_and_current<T>( | ||
| 284 | + toplevel: &ToplevelSurface, | ||
| 285 | + f: impl FnOnce(&mut XdgToplevelSurfaceRoleAttributes, Option<&ToplevelState>) -> T, | ||
| 286 | +) -> T { | ||
| 287 | + with_states(toplevel.wl_surface(), |states| { | ||
| 288 | + let mut role = states | ||
| 289 | + .data_map | ||
| 290 | + .get::<XdgToplevelSurfaceData>() | ||
| 291 | + .unwrap() | ||
| 292 | + .lock() | ||
| 293 | + .unwrap(); | ||
| 294 | + | ||
| 295 | + let mut guard = states.cached_state.get::<ToplevelCachedState>(); | ||
| 296 | + let current = guard.current().last_acked.as_ref().map(|c| &c.state); | ||
| 297 | + | ||
| 298 | + f(&mut role, current) | ||
| 299 | + }) | ||
| 300 | +} | ||
| 301 | + | ||
| 282 | pub fn update_tiled_state( | 302 | pub fn update_tiled_state( |
| 283 | toplevel: &ToplevelSurface, | 303 | toplevel: &ToplevelSurface, |
| 284 | prefer_no_csd: bool, | 304 | prefer_no_csd: bool, |
src/window/mapped.rsmodified+58 -36
| @@ -15,7 +15,10 @@ use smithay::reexports::wayland_server::Resource as _; | |||
| 15 | use smithay::utils::{Logical, Point, Rectangle, Scale, Serial, Size, Transform}; | 15 | use smithay::utils::{Logical, Point, Rectangle, Scale, Serial, Size, Transform}; |
| 16 | use smithay::wayland::compositor::{remove_pre_commit_hook, with_states, HookId, SurfaceData}; | 16 | use smithay::wayland::compositor::{remove_pre_commit_hook, with_states, HookId, SurfaceData}; |
| 17 | use smithay::wayland::seat::WaylandFocus; | 17 | use smithay::wayland::seat::WaylandFocus; |
| 18 | -use smithay::wayland::shell::xdg::{SurfaceCachedState, ToplevelSurface}; | 18 | +use smithay::wayland::shell::xdg::{ |
| 19 | + SurfaceCachedState, ToplevelCachedState, ToplevelConfigure, ToplevelSurface, | ||
| 20 | + XdgToplevelSurfaceData, | ||
| 21 | +}; | ||
| 19 | use wayland_backend::server::Credentials; | 22 | use wayland_backend::server::Credentials; |
| 20 | 23 | ||
| 21 | use super::{ResolvedWindowRules, WindowRef}; | 24 | use super::{ResolvedWindowRules, WindowRef}; |
| @@ -36,7 +39,7 @@ use crate::utils::id::IdCounter; | |||
| 36 | use crate::utils::transaction::Transaction; | 39 | use crate::utils::transaction::Transaction; |
| 37 | use crate::utils::{ | 40 | use crate::utils::{ |
| 38 | get_credentials_for_surface, send_scale_transform, update_tiled_state, with_toplevel_role, | 41 | get_credentials_for_surface, send_scale_transform, update_tiled_state, with_toplevel_role, |
| 39 | - ResizeEdge, | 42 | + with_toplevel_role_and_current, ResizeEdge, |
| 40 | }; | 43 | }; |
| 41 | 44 | ||
| 42 | #[derive(Debug)] | 45 | #[derive(Debug)] |
| @@ -720,28 +723,35 @@ impl LayoutElement for Mapped { | |||
| 720 | // configure, whereas what we potentially want is to unfullscreen the window into its | 723 | // configure, whereas what we potentially want is to unfullscreen the window into its |
| 721 | // fullscreen size. | 724 | // fullscreen size. |
| 722 | let already_sent = with_toplevel_role(self.toplevel(), |role| { | 725 | let already_sent = with_toplevel_role(self.toplevel(), |role| { |
| 723 | - let (last_sent, last_serial) = if let Some(configure) = role.pending_configures().last() | 726 | + let last_sent = if let Some(configure) = role.pending_configures().last() { |
| 724 | - { | ||
| 725 | // FIXME: it would be more optimal to find the *oldest* pending configure that | 727 | // FIXME: it would be more optimal to find the *oldest* pending configure that |
| 726 | // has the same size and fullscreen state to the last pending configure. | 728 | // has the same size and fullscreen state to the last pending configure. |
| 727 | - (&configure.state, configure.serial) | 729 | + configure |
| 728 | } else { | 730 | } else { |
| 729 | - ( | 731 | + role.last_acked.as_ref().unwrap() |
| 730 | - role.last_acked.as_ref().unwrap(), | ||
| 731 | - role.configure_serial.unwrap(), | ||
| 732 | - ) | ||
| 733 | }; | 732 | }; |
| 733 | + let ToplevelConfigure { | ||
| 734 | + serial: last_serial, | ||
| 735 | + state: last_sent, | ||
| 736 | + } = last_sent; | ||
| 734 | 737 | ||
| 735 | let same_size = last_sent.size.unwrap_or_default() == size; | 738 | let same_size = last_sent.size.unwrap_or_default() == size; |
| 736 | let has_fullscreen = last_sent.states.contains(xdg_toplevel::State::Fullscreen); | 739 | let has_fullscreen = last_sent.states.contains(xdg_toplevel::State::Fullscreen); |
| 737 | let same_fullscreen = has_fullscreen == self.is_pending_windowed_fullscreen; | 740 | let same_fullscreen = has_fullscreen == self.is_pending_windowed_fullscreen; |
| 738 | - (same_size && same_fullscreen).then_some(last_serial) | 741 | + (same_size && same_fullscreen).then_some(*last_serial) |
| 739 | }); | 742 | }); |
| 740 | 743 | ||
| 741 | if let Some(serial) = already_sent { | 744 | if let Some(serial) = already_sent { |
| 742 | - if let Some(current_serial) = | 745 | + let current_serial = with_states(self.toplevel().wl_surface(), |states| { |
| 743 | - with_toplevel_role(self.toplevel(), |role| role.current_serial) | 746 | + states |
| 744 | - { | 747 | + .cached_state |
| 748 | + .get::<ToplevelCachedState>() | ||
| 749 | + .current() | ||
| 750 | + .last_acked | ||
| 751 | + .as_ref() | ||
| 752 | + .map(|c| c.serial) | ||
| 753 | + }); | ||
| 754 | + if let Some(current_serial) = current_serial { | ||
| 745 | // God this triple negative... | 755 | // God this triple negative... |
| 746 | if !current_serial.is_no_older_than(&serial) { | 756 | if !current_serial.is_no_older_than(&serial) { |
| 747 | // We have already sent a request for the new size, but the surface has not | 757 | // We have already sent a request for the new size, but the surface has not |
| @@ -805,7 +815,9 @@ impl LayoutElement for Mapped { | |||
| 805 | 815 | ||
| 806 | fn has_ssd(&self) -> bool { | 816 | fn has_ssd(&self) -> bool { |
| 807 | let toplevel = self.toplevel(); | 817 | let toplevel = self.toplevel(); |
| 808 | - let mode = with_toplevel_role(self.toplevel(), |role| role.current.decoration_mode); | 818 | + let mode = self |
| 819 | + .toplevel() | ||
| 820 | + .with_committed_state(|current| current.and_then(|s| s.decoration_mode)); | ||
| 809 | 821 | ||
| 810 | match mode { | 822 | match mode { |
| 811 | Some(zxdg_toplevel_decoration_v1::Mode::ServerSide) => true, | 823 | Some(zxdg_toplevel_decoration_v1::Mode::ServerSide) => true, |
| @@ -892,10 +904,10 @@ impl LayoutElement for Mapped { | |||
| 892 | return ConfigureIntent::ShouldSend; | 904 | return ConfigureIntent::ShouldSend; |
| 893 | } | 905 | } |
| 894 | 906 | ||
| 895 | - with_toplevel_role(self.toplevel(), |attributes| { | 907 | + with_toplevel_role_and_current(self.toplevel(), |attributes, current_committed| { |
| 896 | if let Some(server_pending) = &attributes.server_pending { | 908 | if let Some(server_pending) = &attributes.server_pending { |
| 897 | let current_server = attributes.current_server_state(); | 909 | let current_server = attributes.current_server_state(); |
| 898 | - if server_pending != current_server { | 910 | + if *server_pending != current_server { |
| 899 | // Something changed. Check if the only difference is the size, and if the | 911 | // Something changed. Check if the only difference is the size, and if the |
| 900 | // current server size matches the current committed size. | 912 | // current server size matches the current committed size. |
| 901 | let mut current_server_same_size = current_server.clone(); | 913 | let mut current_server_same_size = current_server.clone(); |
| @@ -903,12 +915,17 @@ impl LayoutElement for Mapped { | |||
| 903 | if current_server_same_size == *server_pending { | 915 | if current_server_same_size == *server_pending { |
| 904 | // Only the size changed. Check if the window committed our previous size | 916 | // Only the size changed. Check if the window committed our previous size |
| 905 | // request. | 917 | // request. |
| 906 | - if attributes.current.size == current_server.size { | 918 | + let Some(current_committed) = current_committed else { |
| 919 | + error!("mapped must have had initial commit"); | ||
| 920 | + return ConfigureIntent::ShouldSend; | ||
| 921 | + }; | ||
| 922 | + | ||
| 923 | + if current_committed.size == current_server.size { | ||
| 907 | // The window had committed for our previous size change, so we can | 924 | // The window had committed for our previous size change, so we can |
| 908 | // change the size again. | 925 | // change the size again. |
| 909 | trace!( | 926 | trace!( |
| 910 | "current size matches server size: {:?}", | 927 | "current size matches server size: {:?}", |
| 911 | - attributes.current.size | 928 | + current_committed.size |
| 912 | ); | 929 | ); |
| 913 | ConfigureIntent::CanSend | 930 | ConfigureIntent::CanSend |
| 914 | } else { | 931 | } else { |
| @@ -960,7 +977,7 @@ impl LayoutElement for Mapped { | |||
| 960 | } | 977 | } |
| 961 | 978 | ||
| 962 | let server_pending = role.server_pending.as_ref().unwrap(); | 979 | let server_pending = role.server_pending.as_ref().unwrap(); |
| 963 | - server_pending != role.current_server_state() | 980 | + *server_pending != role.current_server_state() |
| 964 | }); | 981 | }); |
| 965 | 982 | ||
| 966 | if has_pending_changes { | 983 | if has_pending_changes { |
| @@ -1031,10 +1048,8 @@ impl LayoutElement for Mapped { | |||
| 1031 | return false; | 1048 | return false; |
| 1032 | } | 1049 | } |
| 1033 | 1050 | ||
| 1034 | - with_toplevel_role(self.toplevel(), |role| { | 1051 | + self.toplevel().with_committed_state(|current| { |
| 1035 | - role.current | 1052 | + current.is_some_and(|s| s.states.contains(xdg_toplevel::State::Fullscreen)) |
| 1036 | - .states | ||
| 1037 | - .contains(xdg_toplevel::State::Fullscreen) | ||
| 1038 | }) | 1053 | }) |
| 1039 | } | 1054 | } |
| 1040 | 1055 | ||
| @@ -1076,7 +1091,14 @@ impl LayoutElement for Mapped { | |||
| 1076 | return current_size; | 1091 | return current_size; |
| 1077 | } | 1092 | } |
| 1078 | 1093 | ||
| 1079 | - let pending = with_toplevel_role(self.toplevel(), |role| { | 1094 | + let pending = with_states(self.toplevel().wl_surface(), |states| { |
| 1095 | + let role = states | ||
| 1096 | + .data_map | ||
| 1097 | + .get::<XdgToplevelSurfaceData>() | ||
| 1098 | + .unwrap() | ||
| 1099 | + .lock() | ||
| 1100 | + .unwrap(); | ||
| 1101 | + | ||
| 1080 | // If we have a server-pending size change that we haven't sent yet, use that size. | 1102 | // If we have a server-pending size change that we haven't sent yet, use that size. |
| 1081 | if let Some(server_pending) = &role.server_pending { | 1103 | if let Some(server_pending) = &role.server_pending { |
| 1082 | let current_server = role.current_server_state(); | 1104 | let current_server = role.current_server_state(); |
| @@ -1091,18 +1113,18 @@ impl LayoutElement for Mapped { | |||
| 1091 | } | 1113 | } |
| 1092 | 1114 | ||
| 1093 | // If we have a sent-but-not-committed-to size, use that. | 1115 | // If we have a sent-but-not-committed-to size, use that. |
| 1094 | - let (last_sent, last_serial) = if let Some(configure) = role.pending_configures().last() | 1116 | + let last_sent = role |
| 1095 | - { | 1117 | + .pending_configures() |
| 1096 | - (&configure.state, configure.serial) | 1118 | + .last() |
| 1097 | - } else { | 1119 | + .unwrap_or_else(|| role.last_acked.as_ref().unwrap()); |
| 1098 | - ( | 1120 | + let ToplevelConfigure { |
| 1099 | - role.last_acked.as_ref().unwrap(), | 1121 | + state: last_sent, |
| 1100 | - role.configure_serial.unwrap(), | 1122 | + serial: last_serial, |
| 1101 | - ) | 1123 | + } = last_sent; |
| 1102 | - }; | 1124 | + |
| 1103 | - | 1125 | + let mut guard = states.cached_state.get::<ToplevelCachedState>(); |
| 1104 | - if let Some(current_serial) = role.current_serial { | 1126 | + if let Some(current) = guard.current().last_acked.as_ref() { |
| 1105 | - if !current_serial.is_no_older_than(&last_serial) { | 1127 | + if !current.serial.is_no_older_than(last_serial) { |
| 1106 | return Some(( | 1128 | return Some(( |
| 1107 | last_sent.size.unwrap_or_default(), | 1129 | last_sent.size.unwrap_or_default(), |
| 1108 | last_sent.states.contains(xdg_toplevel::State::Fullscreen), | 1130 | last_sent.states.contains(xdg_toplevel::State::Fullscreen), |