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;
|
||||||
|
@ -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,8 +158,7 @@ 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));
|
||||||
@ -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,7 +298,6 @@ 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.
|
||||||
@ -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