all: split reusable components into workspace crates
This commit is contained in:
parent
2a079ed800
commit
657e7ce2f7
225 changed files with 7422 additions and 17602 deletions
|
|
@ -6,9 +6,9 @@ use {
|
|||
InputDeviceAccelProfile, InputDeviceCapability, InputDeviceClickMethod, InputDeviceId,
|
||||
transaction::BackendConnectorTransactionError,
|
||||
},
|
||||
client::{CAP_JAY_COMPOSITOR, Client, ClientCaps, ClientId},
|
||||
client::{Client, ClientId},
|
||||
cmm::cmm_eotf::Eotf,
|
||||
compositor::{MAX_EXTENTS, WAYLAND_DISPLAY},
|
||||
compositor::MAX_EXTENTS,
|
||||
criteria::{
|
||||
CritLiteralOrRegex, CritMgrExt, CritTarget, CritUpstreamNode,
|
||||
clm::ClmLeafMatcher,
|
||||
|
|
@ -25,7 +25,6 @@ use {
|
|||
output_schedule::map_cursor_hz,
|
||||
scale::Scale,
|
||||
state::{ConnectorData, DeviceHandlerData, DrmDevData, OutputData, State},
|
||||
tagged_acceptor::TaggedAcceptorError,
|
||||
theme::{ThemeColor, ThemeSized},
|
||||
tree::{
|
||||
ContainerSplit, OutputNode, TearingMode, TileState, ToplevelData, ToplevelIdentifier,
|
||||
|
|
@ -37,7 +36,7 @@ use {
|
|||
copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt,
|
||||
numcell::NumCell,
|
||||
oserror::{OsError, OsErrorExt},
|
||||
oserror::OsErrorExt,
|
||||
stack::Stack,
|
||||
timer::{TimerError, TimerFd},
|
||||
},
|
||||
|
|
@ -50,7 +49,7 @@ use {
|
|||
ipc::{ClientMessage, Response, ServerMessage, WorkspaceSource},
|
||||
},
|
||||
Axis, Direction, Workspace,
|
||||
client::{Client as ConfigClient, ClientCapabilities, ClientMatcher},
|
||||
client::{Client as ConfigClient, ClientMatcher},
|
||||
input::{
|
||||
FallbackOutputMode, FocusFollowsMouseMode, InputDevice, LayerDirection, Seat, Timeline,
|
||||
acceleration::{ACCEL_PROFILE_ADAPTIVE, ACCEL_PROFILE_FLAT, AccelProfile},
|
||||
|
|
@ -76,7 +75,6 @@ use {
|
|||
xwayland::XScalingMode,
|
||||
},
|
||||
kbvm::Keycode,
|
||||
libloading::Library,
|
||||
log::Level,
|
||||
regex::Regex,
|
||||
std::{
|
||||
|
|
@ -92,10 +90,8 @@ use {
|
|||
};
|
||||
|
||||
pub(super) struct ConfigProxyHandler {
|
||||
pub path: Option<String>,
|
||||
pub client_data: Cell<*const u8>,
|
||||
pub dropped: Cell<bool>,
|
||||
pub _lib: Option<Library>,
|
||||
pub _version: u32,
|
||||
pub unref: unsafe extern "C" fn(data: *const u8),
|
||||
pub handle_msg: unsafe extern "C" fn(data: *const u8, msg: *const u8, size: usize),
|
||||
|
|
@ -121,24 +117,9 @@ pub(super) struct ConfigProxyHandler {
|
|||
|
||||
pub client_matcher_ids: NumCell<u64>,
|
||||
pub client_matchers:
|
||||
CopyHashMap<ClientMatcher, Rc<CachedCriterion<ClientCriterionIpc, Rc<Client>>>>,
|
||||
pub client_matcher_cache: CriterionCache<ClientCriterionIpc, Rc<Client>>,
|
||||
CopyHashMap<ClientMatcher, Rc<CachedCriterion<ClientCriterionIpc, Client>>>,
|
||||
pub client_matcher_cache: CriterionCache<ClientCriterionIpc, Client>,
|
||||
pub client_matcher_leafs: CopyHashMap<ClientMatcher, Rc<ClmLeafMatcher>>,
|
||||
pub client_matcher_capabilities: CopyHashMap<
|
||||
ClientMatcher,
|
||||
(
|
||||
Rc<CachedCriterion<ClientCriterionIpc, Rc<Client>>>,
|
||||
ClientCaps,
|
||||
),
|
||||
>,
|
||||
pub client_matcher_bounding_capabilities: CopyHashMap<
|
||||
ClientMatcher,
|
||||
(
|
||||
Rc<CachedCriterion<ClientCriterionIpc, Rc<Client>>>,
|
||||
ClientCaps,
|
||||
),
|
||||
>,
|
||||
|
||||
pub window_matcher_ids: NumCell<u64>,
|
||||
pub window_matchers:
|
||||
CopyHashMap<WindowMatcher, Rc<CachedCriterion<WindowCriterionIpc, ToplevelData>>>,
|
||||
|
|
@ -218,11 +199,6 @@ impl ConfigProxyHandler {
|
|||
self.window_matcher_leafs.clear();
|
||||
self.window_matchers.clear();
|
||||
|
||||
if let Some(path) = &self.path
|
||||
&& let Err(e) = uapi::unlink(path.as_str())
|
||||
{
|
||||
log::error!("Could not unlink {}: {}", path, ErrorFmt(OsError(e.0)));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send(&self, msg: &ServerMessage) {
|
||||
|
|
@ -1185,19 +1161,6 @@ impl ConfigProxyHandler {
|
|||
self.state.set_color_management_enabled(enabled);
|
||||
}
|
||||
|
||||
fn handle_get_socket_path(&self) {
|
||||
match self.state.acceptor.get() {
|
||||
Some(a) => {
|
||||
self.respond(Response::GetSocketPath {
|
||||
path: a.socket_name().to_string(),
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
log::warn!("There is no acceptor");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_connector_connected(&self, connector: Connector) -> Result<(), CphError> {
|
||||
let connector = self.get_connector(connector)?;
|
||||
self.respond(Response::ConnectorConnected {
|
||||
|
|
@ -1937,18 +1900,9 @@ impl ConfigProxyHandler {
|
|||
&self,
|
||||
prog: &str,
|
||||
args: Vec<String>,
|
||||
mut env: Vec<(String, String)>,
|
||||
env: Vec<(String, String)>,
|
||||
fds: Vec<(i32, i32)>,
|
||||
tag: Option<&str>,
|
||||
) -> Result<(), CphError> {
|
||||
if let Some(tag) = tag {
|
||||
let display = self
|
||||
.state
|
||||
.tagged_acceptors
|
||||
.get(&self.state, tag)
|
||||
.map_err(CphError::CreateTaggedAcceptor)?;
|
||||
env.push((WAYLAND_DISPLAY.to_string(), display.to_string()));
|
||||
}
|
||||
let fds: Vec<_> = fds
|
||||
.into_iter()
|
||||
.map(|(a, b)| (a, Rc::new(OwnedFd::new(b))))
|
||||
|
|
@ -2125,7 +2079,7 @@ impl ConfigProxyHandler {
|
|||
fn get_client_matcher(
|
||||
&self,
|
||||
matcher: ClientMatcher,
|
||||
) -> Result<Rc<CachedCriterion<ClientCriterionIpc, Rc<Client>>>, CphError> {
|
||||
) -> Result<Rc<CachedCriterion<ClientCriterionIpc, Client>>, CphError> {
|
||||
self.client_matchers
|
||||
.get(&matcher)
|
||||
.ok_or(CphError::ClientMatcherDoesNotExist(matcher))
|
||||
|
|
@ -2226,7 +2180,6 @@ impl ConfigProxyHandler {
|
|||
}
|
||||
ClientCriterionStringField::Comm => mgr.comm(needle),
|
||||
ClientCriterionStringField::Exe => mgr.exe(needle),
|
||||
ClientCriterionStringField::Tag => mgr.tag(needle),
|
||||
}
|
||||
}
|
||||
ClientCriterionIpc::Sandboxed => mgr.sandboxed(),
|
||||
|
|
@ -2249,8 +2202,6 @@ impl ConfigProxyHandler {
|
|||
fn handle_destroy_client_matcher(&self, matcher: ClientMatcher) {
|
||||
self.client_matchers.remove(&matcher);
|
||||
self.client_matcher_leafs.remove(&matcher);
|
||||
self.client_matcher_capabilities.remove(&matcher);
|
||||
self.client_matcher_bounding_capabilities.remove(&matcher);
|
||||
}
|
||||
|
||||
fn handle_enable_client_matcher_events(
|
||||
|
|
@ -2862,28 +2813,6 @@ impl ConfigProxyHandler {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_client_matcher_capabilities(
|
||||
&self,
|
||||
matcher: ClientMatcher,
|
||||
caps: ClientCapabilities,
|
||||
) -> Result<(), CphError> {
|
||||
let m = self.get_client_matcher(matcher)?;
|
||||
self.client_matcher_capabilities
|
||||
.set(matcher, (m, caps.to_client_caps()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_set_client_matcher_bounding_capabilities(
|
||||
&self,
|
||||
matcher: ClientMatcher,
|
||||
caps: ClientCapabilities,
|
||||
) -> Result<(), CphError> {
|
||||
let m = self.get_client_matcher(matcher)?;
|
||||
self.client_matcher_bounding_capabilities
|
||||
.set(matcher, (m, caps.to_client_caps()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_request(self: &Rc<Self>, msg: &[u8]) {
|
||||
if let Err(e) = self.handle_request_(msg) {
|
||||
log::error!("Could not handle client request: {}", ErrorFmt(e));
|
||||
|
|
@ -2946,7 +2875,7 @@ impl ConfigProxyHandler {
|
|||
ClientMessage::GetSeats => self.handle_get_seats(),
|
||||
ClientMessage::RemoveSeat { .. } => {}
|
||||
ClientMessage::Run { prog, args, env } => {
|
||||
self.handle_run(prog, args, env, vec![], None).wrn("run")?
|
||||
self.handle_run(prog, args, env, vec![]).wrn("run")?
|
||||
}
|
||||
ClientMessage::GrabKb { kb, grab } => self.handle_grab(kb, grab).wrn("grab")?,
|
||||
ClientMessage::SetColor { colorable, color } => {
|
||||
|
|
@ -3154,7 +3083,7 @@ impl ConfigProxyHandler {
|
|||
args,
|
||||
env,
|
||||
fds,
|
||||
} => self.handle_run(prog, args, env, fds, None).wrn("run")?,
|
||||
} => self.handle_run(prog, args, env, fds).wrn("run")?,
|
||||
ClientMessage::DisableDefaultSeat => self.state.create_default_seat.set(false),
|
||||
ClientMessage::DestroyKeymap { keymap } => self.handle_destroy_keymap(keymap),
|
||||
ClientMessage::GetConnectorName { connector } => self
|
||||
|
|
@ -3207,7 +3136,6 @@ impl ConfigProxyHandler {
|
|||
ClientMessage::SetExplicitSyncEnabled { enabled } => {
|
||||
self.handle_set_explicit_sync_enabled(enabled)
|
||||
}
|
||||
ClientMessage::GetSocketPath => self.handle_get_socket_path(),
|
||||
ClientMessage::DeviceSetKeymap { device, keymap } => self
|
||||
.handle_set_device_keymap(device, keymap)
|
||||
.wrn("set_device_keymap")?,
|
||||
|
|
@ -3508,12 +3436,6 @@ impl ConfigProxyHandler {
|
|||
.wrn("connector_set_blend_space")?,
|
||||
ClientMessage::SetBarFont { font } => self.handle_set_bar_font(font),
|
||||
ClientMessage::SetTitleFont { font } => self.handle_set_title_font(font),
|
||||
ClientMessage::SetClientMatcherCapabilities { matcher, caps } => self
|
||||
.handle_set_client_matcher_capabilities(matcher, caps)
|
||||
.wrn("set_client_matcher_capabilities")?,
|
||||
ClientMessage::SetClientMatcherBoundingCapabilities { matcher, caps } => self
|
||||
.handle_set_client_matcher_bounding_capabilities(matcher, caps)
|
||||
.wrn("set_client_matcher_bounding_capabilities")?,
|
||||
ClientMessage::ShowWorkspaceOn {
|
||||
seat,
|
||||
workspace,
|
||||
|
|
@ -3559,13 +3481,6 @@ impl ConfigProxyHandler {
|
|||
ClientMessage::SetXWaylandEnabled { enabled } => self
|
||||
.handle_set_x_wayland_enabled(enabled)
|
||||
.wrn("set_x_wayland_enabled")?,
|
||||
ClientMessage::Run3 {
|
||||
prog,
|
||||
args,
|
||||
env,
|
||||
fds,
|
||||
tag,
|
||||
} => self.handle_run(prog, args, env, fds, tag).wrn("run")?,
|
||||
ClientMessage::ConnectorSupportsArbitraryModes { connector } => self
|
||||
.handle_connector_supports_arbitrary_modes(connector)
|
||||
.wrn("connector_supports_arbitrary_modes")?,
|
||||
|
|
@ -3638,41 +3553,6 @@ impl ConfigProxyHandler {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn update_capabilities(
|
||||
&self,
|
||||
data: &Rc<Client>,
|
||||
bounding_caps: ClientCaps,
|
||||
set_bounding_caps: bool,
|
||||
) {
|
||||
let mut have_caps = false;
|
||||
let mut have_bounding_caps = false;
|
||||
let mut caps = ClientCaps::none();
|
||||
let mut new_bounding_caps = ClientCaps::none();
|
||||
for (matcher, state) in self.client_matcher_capabilities.lock().values() {
|
||||
if matcher.node.pull(data) {
|
||||
have_caps = true;
|
||||
caps |= *state;
|
||||
}
|
||||
}
|
||||
for (matcher, state) in self.client_matcher_bounding_capabilities.lock().values() {
|
||||
if matcher.node.pull(data) {
|
||||
have_bounding_caps = true;
|
||||
new_bounding_caps |= *state;
|
||||
}
|
||||
}
|
||||
if have_caps {
|
||||
caps &= bounding_caps;
|
||||
data.effective_caps.set(caps);
|
||||
}
|
||||
if !have_bounding_caps && set_bounding_caps {
|
||||
have_bounding_caps = true;
|
||||
new_bounding_caps = data.effective_caps.get();
|
||||
}
|
||||
if have_bounding_caps {
|
||||
new_bounding_caps &= bounding_caps;
|
||||
data.bounding_caps_for_children.set(new_bounding_caps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
@ -3771,8 +3651,6 @@ enum CphError {
|
|||
UnknownFallbackOutputMode(FallbackOutputMode),
|
||||
#[error("Unknown tile state {0:?}")]
|
||||
UnknownTileState(ConfigTileState),
|
||||
#[error("Could not create a tagged acceptor")]
|
||||
CreateTaggedAcceptor(#[source] TaggedAcceptorError),
|
||||
}
|
||||
|
||||
trait WithRequestName {
|
||||
|
|
@ -3784,13 +3662,3 @@ impl WithRequestName for Result<(), CphError> {
|
|||
self.map_err(move |e| CphError::FailedRequest(request, Box::new(e)))
|
||||
}
|
||||
}
|
||||
|
||||
trait ClientCapabilitiesExt {
|
||||
fn to_client_caps(self) -> ClientCaps;
|
||||
}
|
||||
|
||||
impl ClientCapabilitiesExt for ClientCapabilities {
|
||||
fn to_client_caps(self) -> ClientCaps {
|
||||
ClientCaps(self.0 as u32) & !CAP_JAY_COMPOSITOR & ClientCaps::all()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue