From e8e71847dccceee038338dab4e430957639f3d63 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Wed, 10 Sep 2025 00:38:59 +0800 Subject: xcb window visibility event. --- include/cru/platform/gui/xcb/Window.h | 6 ++++-- src/platform/gui/xcb/Window.cpp | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/cru/platform/gui/xcb/Window.h b/include/cru/platform/gui/xcb/Window.h index 4c9e3f4d..62351645 100644 --- a/include/cru/platform/gui/xcb/Window.h +++ b/include/cru/platform/gui/xcb/Window.h @@ -64,9 +64,9 @@ class XcbWindow : public XcbResource, public virtual INativeWindow { IEvent* CreateEvent() override; IEvent* DestroyEvent() override; - virtual IEvent* PaintEvent() = 0; + IEvent* PaintEvent() override; - virtual IEvent* VisibilityChangeEvent() = 0; + IEvent* VisibilityChangeEvent() override; IEvent* ResizeEvent() override; IEvent* FocusEvent() override; @@ -95,7 +95,9 @@ class XcbWindow : public XcbResource, public virtual INativeWindow { Event create_event_; Event destroy_event_; + Event paint_event_; + Event visibility_change_event_; Event resize_event_; Event focus_event_; Event mouse_enter_leave_event_; diff --git a/src/platform/gui/xcb/Window.cpp b/src/platform/gui/xcb/Window.cpp index 67568dce..3f22e6b0 100644 --- a/src/platform/gui/xcb/Window.cpp +++ b/src/platform/gui/xcb/Window.cpp @@ -59,6 +59,12 @@ IEvent *XcbWindow::CreateEvent() { return &create_event_; } IEvent *XcbWindow::DestroyEvent() { return &destroy_event_; } +IEvent *XcbWindow::PaintEvent() { return &paint_event_; } + +IEvent *XcbWindow::VisibilityChangeEvent() { + return &visibility_change_event_; +} + IEvent *XcbWindow::ResizeEvent() { return &resize_event_; } IEvent *XcbWindow::FocusEvent() { return &focus_event_; } @@ -140,6 +146,14 @@ void XcbWindow::HandleEvent(xcb_generic_event_t *event) { } break; } + case XCB_MAP_NOTIFY: { + visibility_change_event_.Raise(WindowVisibilityType::Show); + break; + } + case XCB_UNMAP_NOTIFY: { + visibility_change_event_.Raise(WindowVisibilityType::Hide); + break; + } case XCB_FOCUS_IN: { focus_event_.Raise(FocusChangeType::Gain); break; @@ -236,6 +250,14 @@ std::optional XcbWindow::GetEventWindow( (xcb_configure_notify_event_t *)event; return configure->event; } + case XCB_MAP_NOTIFY: { + xcb_map_notify_event_t *map = (xcb_map_notify_event_t *)event; + return map->event; + } + case XCB_UNMAP_NOTIFY: { + xcb_unmap_notify_event_t *unmap = (xcb_unmap_notify_event_t *)event; + return unmap->event; + } case XCB_FOCUS_IN: { xcb_focus_in_event_t *fi = (xcb_focus_in_event_t *)event; return fi->event; -- cgit v1.2.3