aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-09-23 22:03:00 +0800
committerYuqian Yang <crupest@crupest.life>2025-09-23 22:03:00 +0800
commit9737b7966c0b061ee80235d1c7c460efc0610894 (patch)
treef0fcbd3e1ae88b385a85bb157f737a500a2bcfa5
parent76f32ee9ce35947413d40ec00c402e40fb5436e5 (diff)
downloadcru-9737b7966c0b061ee80235d1c7c460efc0610894.tar.gz
cru-9737b7966c0b061ee80235d1c7c460efc0610894.tar.bz2
cru-9737b7966c0b061ee80235d1c7c460efc0610894.zip
Init XcbCursor.
-rw-r--r--include/cru/platform/gui/xcb/Cursor.h33
-rw-r--r--src/platform/gui/xcb/Cursor.cpp22
2 files changed, 55 insertions, 0 deletions
diff --git a/include/cru/platform/gui/xcb/Cursor.h b/include/cru/platform/gui/xcb/Cursor.h
index e69de29b..d51c33c1 100644
--- a/include/cru/platform/gui/xcb/Cursor.h
+++ b/include/cru/platform/gui/xcb/Cursor.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <cru/base/io/Stream.h>
+#include "../Cursor.h"
+#include "Base.h"
+
+#include <xcb/xcb.h>
+
+namespace cru::platform::gui::xcb {
+class XcbUiApplication;
+class XcbCursor : public XcbResource, public virtual ICursor {
+ public:
+ /**
+ * Specification at
+ * https://www.x.org/archive/X11R7.7/doc/man/man3/Xcursor.3.xhtml.
+ */
+ static XcbCursor* LoadXCursor(io::Stream* stream);
+
+ XcbCursor(XcbUiApplication* application, xcb_cursor_t cursor, bool auto_free);
+ ~XcbCursor() override;
+
+ xcb_cursor_t GetXcbCursor();
+
+ private:
+ XcbUiApplication* application_;
+ xcb_cursor_t cursor_;
+ bool auto_free_;
+};
+
+class XcbCursorManager : public XcbResource, public virtual ICursorManager {
+ virtual std::shared_ptr<ICursor> GetSystemCursor(SystemCursorType type) = 0;
+};
+} // namespace cru::platform::gui::xcb
diff --git a/src/platform/gui/xcb/Cursor.cpp b/src/platform/gui/xcb/Cursor.cpp
index e69de29b..7bc73f6d 100644
--- a/src/platform/gui/xcb/Cursor.cpp
+++ b/src/platform/gui/xcb/Cursor.cpp
@@ -0,0 +1,22 @@
+#include "cru/platform/gui/xcb/Cursor.h"
+#include "cru/base/Base.h"
+#include "cru/platform/gui/xcb/UiApplication.h"
+
+#include <xcb/xcb.h>
+
+namespace cru::platform::gui::xcb {
+XcbCursor* XcbCursor::LoadXCursor(io::Stream* stream) { NotImplemented(); }
+
+XcbCursor::XcbCursor(XcbUiApplication* application, xcb_cursor_t cursor,
+ bool auto_free)
+ : application_(application), cursor_(cursor), auto_free_(auto_free) {}
+
+XcbCursor::~XcbCursor() {
+ if (auto_free_) {
+ xcb_free_cursor(application_->GetXcbConnection(), cursor_);
+ }
+}
+
+xcb_cursor_t XcbCursor::GetXcbCursor() { return cursor_; }
+
+} // namespace cru::platform::gui::xcb