zed: Persist window stack order across restarts (#15419)
This changes the workspace/session serialization to also persist the order of windows across restarts. Release Notes: - Improved restoring of windows across restarts: the order of the windows is now also restored. That means windows that were in the foreground when Zed was quit will be in the foreground after restart. (Right now only supported on Linux/X11, not on Linux/Wayland.) Demo: https://github.com/user-attachments/assets/0b8162f8-f06d-43df-88d3-c45d8460fb68
This commit is contained in:
parent
6e1f7c6e1d
commit
f58ef9b82b
19 changed files with 365 additions and 55 deletions
|
@ -1345,6 +1345,48 @@ impl LinuxClient for X11Client {
|
|||
.map(|window| window.handle())
|
||||
})
|
||||
}
|
||||
|
||||
fn window_stack(&self) -> Option<Vec<AnyWindowHandle>> {
|
||||
let state = self.0.borrow();
|
||||
let root = state.xcb_connection.setup().roots[state.x_root_index].root;
|
||||
|
||||
let reply = state
|
||||
.xcb_connection
|
||||
.get_property(
|
||||
false,
|
||||
root,
|
||||
state.atoms._NET_CLIENT_LIST_STACKING,
|
||||
xproto::AtomEnum::WINDOW,
|
||||
0,
|
||||
u32::MAX,
|
||||
)
|
||||
.ok()?
|
||||
.reply()
|
||||
.ok()?;
|
||||
|
||||
let window_ids = reply
|
||||
.value
|
||||
.chunks_exact(4)
|
||||
.map(|chunk| u32::from_ne_bytes(chunk.try_into().unwrap()))
|
||||
.collect::<Vec<xproto::Window>>();
|
||||
|
||||
let mut handles = Vec::new();
|
||||
|
||||
// We need to reverse, since _NET_CLIENT_LIST_STACKING has
|
||||
// a back-to-front order.
|
||||
// See: https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html
|
||||
for window_ref in window_ids
|
||||
.iter()
|
||||
.rev()
|
||||
.filter_map(|&win| state.windows.get(&win))
|
||||
{
|
||||
if !window_ref.window.state.borrow().destroyed {
|
||||
handles.push(window_ref.handle());
|
||||
}
|
||||
}
|
||||
|
||||
Some(handles)
|
||||
}
|
||||
}
|
||||
|
||||
// Adatpted from:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue