tree: fix restoration of workspaces to their desired outputs
This commit is contained in:
parent
a4559f5293
commit
c921e2400e
4 changed files with 91 additions and 68 deletions
|
|
@ -19,7 +19,7 @@ use {
|
|||
utils::{
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
linkedlist::{LinkedList, LinkedNode},
|
||||
linkedlist::{LinkedList, LinkedNode, NodeRef},
|
||||
threshold_counter::ThresholdCounter,
|
||||
},
|
||||
wire::JayWorkspaceId,
|
||||
|
|
@ -304,3 +304,43 @@ impl ContainingNode for WorkspaceNode {
|
|||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WsMoveConfig {
|
||||
pub make_visible_if_empty: bool,
|
||||
pub source_is_destroyed: bool,
|
||||
}
|
||||
|
||||
pub fn move_ws_to_output(
|
||||
ws: &NodeRef<Rc<WorkspaceNode>>,
|
||||
target: &Rc<OutputNode>,
|
||||
config: WsMoveConfig,
|
||||
) {
|
||||
let source = ws.output.get();
|
||||
ws.set_output(&target);
|
||||
target.workspaces.add_last_existing(&ws);
|
||||
if config.make_visible_if_empty && target.workspace.is_none() && !target.is_dummy {
|
||||
target.show_workspace(&ws);
|
||||
} else {
|
||||
ws.set_visible(false);
|
||||
}
|
||||
ws.flush_jay_workspaces();
|
||||
if let Some(visible) = source.workspace.get() {
|
||||
if visible.id == ws.id {
|
||||
source.workspace.take();
|
||||
}
|
||||
}
|
||||
if !config.source_is_destroyed && !source.is_dummy {
|
||||
if source.workspace.is_none() {
|
||||
if let Some(ws) = source.workspaces.first() {
|
||||
source.show_workspace(&ws);
|
||||
ws.flush_jay_workspaces();
|
||||
}
|
||||
}
|
||||
}
|
||||
if !target.is_dummy {
|
||||
target.schedule_update_render_data();
|
||||
}
|
||||
if !source.is_dummy {
|
||||
source.schedule_update_render_data();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue