diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 10:35:05 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-02 10:53:55 +0300 |
| commit | 86bdc6898bc8a13368ba852692ff0cc248345128 (patch) | |
| tree | 4c3106f4bc51501289a2cd2aa858f8d14d332677 /src/ipc | |
| parent | e5ca3351153fa6f3d1e3b00806f85058a8182065 (diff) | |
| download | niri-86bdc6898bc8a13368ba852692ff0cc248345128.tar.gz niri-86bdc6898bc8a13368ba852692ff0cc248345128.tar.bz2 niri-86bdc6898bc8a13368ba852692ff0cc248345128.zip | |
Add with_toplevel_role() util function
Diffstat (limited to 'src/ipc')
| -rw-r--r-- | src/ipc/server.rs | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/src/ipc/server.rs b/src/ipc/server.rs index 608bb629..be463aa2 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -19,13 +19,11 @@ use niri_ipc::{Event, KeyboardLayouts, OutputConfigChanged, Reply, Request, Resp use smithay::reexports::calloop::generic::Generic; use smithay::reexports::calloop::{Interest, LoopHandle, Mode, PostAction}; use smithay::reexports::rustix::fs::unlink; -use smithay::wayland::compositor::with_states; -use smithay::wayland::shell::xdg::XdgToplevelSurfaceData; use crate::backend::IpcOutputMap; use crate::layout::workspace::WorkspaceId; use crate::niri::State; -use crate::utils::version; +use crate::utils::{version, with_toplevel_role}; use crate::window::Mapped; // If an event stream client fails to read events fast enough that we accumulate more than this @@ -361,22 +359,12 @@ async fn handle_event_stream_client(client: EventStreamClient) -> anyhow::Result } fn make_ipc_window(mapped: &Mapped, workspace_id: Option<WorkspaceId>) -> niri_ipc::Window { - let wl_surface = mapped.toplevel().wl_surface(); - with_states(wl_surface, |states| { - let role = states - .data_map - .get::<XdgToplevelSurfaceData>() - .unwrap() - .lock() - .unwrap(); - - niri_ipc::Window { - id: mapped.id().get(), - title: role.title.clone(), - app_id: role.app_id.clone(), - workspace_id: workspace_id.map(|id| id.get()), - is_focused: mapped.is_focused(), - } + with_toplevel_role(mapped.toplevel(), |role| niri_ipc::Window { + id: mapped.id().get(), + title: role.title.clone(), + app_id: role.app_id.clone(), + workspace_id: workspace_id.map(|id| id.get()), + is_focused: mapped.is_focused(), }) } @@ -559,15 +547,7 @@ impl State { let workspace_id = ws_id.map(|id| id.get()); let mut changed = ipc_win.workspace_id != workspace_id; - let wl_surface = mapped.toplevel().wl_surface(); - changed |= with_states(wl_surface, |states| { - let role = states - .data_map - .get::<XdgToplevelSurfaceData>() - .unwrap() - .lock() - .unwrap(); - + changed |= with_toplevel_role(mapped.toplevel(), |role| { ipc_win.title != role.title || ipc_win.app_id != role.app_id }); |
