aboutsummaryrefslogtreecommitdiff
path: root/src/platform/gui/xcb
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-09-24 01:43:15 +0800
committerYuqian Yang <crupest@crupest.life>2025-09-24 01:43:15 +0800
commit62aabb7b6dbae4129b36393c0c222f6971e423e2 (patch)
tree5b0167dc9b7866bee1252f437d55ebedc4d120d4 /src/platform/gui/xcb
parenta3a0fb3488d29dd4743e6d4c22da9f5ded070ebc (diff)
downloadcru-62aabb7b6dbae4129b36393c0c222f6971e423e2.tar.gz
cru-62aabb7b6dbae4129b36393c0c222f6971e423e2.tar.bz2
cru-62aabb7b6dbae4129b36393c0c222f6971e423e2.zip
Impl SetQuitOnAllWindowClosed and fix RequestQuit of EventLoop.
Diffstat (limited to 'src/platform/gui/xcb')
-rw-r--r--src/platform/gui/xcb/Window.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/platform/gui/xcb/Window.cpp b/src/platform/gui/xcb/Window.cpp
index a27663a9..863738f1 100644
--- a/src/platform/gui/xcb/Window.cpp
+++ b/src/platform/gui/xcb/Window.cpp
@@ -15,6 +15,7 @@
#include <cairo.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
+#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdint>
@@ -69,6 +70,8 @@ XcbWindow::XcbWindow(XcbUiApplication *application)
XcbWindow::~XcbWindow() { application_->UnregisterWindow(this); }
+bool XcbWindow::IsCreated() { return xcb_window_.has_value(); }
+
void XcbWindow::Close() {
if (xcb_window_) {
xcb_destroy_window(application_->GetXcbConnection(), *xcb_window_);
@@ -410,6 +413,14 @@ void XcbWindow::HandleEvent(xcb_generic_event_t *event) {
cairo_surface_destroy(cairo_surface_);
cairo_surface_ = nullptr;
xcb_window_ = std::nullopt;
+
+ if (application_->IsQuitOnAllWindowClosed() &&
+ std::ranges::none_of(
+ application_->GetAllWindow(),
+ [](INativeWindow *window) { return window->IsCreated(); })) {
+ application_->RequestQuit(0);
+ }
+
break;
}
case XCB_CONFIGURE_NOTIFY: {