Incorporate Reviews
This commit is contained in:
parent
57d364a2fc
commit
211b0bbfd8
@ -13,7 +13,7 @@ using std::map;
|
|||||||
namespace drawtypes {
|
namespace drawtypes {
|
||||||
class label;
|
class label;
|
||||||
using label_t = shared_ptr<label>;
|
using label_t = shared_ptr<label>;
|
||||||
}
|
} // namespace drawtypes
|
||||||
using namespace drawtypes;
|
using namespace drawtypes;
|
||||||
|
|
||||||
class builder {
|
class builder {
|
||||||
|
@ -29,12 +29,12 @@ class parser {
|
|||||||
void codeblock(string&& data, const bar_settings& bar);
|
void codeblock(string&& data, const bar_settings& bar);
|
||||||
size_t text(string&& data);
|
size_t text(string&& data);
|
||||||
|
|
||||||
unsigned int parse_color(const string& s, unsigned int fallback = 0);
|
static unsigned int parse_color(const string& s, unsigned int fallback = 0);
|
||||||
int parse_fontindex(const string& s);
|
static int parse_fontindex(const string& s);
|
||||||
attribute parse_attr(const char attr);
|
static attribute parse_attr(const char attr);
|
||||||
mousebtn parse_action_btn(const string& data);
|
mousebtn parse_action_btn(const string& data);
|
||||||
string parse_action_cmd(string&& data);
|
static string parse_action_cmd(string&& data);
|
||||||
controltag parse_control(const string& data);
|
static controltag parse_control(const string& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
signal_emitter& m_sig;
|
signal_emitter& m_sig;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <bitset>
|
|
||||||
#include <cairo/cairo.h>
|
#include <cairo/cairo.h>
|
||||||
|
#include <bitset>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "cairo/fwd.hpp"
|
#include "cairo/fwd.hpp"
|
||||||
@ -41,8 +41,8 @@ class renderer
|
|||||||
using make_type = unique_ptr<renderer>;
|
using make_type = unique_ptr<renderer>;
|
||||||
static make_type make(const bar_settings& bar);
|
static make_type make(const bar_settings& bar);
|
||||||
|
|
||||||
explicit renderer(
|
explicit renderer(connection& conn, signal_emitter& sig, const config&, const logger& logger, const bar_settings& bar,
|
||||||
connection& conn, signal_emitter& sig, const config&, const logger& logger, const bar_settings& bar, background_manager& background_manager);
|
background_manager& background_manager);
|
||||||
~renderer();
|
~renderer();
|
||||||
|
|
||||||
xcb_window_t window() const;
|
xcb_window_t window() const;
|
||||||
|
@ -48,7 +48,7 @@ enum class syntaxtag {
|
|||||||
*/
|
*/
|
||||||
enum class controltag {
|
enum class controltag {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
R, // Reset all open tags (B, F, T, o, u). Used at module edges
|
R, // Reset all open tags (B, F, T, o, u). Used at module edges
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class mousebtn { NONE = 0, LEFT, MIDDLE, RIGHT, SCROLL_UP, SCROLL_DOWN, DOUBLE_LEFT, DOUBLE_MIDDLE, DOUBLE_RIGHT };
|
enum class mousebtn { NONE = 0, LEFT, MIDDLE, RIGHT, SCROLL_UP, SCROLL_DOWN, DOUBLE_LEFT, DOUBLE_MIDDLE, DOUBLE_RIGHT };
|
||||||
|
@ -9,13 +9,6 @@
|
|||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
// fwd
|
|
||||||
enum class mousebtn;
|
|
||||||
enum class syntaxtag;
|
|
||||||
enum class controltag;
|
|
||||||
enum class alignment;
|
|
||||||
enum class attribute;
|
|
||||||
|
|
||||||
namespace signals {
|
namespace signals {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
class signal {
|
class signal {
|
||||||
@ -55,7 +48,7 @@ namespace signals {
|
|||||||
private:
|
private:
|
||||||
void* m_ptr;
|
void* m_ptr;
|
||||||
};
|
};
|
||||||
}
|
} // namespace detail
|
||||||
|
|
||||||
namespace eventqueue {
|
namespace eventqueue {
|
||||||
struct start : public detail::base_signal<start> {
|
struct start : public detail::base_signal<start> {
|
||||||
@ -76,7 +69,7 @@ namespace signals {
|
|||||||
struct check_state : public detail::base_signal<check_state> {
|
struct check_state : public detail::base_signal<check_state> {
|
||||||
using base_type::base_type;
|
using base_type::base_type;
|
||||||
};
|
};
|
||||||
}
|
} // namespace eventqueue
|
||||||
|
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
struct command : public detail::value_signal<command, string> {
|
struct command : public detail::value_signal<command, string> {
|
||||||
@ -88,7 +81,7 @@ namespace signals {
|
|||||||
struct action : public detail::value_signal<action, string> {
|
struct action : public detail::value_signal<action, string> {
|
||||||
using base_type::base_type;
|
using base_type::base_type;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ipc
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
struct ready : public detail::base_signal<ready> {
|
struct ready : public detail::base_signal<ready> {
|
||||||
@ -129,13 +122,13 @@ namespace signals {
|
|||||||
struct update_geometry : public detail::base_signal<update_geometry> {
|
struct update_geometry : public detail::base_signal<update_geometry> {
|
||||||
using base_type::base_type;
|
using base_type::base_type;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ui
|
||||||
|
|
||||||
namespace ui_tray {
|
namespace ui_tray {
|
||||||
struct mapped_clients : public detail::value_signal<mapped_clients, unsigned int> {
|
struct mapped_clients : public detail::value_signal<mapped_clients, unsigned int> {
|
||||||
using base_type::base_type;
|
using base_type::base_type;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ui_tray
|
||||||
|
|
||||||
namespace parser {
|
namespace parser {
|
||||||
struct change_background : public detail::value_signal<change_background, unsigned int> {
|
struct change_background : public detail::value_signal<change_background, unsigned int> {
|
||||||
@ -183,7 +176,7 @@ namespace signals {
|
|||||||
struct control : public detail::value_signal<control, controltag> {
|
struct control : public detail::value_signal<control, controltag> {
|
||||||
using base_type::base_type;
|
using base_type::base_type;
|
||||||
};
|
};
|
||||||
}
|
} // namespace parser
|
||||||
}
|
} // namespace signals
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -21,12 +21,12 @@ namespace signals {
|
|||||||
struct notify_change;
|
struct notify_change;
|
||||||
struct notify_forcechange;
|
struct notify_forcechange;
|
||||||
struct check_state;
|
struct check_state;
|
||||||
}
|
} // namespace eventqueue
|
||||||
namespace ipc {
|
namespace ipc {
|
||||||
struct command;
|
struct command;
|
||||||
struct hook;
|
struct hook;
|
||||||
struct action;
|
struct action;
|
||||||
}
|
} // namespace ipc
|
||||||
namespace ui {
|
namespace ui {
|
||||||
struct ready;
|
struct ready;
|
||||||
struct changed;
|
struct changed;
|
||||||
@ -40,7 +40,7 @@ namespace signals {
|
|||||||
struct request_snapshot;
|
struct request_snapshot;
|
||||||
struct update_background;
|
struct update_background;
|
||||||
struct update_geometry;
|
struct update_geometry;
|
||||||
}
|
} // namespace ui
|
||||||
namespace ui_tray {
|
namespace ui_tray {
|
||||||
struct mapped_clients;
|
struct mapped_clients;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ namespace signals {
|
|||||||
struct action_end;
|
struct action_end;
|
||||||
struct text;
|
struct text;
|
||||||
struct control;
|
struct control;
|
||||||
}
|
} // namespace parser
|
||||||
}
|
} // namespace signals
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "modules/meta/base.hpp"
|
|
||||||
#include "components/builder.hpp"
|
#include "components/builder.hpp"
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "components/logger.hpp"
|
#include "components/logger.hpp"
|
||||||
#include "events/signal.hpp"
|
#include "events/signal.hpp"
|
||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
|
#include "modules/meta/base.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
@ -178,6 +178,6 @@ namespace modules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
}
|
} // namespace modules
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "components/builder.hpp"
|
#include "components/builder.hpp"
|
||||||
#include "drawtypes/label.hpp"
|
#include "drawtypes/label.hpp"
|
||||||
#include "utils/color.hpp"
|
#include "utils/color.hpp"
|
||||||
#include "utils/math.hpp"
|
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "utils/time.hpp"
|
#include "utils/time.hpp"
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
@ -425,7 +424,7 @@ void builder::control(controltag tag) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!str.empty()) {
|
if (!str.empty()) {
|
||||||
tag_open(syntaxtag::P, str);
|
tag_open(syntaxtag::P, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,8 +487,7 @@ string builder::get_label_text(const label_t& label) {
|
|||||||
if (maxlen > 0 && string_util::char_len(text) > maxlen) {
|
if (maxlen > 0 && string_util::char_len(text) > maxlen) {
|
||||||
if (label->m_ellipsis) {
|
if (label->m_ellipsis) {
|
||||||
text = string_util::utf8_truncate(std::move(text), maxlen - 3) + "...";
|
text = string_util::utf8_truncate(std::move(text), maxlen - 3) + "...";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
text = string_util::utf8_truncate(std::move(text), maxlen);
|
text = string_util::utf8_truncate(std::move(text), maxlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "utils/color.hpp"
|
#include "utils/color.hpp"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/file.hpp"
|
|
||||||
#include "utils/math.hpp"
|
|
||||||
#include "utils/memory.hpp"
|
#include "utils/memory.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
|
||||||
@ -160,32 +158,31 @@ void parser::codeblock(string&& data, const bar_settings& bar) {
|
|||||||
m_sig.emit(attribute_toggle{parse_attr(value[0])});
|
m_sig.emit(attribute_toggle{parse_attr(value[0])});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'A':
|
case 'A': {
|
||||||
{
|
bool has_btn_id = (data[0] != ':');
|
||||||
bool has_btn_id = (data[0] != ':');
|
if (isdigit(data[0]) || !has_btn_id) {
|
||||||
if (isdigit(data[0]) || !has_btn_id) {
|
value = parse_action_cmd(data.substr(has_btn_id ? 1 : 0));
|
||||||
value = parse_action_cmd(data.substr(has_btn_id ? 1 : 0));
|
mousebtn btn = parse_action_btn(data);
|
||||||
mousebtn btn = parse_action_btn(data);
|
m_actions.push_back(static_cast<int>(btn));
|
||||||
m_actions.push_back(static_cast<int>(btn));
|
|
||||||
|
|
||||||
// Unescape colons inside command before sending it to the renderer
|
// Unescape colons inside command before sending it to the renderer
|
||||||
auto cmd = string_util::replace_all(value, "\\:", ":");
|
auto cmd = string_util::replace_all(value, "\\:", ":");
|
||||||
m_sig.emit(action_begin{action{btn, cmd}});
|
m_sig.emit(action_begin{action{btn, cmd}});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure value has the same length as the inside of the action
|
* make sure value has the same length as the inside of the action
|
||||||
* tag which is btn_id + ':' + value + ':'
|
* tag which is btn_id + ':' + value + ':'
|
||||||
*/
|
*/
|
||||||
if (has_btn_id) {
|
if (has_btn_id) {
|
||||||
value += "0";
|
value += "0";
|
||||||
}
|
|
||||||
value += "::";
|
|
||||||
} else if (!m_actions.empty()) {
|
|
||||||
m_sig.emit(action_end{parse_action_btn(value)});
|
|
||||||
m_actions.pop_back();
|
|
||||||
}
|
}
|
||||||
break;
|
value += "::";
|
||||||
|
} else if (!m_actions.empty()) {
|
||||||
|
m_sig.emit(action_end{parse_action_btn(value)});
|
||||||
|
m_actions.pop_back();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Internal Polybar control tags
|
// Internal Polybar control tags
|
||||||
case 'P':
|
case 'P':
|
||||||
@ -298,11 +295,11 @@ string parser::parse_action_cmd(string&& data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
controltag parser::parse_control(const string& data) {
|
controltag parser::parse_control(const string& data) {
|
||||||
if(data.length() != 1) {
|
if (data.length() != 1) {
|
||||||
return controltag::NONE;
|
return controltag::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(data[0]) {
|
switch (data[0]) {
|
||||||
case 'R':
|
case 'R':
|
||||||
return controltag::R;
|
return controltag::R;
|
||||||
break;
|
break;
|
||||||
|
@ -5,12 +5,10 @@
|
|||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
#include "events/signal_receiver.hpp"
|
#include "events/signal_receiver.hpp"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/file.hpp"
|
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
#include "x11/atoms.hpp"
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/background_manager.hpp"
|
#include "x11/background_manager.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/extensions/all.hpp"
|
|
||||||
#include "x11/winspec.hpp"
|
#include "x11/winspec.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
@ -35,15 +33,14 @@ renderer::make_type renderer::make(const bar_settings& bar) {
|
|||||||
/**
|
/**
|
||||||
* Construct renderer instance
|
* Construct renderer instance
|
||||||
*/
|
*/
|
||||||
renderer::renderer(
|
renderer::renderer(connection& conn, signal_emitter& sig, const config& conf, const logger& logger,
|
||||||
connection& conn, signal_emitter& sig, const config& conf, const logger& logger, const bar_settings& bar, background_manager& background)
|
const bar_settings& bar, background_manager& background)
|
||||||
: m_connection(conn)
|
: m_connection(conn)
|
||||||
, m_sig(sig)
|
, m_sig(sig)
|
||||||
, m_conf(conf)
|
, m_conf(conf)
|
||||||
, m_log(logger)
|
, m_log(logger)
|
||||||
, m_bar(forward<const bar_settings&>(bar))
|
, m_bar(forward<const bar_settings&>(bar))
|
||||||
, m_rect(m_bar.inner_area()) {
|
, m_rect(m_bar.inner_area()) {
|
||||||
|
|
||||||
m_sig.attach(this);
|
m_sig.attach(this);
|
||||||
m_log.trace("renderer: Get TrueColor visual");
|
m_log.trace("renderer: Get TrueColor visual");
|
||||||
{
|
{
|
||||||
@ -301,13 +298,12 @@ void renderer::end() {
|
|||||||
fill_background();
|
fill_background();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// For pseudo-transparency, capture the contents of the rendered bar and
|
// For pseudo-transparency, capture the contents of the rendered bar and
|
||||||
// composite it against the desktop wallpaper. This way transparent parts of
|
// composite it against the desktop wallpaper. This way transparent parts of
|
||||||
// the bar will be filled by the wallpaper creating illusion of transparency.
|
// the bar will be filled by the wallpaper creating illusion of transparency.
|
||||||
if (m_pseudo_transparency) {
|
if (m_pseudo_transparency) {
|
||||||
cairo_pattern_t* barcontents{};
|
cairo_pattern_t* barcontents{};
|
||||||
m_context->pop(&barcontents); // corresponding push is in renderer::begin
|
m_context->pop(&barcontents); // corresponding push is in renderer::begin
|
||||||
|
|
||||||
auto root_bg = m_background->get_surface();
|
auto root_bg = m_background->get_surface();
|
||||||
if (root_bg != nullptr) {
|
if (root_bg != nullptr) {
|
||||||
@ -449,7 +445,7 @@ double renderer::block_x(alignment a) const {
|
|||||||
* So we can just subtract the tray_width = m_rect.x - border_left from the base_pos to correct for the tray being
|
* So we can just subtract the tray_width = m_rect.x - border_left from the base_pos to correct for the tray being
|
||||||
* placed on the left
|
* placed on the left
|
||||||
*/
|
*/
|
||||||
if(m_rect.x > border_left) {
|
if (m_rect.x > border_left) {
|
||||||
base_pos -= m_rect.x - border_left;
|
base_pos -= m_rect.x - border_left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -831,7 +827,7 @@ bool renderer::on(const signals::parser::text& evt) {
|
|||||||
bool renderer::on(const signals::parser::control& evt) {
|
bool renderer::on(const signals::parser::control& evt) {
|
||||||
auto ctrl = evt.cast();
|
auto ctrl = evt.cast();
|
||||||
|
|
||||||
switch(ctrl) {
|
switch (ctrl) {
|
||||||
case controltag::R:
|
case controltag::R:
|
||||||
m_bg = m_bar.background;
|
m_bg = m_bar.background;
|
||||||
m_fg = m_bar.foreground;
|
m_fg = m_bar.foreground;
|
||||||
|
@ -51,6 +51,6 @@ namespace modules {
|
|||||||
|
|
||||||
return m_builder->flush();
|
return m_builder->flush();
|
||||||
}
|
}
|
||||||
}
|
} // namespace modules
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
Loading…
Reference in New Issue
Block a user