Implement scratchpad window toggling
This commit is contained in:
parent
4c10713073
commit
290b290fdf
17 changed files with 515 additions and 3 deletions
|
|
@ -1323,3 +1323,64 @@ pub fn toplevel_set_workspace(state: &Rc<State>, tl: Rc<dyn ToplevelNode>, ws: &
|
|||
tl.tl_set_fullscreen(true, Some(ws.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ScratchpadToplevelState {
|
||||
pub floating: bool,
|
||||
pub fullscreen: bool,
|
||||
pub workspace: Option<Rc<WorkspaceNode>>,
|
||||
}
|
||||
|
||||
pub fn toplevel_hide_for_scratchpad(tl: Rc<dyn ToplevelNode>) -> Option<ScratchpadToplevelState> {
|
||||
if tl.node_is_placeholder() {
|
||||
return None;
|
||||
}
|
||||
let data = tl.tl_data();
|
||||
let scratchpad_state = ScratchpadToplevelState {
|
||||
floating: data.parent_is_float.get(),
|
||||
fullscreen: data.is_fullscreen.get(),
|
||||
workspace: data.workspace.get(),
|
||||
};
|
||||
if data.is_fullscreen.get() {
|
||||
tl.clone().tl_set_fullscreen(false, None);
|
||||
if data.is_fullscreen.get() {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
let parent = data.parent.get()?;
|
||||
let kb_foci = collect_kb_foci(tl.clone());
|
||||
parent.cnode_remove_child2(&*tl, true);
|
||||
data.parent.take();
|
||||
data.float.take();
|
||||
if data.parent_is_float.replace(false) {
|
||||
data.property_changed(TL_CHANGED_FLOATING);
|
||||
}
|
||||
if data.workspace.take().is_some() {
|
||||
data.property_changed(TL_CHANGED_WORKSPACE);
|
||||
}
|
||||
tl.tl_set_visible(false);
|
||||
if let Some(workspace) = &scratchpad_state.workspace {
|
||||
for seat in kb_foci {
|
||||
workspace
|
||||
.clone()
|
||||
.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
}
|
||||
Some(scratchpad_state)
|
||||
}
|
||||
|
||||
pub fn toplevel_restore_from_scratchpad(
|
||||
state: &Rc<State>,
|
||||
tl: Rc<dyn ToplevelNode>,
|
||||
ws: &Rc<WorkspaceNode>,
|
||||
scratchpad_state: &ScratchpadToplevelState,
|
||||
) {
|
||||
if scratchpad_state.floating {
|
||||
let (width, height) = tl.tl_data().float_size(ws);
|
||||
state.map_floating(tl.clone(), width, height, ws, None);
|
||||
} else {
|
||||
state.map_tiled_on(tl.clone(), ws);
|
||||
}
|
||||
if scratchpad_state.fullscreen && ws.fullscreen.is_none() {
|
||||
tl.tl_set_fullscreen(true, Some(ws.clone()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue