2016-11-21 14:07:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-25 08:54:18 +00:00
|
|
|
#include <cairo/cairo.h>
|
2019-10-27 21:27:58 +00:00
|
|
|
|
2019-08-06 17:35:07 +00:00
|
|
|
#include <bitset>
|
2019-01-05 00:08:18 +00:00
|
|
|
#include <memory>
|
2017-01-19 04:38:42 +00:00
|
|
|
|
|
|
|
#include "cairo/fwd.hpp"
|
2016-11-21 14:07:00 +00:00
|
|
|
#include "common.hpp"
|
2021-01-06 14:46:57 +00:00
|
|
|
#include "components/renderer_interface.hpp"
|
2016-11-21 14:07:00 +00:00
|
|
|
#include "components/types.hpp"
|
2016-12-05 19:41:00 +00:00
|
|
|
#include "events/signal_fwd.hpp"
|
|
|
|
#include "events/signal_receiver.hpp"
|
2016-12-26 08:40:15 +00:00
|
|
|
#include "x11/extensions/fwd.hpp"
|
2016-11-21 14:07:00 +00:00
|
|
|
#include "x11/types.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
2017-01-19 04:38:42 +00:00
|
|
|
// fwd {{{
|
2016-11-21 14:07:00 +00:00
|
|
|
class connection;
|
2017-01-19 04:38:42 +00:00
|
|
|
class config;
|
2016-11-21 14:07:00 +00:00
|
|
|
class logger;
|
2017-05-23 19:32:34 +00:00
|
|
|
class background_manager;
|
2019-01-05 00:08:18 +00:00
|
|
|
class bg_slice;
|
2017-01-19 04:38:42 +00:00
|
|
|
// }}}
|
2016-11-21 14:07:00 +00:00
|
|
|
|
2016-12-09 08:02:47 +00:00
|
|
|
using std::map;
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2017-01-24 05:59:58 +00:00
|
|
|
struct alignment_block {
|
2017-01-25 08:54:18 +00:00
|
|
|
cairo_pattern_t* pattern;
|
2017-01-24 05:59:58 +00:00
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
};
|
|
|
|
|
2021-01-10 20:30:10 +00:00
|
|
|
class renderer : public renderer_interface,
|
|
|
|
public signal_receiver<SIGN_PRIORITY_RENDERER, signals::ui::request_snapshot> {
|
2016-11-21 14:07:00 +00:00
|
|
|
public:
|
2016-12-09 08:40:46 +00:00
|
|
|
using make_type = unique_ptr<renderer>;
|
2021-01-10 22:05:48 +00:00
|
|
|
static make_type make(const bar_settings& bar, tags::action_context& action_ctxt);
|
2016-12-09 08:02:47 +00:00
|
|
|
|
2019-08-06 17:35:07 +00:00
|
|
|
explicit renderer(connection& conn, signal_emitter& sig, const config&, const logger& logger, const bar_settings& bar,
|
2021-01-10 22:05:48 +00:00
|
|
|
background_manager& background_manager, tags::action_context& action_ctxt);
|
2016-11-25 10:41:41 +00:00
|
|
|
~renderer();
|
2016-11-21 14:07:00 +00:00
|
|
|
|
|
|
|
xcb_window_t window() const;
|
|
|
|
|
2017-01-25 22:36:34 +00:00
|
|
|
void begin(xcb_rectangle_t rect);
|
2016-11-21 14:07:00 +00:00
|
|
|
void end();
|
2017-01-19 04:38:42 +00:00
|
|
|
void flush();
|
2016-11-21 14:07:00 +00:00
|
|
|
|
2021-01-10 19:49:50 +00:00
|
|
|
void render_offset(const tags::context& ctxt, int pixels) override;
|
|
|
|
void render_text(const tags::context& ctxt, const string&&) override;
|
|
|
|
|
2021-01-10 20:30:10 +00:00
|
|
|
void change_alignment(const tags::context& ctxt) override;
|
|
|
|
|
2021-01-10 19:49:50 +00:00
|
|
|
void action_open(const tags::context& ctxt, mousebtn btn, tags::action_t id) override;
|
|
|
|
void action_close(const tags::context& ctxt, tags::action_t id) override;
|
|
|
|
|
|
|
|
protected:
|
2016-11-21 14:07:00 +00:00
|
|
|
void fill_background();
|
2021-01-06 15:53:52 +00:00
|
|
|
void fill_overline(rgba color, double x, double w);
|
|
|
|
void fill_underline(rgba color, double x, double w);
|
2017-01-19 04:38:42 +00:00
|
|
|
void fill_borders();
|
2016-11-21 14:07:00 +00:00
|
|
|
|
2017-01-24 05:59:58 +00:00
|
|
|
double block_x(alignment a) const;
|
|
|
|
double block_y(alignment a) const;
|
|
|
|
double block_w(alignment a) const;
|
2017-01-25 08:54:18 +00:00
|
|
|
double block_h(alignment a) const;
|
2017-01-24 05:59:58 +00:00
|
|
|
|
2017-01-25 08:54:18 +00:00
|
|
|
void flush(alignment a);
|
2017-01-19 04:38:42 +00:00
|
|
|
void highlight_clickable_areas();
|
|
|
|
|
2021-01-04 09:38:43 +00:00
|
|
|
bool on(const signals::ui::request_snapshot& evt) override;
|
2016-11-21 14:07:00 +00:00
|
|
|
|
2016-12-05 02:49:57 +00:00
|
|
|
protected:
|
|
|
|
struct reserve_area {
|
|
|
|
edge side{edge::NONE};
|
2017-01-19 10:11:28 +00:00
|
|
|
unsigned int size{0U};
|
2016-12-05 02:49:57 +00:00
|
|
|
};
|
|
|
|
|
2016-11-21 14:07:00 +00:00
|
|
|
private:
|
|
|
|
connection& m_connection;
|
2016-12-05 19:41:00 +00:00
|
|
|
signal_emitter& m_sig;
|
2017-01-19 04:38:42 +00:00
|
|
|
const config& m_conf;
|
2016-11-21 14:07:00 +00:00
|
|
|
const logger& m_log;
|
|
|
|
const bar_settings& m_bar;
|
2019-01-05 00:08:18 +00:00
|
|
|
std::shared_ptr<bg_slice> m_background;
|
2016-11-21 14:07:00 +00:00
|
|
|
|
2017-01-19 10:11:28 +00:00
|
|
|
int m_depth{32};
|
2016-11-21 14:07:00 +00:00
|
|
|
xcb_window_t m_window;
|
|
|
|
xcb_colormap_t m_colormap;
|
|
|
|
xcb_visualtype_t* m_visual;
|
2017-01-19 04:38:42 +00:00
|
|
|
xcb_gcontext_t m_gcontext;
|
2016-11-21 14:07:00 +00:00
|
|
|
xcb_pixmap_t m_pixmap;
|
|
|
|
|
2017-01-24 05:59:58 +00:00
|
|
|
xcb_rectangle_t m_rect{0, 0, 0U, 0U};
|
|
|
|
reserve_area m_cleararea{};
|
2016-11-21 14:07:00 +00:00
|
|
|
|
|
|
|
// bool m_autosize{false};
|
2017-01-19 04:38:42 +00:00
|
|
|
|
|
|
|
unique_ptr<cairo::context> m_context;
|
2017-01-24 05:59:58 +00:00
|
|
|
unique_ptr<cairo::xcb_surface> m_surface;
|
|
|
|
map<alignment, alignment_block> m_blocks;
|
2017-01-27 14:36:37 +00:00
|
|
|
cairo_pattern_t* m_cornermask{};
|
2017-01-24 05:59:58 +00:00
|
|
|
|
2017-01-27 14:36:37 +00:00
|
|
|
cairo_operator_t m_comp_bg{CAIRO_OPERATOR_SOURCE};
|
2017-01-25 22:36:34 +00:00
|
|
|
cairo_operator_t m_comp_fg{CAIRO_OPERATOR_OVER};
|
|
|
|
cairo_operator_t m_comp_ol{CAIRO_OPERATOR_OVER};
|
|
|
|
cairo_operator_t m_comp_ul{CAIRO_OPERATOR_OVER};
|
|
|
|
cairo_operator_t m_comp_border{CAIRO_OPERATOR_OVER};
|
2018-07-06 13:19:12 +00:00
|
|
|
bool m_pseudo_transparency{false};
|
2017-01-24 05:59:58 +00:00
|
|
|
|
|
|
|
alignment m_align;
|
2016-11-21 14:07:00 +00:00
|
|
|
|
2017-01-24 05:59:58 +00:00
|
|
|
bool m_fixedcenter;
|
|
|
|
string m_snapshot_dst;
|
2016-11-21 14:07:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
POLYBAR_NS_END
|