Skip to content

Commit

Permalink
feat(XWayland): add '[get|set]_baselayer_app_id' methods to primary x…
Browse files Browse the repository at this point in the history
…wayland
  • Loading branch information
ShadowApex committed Sep 29, 2024
1 parent 6b39e80 commit 9e9a661
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
36 changes: 36 additions & 0 deletions src/gamescope/xwayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()>;
Expand Down Expand Up @@ -615,6 +619,34 @@ impl DBusInterfacePrimary {
Ok(())
}

/// Returns the currently set manual app focus
async fn get_baselayer_app_id(&self) -> fdo::Result<u32> {
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<u32> {
self.ensure_connected().await;
Expand Down Expand Up @@ -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));
}
});
}
Expand Down

0 comments on commit 9e9a661

Please sign in to comment.