Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for window lifecycle events and deprecate window created event #12

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ 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 = "deeab5be067bfbb2add2446d8c7fbcbeba7c8c7f" }
gamescope-x11-client = { git = "https://github.com/ShadowBlip/gamescope-x11-client.git", rev = "9526a6e0d684d9530e8705f7f1a53efa401350f3" }
serde = "1.0.214"
18 changes: 16 additions & 2 deletions src/gamescope/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Manager {

// Create any xwaylands that don't exist
for (i, name) in current_xwaylands.into_iter().enumerate() {
if self.xwaylands.get(&name).is_some() {
if self.xwaylands.contains_key(&name) {
log::debug!("XWayland is already managed for {}. Skipping.", name);
continue;
}
Expand All @@ -193,10 +193,22 @@ impl Manager {
let path = format!("/org/shadowblip/Gamescope/XWayland{}", i);
let instance =
xwayland::DBusInterface::new(name.clone(), path.clone(), self.dbus.clone())?;
let is_primary = instance.primary().await?;

// Listen for new windows lifecycle
let window_lifecycle_rx = instance.listen_for_window_lifecycle()?;
// Propagate gamescope changes to DBus signals
xwayland::dispatch_window_lifecycle(
self.dbus.clone(),
path.clone(),
window_lifecycle_rx,
is_primary,
)
.await?;

// Check to see if this is a primary xwayland instance. If it is,
// also attach the dbus interface with extra methods
if instance.primary().await? {
if is_primary {
log::debug!("Discovered XWayland {} is primary", name);

// Property changes events
Expand All @@ -206,6 +218,7 @@ impl Manager {
self.dbus.clone(),
)?;
let property_changes_rx = primary.listen_for_property_changes()?;
#[allow(deprecated)]
let window_created_rx = primary.listen_for_window_created()?;
self.dbus.object_server().at(path.clone(), primary).await?;

Expand All @@ -218,6 +231,7 @@ impl Manager {
.await?;

// Propagate gamescope changes to DBus signals
#[allow(deprecated)]
xwayland::dispatch_primary_window_created(
self.dbus.clone(),
path.clone(),
Expand Down
Loading
Loading