mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-24 18:31:22 +01:00
refactor(wm): reduce process_event log noise
This commit is contained in:
@@ -64,7 +64,7 @@ pub fn listen_for_events(wm: Arc<Mutex<WindowManager>>) {
|
||||
|
||||
impl WindowManager {
|
||||
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)]
|
||||
#[tracing::instrument(skip(self))]
|
||||
#[tracing::instrument(skip(self, event), fields(event = event.title(), winevent = event.winevent(), hwnd = event.hwnd()))]
|
||||
pub fn process_event(&mut self, event: WindowManagerEvent) -> Result<()> {
|
||||
if self.is_paused {
|
||||
tracing::trace!("ignoring while paused");
|
||||
|
||||
@@ -102,6 +102,48 @@ impl WindowManagerEvent {
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn hwnd(self) -> isize {
|
||||
self.window().hwnd
|
||||
}
|
||||
|
||||
pub const fn title(self) -> &'static str {
|
||||
match self {
|
||||
WindowManagerEvent::Destroy(_, _) => "Destroy",
|
||||
WindowManagerEvent::FocusChange(_, _) => "FocusChange",
|
||||
WindowManagerEvent::Hide(_, _) => "Hide",
|
||||
WindowManagerEvent::Cloak(_, _) => "Cloak",
|
||||
WindowManagerEvent::Minimize(_, _) => "Minimize",
|
||||
WindowManagerEvent::Show(_, _) => "Show",
|
||||
WindowManagerEvent::Uncloak(_, _) => "Uncloak",
|
||||
WindowManagerEvent::MoveResizeStart(_, _) => "MoveResizeStart",
|
||||
WindowManagerEvent::MoveResizeEnd(_, _) => "MoveResizeEnd",
|
||||
WindowManagerEvent::MouseCapture(_, _) => "MouseCapture",
|
||||
WindowManagerEvent::Manage(_) => "Manage",
|
||||
WindowManagerEvent::Unmanage(_) => "Unmanage",
|
||||
WindowManagerEvent::Raise(_) => "Raise",
|
||||
WindowManagerEvent::TitleUpdate(_, _) => "TitleUpdate",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn winevent(self) -> Option<String> {
|
||||
match self {
|
||||
WindowManagerEvent::Destroy(event, _)
|
||||
| WindowManagerEvent::FocusChange(event, _)
|
||||
| WindowManagerEvent::Hide(event, _)
|
||||
| WindowManagerEvent::Cloak(event, _)
|
||||
| WindowManagerEvent::Minimize(event, _)
|
||||
| WindowManagerEvent::Show(event, _)
|
||||
| WindowManagerEvent::Uncloak(event, _)
|
||||
| WindowManagerEvent::MoveResizeStart(event, _)
|
||||
| WindowManagerEvent::MoveResizeEnd(event, _)
|
||||
| WindowManagerEvent::MouseCapture(event, _)
|
||||
| WindowManagerEvent::TitleUpdate(event, _) => Some(event.to_string()),
|
||||
WindowManagerEvent::Manage(_)
|
||||
| WindowManagerEvent::Unmanage(_)
|
||||
| WindowManagerEvent::Raise(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_win_event(winevent: WinEvent, window: Window) -> Option<Self> {
|
||||
match winevent {
|
||||
WinEvent::ObjectDestroy => Option::from(Self::Destroy(winevent, window)),
|
||||
|
||||
Reference in New Issue
Block a user