Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Cargo.lock
*.bk
.vscode
.vagga
/wlcs
127 changes: 127 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,133 @@ enables accepting dmabufs originating from any node.
All other methods have moved to this new type, allowing compositors to take the same lock across multiple
operations.

xdg_shell, layer_shell, and session_lock surfaces now track `last_acked` state for each commit.
You can find it in the `last_acked` field of the corresponding `...CachedState` structs.

The "current state" and "current serial" attribute fields were removed; use `last_acked` from the new `with_committed_state()` accessors instead (and verify that you didn't actually want `with_pending_state()` instead where you used the "current state").

```diff
-ToplevelSurface::current_state();
+ToplevelSurface::with_committed_state(|state| {
+ // ...
+});

-PopupSurface::current_state();
+PopupSurface::with_committed_state(|state| {
+ // ...
+});

-LayerSurface::current_state();
+LayerSurface::with_committed_state(|state| {
+ // ...
+});

-LockSurface::current_state();
+LockSurface::with_committed_state(|state| {
+ // ...
+});

struct XdgToplevelSurfaceRoleAttributes {
- configured: bool,
- configure_serial: Option<Serial>,
- current: ToplevelState,
- current_serial: Option<Serial>,
- last_acked: Option<ToplevelState>,
+ last_acked: Option<ToplevelConfigure>,
// ...
}

struct XdgPopupSurfaceRoleAttributes {
- configured: bool,
- configure_serial: Option<Serial>,
- current: PopupState,
- current_serial: Option<Serial>,
- committed: bool,
- last_acked: Option<PopupState>,
+ last_acked: Option<PopupConfigure>,
// ...
}

struct LayerSurfaceAttributes {
- configured: bool,
- configure_serial: Option<Serial>,
- current: LayerSurfaceState,
- last_acked: Option<LayerSurfaceState>,
+ last_acked: Option<LayerSurfaceConfigure>,
// ...
}

-impl Copy for LayerSurfaceCachedState;
```

The following methods are no longer needed as Smithay does them automatically now:
```diff
-ToplevelSurface::reset_initial_configure_sent();
-PopupSurface::reset_initial_configure_sent();
```

You also no longer need to manually set `LayerSurfaceAttributes::initial_configure_sent`, Smithay handles it automatically.

### Additions

xdg_shell and layer_shell now enforce the client acking a configure before committing a buffer, as required by the protocols.

```rs
struct ToplevelCachedState {
/// Configure last acknowledged by the client at the time of the commit.
last_acked: Option<ToplevelConfigure>,
}

/// Provides access to the current committed cached state.
fn ToplevelSurface::with_cached_state<T>(&self, f: impl FnOnce(&ToplevelCachedState) -> T) -> T;
/// Provides access to the current committed state.
fn ToplevelSurface::with_committed_state<T>(&self, f: impl FnOnce(Option<&ToplevelState>) -> T) -> T;

struct PopupCachedState {
/// Configure last acknowledged by the client at the time of the commit.
last_acked: Option<ToplevelConfigure>,
}

/// Provides access to the current committed cached state.
fn PopupSurface::with_cached_state<T>(&self, f: impl FnOnce(&PopupCachedState) -> T) -> T;
/// Provides access to the current committed state.
fn PopupSurface::with_committed_state<T>(&self, f: impl FnOnce(Option<&PopupState>) -> T) -> T;

struct LayerSurfaceCachedState {
/// Configure last acknowledged by the client at the time of the commit.
last_acked: Option<LayerSurfaceConfigure>,
// ...
}

/// Provides access to the current committed cached state.
fn LayerSurface::with_cached_state<T>(&self, f: impl FnOnce(&LayerSurfaceCachedState) -> T) -> T;
/// Provides access to the current committed state.
fn LayerSurface::with_committed_state<T>(&self, f: impl FnOnce(Option<&LayerSurfaceState>) -> T) -> T;

struct LockSurfaceCachedState {
/// Configure last acknowledged by the client at the time of the commit.
last_acked: Option<LockSurfaceConfigure>,
}

/// Provides access to the current committed cached state.
fn LockSurface::with_cached_state<T>(&self, f: impl FnOnce(&LockSurfaceCachedState) -> T) -> T;
/// Provides access to the current committed state.
fn LockSurface::with_committed_state<T>(&self, f: impl FnOnce(Option<&LockSurfaceState>) -> T) -> T;

struct LockSurfaceAttributes {
server_pending: Option<LockSurfaceState>,
pending_configures: Vec<LockSurfaceConfigure>,
last_acked: Option<LockSurfaceConfigure>,
}

type LockSurfaceData = Mutex<LockSurfaceAttributes>;

struct LockSurfaceConfigure {
state: LockSurfaceState,
serial: Serial,
}
```

## 0.7.0

### Breaking changes
Expand Down
12 changes: 5 additions & 7 deletions anvil/src/input_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ use smithay::{
},
utils::{Logical, Point, Serial, Transform, SERIAL_COUNTER as SCOUNTER},
wayland::{
compositor::with_states,
input_method::InputMethodSeat,
keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitorSeat,
shell::wlr_layer::{KeyboardInteractivity, Layer as WlrLayer, LayerSurfaceCachedState},
shell::wlr_layer::{KeyboardInteractivity, Layer as WlrLayer},
},
};

Expand Down Expand Up @@ -146,12 +145,11 @@ impl<BackendData: Backend> AnvilState<BackendData> {
let keyboard = self.seat.get_keyboard().unwrap();

for layer in self.layer_shell_state.layer_surfaces().rev() {
let data = with_states(layer.wl_surface(), |states| {
*states.cached_state.get::<LayerSurfaceCachedState>().current()
let exclusive = layer.with_cached_state(|data| {
data.keyboard_interactivity == KeyboardInteractivity::Exclusive
&& (data.layer == WlrLayer::Top || data.layer == WlrLayer::Overlay)
});
if data.keyboard_interactivity == KeyboardInteractivity::Exclusive
&& (data.layer == WlrLayer::Top || data.layer == WlrLayer::Overlay)
{
if exclusive {
let surface = self.space.outputs().find_map(|o| {
let map = layer_map_for_output(o);
let cloned = map.layers().find(|l| l.layer_surface() == &layer).cloned();
Expand Down
Loading
Loading