aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cru/platform/gui/xcb/Window.h4
-rw-r--r--src/platform/gui/xcb/Window.cpp19
2 files changed, 22 insertions, 1 deletions
diff --git a/include/cru/platform/gui/xcb/Window.h b/include/cru/platform/gui/xcb/Window.h
index 475f2527..4c9e3f4d 100644
--- a/include/cru/platform/gui/xcb/Window.h
+++ b/include/cru/platform/gui/xcb/Window.h
@@ -67,7 +67,7 @@ class XcbWindow : public XcbResource, public virtual INativeWindow {
virtual IEvent<std::nullptr_t>* PaintEvent() = 0;
virtual IEvent<WindowVisibilityType>* VisibilityChangeEvent() = 0;
- virtual IEvent<Size>* ResizeEvent() = 0;
+ IEvent<Size>* ResizeEvent() override;
IEvent<FocusChangeType>* FocusEvent() override;
IEvent<MouseEnterLeaveType>* MouseEnterLeaveEvent() override;
@@ -91,10 +91,12 @@ class XcbWindow : public XcbResource, public virtual INativeWindow {
private:
XcbUiApplication* application_;
std::optional<xcb_window_t> xcb_window_;
+ Size current_size_;
Event<std::nullptr_t> create_event_;
Event<std::nullptr_t> destroy_event_;
+ Event<Size> resize_event_;
Event<FocusChangeType> focus_event_;
Event<MouseEnterLeaveType> mouse_enter_leave_event_;
Event<Point> mouse_move_event_;
diff --git a/src/platform/gui/xcb/Window.cpp b/src/platform/gui/xcb/Window.cpp
index 179e13af..67568dce 100644
--- a/src/platform/gui/xcb/Window.cpp
+++ b/src/platform/gui/xcb/Window.cpp
@@ -59,6 +59,8 @@ IEvent<std::nullptr_t> *XcbWindow::CreateEvent() { return &create_event_; }
IEvent<std::nullptr_t> *XcbWindow::DestroyEvent() { return &destroy_event_; }
+IEvent<Size> *XcbWindow::ResizeEvent() { return &resize_event_; }
+
IEvent<FocusChangeType> *XcbWindow::FocusEvent() { return &focus_event_; }
IEvent<MouseEnterLeaveType> *XcbWindow::MouseEnterLeaveEvent() {
@@ -104,6 +106,7 @@ xcb_window_t XcbWindow::DoCreateWindow() {
xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, screen->root,
100, 100, 400, 200, 10, XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->root_visual, mask, values);
+ current_size_ = {400, 200};
create_event_.Raise(nullptr);
@@ -125,6 +128,17 @@ void XcbWindow::HandleEvent(xcb_generic_event_t *event) {
case XCB_DESTROY_NOTIFY: {
destroy_event_.Raise(nullptr);
xcb_window_ = std::nullopt;
+ break;
+ }
+ case XCB_CONFIGURE_NOTIFY: {
+ xcb_configure_notify_event_t *configure =
+ (xcb_configure_notify_event_t *)event;
+ if (configure->width != current_size_.width ||
+ configure->height != current_size_.height) {
+ current_size_ = Size(configure->width, configure->height);
+ resize_event_.Raise(current_size_);
+ }
+ break;
}
case XCB_FOCUS_IN: {
focus_event_.Raise(FocusChangeType::Gain);
@@ -217,6 +231,11 @@ std::optional<xcb_window_t> XcbWindow::GetEventWindow(
xcb_destroy_notify_event_t *destroy = (xcb_destroy_notify_event_t *)event;
return destroy->event;
}
+ case XCB_CONFIGURE_NOTIFY: {
+ xcb_configure_notify_event_t *configure =
+ (xcb_configure_notify_event_t *)event;
+ return configure->event;
+ }
case XCB_FOCUS_IN: {
xcb_focus_in_event_t *fi = (xcb_focus_in_event_t *)event;
return fi->event;