1
0
Fork 0
forked from wry/wry

config: allow capturing only selected workspaces

This commit is contained in:
Julian Orth 2023-02-04 14:07:55 +01:00
parent de71be0674
commit 9c7299234a
14 changed files with 224 additions and 4 deletions

View file

@ -287,6 +287,32 @@ impl Client {
connector
}
pub fn get_seat_workspace(&self, seat: Seat) -> Workspace {
let res = self.send_with_response(&ClientMessage::GetSeatWorkspace { seat });
get_response!(res, Workspace(0), GetSeatWorkspace { workspace });
workspace
}
pub fn set_default_workspace_capture(&self, capture: bool) {
self.send(&ClientMessage::SetDefaultWorkspaceCapture { capture });
}
pub fn set_workspace_capture(&self, workspace: Workspace, capture: bool) {
self.send(&ClientMessage::SetWorkspaceCapture { workspace, capture });
}
pub fn get_default_workspace_capture(&self) -> bool {
let res = self.send_with_response(&ClientMessage::GetDefaultWorkspaceCapture);
get_response!(res, true, GetDefaultWorkspaceCapture { capture });
capture
}
pub fn get_workspace_capture(&self, workspace: Workspace) -> bool {
let res = self.send_with_response(&ClientMessage::GetWorkspaceCapture { workspace });
get_response!(res, true, GetWorkspaceCapture { capture });
capture
}
pub fn show_workspace(&self, seat: Seat, workspace: Workspace) {
self.send(&ClientMessage::ShowWorkspace { seat, workspace });
}

View file

@ -316,6 +316,20 @@ pub enum ClientMessage<'a> {
MakeRenderDevice {
device: DrmDevice,
},
GetSeatWorkspace {
seat: Seat,
},
SetDefaultWorkspaceCapture {
capture: bool,
},
GetDefaultWorkspaceCapture,
SetWorkspaceCapture {
workspace: Workspace,
capture: bool,
},
GetWorkspaceCapture {
workspace: Workspace,
},
}
#[derive(Encode, Decode, Debug)]
@ -409,6 +423,15 @@ pub enum Response {
width: i32,
height: i32,
},
GetSeatWorkspace {
workspace: Workspace,
},
GetDefaultWorkspaceCapture {
capture: bool,
},
GetWorkspaceCapture {
capture: bool,
},
}
#[derive(Encode, Decode, Debug)]

View file

@ -254,6 +254,14 @@ impl Seat {
get!().toggle_floating(self);
}
/// Returns the workspace that is currently active on the output that contains the seat's
/// cursor.
///
/// If no such workspace exists, `exists` returns `false` for the returned workspace.
pub fn get_workspace(self) -> Workspace {
get!(Workspace(0)).get_seat_workspace(self)
}
/// Shows the workspace and sets the keyboard focus of the seat to that workspace.
///
/// If the workspace doesn't currently exist, it is created on the output that contains the

View file

@ -106,10 +106,53 @@ pub fn is_reload() -> bool {
get!(false).is_reload()
}
/// Sets whether new workspaces are captured by default.
///
/// The default is `true`.
pub fn set_default_workspace_capture(capture: bool) {
get!().set_default_workspace_capture(capture)
}
/// Returns whether new workspaces are captured by default.
pub fn get_default_workspace_capture() -> bool {
get!(true).get_default_workspace_capture()
}
/// Toggles whether new workspaces are captured by default.
pub fn toggle_default_workspace_capture() {
let get = get!();
get.set_default_workspace_capture(!get.get_default_workspace_capture());
}
/// A workspace.
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Workspace(pub u64);
impl Workspace {
/// Returns whether this workspace existed at the time `Seat::get_workspace` was called.
pub fn exists(self) -> bool {
self.0 != 0
}
/// Sets whether the workspaces is captured.
///
/// The default is determined by `set_default_workspace_capture`.
pub fn set_capture(self, capture: bool) {
get!().set_workspace_capture(self, capture)
}
/// Returns whether the workspaces is captured.
pub fn get_capture(self) -> bool {
get!(true).get_workspace_capture(self)
}
/// Toggles whether the workspaces is captured.
pub fn toggle_capture(self) {
let get = get!();
get.set_workspace_capture(self, !get.get_workspace_capture(self));
}
}
/// Returns the workspace with the given name.
///
/// Workspaces are identified by their name. Calling this function alone does not create the

View file

@ -245,6 +245,14 @@ pub mod colors {
///
/// Default: `#ffffff`.
const 11 => BAR_STATUS_TEXT_COLOR,
/// The title background color of an unfocused window that might be captured.
///
/// Default: `#220303`.
const 12 => CAPTURED_UNFOCUSED_TITLE_BACKGROUND_COLOR,
/// The title background color of a focused window that might be captured.
///
/// Default: `#772831`.
const 13 => CAPTURED_FOCUSED_TITLE_BACKGROUND_COLOR,
}
}