refactor(clang-tidy): Apply fixes
This commit is contained in:
parent
8b9461e63e
commit
a5d6670121
@ -18,7 +18,7 @@ POLYBAR_NS
|
|||||||
namespace alsa {
|
namespace alsa {
|
||||||
class mixer {
|
class mixer {
|
||||||
public:
|
public:
|
||||||
explicit mixer(string&& mixer_selem_name, string&& sound_card_name);
|
explicit mixer(string&& mixer_selem_name, string&& soundcard_name);
|
||||||
~mixer();
|
~mixer();
|
||||||
|
|
||||||
mixer(const mixer& o) = delete;
|
mixer(const mixer& o) = delete;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cairo/cairo.h>
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
#include "cairo/fwd.hpp"
|
#include "cairo/fwd.hpp"
|
||||||
@ -38,7 +37,7 @@ class 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& emitter, const config&, const logger& logger, const bar_settings& bar);
|
connection& conn, signal_emitter& sig, const config&, const logger& logger, const bar_settings& bar);
|
||||||
~renderer();
|
~renderer();
|
||||||
|
|
||||||
xcb_window_t window() const;
|
xcb_window_t window() const;
|
||||||
@ -106,19 +105,19 @@ class renderer
|
|||||||
unique_ptr<cairo::xcb_surface> m_surface;
|
unique_ptr<cairo::xcb_surface> m_surface;
|
||||||
map<alignment, alignment_block> m_blocks;
|
map<alignment, alignment_block> m_blocks;
|
||||||
|
|
||||||
cairo_operator_t m_comp_bg;
|
int m_comp_bg{0};
|
||||||
cairo_operator_t m_comp_fg;
|
int m_comp_fg{0};
|
||||||
cairo_operator_t m_comp_ol;
|
int m_comp_ol{0};
|
||||||
cairo_operator_t m_comp_ul;
|
int m_comp_ul{0};
|
||||||
cairo_operator_t m_comp_border;
|
int m_comp_border{0};
|
||||||
|
|
||||||
alignment m_align;
|
alignment m_align;
|
||||||
std::bitset<3> m_attr;
|
std::bitset<3> m_attr;
|
||||||
int m_font;
|
int m_font{0};
|
||||||
unsigned int m_bg;
|
unsigned int m_bg{0U};
|
||||||
unsigned int m_fg;
|
unsigned int m_fg{0U};
|
||||||
unsigned int m_ol;
|
unsigned int m_ol{0U};
|
||||||
unsigned int m_ul;
|
unsigned int m_ul{0U};
|
||||||
vector<action_block> m_actions;
|
vector<action_block> m_actions;
|
||||||
|
|
||||||
bool m_fixedcenter;
|
bool m_fixedcenter;
|
||||||
|
@ -90,7 +90,7 @@ namespace string_util {
|
|||||||
string floating_point(double value, size_t precision, bool fixed = false, const string& locale = "");
|
string floating_point(double value, size_t precision, bool fixed = false, const string& locale = "");
|
||||||
string filesize_mb(unsigned long long kbytes, size_t precision = 0, const string& locale = "");
|
string filesize_mb(unsigned long long kbytes, size_t precision = 0, const string& locale = "");
|
||||||
string filesize_gb(unsigned long long kbytes, size_t precision = 0, const string& locale = "");
|
string filesize_gb(unsigned long long kbytes, size_t precision = 0, const string& locale = "");
|
||||||
string filesize(unsigned long long bytes, size_t precision = 0, bool fixed = false, const string& locale = "");
|
string filesize(unsigned long long kbytes, size_t precision = 0, bool fixed = false, const string& locale = "");
|
||||||
|
|
||||||
hash_type hash(const string& src);
|
hash_type hash(const string& src);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
|
||||||
|
|
||||||
#include "common.hpp"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
|
||||||
|
|
||||||
namespace draw_util {
|
|
||||||
void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect);
|
|
||||||
void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, short int x, short int y, unsigned short int w, unsigned short int h);
|
|
||||||
}
|
|
||||||
|
|
||||||
POLYBAR_NS_END
|
|
@ -12,7 +12,8 @@ namespace alsa {
|
|||||||
/**
|
/**
|
||||||
* Construct mixer object
|
* Construct mixer object
|
||||||
*/
|
*/
|
||||||
mixer::mixer(string&& mixer_selem_name, string&& soundcard_name) : m_name(forward<string>(mixer_selem_name)), s_name(soundcard_name) {
|
mixer::mixer(string&& mixer_selem_name, string&& soundcard_name)
|
||||||
|
: m_name(forward<string>(mixer_selem_name)), s_name(soundcard_name) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if ((err = snd_mixer_open(&m_mixer, 1)) == -1) {
|
if ((err = snd_mixer_open(&m_mixer, 1)) == -1) {
|
||||||
|
@ -10,8 +10,7 @@ namespace command_line {
|
|||||||
* Create instance
|
* Create instance
|
||||||
*/
|
*/
|
||||||
parser::make_type parser::make(string&& scriptname, const options&& opts) {
|
parser::make_type parser::make(string&& scriptname, const options&& opts) {
|
||||||
return factory_util::unique<parser>(
|
return factory_util::unique<parser>("Usage: " + scriptname + " [OPTION]... BAR", forward<decltype(opts)>(opts));
|
||||||
"Usage: " + scriptname + " [OPTION]... BAR", forward<decltype(opts)>(opts));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "x11/tray_manager.hpp"
|
#include "x11/tray_manager.hpp"
|
||||||
#include "x11/types.hpp"
|
#include "x11/types.hpp"
|
||||||
|
|
||||||
#include <signal.h>
|
#include <csignal>
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
@ -586,7 +586,7 @@ bool controller::on(const signals::ui::ready&) {
|
|||||||
enqueue(make_update_evt(true));
|
enqueue(make_update_evt(true));
|
||||||
|
|
||||||
if (!m_snapshot_dst.empty()) {
|
if (!m_snapshot_dst.empty()) {
|
||||||
m_threads.emplace_back(thread([&]{
|
m_threads.emplace_back(thread([&] {
|
||||||
this_thread::sleep_for(3s);
|
this_thread::sleep_for(3s);
|
||||||
m_sig.emit(signals::ui::request_snapshot{move(m_snapshot_dst)});
|
m_sig.emit(signals::ui::request_snapshot{move(m_snapshot_dst)});
|
||||||
enqueue(make_update_evt(true));
|
enqueue(make_update_evt(true));
|
||||||
|
@ -1,22 +1,13 @@
|
|||||||
#include "components/renderer.hpp"
|
#include "components/renderer.hpp"
|
||||||
#include "cairo/context.hpp"
|
#include "cairo/context.hpp"
|
||||||
#include "cairo/font.hpp"
|
|
||||||
#include "cairo/surface.hpp"
|
|
||||||
#include "cairo/types.hpp"
|
|
||||||
#include "cairo/utils.hpp"
|
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "components/logger.hpp"
|
|
||||||
#include "errors.hpp"
|
|
||||||
#include "events/signal.hpp"
|
#include "events/signal.hpp"
|
||||||
#include "events/signal_receiver.hpp"
|
#include "events/signal_receiver.hpp"
|
||||||
#include "utils/color.hpp"
|
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
#include "utils/string.hpp"
|
|
||||||
#include "x11/atoms.hpp"
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/draw.hpp"
|
|
||||||
#include "x11/extensions/all.hpp"
|
#include "x11/extensions/all.hpp"
|
||||||
#include "x11/generic.hpp"
|
#include "x11/generic.hpp"
|
||||||
#include "x11/winspec.hpp"
|
#include "x11/winspec.hpp"
|
||||||
@ -388,7 +379,7 @@ void renderer::reserve_space(edge side, unsigned int w) {
|
|||||||
*/
|
*/
|
||||||
void renderer::fill_background() {
|
void renderer::fill_background() {
|
||||||
m_context->save();
|
m_context->save();
|
||||||
*m_context << m_comp_bg;
|
*m_context << static_cast<cairo_operator_t>(m_comp_bg);
|
||||||
|
|
||||||
if (m_bar.radius != 0.0) {
|
if (m_bar.radius != 0.0) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
@ -424,7 +415,7 @@ void renderer::fill_overline(double x, double w) {
|
|||||||
if (m_bar.overline.size && m_attr.test(static_cast<int>(attribute::OVERLINE))) {
|
if (m_bar.overline.size && m_attr.test(static_cast<int>(attribute::OVERLINE))) {
|
||||||
m_log.trace_x("renderer: overline(x=%f, w=%f)", x, w);
|
m_log.trace_x("renderer: overline(x=%f, w=%f)", x, w);
|
||||||
m_context->save();
|
m_context->save();
|
||||||
*m_context << m_comp_ol;
|
*m_context << static_cast<cairo_operator_t>(m_comp_ol);
|
||||||
*m_context << m_ol;
|
*m_context << m_ol;
|
||||||
*m_context << cairo::rect{x, static_cast<double>(m_rect.y), w, static_cast<double>(m_bar.overline.size)};
|
*m_context << cairo::rect{x, static_cast<double>(m_rect.y), w, static_cast<double>(m_bar.overline.size)};
|
||||||
m_context->fill();
|
m_context->fill();
|
||||||
@ -439,7 +430,7 @@ void renderer::fill_underline(double x, double w) {
|
|||||||
if (m_bar.underline.size && m_attr.test(static_cast<int>(attribute::UNDERLINE))) {
|
if (m_bar.underline.size && m_attr.test(static_cast<int>(attribute::UNDERLINE))) {
|
||||||
m_log.trace_x("renderer: underline(x=%f, w=%f)", x, w);
|
m_log.trace_x("renderer: underline(x=%f, w=%f)", x, w);
|
||||||
m_context->save();
|
m_context->save();
|
||||||
*m_context << m_comp_ul;
|
*m_context << static_cast<cairo_operator_t>(m_comp_ul);
|
||||||
*m_context << m_ul;
|
*m_context << m_ul;
|
||||||
*m_context << cairo::rect{x, static_cast<double>(m_rect.y + m_rect.height - m_bar.underline.size), w,
|
*m_context << cairo::rect{x, static_cast<double>(m_rect.y + m_rect.height - m_bar.underline.size), w,
|
||||||
static_cast<double>(m_bar.underline.size)};
|
static_cast<double>(m_bar.underline.size)};
|
||||||
@ -453,7 +444,7 @@ void renderer::fill_underline(double x, double w) {
|
|||||||
*/
|
*/
|
||||||
void renderer::fill_borders() {
|
void renderer::fill_borders() {
|
||||||
m_context->save();
|
m_context->save();
|
||||||
*m_context << m_comp_border;
|
*m_context << static_cast<cairo_operator_t>(m_comp_border);
|
||||||
|
|
||||||
cairo::rect top{0.0, 0.0, 0.0, 0.0};
|
cairo::rect top{0.0, 0.0, 0.0, 0.0};
|
||||||
top.x += m_bar.borders.at(edge::LEFT).size;
|
top.x += m_bar.borders.at(edge::LEFT).size;
|
||||||
@ -508,7 +499,7 @@ void renderer::draw_text(const string& contents) {
|
|||||||
|
|
||||||
if (m_bg && m_bg != m_bar.background) {
|
if (m_bg && m_bg != m_bar.background) {
|
||||||
block.bg = m_bg;
|
block.bg = m_bg;
|
||||||
block.bg_operator = m_comp_bg;
|
block.bg_operator = static_cast<cairo_operator_t>(m_comp_bg);
|
||||||
block.bg_rect.x = m_rect.x + m_blocks[m_align].x;
|
block.bg_rect.x = m_rect.x + m_blocks[m_align].x;
|
||||||
block.bg_rect.y = m_rect.y;
|
block.bg_rect.y = m_rect.y;
|
||||||
block.bg_rect.h = m_rect.height;
|
block.bg_rect.h = m_rect.height;
|
||||||
@ -516,7 +507,7 @@ void renderer::draw_text(const string& contents) {
|
|||||||
|
|
||||||
m_context->save();
|
m_context->save();
|
||||||
*m_context << origin;
|
*m_context << origin;
|
||||||
*m_context << m_comp_fg;
|
*m_context << static_cast<cairo_operator_t>(m_comp_fg);
|
||||||
*m_context << m_fg;
|
*m_context << m_fg;
|
||||||
*m_context << block;
|
*m_context << block;
|
||||||
m_context->restore();
|
m_context->restore();
|
||||||
|
@ -229,13 +229,16 @@ namespace modules {
|
|||||||
bool headphones{m_headphones};
|
bool headphones{m_headphones};
|
||||||
|
|
||||||
if (m_mixer[mixer::MASTER] && !m_mixer[mixer::MASTER]->get_name().empty()) {
|
if (m_mixer[mixer::MASTER] && !m_mixer[mixer::MASTER]->get_name().empty()) {
|
||||||
mixers.emplace_back(new mixer_t::element_type(string{m_mixer[mixer::MASTER]->get_name()}, string{m_mixer[mixer::MASTER]->get_sound_card()}));
|
mixers.emplace_back(new mixer_t::element_type(
|
||||||
|
string{m_mixer[mixer::MASTER]->get_name()}, string{m_mixer[mixer::MASTER]->get_sound_card()}));
|
||||||
}
|
}
|
||||||
if (m_mixer[mixer::HEADPHONE] && !m_mixer[mixer::HEADPHONE]->get_name().empty() && headphones) {
|
if (m_mixer[mixer::HEADPHONE] && !m_mixer[mixer::HEADPHONE]->get_name().empty() && headphones) {
|
||||||
mixers.emplace_back(new mixer_t::element_type(string{m_mixer[mixer::HEADPHONE]->get_name()}, string{m_mixer[mixer::HEADPHONE]->get_sound_card()}));
|
mixers.emplace_back(new mixer_t::element_type(
|
||||||
|
string{m_mixer[mixer::HEADPHONE]->get_name()}, string{m_mixer[mixer::HEADPHONE]->get_sound_card()}));
|
||||||
}
|
}
|
||||||
if (m_mixer[mixer::SPEAKER] && !m_mixer[mixer::SPEAKER]->get_name().empty() && !headphones) {
|
if (m_mixer[mixer::SPEAKER] && !m_mixer[mixer::SPEAKER]->get_name().empty() && !headphones) {
|
||||||
mixers.emplace_back(new mixer_t::element_type(string{m_mixer[mixer::SPEAKER]->get_name()}, string{m_mixer[mixer::HEADPHONE]->get_sound_card()}));
|
mixers.emplace_back(new mixer_t::element_type(
|
||||||
|
string{m_mixer[mixer::SPEAKER]->get_name()}, string{m_mixer[mixer::HEADPHONE]->get_sound_card()}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.compare(0, strlen(EVENT_TOGGLE_MUTE), EVENT_TOGGLE_MUTE) == 0) {
|
if (cmd.compare(0, strlen(EVENT_TOGGLE_MUTE), EVENT_TOGGLE_MUTE) == 0) {
|
||||||
|
@ -208,7 +208,7 @@ namespace file_util {
|
|||||||
* Get glob results using given pattern
|
* Get glob results using given pattern
|
||||||
*/
|
*/
|
||||||
vector<string> glob(const string& pattern) {
|
vector<string> glob(const string& pattern) {
|
||||||
glob_t result;
|
glob_t result{};
|
||||||
vector<string> ret;
|
vector<string> ret;
|
||||||
|
|
||||||
if (glob(pattern.c_str(), GLOB_TILDE, nullptr, &result) == 0) {
|
if (glob(pattern.c_str(), GLOB_TILDE, nullptr, &result) == 0) {
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#include "x11/draw.hpp"
|
|
||||||
#include "utils/color.hpp"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
|
||||||
|
|
||||||
namespace draw_util {
|
|
||||||
/**
|
|
||||||
* Fill region of drawable with color defined by gcontext
|
|
||||||
*/
|
|
||||||
void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect) {
|
|
||||||
xcb_poly_fill_rectangle(c, d, g, 1, &rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fill region of drawable with color defined by gcontext
|
|
||||||
*/
|
|
||||||
void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, short int x, short int y, unsigned short int w, unsigned short int h) {
|
|
||||||
fill(c, d, g, {x, y, w, h});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
POLYBAR_NS_END
|
|
@ -61,7 +61,8 @@ namespace randr_util {
|
|||||||
/**
|
/**
|
||||||
* Define monitor
|
* Define monitor
|
||||||
*/
|
*/
|
||||||
monitor_t make_monitor(xcb_randr_output_t randr, string name, unsigned short int w, unsigned short int h, short int x, short int y) {
|
monitor_t make_monitor(
|
||||||
|
xcb_randr_output_t randr, string name, unsigned short int w, unsigned short int h, short int x, short int y) {
|
||||||
monitor_t mon{new monitor_t::element_type{}};
|
monitor_t mon{new monitor_t::element_type{}};
|
||||||
mon->output = randr;
|
mon->output = randr;
|
||||||
mon->name = move(name);
|
mon->name = move(name);
|
||||||
|
@ -13,8 +13,8 @@ namespace graphics_util {
|
|||||||
/**
|
/**
|
||||||
* Create a basic window
|
* Create a basic window
|
||||||
*/
|
*/
|
||||||
bool create_window(
|
bool create_window(connection& conn, xcb_window_t* win, short int x, short int y, unsigned short int w,
|
||||||
connection& conn, xcb_window_t* win, short int x, short int y, unsigned short int w, unsigned short int h, xcb_window_t root) {
|
unsigned short int h, xcb_window_t root) {
|
||||||
if (!root) {
|
if (!root) {
|
||||||
root = conn.screen()->root;
|
root = conn.screen()->root;
|
||||||
}
|
}
|
||||||
@ -35,14 +35,16 @@ namespace graphics_util {
|
|||||||
* Create a basic pixmap with the same depth as the
|
* Create a basic pixmap with the same depth as the
|
||||||
* root depth of the default screen
|
* root depth of the default screen
|
||||||
*/
|
*/
|
||||||
bool create_pixmap(connection& conn, xcb_drawable_t dst, unsigned short int w, unsigned short int h, xcb_pixmap_t* pixmap) {
|
bool create_pixmap(
|
||||||
|
connection& conn, xcb_drawable_t dst, unsigned short int w, unsigned short int h, xcb_pixmap_t* pixmap) {
|
||||||
return graphics_util::create_pixmap(conn, dst, w, h, conn.screen()->root_depth, pixmap);
|
return graphics_util::create_pixmap(conn, dst, w, h, conn.screen()->root_depth, pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a basic pixmap with specific depth
|
* Create a basic pixmap with specific depth
|
||||||
*/
|
*/
|
||||||
bool create_pixmap(connection& conn, xcb_drawable_t dst, unsigned short int w, unsigned short int h, unsigned char d, xcb_pixmap_t* pixmap) {
|
bool create_pixmap(connection& conn, xcb_drawable_t dst, unsigned short int w, unsigned short int h, unsigned char d,
|
||||||
|
xcb_pixmap_t* pixmap) {
|
||||||
try {
|
try {
|
||||||
*pixmap = conn.generate_id();
|
*pixmap = conn.generate_id();
|
||||||
conn.create_pixmap_checked(d, *pixmap, dst, w, h);
|
conn.create_pixmap_checked(d, *pixmap, dst, w, h);
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "utils/process.hpp"
|
#include "utils/process.hpp"
|
||||||
#include "x11/atoms.hpp"
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/draw.hpp"
|
|
||||||
#include "x11/graphics.hpp"
|
#include "x11/graphics.hpp"
|
||||||
#include "x11/tray_manager.hpp"
|
#include "x11/tray_manager.hpp"
|
||||||
#include "x11/window.hpp"
|
#include "x11/window.hpp"
|
||||||
@ -489,7 +488,8 @@ void tray_manager::refresh_window() {
|
|||||||
auto height = calculate_h();
|
auto height = calculate_h();
|
||||||
|
|
||||||
if (m_opts.transparent && !m_rootpixmap.pixmap) {
|
if (m_opts.transparent && !m_rootpixmap.pixmap) {
|
||||||
draw_util::fill(m_connection, m_pixmap, m_gc, 0, 0, width, height);
|
xcb_rectangle_t rect{0, 0, static_cast<uint16_t>(width), static_cast<uint16_t>(height)};
|
||||||
|
m_connection.poly_fill_rectangle(m_pixmap, m_gc, 1, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connection.clear_area(0, m_tray, 0, 0, width, height);
|
m_connection.clear_area(0, m_tray, 0, 0, width, height);
|
||||||
|
@ -17,7 +17,8 @@ window& window::operator=(const xcb_window_t win) {
|
|||||||
/**
|
/**
|
||||||
* Create window and check for errors
|
* Create window and check for errors
|
||||||
*/
|
*/
|
||||||
window window::create_checked(short int x, short int y, unsigned short int w, unsigned short int h, unsigned int mask, const xcb_params_cw_t* p) {
|
window window::create_checked(
|
||||||
|
short int x, short int y, unsigned short int w, unsigned short int h, unsigned int mask, const xcb_params_cw_t* p) {
|
||||||
if (*this == XCB_NONE) {
|
if (*this == XCB_NONE) {
|
||||||
*this = connection().generate_id();
|
*this = connection().generate_id();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user