config: add move-to-output action
This commit is contained in:
parent
2a517f437a
commit
fecfd24ba0
15 changed files with 357 additions and 76 deletions
|
|
@ -440,9 +440,8 @@ fn create_dummy_output(state: &Rc<State>) {
|
|||
title_texture: Cell::new(None),
|
||||
attention_requests: Default::default(),
|
||||
});
|
||||
dummy_workspace.output_link.set(Some(
|
||||
dummy_output.workspaces.add_last(dummy_workspace.clone()),
|
||||
));
|
||||
*dummy_workspace.output_link.borrow_mut() =
|
||||
Some(dummy_output.workspaces.add_last(dummy_workspace.clone()));
|
||||
dummy_output.show_workspace(&dummy_workspace);
|
||||
state.dummy_output.set(Some(dummy_output));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ use {
|
|||
scale::Scale,
|
||||
state::{ConnectorData, DeviceHandlerData, DrmDevData, OutputData, State},
|
||||
theme::{Color, ThemeSized, DEFAULT_FONT},
|
||||
tree::{ContainerNode, ContainerSplit, FloatNode, Node, NodeVisitorBase, OutputNode},
|
||||
tree::{
|
||||
move_ws_to_output, ContainerNode, ContainerSplit, FloatNode, Node, NodeVisitorBase,
|
||||
OutputNode, WsMoveConfig,
|
||||
},
|
||||
utils::{
|
||||
asyncevent::AsyncEvent,
|
||||
copyhashmap::CopyHashMap,
|
||||
|
|
@ -29,7 +32,7 @@ use {
|
|||
jay_config::{
|
||||
_private::{
|
||||
bincode_ops,
|
||||
ipc::{ClientMessage, Response, ServerMessage},
|
||||
ipc::{ClientMessage, Response, ServerMessage, WorkspaceSource},
|
||||
PollableId, WireMode,
|
||||
},
|
||||
input::{
|
||||
|
|
@ -753,6 +756,45 @@ impl ConfigProxyHandler {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_move_to_output(
|
||||
&self,
|
||||
workspace: WorkspaceSource,
|
||||
connector: Connector,
|
||||
) -> Result<(), CphError> {
|
||||
let output = self.get_output(connector)?;
|
||||
let ws = match workspace {
|
||||
WorkspaceSource::Explicit(ws) => {
|
||||
let name = self.get_workspace(ws)?;
|
||||
match self.state.workspaces.get(name.as_str()) {
|
||||
Some(ws) => ws,
|
||||
_ => return Ok(()),
|
||||
}
|
||||
}
|
||||
WorkspaceSource::Seat(s) => match self.get_seat(s)?.get_output().workspace.get() {
|
||||
Some(ws) => ws,
|
||||
_ => return Ok(()),
|
||||
},
|
||||
};
|
||||
if ws.is_dummy || output.node.is_dummy {
|
||||
return Ok(());
|
||||
}
|
||||
if ws.output.get().id == output.node.id {
|
||||
return Ok(());
|
||||
}
|
||||
let link = match &*ws.output_link.borrow() {
|
||||
None => return Ok(()),
|
||||
Some(l) => l.to_ref(),
|
||||
};
|
||||
let config = WsMoveConfig {
|
||||
make_visible_if_empty: true,
|
||||
source_is_destroyed: false,
|
||||
};
|
||||
move_ws_to_output(&link, &output.node, config);
|
||||
self.state.tree_changed();
|
||||
self.state.damage();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_idle(&self, timeout: Duration) {
|
||||
self.state.idle.set_timeout(timeout);
|
||||
}
|
||||
|
|
@ -1676,6 +1718,12 @@ impl ConfigProxyHandler {
|
|||
.handle_get_input_device_devnode(device)
|
||||
.wrn("get_input_device_devnode")?,
|
||||
ClientMessage::SetIdle { timeout } => self.handle_set_idle(timeout),
|
||||
ClientMessage::MoveToOutput {
|
||||
workspace,
|
||||
connector,
|
||||
} => self
|
||||
.handle_move_to_output(workspace, connector)
|
||||
.wrn("move_to_output")?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ impl OutputNode {
|
|||
stacked: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
name: name.to_string(),
|
||||
output_link: Cell::new(None),
|
||||
output_link: Default::default(),
|
||||
visible: Cell::new(false),
|
||||
fullscreen: Default::default(),
|
||||
visible_on_desired_output: Cell::new(false),
|
||||
|
|
@ -347,8 +347,7 @@ impl OutputNode {
|
|||
title_texture: Default::default(),
|
||||
attention_requests: Default::default(),
|
||||
});
|
||||
ws.output_link
|
||||
.set(Some(self.workspaces.add_last(ws.clone())));
|
||||
*ws.output_link.borrow_mut() = Some(self.workspaces.add_last(ws.clone()));
|
||||
self.state.workspaces.set(name.to_string(), ws.clone());
|
||||
if self.workspace.is_none() {
|
||||
self.show_workspace(&ws);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,12 @@ use {
|
|||
},
|
||||
wire::JayWorkspaceId,
|
||||
},
|
||||
std::{cell::Cell, fmt::Debug, ops::Deref, rc::Rc},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
fmt::Debug,
|
||||
ops::Deref,
|
||||
rc::Rc,
|
||||
},
|
||||
};
|
||||
|
||||
tree_id!(WorkspaceNodeId);
|
||||
|
|
@ -38,7 +43,7 @@ pub struct WorkspaceNode {
|
|||
pub stacked: LinkedList<Rc<dyn StackedNode>>,
|
||||
pub seat_state: NodeSeatState,
|
||||
pub name: String,
|
||||
pub output_link: Cell<Option<LinkedNode<Rc<WorkspaceNode>>>>,
|
||||
pub output_link: RefCell<Option<LinkedNode<Rc<WorkspaceNode>>>>,
|
||||
pub visible: Cell<bool>,
|
||||
pub fullscreen: CloneCell<Option<Rc<dyn ToplevelNode>>>,
|
||||
pub visible_on_desired_output: Cell<bool>,
|
||||
|
|
@ -52,7 +57,7 @@ pub struct WorkspaceNode {
|
|||
impl WorkspaceNode {
|
||||
pub fn clear(&self) {
|
||||
self.container.set(None);
|
||||
self.output_link.set(None);
|
||||
*self.output_link.borrow_mut() = None;
|
||||
self.fullscreen.set(None);
|
||||
self.jay_workspaces.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue