aboutsummaryrefslogtreecommitdiff
path: root/src/platform/gui/xcb/Window.cpp
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-10-11 18:24:55 +0800
committerYuqian Yang <crupest@crupest.life>2025-10-11 18:24:55 +0800
commit9768b98d46982501c3b34c171aa51389b06add3b (patch)
tree762b538d4a8afa3312a032ac160262084aa875a9 /src/platform/gui/xcb/Window.cpp
parentdb26d6e0785f9e1a8420130f9441c72c6a842df5 (diff)
downloadcru-9768b98d46982501c3b34c171aa51389b06add3b.tar.gz
cru-9768b98d46982501c3b34c171aa51389b06add3b.tar.bz2
cru-9768b98d46982501c3b34c171aa51389b06add3b.zip
Add more logging and fix init black window.
Diffstat (limited to 'src/platform/gui/xcb/Window.cpp')
-rw-r--r--src/platform/gui/xcb/Window.cpp22
1 files changed, 17 insertions, 5 deletions
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;