From 9e9a661589be828a2bfaa17472529c8b916aa0ab Mon Sep 17 00:00:00 2001 From: William Edwards Date: Sun, 29 Sep 2024 13:53:51 -0700 Subject: [PATCH] feat(XWayland): add '[get|set]_baselayer_app_id' methods to primary xwayland --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/gamescope/xwayland.rs | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0172890..4c31eea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -529,7 +529,7 @@ dependencies = [ [[package]] name = "gamescope-x11-client" version = "0.1.0" -source = "git+https://github.com/ShadowBlip/gamescope-x11-client.git?rev=3a0cbe64ba60dffb5ad85f156101c056f764e659#3a0cbe64ba60dffb5ad85f156101c056f764e659" +source = "git+https://github.com/ShadowBlip/gamescope-x11-client.git?rev=deeab5be067bfbb2add2446d8c7fbcbeba7c8c7f#deeab5be067bfbb2add2446d8c7fbcbeba7c8c7f" dependencies = [ "log", "strum", diff --git a/Cargo.toml b/Cargo.toml index bc0c246..2d62e99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,4 +22,4 @@ zbus = { version = "3.15.2", default-features = false, features = ["tokio"] } zbus_macros = "3.15.2" inotify = "0.11.0" gamescope-wayland-client = { git = "https://github.com/ShadowBlip/gamescope-wayland-client.git", version = "0.1.0" } -gamescope-x11-client = { git = "https://github.com/ShadowBlip/gamescope-x11-client.git", rev = "3a0cbe64ba60dffb5ad85f156101c056f764e659" } +gamescope-x11-client = { git = "https://github.com/ShadowBlip/gamescope-x11-client.git", rev = "deeab5be067bfbb2add2446d8c7fbcbeba7c8c7f" } diff --git a/src/gamescope/xwayland.rs b/src/gamescope/xwayland.rs index d34fa40..fb8e097 100644 --- a/src/gamescope/xwayland.rs +++ b/src/gamescope/xwayland.rs @@ -548,6 +548,10 @@ impl DBusInterfacePrimary { Ok(value) } + /// Fires when the baselayer app id has been updated + #[dbus_interface(signal)] + async fn baselayer_app_id_updated(ctxt: &SignalContext<'_>) -> zbus::Result<()>; + /// Fires when the baselayer window has been updated #[dbus_interface(signal)] async fn baselayer_window_updated(ctxt: &SignalContext<'_>) -> zbus::Result<()>; @@ -615,6 +619,34 @@ impl DBusInterfacePrimary { Ok(()) } + /// Returns the currently set manual app focus + async fn get_baselayer_app_id(&self) -> fdo::Result { + self.ensure_connected().await; + let value = self + .xwayland + .get_baselayer_app_id() + .map_err(|err| fdo::Error::Failed(err.to_string()))?; + Ok(value.unwrap_or_default()) + } + + /// Focuses the app with the given app id + async fn set_baselayer_app_id(&self, app_id: u32) -> fdo::Result<()> { + self.ensure_connected().await; + self.xwayland + .set_baselayer_app_id(app_id) + .map_err(|err| fdo::Error::Failed(err.to_string()))?; + Ok(()) + } + + /// Removes the baselayer property to un-focus an app + async fn remove_baselayer_app_id(&self) -> fdo::Result<()> { + self.ensure_connected().await; + self.xwayland + .remove_baselayer_app_id() + .map_err(|err| fdo::Error::Failed(err.to_string()))?; + Ok(()) + } + /// Returns the currently set manual focus async fn get_baselayer_window(&self) -> fdo::Result { self.ensure_connected().await; @@ -744,6 +776,10 @@ fn dispatch_property_change_to_dbus(conn: zbus::Connection, path: String, event: DBusInterfacePrimary::baselayer_window_updated(iface_ref.signal_context()) .await .unwrap_or_else(|error| log::warn!("Unable to signal value change: {:?}", error)); + } else if event == GamescopeAtom::BaselayerAppId.to_string() { + DBusInterfacePrimary::baselayer_app_id_updated(iface_ref.signal_context()) + .await + .unwrap_or_else(|error| log::warn!("Unable to signal value change: {:?}", error)); } }); }