Skip to content

Commit

Permalink
xdg-shell: Add callbacks for app-id and title changes
Browse files Browse the repository at this point in the history
Otherwise there's no good way to track this.
  • Loading branch information
YaLTeR authored and Drakulix committed Feb 15, 2024
1 parent e6e6e77 commit c9ef9d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/wayland/shell/xdg/handlers/surface/toplevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,35 @@ where
}
xdg_toplevel::Request::SetTitle { title } => {
// Title is not double buffered, we can set it directly
with_surface_toplevel_role_data(toplevel, |data| {
data.title = Some(title);
let changed = with_surface_toplevel_role_data(toplevel, |role| {
if role.title.as_ref() != Some(&title) {
role.title = Some(title);
true
} else {
false
}
});

if changed {
let handle = make_toplevel_handle(toplevel);
XdgShellHandler::title_changed(state, handle);
}
}
xdg_toplevel::Request::SetAppId { app_id } => {
// AppId is not double buffered, we can set it directly
with_surface_toplevel_role_data(toplevel, |role| {
role.app_id = Some(app_id);
let changed = with_surface_toplevel_role_data(toplevel, |role| {
if role.app_id.as_ref() != Some(&app_id) {
role.app_id = Some(app_id);
true
} else {
false
}
});

if changed {
let handle = make_toplevel_handle(toplevel);
XdgShellHandler::app_id_changed(state, handle);
}
}
xdg_toplevel::Request::ShowWindowMenu { seat, serial, x, y } => {
// This has to be handled by the compositor
Expand Down
6 changes: 6 additions & 0 deletions src/wayland/shell/xdg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,12 @@ pub trait XdgShellHandler {

/// A popup surface was destroyed.
fn popup_destroyed(&mut self, surface: PopupSurface) {}

/// The toplevel surface set a different app id.
fn app_id_changed(&mut self, surface: ToplevelSurface) {}

/// The toplevel surface set a different title.
fn title_changed(&mut self, surface: ToplevelSurface) {}
}

/// Shell global state
Expand Down

0 comments on commit c9ef9d6

Please sign in to comment.