Improve handling of XDG activation tokens in shell

Requires https://github.com/Smithay/smithay/pull/1676.

This changes two things:
* `Workspace::is_empty` no longer checks if there are activation tokens,
  but a separate `Workspace::can_auto_remove` checks if the workspace is
  empty and has no activation tokens.
  - When we add workspace pinning, that can also be checked there.
* `Workspace` no longer contains a `pending_tokens` list that is updated
  on `refresh`. Instead, `can_auto_remove` takes the xdg activation
  state as an argument.

Since `Workspace::refresh` normally is run for focused workspaces, this
fixes allowing non-focused workspaces to be removed when an activation
token expires. It seems generally good to avoid tracking the activation
tokens in two places, and this is probably more efficient than needing
to refresh in more places.

By splitting this, we still don't remove an empty workspace if it has a
pending activation token, but we also don't add an empty workspace for
an activation token.

This mitigates the confusing behavior with activation tokens that aren't
used, but having to wait a few seconds in some cases before a workspace
is removed is still a little confusing. (We probably want `cosmic-term`
and `cosmic-workspace` to either consume the activation tokens they are
passed, or not be passed tokens when started by keybinding?)

Fixes https://github.com/pop-os/cosmic-comp/issues/1099.
This commit is contained in:
Ian Douglas Scott 2025-03-13 12:50:02 -07:00 committed by Victoria Brekenfeld
parent 96cbaad7b7
commit 7340e2beff
11 changed files with 61 additions and 69 deletions

View file

@ -705,7 +705,6 @@ impl CosmicStack {
true,
&state.common.config,
&state.common.event_loop_handle,
&state.common.xdg_activation_state,
false,
);
if let Some((grab, focus)) = res {
@ -848,7 +847,6 @@ impl Program for CosmicStackInternal {
false,
&state.common.config,
&state.common.event_loop_handle,
&state.common.xdg_activation_state,
false,
);
if let Some((grab, focus)) = res {
@ -1493,7 +1491,6 @@ impl PointerTarget<State> for CosmicStack {
true,
&state.common.config,
&state.common.event_loop_handle,
&state.common.xdg_activation_state,
false,
);
if let Some((grab, focus)) = res {

View file

@ -439,7 +439,6 @@ impl Program for CosmicWindowInternal {
false,
&state.common.config,
&state.common.event_loop_handle,
&state.common.xdg_activation_state,
false,
);
if let Some((grab, focus)) = res {