diff options
-rw-r--r-- | include/cru/platform/graphics/cairo/CairoPainter.h | 2 | ||||
-rw-r--r-- | include/cru/platform/gui/xcb/Window.h | 5 | ||||
-rw-r--r-- | src/platform/graphics/cairo/CairoPainter.cpp | 2 | ||||
-rw-r--r-- | src/platform/gui/xcb/Window.cpp | 22 |
4 files changed, 25 insertions, 6 deletions
diff --git a/include/cru/platform/graphics/cairo/CairoPainter.h b/include/cru/platform/graphics/cairo/CairoPainter.h index 477bd289..1c071fb0 100644 --- a/include/cru/platform/graphics/cairo/CairoPainter.h +++ b/include/cru/platform/graphics/cairo/CairoPainter.h @@ -1,4 +1,5 @@ #pragma once +#include <cru/base/Base.h> #include "../Painter.h" #include "CairoResource.h" @@ -7,6 +8,7 @@ namespace cru::platform::graphics::cairo { class CRU_PLATFORM_GRAPHICS_CAIRO_API CairoPainter : public CairoResource, public virtual IPainter { + CRU_DEFINE_CLASS_LOG_TAG("cru::platform::graphics::cairo::CairoPainter") public: CairoPainter(CairoGraphicsFactory* factory, cairo_t* cairo, bool auto_release, cairo_surface_t* cairo_surface = nullptr); diff --git a/include/cru/platform/gui/xcb/Window.h b/include/cru/platform/gui/xcb/Window.h index d9bef0c3..5f1fd66e 100644 --- a/include/cru/platform/gui/xcb/Window.h +++ b/include/cru/platform/gui/xcb/Window.h @@ -1,8 +1,9 @@ #pragma once +#include <cru/base/Base.h> #include "../../GraphicsBase.h" -#include "../Window.h" #include "../TimerHelper.h" +#include "../Window.h" #include "Base.h" #include <cairo.h> @@ -16,6 +17,8 @@ class XcbCursor; class XcbXimInputMethodContext; class XcbWindow : public XcbResource, public virtual INativeWindow { + CRU_DEFINE_CLASS_LOG_TAG("cru::platform::gui::xcb::XcbWindow") + friend XcbUiApplication; public: diff --git a/src/platform/graphics/cairo/CairoPainter.cpp b/src/platform/graphics/cairo/CairoPainter.cpp index 8dd214cc..3178876c 100644 --- a/src/platform/graphics/cairo/CairoPainter.cpp +++ b/src/platform/graphics/cairo/CairoPainter.cpp @@ -1,5 +1,6 @@ #include "cru/platform/graphics/cairo/CairoPainter.h" #include "cru/base/Exception.h" +#include "cru/base/log/Logger.h" #include "cru/platform/Check.h" #include "cru/platform/Exception.h" #include "cru/platform/graphics/cairo/Base.h" @@ -237,6 +238,7 @@ void CairoPainter::PopState() { void CairoPainter::EndDraw() { if (cairo_surface_ != nullptr) { + CRU_LOG_TAG_DEBUG("Flush cairo painter."); cairo_surface_flush(cairo_surface_); } valid_ = false; diff --git a/src/platform/gui/xcb/Window.cpp b/src/platform/gui/xcb/Window.cpp index 0085dae7..d94e8a0e 100644 --- a/src/platform/gui/xcb/Window.cpp +++ b/src/platform/gui/xcb/Window.cpp @@ -1,6 +1,7 @@ #include "cru/platform/gui/xcb/Window.h" #include "cru/base/Base.h" #include "cru/base/Guard.h" +#include "cru/base/log/Logger.h" #include "cru/platform/Check.h" #include "cru/platform/GraphicsBase.h" #include "cru/platform/graphics/NullPainter.h" @@ -69,6 +70,11 @@ XcbWindow::XcbWindow(XcbUiApplication *application) application->RegisterWindow(this); input_method_ = new XcbXimInputMethodContext( application->GetXcbXimInputMethodManager(), this); + + paint_event_.AddSpyOnlyHandler([this] { + if (xcb_window_) + CRU_LOG_TAG_DEBUG("{:#x} Paint event triggered.", *xcb_window_); + }); } XcbWindow::~XcbWindow() { @@ -301,6 +307,8 @@ void XcbWindow::SetToForeground() { } void XcbWindow::RequestRepaint() { + if (!xcb_window_.has_value()) return; + CRU_LOG_TAG_DEBUG("{:#x} Repaint requested.", *xcb_window_); // TODO: true throttle repaint_canceler_.Reset( application_->SetImmediate([this] { paint_event_.Raise(nullptr); })); @@ -428,6 +436,8 @@ xcb_window_t XcbWindow::DoCreateWindow() { cairo_xcb_surface_create(connection, window, visual_type, width, height); create_event_.Raise(nullptr); + resize_event_.Raise(current_size_); + RequestRepaint(); return window; } @@ -435,7 +445,7 @@ xcb_window_t XcbWindow::DoCreateWindow() { void XcbWindow::HandleEvent(xcb_generic_event_t *event) { switch (event->response_type & ~0x80) { case XCB_EXPOSE: { - paint_event_.Raise(nullptr); + RequestRepaint(); break; } case XCB_DESTROY_NOTIFY: { @@ -459,6 +469,8 @@ void XcbWindow::HandleEvent(xcb_generic_event_t *event) { (xcb_configure_notify_event_t *)event; auto width = configure->width, height = configure->height; if (width != current_size_.width || height != current_size_.height) { + CRU_LOG_TAG_DEBUG("{:#x} Size changed {} x {}.", *xcb_window_, width, + height); current_size_ = Size(width, height); assert(cairo_surface_); cairo_xcb_surface_set_size(cairo_surface_, width, height); @@ -573,20 +585,20 @@ std::optional<xcb_window_t> XcbWindow::GetEventWindow( } case XCB_DESTROY_NOTIFY: { xcb_destroy_notify_event_t *destroy = (xcb_destroy_notify_event_t *)event; - return destroy->event; + return destroy->window; } case XCB_CONFIGURE_NOTIFY: { xcb_configure_notify_event_t *configure = (xcb_configure_notify_event_t *)event; - return configure->event; + return configure->window; } case XCB_MAP_NOTIFY: { xcb_map_notify_event_t *map = (xcb_map_notify_event_t *)event; - return map->event; + return map->window; } case XCB_UNMAP_NOTIFY: { xcb_unmap_notify_event_t *unmap = (xcb_unmap_notify_event_t *)event; - return unmap->event; + return unmap->window; } case XCB_FOCUS_IN: { xcb_focus_in_event_t *fi = (xcb_focus_in_event_t *)event; |