diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-26 10:08:07 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-06-28 10:39:35 +0400 |
| commit | 40aff3a094756b2cfa9c0ce48c1ab2be26b1f9ee (patch) | |
| tree | 662ddc0e7ecb92bc01e025d7f7c54a0522e91d9e /src/niri.rs | |
| parent | 6c5f10035a24963336d99f801164e7437ebffa77 (diff) | |
| download | niri-40aff3a094756b2cfa9c0ce48c1ab2be26b1f9ee.tar.gz niri-40aff3a094756b2cfa9c0ce48c1ab2be26b1f9ee.tar.bz2 niri-40aff3a094756b2cfa9c0ce48c1ab2be26b1f9ee.zip | |
Implement org/gnome/shell/Introspect/GetWindows
Diffstat (limited to 'src/niri.rs')
| -rw-r--r-- | src/niri.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/niri.rs b/src/niri.rs index 13e8b963..6767faaa 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -99,6 +99,8 @@ use crate::backend::tty::SurfaceDmabufFeedback; use crate::backend::{Backend, RenderResult, Tty, Winit}; use crate::cursor::{CursorManager, CursorTextureCache, RenderCursor, XCursor}; #[cfg(feature = "dbus")] +use crate::dbus::gnome_shell_introspect::{self, IntrospectToNiri, NiriToIntrospect}; +#[cfg(feature = "dbus")] use crate::dbus::gnome_shell_screenshot::{NiriToScreenshot, ScreenshotToNiri}; #[cfg(feature = "xdp-gnome-screencast")] use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri}; @@ -1273,6 +1275,50 @@ impl State { } } } + + #[cfg(feature = "dbus")] + pub fn on_introspect_msg( + &mut self, + to_introspect: &async_channel::Sender<NiriToIntrospect>, + msg: IntrospectToNiri, + ) { + use smithay::wayland::shell::xdg::XdgToplevelSurfaceData; + + let IntrospectToNiri::GetWindows = msg; + let _span = tracy_client::span!("GetWindows"); + + let mut windows = HashMap::new(); + + self.niri.layout.with_windows(|mapped, _| { + let wl_surface = mapped + .window + .toplevel() + .expect("no X11 support") + .wl_surface(); + + let id = u64::from(mapped.id().get()); + let props = with_states(wl_surface, |states| { + let role = states + .data_map + .get::<XdgToplevelSurfaceData>() + .unwrap() + .lock() + .unwrap(); + + gnome_shell_introspect::WindowProperties { + title: role.title.clone().unwrap_or_default(), + app_id: role.app_id.clone().unwrap_or_default(), + } + }); + + windows.insert(id, props); + }); + + let msg = NiriToIntrospect::Windows(windows); + if let Err(err) = to_introspect.send_blocking(msg) { + warn!("error sending windows to introspect: {err:?}"); + } + } } impl Niri { |
