refactor(clang-tidy): Apply fixes
This commit is contained in:
parent
8b9461e63e
commit
a5d6670121
@ -18,7 +18,7 @@ POLYBAR_NS
|
||||
namespace alsa {
|
||||
class mixer {
|
||||
public:
|
||||
explicit mixer(string&& mixer_selem_name, string&& sound_card_name);
|
||||
explicit mixer(string&& mixer_selem_name, string&& soundcard_name);
|
||||
~mixer();
|
||||
|
||||
mixer(const mixer& o) = delete;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
#include <bitset>
|
||||
|
||||
#include "cairo/fwd.hpp"
|
||||
@ -38,7 +37,7 @@ class renderer
|
||||
static make_type make(const bar_settings& bar);
|
||||
|
||||
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();
|
||||
|
||||
xcb_window_t window() const;
|
||||
@ -106,19 +105,19 @@ class renderer
|
||||
unique_ptr<cairo::xcb_surface> m_surface;
|
||||
map<alignment, alignment_block> m_blocks;
|
||||
|
||||
cairo_operator_t m_comp_bg;
|
||||
cairo_operator_t m_comp_fg;
|
||||
cairo_operator_t m_comp_ol;
|
||||
cairo_operator_t m_comp_ul;
|
||||
cairo_operator_t m_comp_border;
|
||||
int m_comp_bg{0};
|
||||
int m_comp_fg{0};
|
||||
int m_comp_ol{0};
|
||||
int m_comp_ul{0};
|
||||
int m_comp_border{0};
|
||||
|
||||
alignment m_align;
|
||||
std::bitset<3> m_attr;
|
||||
int m_font;
|
||||
unsigned int m_bg;
|
||||
unsigned int m_fg;
|
||||
unsigned int m_ol;
|
||||
unsigned int m_ul;
|
||||
int m_font{0};
|
||||
unsigned int m_bg{0U};
|
||||
unsigned int m_fg{0U};
|
||||
unsigned int m_ol{0U};
|
||||
unsigned int m_ul{0U};
|
||||
vector<action_block> m_actions;
|
||||
|
||||
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 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(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);
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
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;
|
||||
|
||||
if ((err = snd_mixer_open(&m_mixer, 1)) == -1) {
|
||||
|
@ -10,8 +10,7 @@ namespace command_line {
|
||||
* Create instance
|
||||
*/
|
||||
parser::make_type parser::make(string&& scriptname, const options&& opts) {
|
||||
return factory_util::unique<parser>(
|
||||
"Usage: " + scriptname + " [OPTION]... BAR", forward<decltype(opts)>(opts));
|
||||
return factory_util::unique<parser>("Usage: " + scriptname + " [OPTION]... BAR", forward<decltype(opts)>(opts));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "x11/tray_manager.hpp"
|
||||
#include "x11/types.hpp"
|
||||
|
||||
#include <signal.h>
|
||||
#include <csignal>
|
||||
|
||||
POLYBAR_NS
|
||||
|
||||
@ -586,7 +586,7 @@ bool controller::on(const signals::ui::ready&) {
|
||||
enqueue(make_update_evt(true));
|
||||
|
||||
if (!m_snapshot_dst.empty()) {
|
||||
m_threads.emplace_back(thread([&]{
|
||||
m_threads.emplace_back(thread([&] {
|
||||
this_thread::sleep_for(3s);
|
||||
m_sig.emit(signals::ui::request_snapshot{move(m_snapshot_dst)});
|
||||
enqueue(make_update_evt(true));
|
||||
|
@ -1,22 +1,13 @@
|
||||
#include "components/renderer.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/logger.hpp"
|
||||
#include "errors.hpp"
|
||||
#include "events/signal.hpp"
|
||||
#include "events/signal_receiver.hpp"
|
||||
#include "utils/color.hpp"
|
||||
#include "utils/factory.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#include "utils/math.hpp"
|
||||
#include "utils/string.hpp"
|
||||
#include "x11/atoms.hpp"
|
||||
#include "x11/connection.hpp"
|
||||
#include "x11/draw.hpp"
|
||||
#include "x11/extensions/all.hpp"
|
||||
#include "x11/generic.hpp"
|
||||
#include "x11/winspec.hpp"
|
||||
@ -388,7 +379,7 @@ void renderer::reserve_space(edge side, unsigned int w) {
|
||||
*/
|
||||
void renderer::fill_background() {
|
||||
m_context->save();
|
||||
*m_context << m_comp_bg;
|
||||
*m_context << static_cast<cairo_operator_t>(m_comp_bg);
|
||||
|
||||
if (m_bar.radius != 0.0) {
|
||||
// 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))) {
|
||||
m_log.trace_x("renderer: overline(x=%f, w=%f)", x, w);
|
||||
m_context->save();
|
||||
*m_context << m_comp_ol;
|
||||
*m_context << static_cast<cairo_operator_t>(m_comp_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->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))) {
|
||||
m_log.trace_x("renderer: underline(x=%f, w=%f)", x, w);
|
||||
m_context->save();
|
||||
*m_context << m_comp_ul;
|
||||
*m_context << static_cast<cairo_operator_t>(m_comp_ul);
|
||||
*m_context << m_ul;
|
||||
*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)};
|
||||
@ -453,7 +444,7 @@ void renderer::fill_underline(double x, double w) {
|
||||
*/
|
||||
void renderer::fill_borders() {
|
||||
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};
|
||||
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) {
|
||||
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.y = m_rect.y;
|
||||
block.bg_rect.h = m_rect.height;
|
||||
@ -516,7 +507,7 @@ void renderer::draw_text(const string& contents) {
|
||||
|
||||
m_context->save();
|
||||
*m_context << origin;
|
||||
*m_context << m_comp_fg;
|
||||
*m_context << static_cast<cairo_operator_t>(m_comp_fg);
|
||||
*m_context << m_fg;
|
||||
*m_context << block;
|
||||
m_context->restore();
|
||||
|
@ -229,13 +229,16 @@ namespace modules {
|
||||
bool headphones{m_headphones};
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
|
@ -208,7 +208,7 @@ namespace file_util {
|
||||
* Get glob results using given pattern
|
||||
*/
|
||||
vector<string> glob(const string& pattern) {
|
||||
glob_t result;
|
||||
glob_t result{};
|
||||
vector<string> ret;
|
||||
|
||||
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
|
||||
*/
|
||||
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{}};
|
||||
mon->output = randr;
|
||||
mon->name = move(name);
|
||||
|
@ -13,8 +13,8 @@ namespace graphics_util {
|
||||
/**
|
||||
* Create a basic window
|
||||
*/
|
||||
bool create_window(
|
||||
connection& conn, xcb_window_t* win, short int x, short int y, unsigned short int w, unsigned short int h, xcb_window_t root) {
|
||||
bool create_window(connection& conn, xcb_window_t* win, short int x, short int y, unsigned short int w,
|
||||
unsigned short int h, xcb_window_t root) {
|
||||
if (!root) {
|
||||
root = conn.screen()->root;
|
||||
}
|
||||
@ -35,14 +35,16 @@ namespace graphics_util {
|
||||
* Create a basic pixmap with the same depth as the
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
*pixmap = conn.generate_id();
|
||||
conn.create_pixmap_checked(d, *pixmap, dst, w, h);
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "utils/process.hpp"
|
||||
#include "x11/atoms.hpp"
|
||||
#include "x11/connection.hpp"
|
||||
#include "x11/draw.hpp"
|
||||
#include "x11/graphics.hpp"
|
||||
#include "x11/tray_manager.hpp"
|
||||
#include "x11/window.hpp"
|
||||
@ -489,7 +488,8 @@ void tray_manager::refresh_window() {
|
||||
auto height = calculate_h();
|
||||
|
||||
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);
|
||||
|
@ -17,7 +17,8 @@ window& window::operator=(const xcb_window_t win) {
|
||||
/**
|
||||
* 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) {
|
||||
*this = connection().generate_id();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user