diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-09-22 14:58:02 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-09-22 21:56:27 +0800 |
commit | ce07249c9b99959fdac7973257526e7dd700d5d9 (patch) | |
tree | f12769dcc204bb8fe52ecf1a5bf8bdc7bdd0b1fb | |
parent | 39b4261324bd61a9df7861c314459746bc0acd30 (diff) | |
download | cru-ce07249c9b99959fdac7973257526e7dd700d5d9.tar.gz cru-ce07249c9b99959fdac7973257526e7dd700d5d9.tar.bz2 cru-ce07249c9b99959fdac7973257526e7dd700d5d9.zip |
Impl SetToForeground RequestRepaint of xcb window.
-rw-r--r-- | include/cru/platform/gui/xcb/Window.h | 4 | ||||
-rw-r--r-- | src/platform/gui/xcb/Window.cpp | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/include/cru/platform/gui/xcb/Window.h b/include/cru/platform/gui/xcb/Window.h index 85c2ae8c..560eab50 100644 --- a/include/cru/platform/gui/xcb/Window.h +++ b/include/cru/platform/gui/xcb/Window.h @@ -51,9 +51,9 @@ class XcbWindow : public XcbResource, public virtual INativeWindow { void SetCursor(std::shared_ptr<ICursor> cursor) override; - virtual void SetToForeground() = 0; + void SetToForeground() override; - virtual void RequestRepaint() = 0; + void RequestRepaint() override; std::unique_ptr<graphics::IPainter> BeginPaint() override; diff --git a/src/platform/gui/xcb/Window.cpp b/src/platform/gui/xcb/Window.cpp index 5e63e08e..63ea68b1 100644 --- a/src/platform/gui/xcb/Window.cpp +++ b/src/platform/gui/xcb/Window.cpp @@ -13,6 +13,7 @@ #include <cairo-xcb.h> #include <cairo.h> #include <xcb/xcb.h> +#include <xcb/xproto.h> #include <cassert> #include <cinttypes> #include <cstdint> @@ -262,6 +263,19 @@ bool XcbWindow::ReleaseMouse() { void XcbWindow::SetCursor(std::shared_ptr<ICursor> cursor) { NotImplemented(); } +void XcbWindow::SetToForeground() { + SetVisibility(WindowVisibilityType::Show); + assert(xcb_window_.has_value()); + const static uint32_t values[] = {XCB_STACK_MODE_ABOVE}; + xcb_configure_window(application_->GetXcbConnection(), *xcb_window_, + XCB_CONFIG_WINDOW_STACK_MODE, values); +} + +void XcbWindow::RequestRepaint() { + // TODO: true throttle + paint_event_.Raise(nullptr); +} + std::unique_ptr<graphics::IPainter> XcbWindow::BeginPaint() { assert(cairo_surface_); |