From 06950aab233de6a2f47293d59575bb42f6131660 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 27 Jan 2021 22:06:49 +0100 Subject: Complete rewrite using C++ and with shared state support --- src/xcb_colors.hh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/xcb_colors.hh (limited to 'src/xcb_colors.hh') 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 + +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 colors, size_t id) + : colors_(colors), id_(id) {} + + private: + std::shared_ptr 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 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 -- cgit v1.2.3-70-g09d2