summaryrefslogtreecommitdiff
path: root/src/xcb_colors.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/xcb_colors.hh')
-rw-r--r--src/xcb_colors.hh57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/xcb_colors.hh b/src/xcb_colors.hh
new file mode 100644
index 0000000..4db2b93
--- /dev/null
+++ b/src/xcb_colors.hh
@@ -0,0 +1,57 @@
+#ifndef XCB_COLORS_HH
+#define XCB_COLORS_HH
+
+#include "xcb_connection.hh"
+
+#include <memory>
+
+namespace xcb {
+
+class Colors {
+protected:
+ class Storage;
+
+public:
+ virtual ~Colors() = default;
+
+ class Color {
+ public:
+ uint32_t get() {
+ return colors_->get(id_);
+ }
+
+ Color(std::shared_ptr<Storage> colors, size_t id)
+ : colors_(colors), id_(id) {}
+
+ private:
+ std::shared_ptr<Storage> colors_;
+ size_t id_;
+ };
+
+ virtual Color get_with_fallback(uint8_t r, uint8_t g, uint8_t b,
+ uint32_t fallback) = 0;
+
+ virtual bool sync() = 0;
+
+ static std::unique_ptr<Colors> create(shared_conn conn,
+ xcb_colormap_t colormap);
+
+protected:
+ Colors() = default;
+ Colors(Colors const&) = delete;
+ Colors& operator=(Colors const&) = delete;
+
+ class Storage {
+ public:
+ virtual ~Storage() = default;
+
+ virtual uint32_t get(size_t id) const = 0;
+
+ protected:
+ Storage() = default;
+ };
+};
+
+} // namespace xcb
+
+#endif // XCB_COLORS_HH