Skip to content

Commit c9f7402

Browse files
ids1024Drakulix
authored andcommitted
toplevel-info: Send initial state even if empty
This is imported given how pop-os/cosmic-protocols#39 uses this event. But the protocol spec also states the event "is emitted on creation" so this is seemingly incorrect regardless.
1 parent addcbc5 commit c9f7402

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/wayland/protocols/toplevel_info.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub struct ToplevelHandleStateInner<W: Window> {
9393
workspaces: Vec<WorkspaceHandle>,
9494
title: String,
9595
app_id: String,
96-
states: Vec<States>,
96+
states: Option<Vec<States>>,
9797
pub(super) window: Option<W>,
9898
}
9999
pub type ToplevelHandleState<W> = Mutex<ToplevelHandleStateInner<W>>;
@@ -107,7 +107,7 @@ impl<W: Window> ToplevelHandleStateInner<W> {
107107
workspaces: Vec::new(),
108108
title: String::new(),
109109
app_id: String::new(),
110-
states: Vec::new(),
110+
states: None,
111111
window: Some(window.clone()),
112112
})
113113
}
@@ -120,7 +120,7 @@ impl<W: Window> ToplevelHandleStateInner<W> {
120120
workspaces: Vec::new(),
121121
title: String::new(),
122122
app_id: String::new(),
123-
states: Vec::new(),
123+
states: None,
124124
window: None,
125125
})
126126
}
@@ -502,11 +502,12 @@ where
502502
changed = true;
503503
}
504504

505-
if (handle_state.states.contains(&States::Maximized) != window.is_maximized())
506-
|| (handle_state.states.contains(&States::Fullscreen) != window.is_fullscreen())
507-
|| (handle_state.states.contains(&States::Activated) != window.is_activated())
508-
|| (handle_state.states.contains(&States::Minimized) != window.is_minimized())
509-
{
505+
if handle_state.states.as_ref().map_or(true, |states| {
506+
(states.contains(&States::Maximized) != window.is_maximized())
507+
|| (states.contains(&States::Fullscreen) != window.is_fullscreen())
508+
|| (states.contains(&States::Activated) != window.is_activated())
509+
|| (states.contains(&States::Minimized) != window.is_minimized())
510+
}) {
510511
let mut states = Vec::new();
511512
if window.is_maximized() {
512513
states.push(States::Maximized);
@@ -525,7 +526,7 @@ where
525526
{
526527
states.push(States::Sticky);
527528
}
528-
handle_state.states = states.clone();
529+
handle_state.states = Some(states.clone());
529530

530531
let states = states
531532
.iter()

0 commit comments

Comments
 (0)