2016-11-21 09:07:00 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-18 23:38:42 -05:00
|
|
|
#include <cairo/cairo.h>
|
|
|
|
#include <bitset>
|
|
|
|
|
|
|
|
#include "cairo/fwd.hpp"
|
2016-11-21 09:07:00 -05:00
|
|
|
#include "common.hpp"
|
|
|
|
#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-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
|
|
|
|
|
|
|
class renderer
|
2017-01-18 23:38:42 -05:00
|
|
|
: public signal_receiver<SIGN_PRIORITY_RENDERER, signals::parser::change_background,
|
|
|
|
signals::parser::change_foreground, signals::parser::change_underline, signals::parser::change_overline,
|
|
|
|
signals::parser::change_font, signals::parser::change_alignment, signals::parser::offset_pixel,
|
|
|
|
signals::parser::attribute_set, signals::parser::attribute_unset, signals::parser::attribute_toggle,
|
|
|
|
signals::parser::action_begin, signals::parser::action_end, signals::parser::text> {
|
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
|
|
|
|
2017-01-18 23:38:42 -05:00
|
|
|
explicit renderer(
|
|
|
|
connection& conn, signal_emitter& emitter, const config&, const logger& logger, const bar_settings& bar);
|
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
|
|
|
|
|
|
|
void begin();
|
|
|
|
void end();
|
2017-01-18 23:38:42 -05:00
|
|
|
void flush();
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2017-01-19 05:11:28 -05:00
|
|
|
void reserve_space(edge side, unsigned int w);
|
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
|
|
|
|
|
|
|
protected:
|
2017-01-18 23:38:42 -05:00
|
|
|
void adjust_clickable_areas(double width);
|
|
|
|
void highlight_clickable_areas();
|
|
|
|
|
|
|
|
bool on(const signals::parser::change_background& evt);
|
|
|
|
bool on(const signals::parser::change_foreground& evt);
|
|
|
|
bool on(const signals::parser::change_underline& evt);
|
|
|
|
bool on(const signals::parser::change_overline& evt);
|
|
|
|
bool on(const signals::parser::change_font& evt);
|
|
|
|
bool on(const signals::parser::change_alignment& evt);
|
|
|
|
bool on(const signals::parser::offset_pixel& evt);
|
|
|
|
bool on(const signals::parser::attribute_set& evt);
|
|
|
|
bool on(const signals::parser::attribute_unset& evt);
|
|
|
|
bool on(const signals::parser::attribute_toggle& evt);
|
|
|
|
bool on(const signals::parser::action_begin& evt);
|
|
|
|
bool on(const signals::parser::action_end& evt);
|
|
|
|
bool on(const signals::parser::text& evt);
|
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;
|
|
|
|
|
2016-11-24 22:10:26 -05:00
|
|
|
xcb_rectangle_t m_rect{0, 0, 0U, 0U};
|
2016-12-04 21:49:57 -05:00
|
|
|
reserve_area m_cleararea{};
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
vector<action_block> m_actions;
|
|
|
|
|
|
|
|
// bool m_autosize{false};
|
2017-01-18 23:38:42 -05:00
|
|
|
|
|
|
|
unique_ptr<cairo::context> m_context;
|
|
|
|
unique_ptr<cairo::surface> m_surface;
|
|
|
|
|
|
|
|
cairo_operator_t m_compositing_background;
|
|
|
|
cairo_operator_t m_compositing_foreground;
|
|
|
|
cairo_operator_t m_compositing_overline;
|
|
|
|
cairo_operator_t m_compositing_underline;
|
|
|
|
cairo_operator_t m_compositing_borders;
|
|
|
|
|
2016-11-21 09:07:00 -05:00
|
|
|
alignment m_alignment{alignment::NONE};
|
2017-01-18 23:38:42 -05:00
|
|
|
std::bitset<2> m_attributes;
|
|
|
|
|
2017-01-19 05:11:28 -05:00
|
|
|
int m_fontindex;
|
2017-01-18 23:38:42 -05:00
|
|
|
|
2017-01-19 05:11:28 -05:00
|
|
|
unsigned int m_color_background;
|
|
|
|
unsigned int m_color_foreground;
|
|
|
|
unsigned int m_color_overline;
|
|
|
|
unsigned int m_color_underline;
|
2016-11-21 09:07:00 -05:00
|
|
|
|
2017-01-18 23:38:42 -05:00
|
|
|
double m_x{0.0};
|
|
|
|
double m_y{0.0};
|
2016-11-21 09:07:00 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
POLYBAR_NS_END
|