// Copyright 2026 rootiest // SPDX-License-Identifier: GPL-3.0-or-later //! Active application / window monitor — **reserved, not yet implemented**. //! //! When implemented this module will detect the active window on a KDE6 //! Wayland desktop and send `CMD_ACTIVE_APP` (0x43) packets containing the //! application name (null-terminated UTF-8, max 28 bytes) to all connected //! keyboards. //! //! # Implementation notes for KDE6 / Wayland //! //! Candidate approaches (to evaluate during the brainstorming phase): //! //! 1. **KWin D-Bus interface** — `org.kde.KWin` exposes `activeWindow()` on //! the scripting API. The window object has `resourceName` / `caption` //! properties. Can subscribe to `windowActivated` signal. //! → easiest; requires D-Bus session access. //! //! 2. **KWin Script** — inject a tiny `.kwinscript` that emits a custom //! D-Bus signal or writes to a FIFO on `windowActivated`. //! → portable across KWin versions; slightly invasive. //! //! 3. **`xdg-foreign` / `wlr-foreign-toplevel`** — Wayland protocols for //! enumerating toplevels. KWin supports `ext-foreign-toplevel-list-v1`. //! → protocol-level, no D-Bus, but requires a Wayland client loop. //! //! 4. **`qdbus6` / `busctl` polling** — parse output of //! `busctl call org.kde.KWin /KWin org.kde.KWin activeWindow` //! in a poll loop. Simple but coarse. //! //! The chosen approach will be implemented here once the brainstorming is //! complete. The `Packet::active_app()` constructor in `protocol.rs` is //! already in place. use log::info; use crate::keyboard::Keyboard; /// Monitor the active application and notify keyboards. /// Currently a no-op stub — safe to call, does nothing. pub fn monitor(_keyboards: Vec) { info!("Active-application monitor: not yet implemented (stub)"); // Future: block here in an event loop and send Packet::active_app() // packets to keyboards whenever the active window changes. }