From 8c72ae3d928ecbf11564695f3addae5caf718287 Mon Sep 17 00:00:00 2001 From: William Edwards Date: Sun, 29 Sep 2024 13:53:51 -0700 Subject: [PATCH 1/2] 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)); } }); } From 6c06c1f487ece2b50deb5b29acea56cfdaa2c3aa Mon Sep 17 00:00:00 2001 From: William Edwards Date: Sun, 29 Sep 2024 13:54:16 -0700 Subject: [PATCH 2/2] chore(Docs): update docs and bindings with baselayer_app_id methods --- .../org-shadowblip-gamescope-manager.xml | 30 +- .../org-shadowblip-gamescope-xwayland.xml | 254 +++++++------ docs/manager.md | 97 +++-- docs/xwayland.md | 352 ++++++++++++------ 4 files changed, 459 insertions(+), 274 deletions(-) diff --git a/bindings/dbus-xml/org-shadowblip-gamescope-manager.xml b/bindings/dbus-xml/org-shadowblip-gamescope-manager.xml index 4129391..0ba489e 100644 --- a/bindings/dbus-xml/org-shadowblip-gamescope-manager.xml +++ b/bindings/dbus-xml/org-shadowblip-gamescope-manager.xml @@ -1,21 +1,6 @@ - - - - - - - - - - - - - - - @@ -40,4 +25,19 @@ + + + + + + + + + + + + + + + diff --git a/bindings/dbus-xml/org-shadowblip-gamescope-xwayland.xml b/bindings/dbus-xml/org-shadowblip-gamescope-xwayland.xml index 268682f..ac2cee8 100644 --- a/bindings/dbus-xml/org-shadowblip-gamescope-xwayland.xml +++ b/bindings/dbus-xml/org-shadowblip-gamescope-xwayland.xml @@ -1,122 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -181,6 +70,23 @@ + + + + + + + + + + + @@ -260,6 +166,11 @@ --> + + + + + @@ -284,4 +195,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/manager.md b/docs/manager.md index 149859f..50a51f1 100644 --- a/docs/manager.md +++ b/docs/manager.md @@ -1,29 +1,76 @@ + # Manager DBus Interface API -## org.freedesktop.DBus.Introspectable +## org.freedesktop.DBus.Properties ### Methods -#### Introspect +#### Get + + ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| \*\*\*\* | *out* | *s* | | + | **interface\_name** | *in* | *s* | | + | **property\_name** | *in* | *s* | | + | **** | *out* | *v* | | + + +#### Set + + + +##### Arguments + +| Name | Direction | Type | Description | +| --- | :---: | :---: | --- | + | **interface\_name** | *in* | *s* | | + | **property\_name** | *in* | *s* | | + | **value** | *in* | *v* | | + + +#### GetAll + + + +##### Arguments + +| Name | Direction | Type | Description | +| --- | :---: | :---: | --- | + | **interface\_name** | *in* | *s* | | + | **** | *out* | *a{sv}* | | + + ### Signals +#### PropertiesChanged + + + +##### Arguments + +| Name | Direction | Type | Description | +| --- | :---: | :---: | --- | + | **interface\_name** | ** | *s* | | + | **changed\_properties** | ** | *a{sv}* | | + | **invalidated\_properties** | ** | *as* | | + + ## org.shadowblip.Gamescope.Manager ### Properties + | Name | Access | Type | Description | | --- | :---: | :---: | --- | | **Name** | *read* | *s* | | ### Methods + ### Signals ## org.freedesktop.DBus.Peer @@ -32,57 +79,37 @@ #### Ping -#### GetMachineId - -##### Arguments -| Name | Direction | Type | Description | -| --- | :---: | :---: | --- | -| \*\*\*\* | *out* | *s* | | -### Signals -## org.freedesktop.DBus.Properties +#### GetMachineId -### Methods -#### Get ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **interface_name** | *in* | *s* | | -| **property_name** | *in* | *s* | | -| \*\*\*\* | *out* | *v* | | - -#### Set + | **** | *out* | *s* | | + -##### Arguments -| Name | Direction | Type | Description | -| --- | :---: | :---: | --- | -| **interface_name** | *in* | *s* | | -| **property_name** | *in* | *s* | | -| **value** | *in* | *v* | | +### Signals -#### GetAll +## org.freedesktop.DBus.Introspectable -##### Arguments +### Methods -| Name | Direction | Type | Description | -| --- | :---: | :---: | --- | -| **interface_name** | *in* | *s* | | -| \*\*\*\* | *out* | *a{sv}* | | +#### Introspect -### Signals -#### PropertiesChanged ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **interface_name** | \*\* | *s* | | -| **changed_properties** | \*\* | *a{sv}* | | -| **invalidated_properties** | \*\* | *as* | | + | **** | *out* | *s* | | + + + +### Signals diff --git a/docs/xwayland.md b/docs/xwayland.md index 0015446..f9bdb01 100644 --- a/docs/xwayland.md +++ b/docs/xwayland.md @@ -1,310 +1,446 @@ + # XWayland DBus Interface API -## org.shadowblip.Gamescope.XWayland +## org.shadowblip.Gamescope.XWayland.Primary ### Properties + | Name | Access | Type | Description | | --- | :---: | :---: | --- | -| **Name** | *read* | *s* | | -| **Primary** | *read* | *b* | | -| **RootWindowId** | *read* | *u* | | -| **WatchedWindows** | *read* | *au* | | +| **AllowTearing** | *readwrite* | *b* | | +| **BlurMode** | *readwrite* | *u* | | +| **BlurRadius** | *readwrite* | *u* | | +| **FocusableApps** | *read* | *au* | | +| **FocusableWindowNames** | *read* | *as* | | +| **FocusableWindows** | *read* | *au* | | +| **FocusedApp** | *read* | *u* | | +| **FocusedAppGfx** | *read* | *u* | | +| **FocusedWindow** | *read* | *u* | | +| **FpsLimit** | *readwrite* | *u* | | +| **OverlayFocused** | *read* | *b* | | ### Methods -#### WatchWindow +#### IsFocusableApp + + ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | + | **window\_id** | *in* | *u* | | + | **** | *out* | *b* | | + + +#### SetMainApp + -#### UnwatchWindow ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | + | **window\_id** | *in* | *u* | | + + +#### SetInputFocus + -#### GetPidsForWindow ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *au* | | + | **window\_id** | *in* | *u* | | + | **value** | *in* | *u* | | + + +#### GetOverlay + -#### GetWindowsForPid ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **pid** | *in* | *u* | | -| \*\*\*\* | *out* | *au* | | + | **window\_id** | *in* | *u* | | + | **** | *out* | *u* | | + + +#### SetOverlay + -#### GetWindowName ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *s* | | + | **window\_id** | *in* | *u* | | + | **value** | *in* | *u* | | + + +#### SetNotification + -#### GetWindowChildren ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *au* | | + | **window\_id** | *in* | *u* | | + | **value** | *in* | *u* | | + + +#### SetExternalOverlay + -#### GetAllWindows ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *au* | | + | **window\_id** | *in* | *u* | | + | **value** | *in* | *u* | | + + +#### GetBaselayerAppId + -#### GetAppId ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *u* | | + | **** | *out* | *u* | | + + +#### SetBaselayerAppId + -#### SetAppId ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| **app_id** | *in* | *u* | | + | **app\_id** | *in* | *u* | | + + +#### RemoveBaselayerAppId + + + + +#### GetBaselayerWindow + -#### RemoveAppId ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | + | **** | *out* | *u* | | + + +#### SetBaselayerWindow + -#### HasAppId ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *b* | | + | **window\_id** | *in* | *u* | | + + +#### RemoveBaselayerWindow + + + + +#### RequestScreenshot + + + + ### Signals -#### WindowPropertyChanged +#### BaselayerAppIdUpdated + + + + +#### BaselayerWindowUpdated + + + + +#### WindowCreated + + ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window** | \*\* | *u* | | -| **prop** | \*\* | *s* | | + | **window\_id** | ** | *u* | | + -## org.freedesktop.DBus.Peer +## org.freedesktop.DBus.Introspectable ### Methods -#### Ping +#### Introspect + -#### GetMachineId ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| \*\*\*\* | *out* | *s* | | + | **** | *out* | *s* | | + + ### Signals -## org.freedesktop.DBus.Introspectable +## org.freedesktop.DBus.Properties ### Methods -#### Introspect +#### Get + + ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| \*\*\*\* | *out* | *s* | | + | **interface\_name** | *in* | *s* | | + | **property\_name** | *in* | *s* | | + | **** | *out* | *v* | | + -### Signals +#### Set -## org.shadowblip.Gamescope.XWayland.Primary -### Properties -| Name | Access | Type | Description | +##### Arguments + +| Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **AllowTearing** | *readwrite* | *b* | | -| **BlurMode** | *readwrite* | *u* | | -| **BlurRadius** | *readwrite* | *u* | | -| **FocusableApps** | *read* | *au* | | -| **FocusableWindowNames** | *read* | *as* | | -| **FocusableWindows** | *read* | *au* | | -| **FocusedApp** | *read* | *u* | | -| **FocusedAppGfx** | *read* | *u* | | -| **FocusedWindow** | *read* | *u* | | -| **FpsLimit** | *readwrite* | *u* | | -| **OverlayFocused** | *read* | *b* | | + | **interface\_name** | *in* | *s* | | + | **property\_name** | *in* | *s* | | + | **value** | *in* | *v* | | + + +#### GetAll -### Methods -#### IsFocusableApp ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *b* | | + | **interface\_name** | *in* | *s* | | + | **** | *out* | *a{sv}* | | + + + +### Signals + +#### PropertiesChanged + -#### SetMainApp ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | + | **interface\_name** | ** | *s* | | + | **changed\_properties** | ** | *a{sv}* | | + | **invalidated\_properties** | ** | *as* | | + + +## org.freedesktop.DBus.Peer + +### Methods + +#### Ping + + + + +#### GetMachineId + -#### SetInputFocus ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| **value** | *in* | *u* | | + | **** | *out* | *s* | | + + + +### Signals + +## org.shadowblip.Gamescope.XWayland + +### Properties + + +| Name | Access | Type | Description | +| --- | :---: | :---: | --- | +| **Name** | *read* | *s* | | +| **Primary** | *read* | *b* | | +| **RootWindowId** | *read* | *u* | | +| **WatchedWindows** | *read* | *au* | | + +### Methods + +#### WatchWindow + -#### GetOverlay ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| \*\*\*\* | *out* | *u* | | + | **window\_id** | *in* | *u* | | + + +#### UnwatchWindow + -#### SetOverlay ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| **value** | *in* | *u* | | + | **window\_id** | *in* | *u* | | + + +#### GetPidsForWindow + -#### SetNotification ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| **value** | *in* | *u* | | + | **window\_id** | *in* | *u* | | + | **** | *out* | *au* | | + + +#### GetWindowsForPid + -#### SetExternalOverlay ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | -| **value** | *in* | *u* | | + | **pid** | *in* | *u* | | + | **** | *out* | *au* | | + + +#### GetWindowName + -#### GetBaselayerWindow ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| \*\*\*\* | *out* | *u* | | + | **window\_id** | *in* | *u* | | + | **** | *out* | *s* | | + + +#### GetWindowChildren + -#### SetBaselayerWindow ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | *in* | *u* | | + | **window\_id** | *in* | *u* | | + | **** | *out* | *au* | | + -#### RemoveBaselayerWindow +#### GetAllWindows -#### RequestScreenshot -### Signals -#### BaselayerWindowUpdated +##### Arguments + +| Name | Direction | Type | Description | +| --- | :---: | :---: | --- | + | **window\_id** | *in* | *u* | | + | **** | *out* | *au* | | + + +#### GetAppId + -#### WindowCreated ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **window_id** | \*\* | *u* | | + | **window\_id** | *in* | *u* | | + | **** | *out* | *u* | | + -## org.freedesktop.DBus.Properties +#### SetAppId -### Methods -#### Get ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **interface_name** | *in* | *s* | | -| **property_name** | *in* | *s* | | -| \*\*\*\* | *out* | *v* | | + | **window\_id** | *in* | *u* | | + | **app\_id** | *in* | *u* | | + + +#### RemoveAppId + -#### Set ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **interface_name** | *in* | *s* | | -| **property_name** | *in* | *s* | | -| **value** | *in* | *v* | | + | **window\_id** | *in* | *u* | | + + +#### HasAppId + -#### GetAll ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **interface_name** | *in* | *s* | | -| \*\*\*\* | *out* | *a{sv}* | | + | **window\_id** | *in* | *u* | | + | **** | *out* | *b* | | + + ### Signals -#### PropertiesChanged +#### WindowPropertyChanged + + ##### Arguments | Name | Direction | Type | Description | | --- | :---: | :---: | --- | -| **interface_name** | \*\* | *s* | | -| **changed_properties** | \*\* | *a{sv}* | | -| **invalidated_properties** | \*\* | *as* | | + | **window** | ** | *u* | | + | **prop** | ** | *s* | | +