refactor(wm): reduce process_event log noise

This commit is contained in:
LGUG2Z
2024-08-06 17:12:36 -07:00
parent 13e2cbc7a1
commit 8f7b9202b2
2 changed files with 43 additions and 1 deletions

View File

@@ -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");

View File

@@ -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)),