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
|
|
@ -1385,6 +1385,31 @@ impl ConfigClient {
|
|||
workspaces
|
||||
}
|
||||
|
||||
/// Returns the connector that the workspace is currently on.
|
||||
/// Returns `Connector(0)` (invalid connector) if the workspace doesn't exist or
|
||||
/// isn't assigned to any connector.
|
||||
pub fn get_workspace_connector(&self, workspace: Workspace) -> Connector {
|
||||
let res = self.send_with_response(&ClientMessage::GetWorkspaceConnector { workspace });
|
||||
get_response!(res, Connector(0), GetWorkspaceConnector { connector });
|
||||
connector
|
||||
}
|
||||
|
||||
/// Finds the connector in the specified direction from the given connector.
|
||||
/// Returns `Connector(0)` (invalid connector) if no connector exists in that direction
|
||||
/// or if the source connector is invalid.
|
||||
pub fn get_connector_in_direction(
|
||||
&self,
|
||||
connector: Connector,
|
||||
direction: Direction,
|
||||
) -> Connector {
|
||||
let res = self.send_with_response(&ClientMessage::GetConnectorInDirection {
|
||||
connector,
|
||||
direction,
|
||||
});
|
||||
get_response!(res, Connector(0), GetConnectorInDirection { connector });
|
||||
connector
|
||||
}
|
||||
|
||||
pub fn set_client_matcher_capabilities(
|
||||
&self,
|
||||
matcher: ClientMatcher,
|
||||
|
|
|
|||
|
|
@ -805,6 +805,13 @@ pub enum ClientMessage<'a> {
|
|||
show: bool,
|
||||
},
|
||||
GetShowTitles,
|
||||
GetWorkspaceConnector {
|
||||
workspace: Workspace,
|
||||
},
|
||||
GetConnectorInDirection {
|
||||
connector: Connector,
|
||||
direction: Direction,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
@ -1043,6 +1050,12 @@ pub enum Response {
|
|||
GetShowTitles {
|
||||
show: bool,
|
||||
},
|
||||
GetWorkspaceConnector {
|
||||
connector: Connector,
|
||||
},
|
||||
GetConnectorInDirection {
|
||||
connector: Connector,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -186,6 +186,13 @@ impl Workspace {
|
|||
pub fn window(self) -> Window {
|
||||
get!(Window(0)).get_workspace_window(self)
|
||||
}
|
||||
|
||||
/// Returns the connector that contains this workspace.
|
||||
///
|
||||
/// If no such connector exists, [`Connector::exists`] returns false.
|
||||
pub fn connector(self) -> Connector {
|
||||
get!(Connector(0)).get_workspace_connector(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the workspace with the given name.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use {
|
||||
crate::{
|
||||
_private::WireMode,
|
||||
PciId, Workspace,
|
||||
Direction, PciId, Workspace,
|
||||
video::connector_type::{
|
||||
CON_9PIN_DIN, CON_COMPONENT, CON_COMPOSITE, CON_DISPLAY_PORT, CON_DPI, CON_DSI,
|
||||
CON_DVIA, CON_DVID, CON_DVII, CON_EDP, CON_EMBEDDED_WINDOW, CON_HDMIA, CON_HDMIB,
|
||||
|
|
@ -327,6 +327,17 @@ impl Connector {
|
|||
pub fn workspaces(self) -> Vec<Workspace> {
|
||||
get!().get_connector_workspaces(self)
|
||||
}
|
||||
|
||||
/// Find the closest connector in the given direction.
|
||||
///
|
||||
/// Uses center-to-center distance calculation and prefers outputs better aligned
|
||||
/// with the movement axis.
|
||||
///
|
||||
/// If no connector exists in the given direction, returns a connector whose
|
||||
/// `exists()` returns false.
|
||||
pub fn connector_in_direction(self, direction: Direction) -> Connector {
|
||||
get!(Connector(0)).get_connector_in_direction(self, direction)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all available DRM devices.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue