2016-11-21 09:07:00 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-25 03:54:18 -05:00
|
|
|
#include <cairo/cairo.h>
|
2019-10-27 17:27:58 -04:00
|
|
|
|
2019-08-06 13:35:07 -04:00
|
|
|
#include <bitset>
|
2019-01-04 19:08:18 -05:00
|
|
|
#include <memory>
|
2017-01-18 23:38:42 -05:00
|
|
|
|
|
|
|
#include "cairo/fwd.hpp"
|
2016-11-21 09:07:00 -05:00
|
|
|
#include "common.hpp"
|
2021-01-06 09:46:57 -05:00
|
|
|
#include "components/renderer_interface.hpp"
|
2016-11-21 09:07:00 -05:00
|
|
|
#include "components/types.hpp"
|
2016-12-05 14:41:00 -05:00
|
|
|
#include "events/signal_fwd.hpp"
|
|
|
|
#include "events/signal_receiver.hpp"
|
2016-12-26 03:40:15 -05:00
|
|
|
#include "x11/extensions/fwd.hpp"
|
2016-11-21 09:07:00 -05:00
|
|
|
#include "x11/types.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
2017-01-18 23:38:42 -05:00
|
|
|
// fwd {{{
|
2016-11-21 09:07:00 -05:00
|
|
|
class connection;
|
2017-01-18 23:38:42 -05:00
|
|
|
class config;
|
2016-11-21 09:07:00 -05:00
|
|
|
class logger;
|
2017-05-23 15:32:34 -04:00
|
|
|
class background_manager;
|
2019-01-04 19:08:18 -05:00
|
|
|
class bg_slice;
|
2017-01-18 23:38:42 -05:00
|
|
|
// }}}
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2016-12-09 03:02:47 -05:00
|
|
|
using std::map;
|
2016-12-05 14:41:00 -05:00
|
|
|
|
2017-01-24 00:59:58 -05:00
|
|
|
struct alignment_block {
|
2017-01-25 03:54:18 -05:00
|
|
|
cairo_pattern_t* pattern;
|
2017-01-24 00:59:58 -05:00
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
};
|
|
|
|
|
2016-12-05 14:41:00 -05:00
|
|
|
class renderer
|
2021-01-06 09:46:57 -05:00
|
|
|
: public renderer_interface,
|
|
|
|
public signal_receiver<SIGN_PRIORITY_RENDERER, signals::ui::request_snapshot, signals::parser::change_background,
|
2017-01-18 23:38:42 -05:00
|
|
|
signals::parser::change_foreground, signals::parser::change_underline, signals::parser::change_overline,
|
2017-05-17 17:11:06 -04:00
|
|
|
signals::parser::change_font, signals::parser::change_alignment, signals::parser::reverse_colors,
|
2021-01-06 09:46:57 -05:00
|
|
|
signals::parser::attribute_set, signals::parser::attribute_unset, signals::parser::attribute_toggle,
|
|
|
|
signals::parser::action_begin, signals::parser::action_end, signals::parser::text, signals::parser::control> {
|
2016-11-21 09:07:00 -05:00
|
|
|
public:
|
2016-12-09 03:40:46 -05:00
|
|
|
using make_type = unique_ptr<renderer>;
|
2017-01-18 23:38:42 -05:00
|
|
|
static make_type make(const bar_settings& bar);
|
2016-12-09 03:02:47 -05:00
|
|
|
|
2019-08-06 13:35:07 -04:00
|
|
|
explicit renderer(connection& conn, signal_emitter& sig, const config&, const logger& logger, const bar_settings& bar,
|
|
|
|
background_manager& background_manager);
|
2016-11-25 05:41:41 -05:00
|
|
|
~renderer();
|
2016-11-21 09:07:00 -05:00
|
|
|
|
|
|
|
xcb_window_t window() const;
|
2017-01-18 23:38:42 -05:00
|
|
|
const vector<action_block> actions() const;
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2017-01-25 17:36:34 -05:00
|
|
|
void begin(xcb_rectangle_t rect);
|
2016-11-21 09:07:00 -05:00
|
|
|
void end();
|
2017-01-18 23:38:42 -05:00
|
|
|
void flush();
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2017-01-25 17:36:34 -05:00
|
|
|
#if 0
|
2017-01-19 05:11:28 -05:00
|
|
|
void reserve_space(edge side, unsigned int w);
|
2017-01-25 17:36:34 -05:00
|
|
|
#endif
|
2016-11-21 09:07:00 -05:00
|
|
|
void fill_background();
|
2017-01-18 23:38:42 -05:00
|
|
|
void fill_overline(double x, double w);
|
|
|
|
void fill_underline(double x, double w);
|
|
|
|
void fill_borders();
|
|
|
|
void draw_text(const string& contents);
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2021-01-06 09:46:57 -05:00
|
|
|
void render_offset(const tags::context& ctxt, int pixels) override;
|
|
|
|
|
2016-11-21 09:07:00 -05:00
|
|
|
protected:
|
2017-01-24 00:59:58 -05:00
|
|
|
double block_x(alignment a) const;
|
|
|
|
double block_y(alignment a) const;
|
|
|
|
double block_w(alignment a) const;
|
2017-01-25 03:54:18 -05:00
|
|
|
double block_h(alignment a) const;
|
2017-01-24 00:59:58 -05:00
|
|
|
|
2017-01-25 03:54:18 -05:00
|
|
|
void flush(alignment a);
|
2017-01-18 23:38:42 -05:00
|
|
|
void highlight_clickable_areas();
|
|
|
|
|
2021-01-04 04:38:43 -05:00
|
|
|
bool on(const signals::ui::request_snapshot& evt) override;
|
|
|
|
bool on(const signals::parser::change_background& evt) override;
|
|
|
|
bool on(const signals::parser::change_foreground& evt) override;
|
|
|
|
bool on(const signals::parser::change_underline& evt) override;
|
|
|
|
bool on(const signals::parser::change_overline& evt) override;
|
|
|
|
bool on(const signals::parser::change_font& evt) override;
|
|
|
|
bool on(const signals::parser::change_alignment& evt) override;
|
|
|
|
bool on(const signals::parser::reverse_colors&) override;
|
|
|
|
bool on(const signals::parser::attribute_set& evt) override;
|
|
|
|
bool on(const signals::parser::attribute_unset& evt) override;
|
|
|
|
bool on(const signals::parser::attribute_toggle& evt) override;
|
|
|
|
bool on(const signals::parser::action_begin& evt) override;
|
|
|
|
bool on(const signals::parser::action_end& evt) override;
|
|
|
|
bool on(const signals::parser::text& evt) override;
|
|
|
|
bool on(const signals::parser::control& evt) override;
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2016-12-04 21:49:57 -05:00
|
|
|
protected:
|
|
|
|
struct reserve_area {
|
|
|
|
edge side{edge::NONE};
|
2017-01-19 05:11:28 -05:00
|
|
|
unsigned int size{0U};
|
2016-12-04 21:49:57 -05:00
|
|
|
};
|
|
|
|
|
2016-11-21 09:07:00 -05:00
|
|
|
private:
|
|
|
|
connection& m_connection;
|
2016-12-05 14:41:00 -05:00
|
|
|
signal_emitter& m_sig;
|
2017-01-18 23:38:42 -05:00
|
|
|
const config& m_conf;
|
2016-11-21 09:07:00 -05:00
|
|
|
const logger& m_log;
|
|
|
|
const bar_settings& m_bar;
|
2019-01-04 19:08:18 -05:00
|
|
|
std::shared_ptr<bg_slice> m_background;
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2017-01-19 05:11:28 -05:00
|
|
|
int m_depth{32};
|
2016-11-21 09:07:00 -05:00
|
|
|
xcb_window_t m_window;
|
|
|
|
xcb_colormap_t m_colormap;
|
|
|
|
xcb_visualtype_t* m_visual;
|
2017-01-18 23:38:42 -05:00
|
|
|
xcb_gcontext_t m_gcontext;
|
2016-11-21 09:07:00 -05:00
|
|
|
xcb_pixmap_t m_pixmap;
|
|
|
|
|
2017-01-24 00:59:58 -05:00
|
|
|
xcb_rectangle_t m_rect{0, 0, 0U, 0U};
|
|
|
|
reserve_area m_cleararea{};
|
2016-11-21 09:07:00 -05:00
|
|
|
|
|
|
|
// bool m_autosize{false};
|
2017-01-18 23:38:42 -05:00
|
|
|
|
|
|
|
unique_ptr<cairo::context> m_context;
|
2017-01-24 00:59:58 -05:00
|
|
|
unique_ptr<cairo::xcb_surface> m_surface;
|
|
|
|
map<alignment, alignment_block> m_blocks;
|
2017-01-27 09:36:37 -05:00
|
|
|
cairo_pattern_t* m_cornermask{};
|
2017-01-24 00:59:58 -05:00
|
|
|
|
2017-01-27 09:36:37 -05:00
|
|
|
cairo_operator_t m_comp_bg{CAIRO_OPERATOR_SOURCE};
|
2017-01-25 17:36:34 -05: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 09:19:12 -04:00
|
|
|
bool m_pseudo_transparency{false};
|
2017-01-24 00:59:58 -05:00
|
|
|
|
|
|
|
alignment m_align;
|
|
|
|
std::bitset<3> m_attr;
|
2017-01-24 02:01:04 -05:00
|
|
|
int m_font{0};
|
2019-10-27 19:40:59 -04:00
|
|
|
rgba m_bg{};
|
|
|
|
rgba m_fg{};
|
|
|
|
rgba m_ol{};
|
|
|
|
rgba m_ul{};
|
2017-01-24 00:59:58 -05:00
|
|
|
vector<action_block> m_actions;
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2017-01-24 00:59:58 -05:00
|
|
|
bool m_fixedcenter;
|
|
|
|
string m_snapshot_dst;
|
2016-11-21 09:07:00 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
POLYBAR_NS_END
|