feat(config): Add directional output selection via separate direction field
Add support for directional output selection in the move-to-output action
using a separate `direction` field instead of overloading OutputMatch.
API additions:
- Add Workspace::connector() to get the connector showing a workspace
- Add Connector::connector_in_direction() to find outputs directionally
Implementation:
- Move directional finding logic from toml-config to compositor
- Algorithm uses center-to-center distance with axis-aligned preference
- Add GetWorkspaceConnector and GetConnectorInDirection IPC messages
Configuration changes:
- Add optional `direction` field to move-to-output action
- Either `output` or `direction` must be specified (not both)
- Valid directions: "left", "right", "up", "down"
Example usage:
logo+control+shift+right = { type = "move-to-output", direction = "right" }
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
parent
e81b31b452
commit
5529306c67
13 changed files with 348 additions and 25 deletions
|
|
@ -1577,6 +1577,32 @@ impl ConfigProxyHandler {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_get_workspace_connector(&self, workspace: Workspace) -> Result<(), CphError> {
|
||||
let connector = self
|
||||
.get_existing_workspace(workspace)?
|
||||
.map(|ws| ws.output.get())
|
||||
.filter(|o| !o.is_dummy)
|
||||
.map(|o| Connector(o.global.connector.id.raw() as _))
|
||||
.unwrap_or(Connector(0));
|
||||
self.respond(Response::GetWorkspaceConnector { connector });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_get_connector_in_direction(
|
||||
&self,
|
||||
connector: Connector,
|
||||
direction: Direction,
|
||||
) -> Result<(), CphError> {
|
||||
let source_output = self.get_output_node(connector)?;
|
||||
let connector = self
|
||||
.state
|
||||
.find_connector_in_direction(&source_output, direction.into())
|
||||
.map(|o| Connector(o.global.connector.id.raw() as u64))
|
||||
.unwrap_or(Connector(0));
|
||||
self.respond(Response::GetConnectorInDirection { connector });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_has_capability(&self, device: InputDevice, cap: Capability) -> Result<(), CphError> {
|
||||
let dev = self.get_device_handler_data(device)?;
|
||||
let mut is_unknown = false;
|
||||
|
|
@ -3073,6 +3099,15 @@ impl ConfigProxyHandler {
|
|||
ClientMessage::GetConnectorWorkspaces { connector } => self
|
||||
.handle_get_connector_workspaces(connector)
|
||||
.wrn("get_connector_workspaces")?,
|
||||
ClientMessage::GetWorkspaceConnector { workspace } => self
|
||||
.handle_get_workspace_connector(workspace)
|
||||
.wrn("get_workspace_connector")?,
|
||||
ClientMessage::GetConnectorInDirection {
|
||||
connector,
|
||||
direction,
|
||||
} => self
|
||||
.handle_get_connector_in_direction(connector, direction)
|
||||
.wrn("get_connector_in_direction")?,
|
||||
ClientMessage::GetClients => self.handle_get_clients(),
|
||||
ClientMessage::ClientExists { client } => self.handle_client_exists(client),
|
||||
ClientMessage::ClientIsXwayland { client } => self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue