diff options
| author | Joel Klinghed <the_jk@opera.com> | 2026-01-12 23:06:20 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@opera.com> | 2026-01-12 23:06:20 +0100 |
| commit | dfeb19b0a83b8ce57d28bf94a4f8d129993d1064 (patch) | |
| tree | d352908df286058059e306c350d89a07c67049eb /src/xcb_colors.hh | |
Initial commit
Diffstat (limited to 'src/xcb_colors.hh')
| -rw-r--r-- | src/xcb_colors.hh | 57 |
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..a1bc610 --- /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_; + }; + + [[nodiscard]] + virtual Color get_with_fallback(uint8_t r, uint8_t g, uint8_t b, + uint32_t fallback) = 0; + + virtual bool sync() = 0; + + [[nodiscard]] + 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 |
