refactor(clang-tidy): Apply fixes
This commit is contained in:
parent
78b5f9651f
commit
f9062d031c
42 changed files with 123 additions and 111 deletions
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
Checks: '-*,performance-*,readability-*,modernize-use-*,-modernize-raw-string-literal,-modernize-use-bool-literals,-readability-implicit-bool-cast,-readability-else-after-return,-readability-named-parameter'
|
Checks: '-*,performance-*,readability-*,modernize-use-*,modernize-*,-modernize-raw-string-literal,-modernize-use-bool-literals,-readability-implicit-bool-cast,-readability-else-after-return,-readability-named-parameter'
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: modernize-loop-convert.NamingStyle
|
- key: modernize-loop-convert.NamingStyle
|
||||||
value: lower_case
|
value: lower_case
|
||||||
|
|
|
@ -20,13 +20,16 @@ namespace alsa {
|
||||||
explicit control(int numid);
|
explicit control(int numid);
|
||||||
~control();
|
~control();
|
||||||
|
|
||||||
|
control(const control& o) = delete;
|
||||||
|
control& operator=(const control& o) = delete;
|
||||||
|
|
||||||
int get_numid();
|
int get_numid();
|
||||||
bool wait(int timeout = -1);
|
bool wait(int timeout = -1);
|
||||||
bool test_device_plugged();
|
bool test_device_plugged();
|
||||||
void process_events();
|
void process_events();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex m_lock;
|
std::mutex m_lock{};
|
||||||
|
|
||||||
int m_numid{0};
|
int m_numid{0};
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@ namespace alsa {
|
||||||
explicit mixer(string&& mixer_selem_name);
|
explicit mixer(string&& mixer_selem_name);
|
||||||
~mixer();
|
~mixer();
|
||||||
|
|
||||||
|
mixer(const mixer& o) = delete;
|
||||||
|
mixer& operator=(const mixer& o) = delete;
|
||||||
|
|
||||||
const string& get_name();
|
const string& get_name();
|
||||||
|
|
||||||
bool wait(int timeout = -1);
|
bool wait(int timeout = -1);
|
||||||
|
@ -34,7 +37,7 @@ namespace alsa {
|
||||||
bool is_muted();
|
bool is_muted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex m_lock;
|
std::mutex m_lock{};
|
||||||
|
|
||||||
snd_mixer_t* m_mixer{nullptr};
|
snd_mixer_t* m_mixer{nullptr};
|
||||||
snd_mixer_elem_t* m_elem{nullptr};
|
snd_mixer_elem_t* m_elem{nullptr};
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace mpd {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const logger& m_log;
|
const logger& m_log;
|
||||||
mpd_connection_t m_connection;
|
mpd_connection_t m_connection{};
|
||||||
|
|
||||||
bool m_listactive = false;
|
bool m_listactive = false;
|
||||||
bool m_idle = false;
|
bool m_idle = false;
|
||||||
|
@ -151,21 +151,21 @@ namespace mpd {
|
||||||
int get_seek_position(int percentage);
|
int get_seek_position(int percentage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mpd_status_t m_status;
|
mpd_status_t m_status{};
|
||||||
unique_ptr<mpdsong> m_song;
|
unique_ptr<mpdsong> m_song{};
|
||||||
mpdstate m_state = mpdstate::UNKNOWN;
|
mpdstate m_state{mpdstate::UNKNOWN};
|
||||||
chrono::system_clock::time_point m_updated_at;
|
chrono::system_clock::time_point m_updated_at{};
|
||||||
|
|
||||||
bool m_random = false;
|
bool m_random{false};
|
||||||
bool m_repeat = false;
|
bool m_repeat{false};
|
||||||
bool m_single = false;
|
bool m_single{false};
|
||||||
|
|
||||||
int m_songid;
|
int m_songid{0};
|
||||||
int m_queuelen;
|
int m_queuelen{0};
|
||||||
|
|
||||||
unsigned long m_total_time;
|
unsigned long m_total_time{0UL};
|
||||||
unsigned long m_elapsed_time;
|
unsigned long m_elapsed_time{0UL};
|
||||||
unsigned long m_elapsed_time_ms;
|
unsigned long m_elapsed_time_ms{0UL};
|
||||||
};
|
};
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
|
@ -111,8 +111,8 @@ namespace net {
|
||||||
void query_quality(const int& socket_fd);
|
void query_quality(const int& socket_fd);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shared_ptr<wireless_info> m_info;
|
shared_ptr<wireless_info> m_info{};
|
||||||
string m_essid;
|
string m_essid{};
|
||||||
quality_range m_signalstrength{};
|
quality_range m_signalstrength{};
|
||||||
quality_range m_linkquality{};
|
quality_range m_linkquality{};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "components/renderer.hpp"
|
||||||
#include "components/screen.hpp"
|
#include "components/screen.hpp"
|
||||||
#include "components/types.hpp"
|
#include "components/types.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
|
@ -20,7 +21,6 @@ POLYBAR_NS
|
||||||
class screen;
|
class screen;
|
||||||
class tray_manager;
|
class tray_manager;
|
||||||
class logger;
|
class logger;
|
||||||
class renderer;
|
|
||||||
|
|
||||||
class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::property_notify> {
|
class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::property_notify> {
|
||||||
public:
|
public:
|
||||||
|
@ -58,9 +58,9 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
|
||||||
|
|
||||||
bar_settings m_opts;
|
bar_settings m_opts;
|
||||||
|
|
||||||
string m_lastinput;
|
string m_lastinput{};
|
||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex{};
|
||||||
|
|
||||||
event_timer m_buttonpress{0L, 5L};
|
event_timer m_buttonpress{0L, 5L};
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,7 +72,7 @@ class builder {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const bar_settings m_bar;
|
const bar_settings m_bar;
|
||||||
string m_output;
|
string m_output{};
|
||||||
|
|
||||||
map<syntaxtag, int> m_tags{
|
map<syntaxtag, int> m_tags{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -97,8 +97,8 @@ class builder {
|
||||||
uint8_t m_attributes{static_cast<uint8_t>(attribute::NONE)};
|
uint8_t m_attributes{static_cast<uint8_t>(attribute::NONE)};
|
||||||
uint8_t m_fontindex{1};
|
uint8_t m_fontindex{1};
|
||||||
|
|
||||||
string m_background;
|
string m_background{};
|
||||||
string m_foreground;
|
string m_foreground{};
|
||||||
};
|
};
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
|
|
@ -58,10 +58,10 @@ namespace command_line {
|
||||||
void parse(const string& input, const string& input_next = "");
|
void parse(const string& input, const string& input_next = "");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_synopsis;
|
string m_synopsis{};
|
||||||
const options m_opts;
|
const options m_opts;
|
||||||
values m_optvalues;
|
values m_optvalues{};
|
||||||
bool m_skipnext = false;
|
bool m_skipnext{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
|
@ -302,7 +302,7 @@ class config {
|
||||||
const xresource_manager& m_xrm;
|
const xresource_manager& m_xrm;
|
||||||
string m_file;
|
string m_file;
|
||||||
string m_barname;
|
string m_barname;
|
||||||
sectionmap_t m_sections;
|
sectionmap_t m_sections{};
|
||||||
};
|
};
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <moodycamel/blockingconcurrentqueue.h>
|
#include <moodycamel/blockingconcurrentqueue.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -60,7 +61,7 @@ class eventloop : public signal_receiver<SIGN_PRIORITY_EVENTLOOP, process_quit,
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
bool enqueue(event&& evt);
|
bool enqueue(event&& evt);
|
||||||
bool enqueue(string&& evt);
|
bool enqueue(string&& input_data);
|
||||||
|
|
||||||
void add_module(const alignment pos, module_t&& module);
|
void add_module(const alignment pos, module_t&& module);
|
||||||
const modulemap_t& modules() const;
|
const modulemap_t& modules() const;
|
||||||
|
|
|
@ -47,8 +47,8 @@ class ipc {
|
||||||
private:
|
private:
|
||||||
signal_emitter& m_sig;
|
signal_emitter& m_sig;
|
||||||
const logger& m_log;
|
const logger& m_log;
|
||||||
string m_fifo;
|
string m_fifo{};
|
||||||
int m_fd;
|
int m_fd{0};
|
||||||
stateflag m_running{false};
|
stateflag m_running{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ struct line_settings {
|
||||||
|
|
||||||
struct action {
|
struct action {
|
||||||
mousebtn button{mousebtn::NONE};
|
mousebtn button{mousebtn::NONE};
|
||||||
string command;
|
string command{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct action_block : public action {
|
struct action_block : public action {
|
||||||
|
@ -95,9 +95,9 @@ struct bar_settings {
|
||||||
explicit bar_settings() = default;
|
explicit bar_settings() = default;
|
||||||
bar_settings(const bar_settings& other) = default;
|
bar_settings(const bar_settings& other) = default;
|
||||||
|
|
||||||
xcb_window_t window;
|
xcb_window_t window{XCB_NONE};
|
||||||
|
|
||||||
monitor_t monitor;
|
monitor_t monitor{};
|
||||||
edge origin{edge::TOP};
|
edge origin{edge::TOP};
|
||||||
struct size size {
|
struct size size {
|
||||||
1U, 1U
|
1U, 1U
|
||||||
|
@ -113,20 +113,20 @@ struct bar_settings {
|
||||||
uint32_t background{0xFFFFFFFF};
|
uint32_t background{0xFFFFFFFF};
|
||||||
uint32_t foreground{0xFF000000};
|
uint32_t foreground{0xFF000000};
|
||||||
|
|
||||||
line_settings underline;
|
line_settings underline{};
|
||||||
line_settings overline;
|
line_settings overline{};
|
||||||
|
|
||||||
std::unordered_map<edge, border_settings> borders;
|
std::unordered_map<edge, border_settings> borders{};
|
||||||
|
|
||||||
uint8_t spacing{1U};
|
uint8_t spacing{1U};
|
||||||
string separator;
|
string separator{};
|
||||||
|
|
||||||
string wmname;
|
string wmname{};
|
||||||
string locale;
|
string locale{};
|
||||||
|
|
||||||
bool override_redirect{false};
|
bool override_redirect{false};
|
||||||
|
|
||||||
vector<action> actions;
|
vector<action> actions{};
|
||||||
|
|
||||||
const xcb_rectangle_t inner_area(bool abspos = false) const {
|
const xcb_rectangle_t inner_area(bool abspos = false) const {
|
||||||
xcb_rectangle_t rect{0, 0, size.w, size.h};
|
xcb_rectangle_t rect{0, 0, size.w, size.h};
|
||||||
|
|
|
@ -30,15 +30,15 @@ namespace drawtypes {
|
||||||
|
|
||||||
class label : public non_copyable_mixin<label> {
|
class label : public non_copyable_mixin<label> {
|
||||||
public:
|
public:
|
||||||
string m_foreground;
|
string m_foreground{};
|
||||||
string m_background;
|
string m_background{};
|
||||||
string m_underline;
|
string m_underline{};
|
||||||
string m_overline;
|
string m_overline{};
|
||||||
int m_font = 0;
|
int m_font{0};
|
||||||
struct side_values m_padding = {0,0};
|
side_values m_padding{0,0};
|
||||||
struct side_values m_margin = {0,0};
|
side_values m_margin{0,0};
|
||||||
size_t m_maxlen = 0;
|
size_t m_maxlen{0};
|
||||||
bool m_ellipsis = true;
|
bool m_ellipsis{true};
|
||||||
|
|
||||||
explicit label(string text, int font) : m_font(font), m_text(text), m_tokenized(m_text) {}
|
explicit label(string text, int font) : m_font(font), m_text(text), m_tokenized(m_text) {}
|
||||||
explicit label(string text, string foreground = "", string background = "", string underline = "",
|
explicit label(string text, string foreground = "", string background = "", string underline = "",
|
||||||
|
@ -67,8 +67,9 @@ namespace drawtypes {
|
||||||
void copy_undefined(const label_t& label);
|
void copy_undefined(const label_t& label);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_text, m_tokenized;
|
string m_text{};
|
||||||
const vector<token> m_tokens;
|
string m_tokenized{};
|
||||||
|
const vector<token> m_tokens{};
|
||||||
};
|
};
|
||||||
|
|
||||||
label_t load_label(const config& conf, const string& section, string name, bool required = true, string def = "");
|
label_t load_label(const config& conf, const string& section, string name, bool required = true, string def = "");
|
||||||
|
|
|
@ -16,6 +16,9 @@ namespace file_util {
|
||||||
|
|
||||||
~file_ptr();
|
~file_ptr();
|
||||||
|
|
||||||
|
file_ptr(const file_ptr& o) = delete;
|
||||||
|
file_ptr& operator=(const file_ptr& o) = delete;
|
||||||
|
|
||||||
operator bool();
|
operator bool();
|
||||||
|
|
||||||
FILE* operator()();
|
FILE* operator()();
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace inotify_util {
|
||||||
|
|
||||||
class inotify_watch {
|
class inotify_watch {
|
||||||
public:
|
public:
|
||||||
explicit inotify_watch(string path) : m_path(path) {}
|
explicit inotify_watch(string path);
|
||||||
~inotify_watch() noexcept;
|
~inotify_watch() noexcept;
|
||||||
|
|
||||||
void attach(int mask = IN_MODIFY);
|
void attach(int mask = IN_MODIFY);
|
||||||
|
|
|
@ -76,9 +76,9 @@ namespace throttle_util {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
queue m_queue;
|
queue m_queue{};
|
||||||
limit m_limit;
|
limit m_limit{};
|
||||||
timewindow m_timewindow;
|
timewindow m_timewindow{};
|
||||||
};
|
};
|
||||||
|
|
||||||
using throttle_t = unique_ptr<event_throttler>;
|
using throttle_t = unique_ptr<event_throttler>;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <xpp/xpp.hpp>
|
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
|
@ -30,6 +29,7 @@ class connection : public xpp_connection {
|
||||||
connection& operator=(const connection&) {
|
connection& operator=(const connection&) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
connection(const connection& o) = delete;
|
||||||
|
|
||||||
virtual ~connection() {}
|
virtual ~connection() {}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify
|
||||||
bool is_embedded(const xcb_window_t& win) const;
|
bool is_embedded(const xcb_window_t& win) const;
|
||||||
shared_ptr<tray_client> find_client(const xcb_window_t& win) const;
|
shared_ptr<tray_client> find_client(const xcb_window_t& win) const;
|
||||||
void remove_client(shared_ptr<tray_client>& client, bool reconfigure = true);
|
void remove_client(shared_ptr<tray_client>& client, bool reconfigure = true);
|
||||||
void remove_client(xcb_window_t window, bool reconfigure = true);
|
void remove_client(xcb_window_t win, bool reconfigure = true);
|
||||||
size_t mapped_clients() const;
|
size_t mapped_clients() const;
|
||||||
|
|
||||||
void handle(const evt::expose& evt);
|
void handle(const evt::expose& evt);
|
||||||
|
|
|
@ -52,13 +52,13 @@ class keyboard {
|
||||||
enum class type { NONE = 0U, CAPS_LOCK, NUM_LOCK };
|
enum class type { NONE = 0U, CAPS_LOCK, NUM_LOCK };
|
||||||
xcb_atom_t atom{};
|
xcb_atom_t atom{};
|
||||||
uint8_t mask{0};
|
uint8_t mask{0};
|
||||||
string name;
|
string name{};
|
||||||
bool enabled{false};
|
bool enabled{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct layout {
|
struct layout {
|
||||||
string group_name;
|
string group_name{};
|
||||||
vector<string> symbols;
|
vector<string> symbols{};
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit keyboard(vector<layout>&& layouts_, map<indicator::type, indicator>&& indicators_, uint8_t group)
|
explicit keyboard(vector<layout>&& layouts_, map<indicator::type, indicator>&& indicators_, uint8_t group)
|
||||||
|
|
|
@ -15,6 +15,9 @@ class xresource_manager {
|
||||||
explicit xresource_manager(shared_ptr<Display>&&);
|
explicit xresource_manager(shared_ptr<Display>&&);
|
||||||
~xresource_manager();
|
~xresource_manager();
|
||||||
|
|
||||||
|
xresource_manager(const xresource_manager& o) = delete;
|
||||||
|
xresource_manager& operator=(const xresource_manager& o) = delete;
|
||||||
|
|
||||||
string get_string(string name, string fallback = "") const;
|
string get_string(string name, string fallback = "") const;
|
||||||
float get_float(string name, float fallback = 0.0f) const;
|
float get_float(string name, float fallback = 0.0f) const;
|
||||||
int get_int(string name, int fallback = 0) const;
|
int get_int(string name, int fallback = 0) const;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
|
|
||||||
#include "adapters/alsa/generic.hpp"
|
#include "adapters/alsa/generic.hpp"
|
||||||
#include "adapters/alsa/mixer.hpp"
|
#include "adapters/alsa/mixer.hpp"
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "components/bar.hpp"
|
#include "components/bar.hpp"
|
||||||
#include "components/config.hpp"
|
#include "components/config.hpp"
|
||||||
#include "components/parser.hpp"
|
#include "components/parser.hpp"
|
||||||
#include "components/renderer.hpp"
|
|
||||||
#include "components/screen.hpp"
|
#include "components/screen.hpp"
|
||||||
#include "events/signal.hpp"
|
#include "events/signal.hpp"
|
||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
|
|
|
@ -109,14 +109,13 @@ void config::parse_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
string key{forward<string>(string_util::trim(forward<string>(line.substr(0, equal_pos)), ' '))};
|
string key{forward<string>(string_util::trim(forward<string>(line.substr(0, equal_pos)), ' '))};
|
||||||
string value{""};
|
string value;
|
||||||
|
|
||||||
auto it = m_sections[section].find(key);
|
auto it = m_sections[section].find(key);
|
||||||
if (it != m_sections[section].end()) {
|
if (it != m_sections[section].end()) {
|
||||||
throw key_error("Duplicate key name \"" + key + "\" defined on line " + to_string(lineno));
|
throw key_error("Duplicate key name \"" + key + "\" defined on line " + to_string(lineno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (equal_pos + 1 < line.size()) {
|
if (equal_pos + 1 < line.size()) {
|
||||||
value = string_util::trim(forward<string>(string_util::trim(line.substr(equal_pos + 1), ' ')), '"');
|
value = string_util::trim(forward<string>(string_util::trim(line.substr(equal_pos + 1), ' ')), '"');
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ controller::make_type controller::make(string&& path_confwatch, bool enable_ipc,
|
||||||
* Construct controller object
|
* Construct controller object
|
||||||
*/
|
*/
|
||||||
controller::controller(connection& conn, signal_emitter& emitter, const logger& logger, const config& config,
|
controller::controller(connection& conn, signal_emitter& emitter, const logger& logger, const config& config,
|
||||||
unique_ptr<eventloop>&& eventloop, unique_ptr<bar>&& bar, unique_ptr<ipc>&& ipc, watch_t&& confwatch, bool writeback)
|
unique_ptr<eventloop>&& eventloop, unique_ptr<bar>&& bar, unique_ptr<ipc>&& ipc, watch_t&& confwatch,
|
||||||
|
bool writeback)
|
||||||
: m_connection(conn)
|
: m_connection(conn)
|
||||||
, m_sig(emitter)
|
, m_sig(emitter)
|
||||||
, m_log(logger)
|
, m_log(logger)
|
||||||
|
|
|
@ -20,8 +20,7 @@ using namespace signals::eventloop;
|
||||||
* Create instance
|
* Create instance
|
||||||
*/
|
*/
|
||||||
screen::make_type screen::make() {
|
screen::make_type screen::make() {
|
||||||
return factory_util::unique<screen>(
|
return factory_util::unique<screen>(connection::make(), signal_emitter::make(), logger::make(), config::make());
|
||||||
connection::make(), signal_emitter::make(), logger::make(), config::make());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "drawtypes/progressbar.hpp"
|
|
||||||
#include "drawtypes/label.hpp"
|
#include "drawtypes/label.hpp"
|
||||||
|
#include "drawtypes/progressbar.hpp"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <istream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
#include "modules/cpu.hpp"
|
#include "modules/cpu.hpp"
|
||||||
|
|
||||||
|
|
|
@ -199,13 +199,15 @@ namespace modules {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
using namespace i3_util;
|
||||||
|
|
||||||
string scrolldir;
|
string scrolldir;
|
||||||
const i3_util::connection_t conn{};
|
const connection_t conn{};
|
||||||
|
|
||||||
if (cmd.compare(0, strlen(EVENT_CLICK), EVENT_CLICK) == 0) {
|
if (cmd.compare(0, strlen(EVENT_CLICK), EVENT_CLICK) == 0) {
|
||||||
const string workspace_num{cmd.substr(strlen(EVENT_CLICK))};
|
const string workspace_num{cmd.substr(strlen(EVENT_CLICK))};
|
||||||
|
|
||||||
if (i3_util::focused_workspace(conn)->num != atoi(workspace_num.c_str())) {
|
if (focused_workspace(conn)->num != atoi(workspace_num.c_str())) {
|
||||||
m_log.info("%s: Sending workspace focus command to ipc handler", name());
|
m_log.info("%s: Sending workspace focus command to ipc handler", name());
|
||||||
conn.send_command("workspace number " + workspace_num);
|
conn.send_command("workspace number " + workspace_num);
|
||||||
}
|
}
|
||||||
|
@ -217,12 +219,14 @@ namespace modules {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrolldir == "next" && (m_wrap || *i3_util::workspaces(conn, m_bar.monitor->name).back() != *i3_util::focused_workspace(conn))) {
|
const string& mon_name{m_bar.monitor->name};
|
||||||
|
|
||||||
|
if (scrolldir == "next" && (m_wrap || *workspaces(conn, mon_name).back() != *focused_workspace(conn))) {
|
||||||
m_log.info("%s: Sending workspace next command to ipc handler", name());
|
m_log.info("%s: Sending workspace next command to ipc handler", name());
|
||||||
i3_util::connection_t{}.send_command("workspace next_on_output");
|
conn.send_command("workspace next_on_output");
|
||||||
} else if (scrolldir == "prev" && (m_wrap || *i3_util::workspaces(conn, m_bar.monitor->name).front() != *i3_util::focused_workspace(conn))) {
|
} else if (scrolldir == "prev" && (m_wrap || *workspaces(conn, mon_name).front() != *focused_workspace(conn))) {
|
||||||
m_log.info("%s: Sending workspace prev command to ipc handler", name());
|
m_log.info("%s: Sending workspace prev command to ipc handler", name());
|
||||||
i3_util::connection_t{}.send_command("workspace prev_on_output");
|
conn.send_command("workspace prev_on_output");
|
||||||
}
|
}
|
||||||
} catch (const exception& err) {
|
} catch (const exception& err) {
|
||||||
m_log.err("%s: %s", name(), err.what());
|
m_log.err("%s: %s", name(), err.what());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <istream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
#include "modules/memory.hpp"
|
#include "modules/memory.hpp"
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,6 @@ namespace modules {
|
||||||
m_output += m_ellipsis ? "..." : "";
|
m_output += m_ellipsis ? "..." : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto counter_str = to_string(m_counter);
|
auto counter_str = to_string(m_counter);
|
||||||
string output{module::get_output()};
|
string output{module::get_output()};
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ namespace modules {
|
||||||
* Construct module
|
* Construct module
|
||||||
*/
|
*/
|
||||||
xbacklight_module::xbacklight_module(const bar_settings& bar, string name)
|
xbacklight_module::xbacklight_module(const bar_settings& bar, string name)
|
||||||
: static_module<xbacklight_module>(bar, move(name))
|
: static_module<xbacklight_module>(bar, move(name)), m_connection(connection::make()) {}
|
||||||
, m_connection(connection::make()) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap the module by grabbing all required components
|
* Bootstrap the module by grabbing all required components
|
||||||
|
|
|
@ -20,10 +20,8 @@ namespace modules {
|
||||||
/**
|
/**
|
||||||
* Construct module
|
* Construct module
|
||||||
*/
|
*/
|
||||||
xworkspaces_module::xworkspaces_module(
|
xworkspaces_module::xworkspaces_module(const bar_settings& bar, string name)
|
||||||
const bar_settings& bar, string name)
|
: static_module<xworkspaces_module>(bar, move(name)), m_connection(connection::make()) {}
|
||||||
: static_module<xworkspaces_module>(bar, move(name))
|
|
||||||
, m_connection(connection::make()) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap the module
|
* Bootstrap the module
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace command_util {
|
namespace command_util {
|
||||||
command::command(const logger& logger, string cmd) : m_log(logger), m_cmd(cmd) {
|
command::command(const logger& logger, string cmd) : m_log(logger), m_cmd(move(cmd)) {
|
||||||
if (pipe(m_stdin) != 0) {
|
if (pipe(m_stdin) != 0) {
|
||||||
throw command_strerror("Failed to allocate input stream");
|
throw command_strerror("Failed to allocate input stream");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
#include <cstring>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "utils/env.hpp"
|
#include "utils/env.hpp"
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace inotify_util {
|
namespace inotify_util {
|
||||||
|
/**
|
||||||
|
* Construct instance
|
||||||
|
*/
|
||||||
|
inotify_watch::inotify_watch(string path) : m_path(move(path)) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +116,7 @@ namespace inotify_util {
|
||||||
}
|
}
|
||||||
|
|
||||||
watch_t make_watch(string path) {
|
watch_t make_watch(string path) {
|
||||||
return watch_t{new watch_t::element_type{path}};
|
return make_unique<watch_t::element_type>(move(path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace process_util {
|
||||||
* Execute command using shell
|
* Execute command using shell
|
||||||
*/
|
*/
|
||||||
void exec_sh(const char* cmd) {
|
void exec_sh(const char* cmd) {
|
||||||
static const string shell{env_util::get("SHELL", "/bin/sh").c_str()};
|
static const string shell{env_util::get("SHELL", "/bin/sh")};
|
||||||
|
|
||||||
if (cmd != nullptr) {
|
if (cmd != nullptr) {
|
||||||
execlp(shell.c_str(), shell.c_str(), "-c", cmd, nullptr);
|
execlp(shell.c_str(), shell.c_str(), "-c", cmd, nullptr);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <utility>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "utils/color.hpp"
|
#include "utils/color.hpp"
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ewmh_util {
|
||||||
ewmh_connection_t initialize() {
|
ewmh_connection_t initialize() {
|
||||||
if (!g_ewmh_connection) {
|
if (!g_ewmh_connection) {
|
||||||
g_ewmh_connection = memory_util::make_malloc_ptr<xcb_ewmh_connection_t>(
|
g_ewmh_connection = memory_util::make_malloc_ptr<xcb_ewmh_connection_t>(
|
||||||
sizeof(xcb_ewmh_connection_t), bind(xcb_ewmh_connection_wipe, std::placeholders::_1));
|
sizeof(xcb_ewmh_connection_t), [=](xcb_ewmh_connection_t* c) { xcb_ewmh_connection_wipe(c); });
|
||||||
|
|
||||||
auto* conn = g_ewmh_connection.get();
|
auto* conn = g_ewmh_connection.get();
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,15 @@ POLYBAR_NS
|
||||||
* Create window and check for errors
|
* Create window and check for errors
|
||||||
*/
|
*/
|
||||||
window window::create_checked(int16_t x, int16_t y, uint16_t w, uint16_t h, uint32_t mask, const xcb_params_cw_t* p) {
|
window window::create_checked(int16_t x, int16_t y, uint16_t w, uint16_t h, uint32_t mask, const xcb_params_cw_t* p) {
|
||||||
auto conn = connection();
|
|
||||||
|
|
||||||
if (*this == XCB_NONE) {
|
if (*this == XCB_NONE) {
|
||||||
*this = conn.generate_id();
|
*this = connection().generate_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto root = conn.screen()->root;
|
auto root = connection().screen()->root;
|
||||||
auto copy = XCB_COPY_FROM_PARENT;
|
auto copy = XCB_COPY_FROM_PARENT;
|
||||||
uint32_t values[16]{0};
|
uint32_t values[16]{0};
|
||||||
xutils::pack_values(mask, p, values);
|
xutils::pack_values(mask, p, values);
|
||||||
conn.create_window_checked(copy, *this, root, x, y, w, h, 0, copy, copy, mask, values);
|
connection().create_window_checked(copy, *this, root, x, y, w, h, 0, copy, copy, mask, values);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -85,8 +83,6 @@ window window::reconfigure_pos(int16_t x, int16_t y) {
|
||||||
* Reconfigure the windows ewmh strut
|
* Reconfigure the windows ewmh strut
|
||||||
*/
|
*/
|
||||||
window window::reconfigure_struts(uint16_t w, uint16_t h, int16_t x, bool bottom) {
|
window window::reconfigure_struts(uint16_t w, uint16_t h, int16_t x, bool bottom) {
|
||||||
auto& conn = connection();
|
|
||||||
|
|
||||||
uint32_t none{0};
|
uint32_t none{0};
|
||||||
uint32_t values[12]{none};
|
uint32_t values[12]{none};
|
||||||
|
|
||||||
|
@ -100,8 +96,9 @@ window window::reconfigure_struts(uint16_t w, uint16_t h, int16_t x, bool bottom
|
||||||
values[static_cast<int>(strut::TOP_END_X)] = x + w - 1;
|
values[static_cast<int>(strut::TOP_END_X)] = x + w - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.change_property_checked(XCB_PROP_MODE_REPLACE, *this, _NET_WM_STRUT, XCB_ATOM_CARDINAL, 32, 4, values);
|
connection().change_property_checked(XCB_PROP_MODE_REPLACE, *this, _NET_WM_STRUT, XCB_ATOM_CARDINAL, 32, 4, values);
|
||||||
conn.change_property_checked(XCB_PROP_MODE_REPLACE, *this, _NET_WM_STRUT_PARTIAL, XCB_ATOM_CARDINAL, 32, 12, values);
|
connection().change_property_checked(
|
||||||
|
XCB_PROP_MODE_REPLACE, *this, _NET_WM_STRUT_PARTIAL, XCB_ATOM_CARDINAL, 32, 12, values);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -110,10 +107,9 @@ window window::reconfigure_struts(uint16_t w, uint16_t h, int16_t x, bool bottom
|
||||||
* Trigger redraw by toggling visibility state
|
* Trigger redraw by toggling visibility state
|
||||||
*/
|
*/
|
||||||
void window::redraw() {
|
void window::redraw() {
|
||||||
auto conn = connection();
|
xutils::visibility_notify(connection(), *this, XCB_VISIBILITY_FULLY_OBSCURED);
|
||||||
xutils::visibility_notify(conn, *this, XCB_VISIBILITY_FULLY_OBSCURED);
|
xutils::visibility_notify(connection(), *this, XCB_VISIBILITY_UNOBSCURED);
|
||||||
xutils::visibility_notify(conn, *this, XCB_VISIBILITY_UNOBSCURED);
|
connection().flush();
|
||||||
conn.flush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
|
|
@ -101,9 +101,8 @@ namespace xkb_util {
|
||||||
|
|
||||||
xcb_xkb_get_names_value_list_t values;
|
xcb_xkb_get_names_value_list_t values;
|
||||||
void* buffer = xcb_xkb_get_names_value_list(reply);
|
void* buffer = xcb_xkb_get_names_value_list(reply);
|
||||||
xcb_xkb_get_names_value_list_unpack(buffer, reply->nTypes, reply->indicators,
|
xcb_xkb_get_names_value_list_unpack(buffer, reply->nTypes, reply->indicators, reply->virtualMods, reply->groupNames,
|
||||||
reply->virtualMods, reply->groupNames, reply->nKeys, reply->nKeyAliases, reply->nRadioGroups, reply->which,
|
reply->nKeys, reply->nKeyAliases, reply->nRadioGroups, reply->which, &values);
|
||||||
&values);
|
|
||||||
|
|
||||||
vector<reply::get_atom_name> replies;
|
vector<reply::get_atom_name> replies;
|
||||||
for (int i = 0; i < xcb_xkb_get_names_value_list_groups_length(reply, &values); i++) {
|
for (int i = 0; i < xcb_xkb_get_names_value_list_groups_length(reply, &values); i++) {
|
||||||
|
@ -143,9 +142,8 @@ namespace xkb_util {
|
||||||
|
|
||||||
xcb_xkb_get_names_value_list_t values;
|
xcb_xkb_get_names_value_list_t values;
|
||||||
void* buffer = xcb_xkb_get_names_value_list(reply);
|
void* buffer = xcb_xkb_get_names_value_list(reply);
|
||||||
xcb_xkb_get_names_value_list_unpack(buffer, reply->nTypes, reply->indicators,
|
xcb_xkb_get_names_value_list_unpack(buffer, reply->nTypes, reply->indicators, reply->virtualMods, reply->groupNames,
|
||||||
reply->virtualMods, reply->groupNames, reply->nKeys, reply->nKeyAliases, reply->nRadioGroups, reply->which,
|
reply->nKeys, reply->nKeyAliases, reply->nRadioGroups, reply->which, &values);
|
||||||
&values);
|
|
||||||
|
|
||||||
map<xcb_atom_t, reply::get_atom_name> entries;
|
map<xcb_atom_t, reply::get_atom_name> entries;
|
||||||
for (int i = 0; i < xcb_xkb_get_names_value_list_indicator_names_length(reply, &values); i++) {
|
for (int i = 0; i < xcb_xkb_get_names_value_list_indicator_names_length(reply, &values); i++) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace xlib {
|
||||||
if (!g_visual_ptr) {
|
if (!g_visual_ptr) {
|
||||||
XVisualInfo info;
|
XVisualInfo info;
|
||||||
if (XMatchVisualInfo(get_display().get(), screen, 32, TrueColor, &info)) {
|
if (XMatchVisualInfo(get_display().get(), screen, 32, TrueColor, &info)) {
|
||||||
g_visual_ptr = shared_ptr<Visual>(info.visual, bind(XFree, placeholders::_1));
|
g_visual_ptr = shared_ptr<Visual>(info.visual, [=](Visual* v) { XFree(v); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ namespace xutils {
|
||||||
|
|
||||||
if (dsp) {
|
if (dsp) {
|
||||||
XSetEventQueueOwner(dsp.get(), XCBOwnsEventQueue);
|
XSetEventQueueOwner(dsp.get(), XCBOwnsEventQueue);
|
||||||
g_connection_ptr = shared_ptr<xcb_connection_t>(XGetXCBConnection(dsp.get()), bind(xcb_disconnect, placeholders::_1));
|
g_connection_ptr =
|
||||||
|
shared_ptr<xcb_connection_t>(XGetXCBConnection(dsp.get()), [=](xcb_connection_t* c) { xcb_disconnect(c); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue