From 452afcdc68bc0ffa3d62c668d9928d7529047988 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Thu, 19 Jan 2017 11:11:28 +0100 Subject: [PATCH] refactor: Integral types --- include/cairo/context.hpp | 20 +++--- include/cairo/types.hpp | 4 +- include/cairo/utils.hpp | 2 +- include/components/bar.hpp | 2 +- include/components/builder.hpp | 4 +- include/components/controller.hpp | 2 +- include/components/logger.hpp | 2 +- include/components/parser.hpp | 8 +-- include/components/renderer.hpp | 16 ++--- include/components/types.hpp | 66 +++++++++--------- include/events/signal.hpp | 20 +++--- include/events/signal_emitter.hpp | 4 +- include/events/signal_fwd.hpp | 2 +- include/events/signal_receiver.hpp | 4 +- include/events/types.hpp | 20 +++--- include/modules/bspwm.hpp | 4 +- include/utils/color.hpp | 84 +++++++++++------------ include/x11/connection.hpp | 18 ++--- include/x11/draw.hpp | 2 +- include/x11/ewmh.hpp | 4 +- include/x11/extensions/randr.hpp | 12 ++-- include/x11/extensions/xkb.hpp | 16 ++--- include/x11/graphics.hpp | 16 ++--- include/x11/tray_client.hpp | 14 ++-- include/x11/tray_manager.hpp | 46 ++++++------- include/x11/window.hpp | 12 ++-- include/x11/winspec.hpp | 106 ++++++++++++++--------------- include/x11/wm.hpp | 4 +- src/components/bar.cpp | 32 ++++----- src/components/builder.cpp | 16 ++--- src/components/config.cpp | 10 +-- src/components/parser.cpp | 8 +-- src/components/renderer.cpp | 30 ++++---- src/drawtypes/label.cpp | 2 +- src/drawtypes/progressbar.cpp | 4 +- src/main.cpp | 2 +- src/modules/bspwm.cpp | 28 ++++---- src/modules/xwindow.cpp | 4 +- src/modules/xworkspaces.cpp | 22 +++--- src/utils/bspwm.cpp | 4 +- src/utils/i3.cpp | 4 +- src/x11/connection.cpp | 24 +++---- src/x11/draw.cpp | 2 +- src/x11/ewmh.cpp | 8 +-- src/x11/extensions/randr.cpp | 8 +-- src/x11/extensions/xkb.cpp | 16 ++--- src/x11/graphics.cpp | 10 +-- src/x11/tray_client.cpp | 16 ++--- src/x11/tray_manager.cpp | 50 +++++++------- src/x11/window.cpp | 28 ++++---- src/x11/winspec.cpp | 2 +- src/x11/wm.cpp | 6 +- src/x11/xembed.cpp | 2 +- tests/unit_tests/utils/color.cpp | 36 +++++----- tests/unit_tests/utils/math.cpp | 4 +- tests/unit_tests/x11/color.cpp | 26 +++---- 56 files changed, 460 insertions(+), 458 deletions(-) diff --git a/include/cairo/context.hpp b/include/cairo/context.hpp index 8a5a1467..c9326ab4 100644 --- a/include/cairo/context.hpp +++ b/include/cairo/context.hpp @@ -51,13 +51,13 @@ namespace cairo { return *this; } - context& operator<<(const uint32_t& c) { + context& operator<<(const unsigned int& c) { // clang-format off cairo_set_source_rgba(m_c, - color_util::red_channel(c) / 255.0, - color_util::green_channel(c) / 255.0, - color_util::blue_channel(c) / 255.0, - color_util::alpha_channel(c) / 255.0); + color_util::red_channel(c) / 255.0, + color_util::green_channel(c) / 255.0, + color_util::blue_channel(c) / 255.0, + color_util::alpha_channel(c) / 255.0); // clang-format on return *this; } @@ -105,10 +105,10 @@ namespace cairo { for (auto&& color : l.steps) { // clang-format off cairo_pattern_add_color_stop_rgba(pattern, offset, - color_util::red_channel(color) / 255.0, - color_util::green_channel(color) / 255.0, - color_util::blue_channel(color) / 255.0, - color_util::alpha_channel(color) / 255.0); + color_util::red_channel(color) / 255.0, + color_util::green_channel(color) / 255.0, + color_util::blue_channel(color) / 255.0, + color_util::alpha_channel(color) / 255.0); // clang-format on offset += step; } @@ -130,7 +130,7 @@ namespace cairo { string utf8 = string(t.contents); unicode_charlist chars; - utils::utf8_to_ucs4((const uint8_t*)utf8.c_str(), chars); + utils::utf8_to_ucs4((const unsigned char*)utf8.c_str(), chars); while (!chars.empty()) { auto remaining = chars.size(); diff --git a/include/cairo/types.hpp b/include/cairo/types.hpp index 72ebcc9a..5313d986 100644 --- a/include/cairo/types.hpp +++ b/include/cairo/types.hpp @@ -34,12 +34,12 @@ namespace cairo { double y0; double x1; double y1; - vector steps; + vector steps; }; struct textblock { string contents; - uint8_t fontindex; + unsigned char fontindex; }; } diff --git a/include/cairo/utils.hpp b/include/cairo/utils.hpp index 6d4a353a..6a2fbf38 100644 --- a/include/cairo/utils.hpp +++ b/include/cairo/utils.hpp @@ -98,7 +98,7 @@ namespace cairo { /** * @brief Convert a UCS-4 codepoint to a utf-8 encoded string */ - size_t ucs4_to_utf8(char* utf8, uint32_t ucs) { + size_t ucs4_to_utf8(char* utf8, unsigned int ucs) { if (ucs <= 0x7f) { *utf8 = ucs; return 1; diff --git a/include/components/bar.hpp b/include/components/bar.hpp index 040f9c10..3d37923a 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -81,7 +81,7 @@ class bar : public xpp::event::sink m_dblclicks{false}; mousebtn m_buttonpress_btn{mousebtn::NONE}; - int16_t m_buttonpress_pos{0}; + int m_buttonpress_pos{0}; event_timer m_buttonpress{0L, 5L}; event_timer m_doubleclick{0L, 150L}; diff --git a/include/components/builder.hpp b/include/components/builder.hpp index 646c71f1..4a5b8066 100644 --- a/include/components/builder.hpp +++ b/include/components/builder.hpp @@ -71,8 +71,8 @@ class builder { map m_tags{}; map m_colors{}; - uint8_t m_attributes{0}; - uint8_t m_fontindex{0}; + int m_attributes{0}; + int m_fontindex{0}; string m_background{}; string m_foreground{}; diff --git a/include/components/controller.hpp b/include/components/controller.hpp index d166c9b8..e3b7ddea 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -16,7 +16,7 @@ POLYBAR_NS // fwd decl {{{ -enum class alignment : uint8_t; +enum class alignment; class bar; class command; class config; diff --git a/include/components/logger.hpp b/include/components/logger.hpp index ee550624..790e945f 100644 --- a/include/components/logger.hpp +++ b/include/components/logger.hpp @@ -17,7 +17,7 @@ POLYBAR_NS -enum class loglevel : uint8_t { +enum class loglevel { NONE = 0, ERROR, WARNING, diff --git a/include/components/parser.hpp b/include/components/parser.hpp index c5690df3..8aeba5c0 100644 --- a/include/components/parser.hpp +++ b/include/components/parser.hpp @@ -6,8 +6,8 @@ POLYBAR_NS class signal_emitter; -enum class attribute : uint8_t; -enum class mousebtn : uint8_t; +enum class attribute; +enum class mousebtn; struct bar_settings; DEFINE_ERROR(parser_error); @@ -28,8 +28,8 @@ class parser { void codeblock(string&& data, const bar_settings& bar); size_t text(string&& data); - uint32_t parse_color(const string& s, uint32_t fallback = 0); - uint8_t parse_fontindex(const string& s); + unsigned int parse_color(const string& s, unsigned int fallback = 0); + int parse_fontindex(const string& s); attribute parse_attr(const char attr); mousebtn parse_action_btn(const string& data); string parse_action_cmd(string&& data); diff --git a/include/components/renderer.hpp b/include/components/renderer.hpp index a8bd8c09..8b97e0d1 100644 --- a/include/components/renderer.hpp +++ b/include/components/renderer.hpp @@ -42,7 +42,7 @@ class renderer void end(); void flush(); - void reserve_space(edge side, uint16_t w); + void reserve_space(edge side, unsigned int w); void fill_background(); void fill_overline(double x, double w); void fill_underline(double x, double w); @@ -70,7 +70,7 @@ class renderer protected: struct reserve_area { edge side{edge::NONE}; - uint16_t size{0U}; + unsigned int size{0U}; }; private: @@ -83,7 +83,7 @@ class renderer xcb_rectangle_t m_rect{0, 0, 0U, 0U}; reserve_area m_cleararea{}; - uint8_t m_depth{32}; + int m_depth{32}; xcb_window_t m_window; xcb_colormap_t m_colormap; xcb_visualtype_t* m_visual; @@ -106,12 +106,12 @@ class renderer alignment m_alignment{alignment::NONE}; std::bitset<2> m_attributes; - uint8_t m_fontindex; + int m_fontindex; - uint32_t m_color_background; - uint32_t m_color_foreground; - uint32_t m_color_overline; - uint32_t m_color_underline; + unsigned int m_color_background; + unsigned int m_color_foreground; + unsigned int m_color_overline; + unsigned int m_color_underline; double m_x{0.0}; double m_y{0.0}; diff --git a/include/components/types.hpp b/include/components/types.hpp index 28f6a1c7..7e20696d 100644 --- a/include/components/types.hpp +++ b/include/components/types.hpp @@ -21,14 +21,14 @@ struct enum_hash { } }; -enum class edge : uint8_t { NONE = 0U, TOP, BOTTOM, LEFT, RIGHT, ALL }; +enum class edge { NONE = 0, TOP, BOTTOM, LEFT, RIGHT, ALL }; -enum class alignment : uint8_t { NONE = 0U, LEFT, CENTER, RIGHT }; +enum class alignment { NONE = 0, LEFT, CENTER, RIGHT }; -enum class attribute : uint8_t { NONE = 0U, UNDERLINE, OVERLINE }; +enum class attribute { NONE = 0, UNDERLINE, OVERLINE }; -enum class syntaxtag : uint8_t { - NONE = 0U, +enum class syntaxtag { + NONE = 0, A, // mouse action B, // background color F, // foreground color @@ -39,8 +39,8 @@ enum class syntaxtag : uint8_t { u, // underline color }; -enum class mousebtn : uint8_t { - NONE = 0U, +enum class mousebtn { + NONE = 0, LEFT, MIDDLE, RIGHT, @@ -51,8 +51,8 @@ enum class mousebtn : uint8_t { DOUBLE_RIGHT }; -enum class strut : uint16_t { - LEFT = 0U, +enum class strut { + LEFT = 0, RIGHT, TOP, BOTTOM, @@ -67,35 +67,35 @@ enum class strut : uint16_t { }; struct position { - int16_t x{0}; - int16_t y{0}; + int x{0}; + int y{0}; }; struct size { - uint16_t w{1U}; - uint16_t h{1U}; + unsigned int w{1U}; + unsigned int h{1U}; }; struct side_values { - uint16_t left{0U}; - uint16_t right{0U}; + unsigned int left{0U}; + unsigned int right{0U}; }; struct edge_values { - uint16_t left{0U}; - uint16_t right{0U}; - uint16_t top{0U}; - uint16_t bottom{0U}; + unsigned int left{0U}; + unsigned int right{0U}; + unsigned int top{0U}; + unsigned int bottom{0U}; }; struct border_settings { - uint32_t color{0xFF000000}; - uint16_t size{0U}; + unsigned int color{0xFF000000}; + unsigned int size{0U}; }; struct line_settings { - uint32_t color{0xFF000000}; - uint16_t size{0U}; + unsigned int color{0xFF000000}; + unsigned int size{0U}; }; struct action { @@ -109,12 +109,12 @@ struct action_block : public action { double end_x{0.0}; bool active{true}; - uint16_t width() const { - return static_cast(end_x - start_x + 0.5); + unsigned int width() const { + return static_cast(end_x - start_x + 0.5); } - bool test(int16_t point) const { - return static_cast(start_x) < point && static_cast(end_x) >= point; + bool test(int point) const { + return static_cast(start_x) < point && static_cast(end_x) >= point; } }; @@ -136,16 +136,16 @@ struct bar_settings { side_values module_margin{0U, 0U}; edge_values strut{0U, 0U, 0U, 0U}; - uint32_t background{0xFF000000}; - uint32_t foreground{0xFFFFFFFF}; - vector background_steps; + unsigned int background{0xFF000000}; + unsigned int foreground{0xFFFFFFFF}; + vector background_steps; line_settings underline{}; line_settings overline{}; std::unordered_map borders{}; - uint8_t spacing{0}; + int spacing{0}; string separator{}; string wmname{}; @@ -165,7 +165,9 @@ struct bar_settings { position shade_pos{1U, 1U}; 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, 0, 0}; + rect.width += size.w; + rect.height += size.h; if (abspos) { rect.x = pos.x; diff --git a/include/events/signal.hpp b/include/events/signal.hpp index 4138ddcd..6e8cd316 100644 --- a/include/events/signal.hpp +++ b/include/events/signal.hpp @@ -10,10 +10,10 @@ POLYBAR_NS // fwd -enum class mousebtn : uint8_t; -enum class syntaxtag : uint8_t; -enum class alignment : uint8_t; -enum class attribute : uint8_t; +enum class mousebtn; +enum class syntaxtag; +enum class alignment; +enum class attribute; namespace signals { namespace detail { @@ -120,25 +120,25 @@ namespace signals { } namespace parser { - struct change_background : public detail::value_signal { + struct change_background : public detail::value_signal { using base_type::base_type; }; - struct change_foreground : public detail::value_signal { + struct change_foreground : public detail::value_signal { using base_type::base_type; }; - struct change_underline : public detail::value_signal { + struct change_underline : public detail::value_signal { using base_type::base_type; }; - struct change_overline : public detail::value_signal { + struct change_overline : public detail::value_signal { using base_type::base_type; }; - struct change_font : public detail::value_signal { + struct change_font : public detail::value_signal { using base_type::base_type; }; struct change_alignment : public detail::value_signal { using base_type::base_type; }; - struct offset_pixel : public detail::value_signal { + struct offset_pixel : public detail::value_signal { using base_type::base_type; }; struct attribute_set : public detail::value_signal { diff --git a/include/events/signal_emitter.hpp b/include/events/signal_emitter.hpp index f651c6e4..2a260032 100644 --- a/include/events/signal_emitter.hpp +++ b/include/events/signal_emitter.hpp @@ -41,12 +41,12 @@ class signal_emitter { return emit(sig) || emit(sig); } - template + template void attach(signal_receiver* s) { attach, Signal, Signals...>(s); } - template + template void detach(signal_receiver* s) { detach, Signal, Signals...>(s); } diff --git a/include/events/signal_fwd.hpp b/include/events/signal_fwd.hpp index 796fc45f..bae459f2 100644 --- a/include/events/signal_fwd.hpp +++ b/include/events/signal_fwd.hpp @@ -6,7 +6,7 @@ POLYBAR_NS class signal_emitter; class signal_receiver_interface; -template +template class signal_receiver; namespace signals { diff --git a/include/events/signal_receiver.hpp b/include/events/signal_receiver.hpp index 2b584f13..9f2a8055 100644 --- a/include/events/signal_receiver.hpp +++ b/include/events/signal_receiver.hpp @@ -11,7 +11,7 @@ POLYBAR_NS class signal_receiver_interface { public: - using prio = unsigned int; + using prio = int; using prio_map = std::multimap; virtual ~signal_receiver_interface() {} virtual prio priority() const = 0; @@ -37,7 +37,7 @@ bool signal_receiver_interface::on(const Signal& s) { } } -template +template class signal_receiver : public signal_receiver_interface, public signal_receiver_impl, public signal_receiver_impl... { diff --git a/include/events/types.hpp b/include/events/types.hpp index 2908cfe2..22e4fe14 100644 --- a/include/events/types.hpp +++ b/include/events/types.hpp @@ -6,7 +6,7 @@ POLYBAR_NS -enum class event_type : uint8_t { +enum class event_type { NONE = 0, UPDATE, CHECK, @@ -15,44 +15,44 @@ enum class event_type : uint8_t { }; struct event { - uint8_t type{0}; + int type{0}; bool flag{false}; }; namespace { - inline bool operator==(uint8_t id, event_type type) { - return id == static_cast(type); + inline bool operator==(int id, event_type type) { + return id == static_cast(type); } - inline bool operator!=(uint8_t id, event_type type) { - return !(id == static_cast(type)); + inline bool operator!=(int id, event_type type) { + return !(id == static_cast(type)); } /** * Create QUIT event */ inline event make_quit_evt(bool reload = false) { - return event{static_cast(event_type::QUIT), reload}; + return event{static_cast(event_type::QUIT), reload}; } /** * Create UPDATE event */ inline event make_update_evt(bool force = false) { - return event{static_cast(event_type::UPDATE), force}; + return event{static_cast(event_type::UPDATE), force}; } /** * Create INPUT event */ inline event make_input_evt() { - return event{static_cast(event_type::INPUT)}; + return event{static_cast(event_type::INPUT)}; } /** * Create CHECK event */ inline event make_check_evt() { - return event{static_cast(event_type::CHECK)}; + return event{static_cast(event_type::CHECK)}; } } diff --git a/include/modules/bspwm.hpp b/include/modules/bspwm.hpp index 360619e0..5e9a07be 100644 --- a/include/modules/bspwm.hpp +++ b/include/modules/bspwm.hpp @@ -31,7 +31,7 @@ namespace modules { }; struct bspwm_monitor { - vector> workspaces; + vector> workspaces; vector modes; label_t label; string name; @@ -69,7 +69,7 @@ namespace modules { vector> m_monitors; map m_modelabels; - map m_statelabels; + map m_statelabels; label_t m_monitorlabel; iconset_t m_icons; diff --git a/include/utils/color.hpp b/include/utils/color.hpp index f39741e2..6c0c6752 100644 --- a/include/utils/color.hpp +++ b/include/utils/color.hpp @@ -5,50 +5,50 @@ POLYBAR_NS -static cache g_cache_hex; -static cache g_cache_colors; +static cache g_cache_hex; +static cache g_cache_colors; struct rgba; namespace color_util { - template - T alpha_channel(const uint32_t value) { - uint8_t a = value >> 24; - if (std::is_same::value) + template + T alpha_channel(const unsigned int value) { + unsigned char a = value >> 24; + if (std::is_same::value) return a << 8 / 0xff; - else if (std::is_same::value) + else if (std::is_same::value) return a << 8 | a << 8 / 0xff; } - template - T red_channel(const uint32_t value) { - uint8_t r = value >> 16; - if (std::is_same::value) + template + T red_channel(const unsigned int value) { + unsigned char r = value >> 16; + if (std::is_same::value) return r << 8 / 0xff; - else if (std::is_same::value) + else if (std::is_same::value) return r << 8 | r << 8 / 0xff; } - template - T green_channel(const uint32_t value) { - uint8_t g = value >> 8; - if (std::is_same::value) + template + T green_channel(const unsigned int value) { + unsigned char g = value >> 8; + if (std::is_same::value) return g << 8 / 0xff; - else if (std::is_same::value) + else if (std::is_same::value) return g << 8 | g << 8 / 0xff; } - template - T blue_channel(const uint32_t value) { - uint8_t b = value; - if (std::is_same::value) + template + T blue_channel(const unsigned int value) { + unsigned char b = value; + if (std::is_same::value) return b << 8 / 0xff; - else if (std::is_same::value) + else if (std::is_same::value) return b << 8 | b << 8 / 0xff; } - template - uint32_t premultiply_alpha(const T value) { + template + unsigned int premultiply_alpha(const T value) { auto a = color_util::alpha_channel(value); auto r = color_util::red_channel(value) * a / 255; auto g = color_util::green_channel(value) * a / 255; @@ -57,21 +57,21 @@ namespace color_util { } template - string hex(uint32_t color) { + string hex(unsigned int color) { string hex; if (!g_cache_hex.check(color)) { char s[12]; size_t len = 0; - uint8_t a = alpha_channel(color); - uint8_t r = red_channel(color); - uint8_t g = green_channel(color); - uint8_t b = blue_channel(color); + unsigned char a = alpha_channel(color); + unsigned char r = red_channel(color); + unsigned char g = green_channel(color); + unsigned char b = blue_channel(color); - if (std::is_same::value) { + if (std::is_same::value) { len = snprintf(s, sizeof(s), "#%02x%02x%02x%02x", a, r, g, b); - } else if (std::is_same::value) { + } else if (std::is_same::value) { len = snprintf(s, sizeof(s), "#%02x%02x%02x", r, g, b); } @@ -93,7 +93,7 @@ namespace color_util { return hex; } - inline uint32_t parse(string hex, uint32_t fallback = 0) { + inline unsigned int parse(string hex, unsigned int fallback = 0) { if ((hex = parse_hex(hex)).empty()) return fallback; return strtoul(&hex[1], nullptr, 16); @@ -123,10 +123,10 @@ struct rgb { // clang-format off explicit rgb(double r, double g, double b) : r(r), g(g), b(b) {} - explicit rgb(uint32_t color) : rgb( - color_util::red_channel(color_util::premultiply_alpha(color) / 255.0), - color_util::green_channel(color_util::premultiply_alpha(color) / 255.0), - color_util::blue_channel(color_util::premultiply_alpha(color) / 255.0)) {} + explicit rgb(unsigned int color) : rgb( + color_util::red_channel(color_util::premultiply_alpha(color) / 255.0), + color_util::green_channel(color_util::premultiply_alpha(color) / 255.0), + color_util::blue_channel(color_util::premultiply_alpha(color) / 255.0)) {} // clang-format on }; @@ -138,14 +138,14 @@ struct rgba { // clang-format off explicit rgba(double r, double g, double b, double a) : r(r), g(g), b(b), a(a) {} - explicit rgba(uint32_t color) : rgba( - color_util::red_channel(color) / 255.0, - color_util::green_channel(color) / 255.0, - color_util::blue_channel(color) / 255.0, - color_util::alpha_channel(color) / 255.0) {} + explicit rgba(unsigned int color) : rgba( + color_util::red_channel(color) / 255.0, + color_util::green_channel(color) / 255.0, + color_util::blue_channel(color) / 255.0, + color_util::alpha_channel(color) / 255.0) {} // clang-format on - operator uint32_t() { + operator unsigned int() { // clang-format off return static_cast(a * 255) << 24 | static_cast(r * 255) << 16 diff --git a/include/x11/connection.hpp b/include/x11/connection.hpp index 1d72258a..fbd9f091 100644 --- a/include/x11/connection.hpp +++ b/include/x11/connection.hpp @@ -125,23 +125,23 @@ class connection : public detail::connection_base make_client_message(xcb_atom_t type, xcb_window_t target) const; void send_client_message(const shared_ptr& message, xcb_window_t target, - uint32_t event_mask = 0xFFFFFF, bool propagate = false) const; + unsigned int event_mask = 0xFFFFFF, bool propagate = false) const; xcb_visualtype_t* visual_type(xcb_screen_t* screen, int match_depth = 32); @@ -149,7 +149,7 @@ class connection : public detail::connection_base& evt) const; - template + template void wait_for_response(function check_event) { int fd = get_file_descriptor(); shared_ptr evt{}; @@ -182,7 +182,7 @@ class connection : public detail::connection_base m_visual; + map m_visual; registry m_registry{*this}; xcb_screen_t* m_screen{nullptr}; }; diff --git a/include/x11/draw.hpp b/include/x11/draw.hpp index 151fb485..7f77a064 100644 --- a/include/x11/draw.hpp +++ b/include/x11/draw.hpp @@ -8,7 +8,7 @@ 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, int16_t x, int16_t y, uint16_t w, uint16_t h); + 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 diff --git a/include/x11/ewmh.hpp b/include/x11/ewmh.hpp index 02d10a3c..02970ca6 100644 --- a/include/x11/ewmh.hpp +++ b/include/x11/ewmh.hpp @@ -23,10 +23,10 @@ namespace ewmh_util { vector get_desktop_viewports(xcb_ewmh_connection_t* conn, int screen = 0); vector get_desktop_names(xcb_ewmh_connection_t* conn, int screen = 0); - uint32_t get_current_desktop(xcb_ewmh_connection_t* conn, int screen = 0); + unsigned int get_current_desktop(xcb_ewmh_connection_t* conn, int screen = 0); xcb_window_t get_active_window(xcb_ewmh_connection_t* conn, int screen = 0); - void change_current_desktop(xcb_ewmh_connection_t* conn, uint32_t desktop); + void change_current_desktop(xcb_ewmh_connection_t* conn, unsigned int desktop); } POLYBAR_NS_END diff --git a/include/x11/extensions/randr.hpp b/include/x11/extensions/randr.hpp index 6f891ede..8c9ea967 100644 --- a/include/x11/extensions/randr.hpp +++ b/include/x11/extensions/randr.hpp @@ -22,7 +22,7 @@ namespace evt { } struct backlight_values { - uint32_t atom{0}; + unsigned int atom{0}; double min{0.0}; double max{0.0}; double val{0.0}; @@ -30,10 +30,10 @@ struct backlight_values { struct randr_output { string name; - uint16_t w{0U}; - uint16_t h{0U}; - int16_t x{0}; - int16_t y{0}; + unsigned short int w{0U}; + unsigned short int h{0U}; + short int x{0}; + short int y{0}; xcb_randr_output_t output; backlight_values backlight; @@ -48,7 +48,7 @@ namespace randr_util { bool check_monitor_support(); - monitor_t make_monitor(xcb_randr_output_t randr, string name, uint16_t w, uint16_t h, int16_t x, int16_t 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); vector get_monitors(connection& conn, xcb_window_t root, bool connected_only = false, bool realloc = false); void get_backlight_range(connection& conn, const monitor_t& mon, backlight_values& dst); diff --git a/include/x11/extensions/xkb.hpp b/include/x11/extensions/xkb.hpp index ab5caa56..7ffcf42e 100644 --- a/include/x11/extensions/xkb.hpp +++ b/include/x11/extensions/xkb.hpp @@ -51,7 +51,7 @@ class keyboard { struct indicator { enum class type { NONE = 0U, CAPS_LOCK, NUM_LOCK }; xcb_atom_t atom{}; - uint8_t mask{0}; + unsigned char mask{0}; string name{}; bool enabled{false}; }; @@ -61,14 +61,14 @@ class keyboard { vector symbols{}; }; - explicit keyboard(vector&& layouts_, map&& indicators_, uint8_t group) + explicit keyboard(vector&& layouts_, map&& indicators_, unsigned char group) : layouts(forward(layouts_)), indicators(forward(indicators_)), current_group(group) {} const indicator& get(const indicator::type& i) const; - void set(uint32_t state); + void set(unsigned int state); bool on(const indicator::type&) const; - void current(uint8_t group); - uint8_t current() const; + void current(unsigned char group); + unsigned char current() const; const string group_name(size_t index = 0) const; const string layout_name(size_t index = 0) const; const string indicator_name(const indicator::type&) const; @@ -77,7 +77,7 @@ class keyboard { private: vector layouts; map indicators; - uint8_t current_group{0}; + unsigned char current_group{0}; }; namespace xkb_util { @@ -85,8 +85,8 @@ namespace xkb_util { void query_extension(connection& conn); - void switch_layout(connection& conn, xcb_xkb_device_spec_t device, uint8_t index); - uint8_t get_current_group(connection& conn, xcb_xkb_device_spec_t device); + void switch_layout(connection& conn, xcb_xkb_device_spec_t device, unsigned char index); + unsigned char get_current_group(connection& conn, xcb_xkb_device_spec_t device); vector get_layouts(connection& conn, xcb_xkb_device_spec_t device); map get_indicators(connection& conn, xcb_xkb_device_spec_t device); string parse_layout_symbol(string&& name); diff --git a/include/x11/graphics.hpp b/include/x11/graphics.hpp index 0899f3fc..ec03a306 100644 --- a/include/x11/graphics.hpp +++ b/include/x11/graphics.hpp @@ -9,18 +9,18 @@ POLYBAR_NS namespace graphics_util { struct root_pixmap { - uint8_t depth{0}; - uint16_t width{0}; - uint16_t height{0}; - int16_t x{0}; - int16_t y{0}; + unsigned char depth{0}; + unsigned short int width{0}; + unsigned short int height{0}; + short int x{0}; + short int y{0}; xcb_pixmap_t pixmap{0}; }; - bool create_window(connection& conn, xcb_window_t* win, int16_t x = 0, int16_t y = 0, uint16_t w = 1, uint16_t h = 1, + bool create_window(connection& conn, xcb_window_t* win, short int x = 0, short int y = 0, unsigned short int w = 1, unsigned short int h = 1, xcb_window_t root = 0); - bool create_pixmap(connection& conn, xcb_drawable_t dst, uint16_t w, uint16_t h, xcb_pixmap_t* pixmap); - bool create_pixmap(connection& conn, xcb_drawable_t dst, uint16_t w, uint16_t h, uint8_t d, 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); + 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_gc(connection& conn, xcb_drawable_t drawable, xcb_gcontext_t* gc); bool get_root_pixmap(connection& conn, root_pixmap* rpix); diff --git a/include/x11/tray_client.hpp b/include/x11/tray_client.hpp index 8cdc2d35..aae9b3f7 100644 --- a/include/x11/tray_client.hpp +++ b/include/x11/tray_client.hpp @@ -13,14 +13,14 @@ struct xembed_data; class tray_client { public: - explicit tray_client(connection& conn, xcb_window_t win, uint16_t w, uint16_t h); + explicit tray_client(connection& conn, xcb_window_t win, unsigned int w, unsigned int h); tray_client(const tray_client& c) = default; tray_client& operator=(tray_client& c) = default; ~tray_client(); - uint16_t width() const; - uint16_t height() const; + unsigned int width() const; + unsigned int height() const; void clear_window() const; bool match(const xcb_window_t& win) const; @@ -31,8 +31,8 @@ class tray_client { xembed_data* xembed() const; void ensure_state() const; - void reconfigure(int16_t x, int16_t y) const; - void configure_notify(int16_t x, int16_t y) const; + void reconfigure(int x, int y) const; + void configure_notify(int x, int y) const; protected: connection& m_connection; @@ -41,8 +41,8 @@ class tray_client { shared_ptr m_xembed; bool m_mapped{false}; - uint16_t m_width; - uint16_t m_height; + unsigned int m_width; + unsigned int m_height; }; POLYBAR_NS_END diff --git a/include/x11/tray_manager.hpp b/include/x11/tray_manager.hpp index e7a53220..060cc34c 100644 --- a/include/x11/tray_manager.hpp +++ b/include/x11/tray_manager.hpp @@ -43,21 +43,21 @@ struct tray_settings { tray_settings& operator=(const tray_settings& o) = default; alignment align{alignment::NONE}; - int16_t running{false}; - int16_t orig_x{0}; - int16_t orig_y{0}; - int16_t configured_x{0}; - int16_t configured_y{0}; - uint16_t configured_w{0}; - uint16_t configured_h{0}; - uint16_t configured_slots{0}; - uint16_t width{0}; - uint16_t width_max{0}; - uint16_t height{0}; - uint16_t height_fill{0}; - uint16_t spacing{0}; - uint32_t sibling{0}; - uint32_t background{0}; + bool running{false}; + int orig_x{0}; + int orig_y{0}; + int configured_x{0}; + int configured_y{0}; + unsigned int configured_w{0}; + unsigned int configured_h{0}; + unsigned int configured_slots{0}; + unsigned int width{0}; + unsigned int width_max{0}; + unsigned int height{0}; + unsigned int height_fill{0}; + unsigned int spacing{0}; + unsigned int sibling{0}; + unsigned int background{0}; bool transparent{false}; bool detached{false}; }; @@ -103,13 +103,13 @@ class tray_manager : public xpp::event::sink find_client(const xcb_window_t& win) const; @@ -143,8 +143,8 @@ class tray_manager : public xpp::event::sink { window& operator=(const xcb_window_t win); window create_checked( - int16_t x, int16_t y, uint16_t w, uint16_t h, uint32_t mask = 0, const xcb_params_cw_t* p = nullptr); + short int x, short int y, unsigned short int w, unsigned short int h, unsigned int mask = 0, const xcb_params_cw_t* p = nullptr); - window change_event_mask(uint32_t mask); - window ensure_event_mask(uint32_t event); + window change_event_mask(unsigned int mask); + window ensure_event_mask(unsigned int event); - window reconfigure_geom(uint16_t w, uint16_t h, int16_t x = 0, int16_t y = 0); - window reconfigure_pos(int16_t x, int16_t y); - window reconfigure_struts(uint16_t w, uint16_t h, int16_t x, bool bottom = false); + window reconfigure_geom(unsigned short int w, unsigned short int h, short int x = 0, short int y = 0); + window reconfigure_pos(short int x, short int y); + window reconfigure_struts(unsigned short int w, unsigned short int h, short int x, bool bottom = false); void redraw(); diff --git a/include/x11/winspec.hpp b/include/x11/winspec.hpp index 235a8969..281e8f51 100644 --- a/include/x11/winspec.hpp +++ b/include/x11/winspec.hpp @@ -9,104 +9,104 @@ POLYBAR_NS struct cw_size { - explicit cw_size(uint16_t w, uint16_t h) : w(w), h(h) {} + explicit cw_size(unsigned short int w, unsigned short int h) : w(w), h(h) {} explicit cw_size(struct size size) : w(size.w), h(size.h) {} - uint16_t w{1}; - uint16_t h{1}; + unsigned short int w{1}; + unsigned short int h{1}; }; struct cw_pos { - explicit cw_pos(int16_t x, int16_t y) : x(x), y(y) {} + explicit cw_pos(short int x, short int y) : x(x), y(y) {} explicit cw_pos(struct position pos) : x(pos.x), y(pos.y) {} - int16_t x{0}; - int16_t y{0}; + short int x{0}; + short int y{0}; }; struct cw_border { - explicit cw_border(uint16_t border_width) : border_width(border_width) {} - uint16_t border_width{0}; + explicit cw_border(unsigned short int border_width) : border_width(border_width) {} + unsigned short int border_width{0}; }; struct cw_class { - explicit cw_class(uint16_t class_) : class_(class_) {} - uint16_t class_{XCB_COPY_FROM_PARENT}; + explicit cw_class(unsigned short int class_) : class_(class_) {} + unsigned short int class_{XCB_COPY_FROM_PARENT}; }; struct cw_parent { explicit cw_parent(xcb_window_t parent) : parent(parent) {} xcb_window_t parent{XCB_NONE}; }; struct cw_depth { - explicit cw_depth(uint8_t depth) : depth(depth) {} - uint8_t depth{XCB_COPY_FROM_PARENT}; + explicit cw_depth(unsigned char depth) : depth(depth) {} + unsigned char depth{XCB_COPY_FROM_PARENT}; }; struct cw_visual { explicit cw_visual(xcb_visualid_t visualid) : visualid(visualid) {} xcb_visualid_t visualid{XCB_COPY_FROM_PARENT}; }; struct cw_mask { - explicit cw_mask(uint32_t mask) : mask(mask) {} - const uint32_t mask{0}; + explicit cw_mask(unsigned int mask) : mask(mask) {} + const unsigned int mask{0}; }; struct cw_params { explicit cw_params(const xcb_params_cw_t* params) : params(params) {} const xcb_params_cw_t* params{nullptr}; }; struct cw_params_back_pixel { - explicit cw_params_back_pixel(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_back_pixel(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_back_pixmap { - explicit cw_params_back_pixmap(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_back_pixmap(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_backing_pixel { - explicit cw_params_backing_pixel(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_backing_pixel(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_backing_planes { - explicit cw_params_backing_planes(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_backing_planes(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_backing_store { - explicit cw_params_backing_store(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_backing_store(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_bit_gravity { - explicit cw_params_bit_gravity(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_bit_gravity(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_border_pixel { - explicit cw_params_border_pixel(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_border_pixel(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_border_pixmap { - explicit cw_params_border_pixmap(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_border_pixmap(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_colormap { - explicit cw_params_colormap(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_colormap(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_cursor { - explicit cw_params_cursor(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_cursor(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_dont_propagate { - explicit cw_params_dont_propagate(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_dont_propagate(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_event_mask { - explicit cw_params_event_mask(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_event_mask(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_override_redirect { - explicit cw_params_override_redirect(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_override_redirect(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_save_under { - explicit cw_params_save_under(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_save_under(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_params_win_gravity { - explicit cw_params_win_gravity(uint32_t value) : value(value) {} - uint32_t value{0}; + explicit cw_params_win_gravity(unsigned int value) : value(value) {} + unsigned int value{0}; }; struct cw_flush { explicit cw_flush(bool checked = false) : checked(checked) {} @@ -164,16 +164,16 @@ class winspec { connection& m_connection; xcb_window_t m_window{XCB_NONE}; - uint32_t m_parent{XCB_NONE}; - uint8_t m_depth{XCB_COPY_FROM_PARENT}; - uint16_t m_class{XCB_COPY_FROM_PARENT}; + unsigned int m_parent{XCB_NONE}; + unsigned char m_depth{XCB_COPY_FROM_PARENT}; + unsigned short int m_class{XCB_COPY_FROM_PARENT}; xcb_visualid_t m_visual{XCB_COPY_FROM_PARENT}; - int16_t m_x{0}; - int16_t m_y{0}; - uint16_t m_width{1U}; - uint16_t m_height{1U}; - uint16_t m_border{0}; - uint32_t m_mask{0}; + short int m_x{0}; + short int m_y{0}; + unsigned short int m_width{1U}; + unsigned short int m_height{1U}; + unsigned short int m_border{0}; + unsigned int m_mask{0}; xcb_params_cw_t m_params{}; }; diff --git a/include/x11/wm.hpp b/include/x11/wm.hpp index cb6faf06..23610dcc 100644 --- a/include/x11/wm.hpp +++ b/include/x11/wm.hpp @@ -12,8 +12,8 @@ namespace wm_util { void set_wm_window_type(xcb_connection_t* conn, xcb_window_t win, vector types); void set_wm_state(xcb_connection_t* conn, xcb_window_t win, vector states); void set_wm_pid(xcb_connection_t* conn, xcb_window_t win, pid_t pid); - void set_wm_desktop(xcb_connection_t* conn, xcb_window_t win, uint32_t desktop = -1u); - void set_wm_window_opacity(xcb_connection_t* conn, xcb_window_t win, uint64_t values); + void set_wm_desktop(xcb_connection_t* conn, xcb_window_t win, unsigned int desktop = -1u); + void set_wm_window_opacity(xcb_connection_t* conn, xcb_window_t win, unsigned long int values); } POLYBAR_NS_END diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 290ce556..843cbed2 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -349,12 +349,12 @@ void bar::parse(string&& data, bool force) { const auto check_dblclicks = [&]() -> bool { for (auto&& action : m_renderer->actions()) { - if (static_cast(action.button) >= static_cast(mousebtn::DOUBLE_LEFT)) { + if (static_cast(action.button) >= static_cast(mousebtn::DOUBLE_LEFT)) { return true; } } for (auto&& action : m_opts.actions) { - if (static_cast(action.button) >= static_cast(mousebtn::DOUBLE_LEFT)) { + if (static_cast(action.button) >= static_cast(mousebtn::DOUBLE_LEFT)) { return true; } } @@ -568,7 +568,7 @@ void bar::handle(const evt::button_press& evt) { return; } } - m_log.warn("No matching input area found (btn=%i)", static_cast(m_buttonpress_btn)); + m_log.warn("No matching input area found (btn=%i)", static_cast(m_buttonpress_btn)); }; const auto check_double = [&](string&& id, mousebtn&& btn) { @@ -586,11 +586,11 @@ void bar::handle(const evt::button_press& evt) { // just by-pass the click timer handling if (!m_dblclicks) { deferred_fn(0); - } else if (evt->detail == static_cast(mousebtn::LEFT)) { + } else if (evt->detail == static_cast(mousebtn::LEFT)) { check_double("buttonpress-left", mousebtn::DOUBLE_LEFT); - } else if (evt->detail == static_cast(mousebtn::MIDDLE)) { + } else if (evt->detail == static_cast(mousebtn::MIDDLE)) { check_double("buttonpress-middle", mousebtn::DOUBLE_MIDDLE); - } else if (evt->detail == static_cast(mousebtn::RIGHT)) { + } else if (evt->detail == static_cast(mousebtn::RIGHT)) { check_double("buttonpress-right", mousebtn::DOUBLE_RIGHT); } else { deferred_fn(0); @@ -750,24 +750,24 @@ bool bar::on(const signals::ui::tick&) { return false; } - uint32_t mask{0}; - uint32_t values[7]{0}; + unsigned int mask{0}; + unsigned int values[7]{0}; xcb_params_configure_window_t params{}; if (m_opts.shade_size.h > geom->height) { - XCB_AUX_ADD_PARAM(&mask, ¶ms, height, static_cast(geom->height + m_anim_step)); - params.height = std::max(1U, std::min(params.height, static_cast(m_opts.shade_size.h))); + XCB_AUX_ADD_PARAM(&mask, ¶ms, height, static_cast(geom->height + m_anim_step)); + params.height = std::max(1U, std::min(params.height, static_cast(m_opts.shade_size.h))); } else if (m_opts.shade_size.h < geom->height) { - XCB_AUX_ADD_PARAM(&mask, ¶ms, height, static_cast(geom->height - m_anim_step)); - params.height = std::max(1U, std::max(params.height, static_cast(m_opts.shade_size.h))); + XCB_AUX_ADD_PARAM(&mask, ¶ms, height, static_cast(geom->height - m_anim_step)); + params.height = std::max(1U, std::max(params.height, static_cast(m_opts.shade_size.h))); } if (m_opts.shade_pos.y > geom->y) { - XCB_AUX_ADD_PARAM(&mask, ¶ms, y, static_cast(geom->y + m_anim_step)); - params.y = std::min(params.y, static_cast(m_opts.shade_pos.y)); + XCB_AUX_ADD_PARAM(&mask, ¶ms, y, static_cast(geom->y + m_anim_step)); + params.y = std::min(params.y, static_cast(m_opts.shade_pos.y)); } else if (m_opts.shade_pos.y < geom->y) { - XCB_AUX_ADD_PARAM(&mask, ¶ms, y, static_cast(geom->y - m_anim_step)); - params.y = std::max(params.y, static_cast(m_opts.shade_pos.y)); + XCB_AUX_ADD_PARAM(&mask, ¶ms, y, static_cast(geom->y - m_anim_step)); + params.y = std::max(params.y, static_cast(m_opts.shade_pos.y)); } connection::pack_values(mask, ¶ms, values); diff --git a/src/components/builder.cpp b/src/components/builder.cpp index c4e8fdca..91dd9ba4 100644 --- a/src/components/builder.cpp +++ b/src/components/builder.cpp @@ -47,10 +47,10 @@ string builder::flush() { if (m_tags[syntaxtag::u]) { underline_color_close(); } - if ((m_attributes >> static_cast(attribute::UNDERLINE)) & 1U) { + if ((m_attributes >> static_cast(attribute::UNDERLINE)) & 1U) { underline_close(); } - if ((m_attributes >> static_cast(attribute::OVERLINE)) & 1U) { + if ((m_attributes >> static_cast(attribute::OVERLINE)) & 1U) { overline_close(); } @@ -542,7 +542,7 @@ void builder::cmd_close(bool condition) { */ string builder::background_hex() { if (m_background.empty()) { - m_background = color_util::hex(m_bar.background); + m_background = color_util::hex(m_bar.background); } return m_background; } @@ -552,7 +552,7 @@ string builder::background_hex() { */ string builder::foreground_hex() { if (m_foreground.empty()) { - m_foreground = color_util::hex(m_bar.foreground); + m_foreground = color_util::hex(m_bar.foreground); } return m_foreground; } @@ -601,11 +601,11 @@ void builder::tag_open(syntaxtag tag, const string& value) { * Insert directive to use given attribute unless already set */ void builder::tag_open(attribute attr) { - if ((m_attributes >> static_cast(attr)) & 1U) { + if ((m_attributes >> static_cast(attr)) & 1) { return; } - m_attributes |= 1U << static_cast(attr); + m_attributes |= 1 << static_cast(attr); switch (attr) { case attribute::NONE: @@ -661,11 +661,11 @@ void builder::tag_close(syntaxtag tag) { * Insert directive to remove given attribute if set */ void builder::tag_close(attribute attr) { - if (!((m_attributes >> static_cast(attr)) & 1U)) { + if (!((m_attributes >> static_cast(attr)) & 1)) { return; } - m_attributes &= ~(1U << static_cast(attr)); + m_attributes &= ~(1 << static_cast(attr)); switch (attr) { case attribute::NONE: diff --git a/src/components/config.cpp b/src/components/config.cpp index 0274fa7d..3572abe8 100644 --- a/src/components/config.cpp +++ b/src/components/config.cpp @@ -79,7 +79,7 @@ void config::parse_file() { std::ifstream in(m_file); string line; string section; - uint32_t lineno{0}; + unsigned int lineno{0}; while (std::getline(in, line)) { lineno++; @@ -279,10 +279,10 @@ rgba config::convert(string&& value) const { auto color = color_util::parse(value, 0); // clang-format off return rgba{ - color_util::red_channel(color) / 255.0, - color_util::green_channel(color) / 255.0, - color_util::blue_channel(color) / 255.0, - color_util::alpha_channel(color) / 255.0}; + color_util::red_channel(color) / 255.0, + color_util::green_channel(color) / 255.0, + color_util::blue_channel(color) / 255.0, + color_util::alpha_channel(color) / 255.0}; // clang-format on } diff --git a/src/components/parser.cpp b/src/components/parser.cpp index 4e855085..d074c097 100644 --- a/src/components/parser.cpp +++ b/src/components/parser.cpp @@ -107,7 +107,7 @@ void parser::codeblock(string&& data, const bar_settings& bar) { break; case 'O': - m_sig.emit(offset_pixel{static_cast(std::atoi(value.c_str()))}); + m_sig.emit(offset_pixel{static_cast(std::atoi(value.c_str()))}); break; case 'l': @@ -180,8 +180,8 @@ size_t parser::text(string&& data) { /** * Process color hex string and convert it to the correct value */ -uint32_t parser::parse_color(const string& s, uint32_t fallback) { - uint32_t color{0}; +unsigned int parser::parse_color(const string& s, unsigned int fallback) { + unsigned int color{0}; if (s.empty() || s[0] == '-' || (color = color_util::parse(s, fallback)) == fallback) { return fallback; } @@ -191,7 +191,7 @@ uint32_t parser::parse_color(const string& s, uint32_t fallback) { /** * Process font index and convert it to the correct value */ -uint8_t parser::parse_fontindex(const string& s) { +int parser::parse_fontindex(const string& s) { if (s.empty() || s[0] == '-') { return 0; } diff --git a/src/components/renderer.cpp b/src/components/renderer.cpp index 8359f2dc..29a392f4 100644 --- a/src/components/renderer.cpp +++ b/src/components/renderer.cpp @@ -100,8 +100,8 @@ renderer::renderer( m_log.trace("renderer: Allocate graphic context"); { - uint32_t mask{0}; - uint32_t value_list[32]{0}; + unsigned int mask{0}; + unsigned int value_list[32]{0}; xcb_params_gc_t params{}; XCB_AUX_ADD_PARAM(&mask, ¶ms, foreground, m_bar.foreground); XCB_AUX_ADD_PARAM(&mask, ¶ms, graphics_exposures, 0); @@ -256,8 +256,8 @@ void renderer::flush() { /** * Reserve space at given edge */ -void renderer::reserve_space(edge side, uint16_t w) { - m_log.trace_x("renderer: reserve_space(%i, %i)", static_cast(side), w); +void renderer::reserve_space(edge side, unsigned short int w) { + m_log.trace_x("renderer: reserve_space(%i, %i)", static_cast(side), w); m_cleararea.side = side; m_cleararea.size = w; @@ -311,7 +311,7 @@ void renderer::fill_background() { * Fill overline color */ void renderer::fill_overline(double x, double w) { - if (m_bar.overline.size && m_attributes.test(static_cast(attribute::OVERLINE))) { + if (m_bar.overline.size && m_attributes.test(static_cast(attribute::OVERLINE))) { m_log.trace_x("renderer: overline(x=%i, w=%i)", x, w); m_context->save(); *m_context << m_compositing_overline; @@ -326,7 +326,7 @@ void renderer::fill_overline(double x, double w) { * Fill underline color */ void renderer::fill_underline(double x, double w) { - if (m_bar.underline.size && m_attributes.test(static_cast(attribute::UNDERLINE))) { + if (m_bar.underline.size && m_attributes.test(static_cast(attribute::UNDERLINE))) { m_log.trace_x("renderer: underline(x=%i, w=%i)", x, w); m_context->save(); *m_context << m_compositing_underline; @@ -450,7 +450,7 @@ void renderer::highlight_clickable_areas() { map hint_num{}; for (auto&& action : m_actions) { if (!action.active) { - uint8_t n = hint_num.find(action.align)->second++; + unsigned char n = hint_num.find(action.align)->second++; double x = action.start_x + n * DEBUG_HINTS_OFFSET_X; double y = m_bar.pos.y + m_rect.y + n * DEBUG_HINTS_OFFSET_Y; double w = action.width(); @@ -467,7 +467,7 @@ void renderer::highlight_clickable_areas() { } bool renderer::on(const signals::parser::change_background& evt) { - const uint32_t color{evt.cast()}; + const unsigned int color{evt.cast()}; if (color != m_color_background) { m_color_background = color; } @@ -475,7 +475,7 @@ bool renderer::on(const signals::parser::change_background& evt) { } bool renderer::on(const signals::parser::change_foreground& evt) { - const uint32_t color{evt.cast()}; + const unsigned int color{evt.cast()}; if (color != m_color_foreground) { m_color_foreground = color; } @@ -483,7 +483,7 @@ bool renderer::on(const signals::parser::change_foreground& evt) { } bool renderer::on(const signals::parser::change_underline& evt) { - const uint32_t color{evt.cast()}; + const unsigned int color{evt.cast()}; if (color != m_color_underline) { m_color_underline = color; } @@ -491,7 +491,7 @@ bool renderer::on(const signals::parser::change_underline& evt) { } bool renderer::on(const signals::parser::change_overline& evt) { - const uint32_t color{evt.cast()}; + const unsigned int color{evt.cast()}; if (color != m_color_overline) { m_color_overline = color; } @@ -518,17 +518,17 @@ bool renderer::on(const signals::parser::offset_pixel& evt) { } bool renderer::on(const signals::parser::attribute_set& evt) { - m_attributes.set(static_cast(evt.cast()), true); + m_attributes.set(static_cast(evt.cast()), true); return true; } bool renderer::on(const signals::parser::attribute_unset& evt) { - m_attributes.set(static_cast(evt.cast()), false); + m_attributes.set(static_cast(evt.cast()), false); return true; } bool renderer::on(const signals::parser::attribute_toggle& evt) { - m_attributes.flip(static_cast(evt.cast())); + m_attributes.flip(static_cast(evt.cast())); return true; } @@ -548,7 +548,7 @@ bool renderer::on(const signals::parser::action_begin& evt) { bool renderer::on(const signals::parser::action_end& evt) { (void) evt; // auto btn = evt.cast(); - // int16_t clickable_width = 0; + // short int clickable_width = 0; // for (auto action = m_actions.rbegin(); action != m_actions.rend(); action++) { // if (action->active && action->align == m_alignment && action->button == btn) { // switch (action->align) { diff --git a/src/drawtypes/label.cpp b/src/drawtypes/label.cpp index 4bc78190..6d53161a 100644 --- a/src/drawtypes/label.cpp +++ b/src/drawtypes/label.cpp @@ -157,7 +157,7 @@ namespace drawtypes { auto value = conf.get(section, key, 0U); auto left = conf.get(section, key + "-left", value); auto right = conf.get(section, key + "-right", value); - return side_values{static_cast(left), static_cast(right)}; + return side_values{static_cast(left), static_cast(right)}; }; padding = get_left_right(name + "-padding"); diff --git a/src/drawtypes/progressbar.cpp b/src/drawtypes/progressbar.cpp index 1fa013aa..6bb7a325 100644 --- a/src/drawtypes/progressbar.cpp +++ b/src/drawtypes/progressbar.cpp @@ -123,10 +123,10 @@ namespace drawtypes { // avoid color bleed if (icon_empty && icon_indicator) { if (!icon_indicator->m_background.empty() && icon_empty->m_background.empty()) { - icon_empty->m_background = color_util::hex(bar.background); + icon_empty->m_background = color_util::hex(bar.background); } if (!icon_indicator->m_foreground.empty() && icon_empty->m_foreground.empty()) { - icon_empty->m_foreground = color_util::hex(bar.foreground); + icon_empty->m_foreground = color_util::hex(bar.foreground); } } diff --git a/src/main.cpp b/src/main.cpp index e0bb104c..95e94b77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) { }; // clang-format on - uint8_t exit_code{EXIT_SUCCESS}; + unsigned char exit_code{EXIT_SUCCESS}; bool reload{false}; logger& logger{const_cast(logger::make(loglevel::WARNING))}; diff --git a/src/modules/bspwm.cpp b/src/modules/bspwm.cpp index d9bfa23f..cd036ad9 100644 --- a/src/modules/bspwm.cpp +++ b/src/modules/bspwm.cpp @@ -14,24 +14,24 @@ POLYBAR_NS namespace { using bspwm_state = modules::bspwm_module::state; - uint32_t make_mask(bspwm_state s1, bspwm_state s2 = bspwm_state::NONE) { - uint32_t mask{0U}; - if (static_cast(s1)) { - mask |= 1U << (static_cast(s1) - 1U); + unsigned int make_mask(bspwm_state s1, bspwm_state s2 = bspwm_state::NONE) { + unsigned int mask{0U}; + if (static_cast(s1)) { + mask |= 1U << (static_cast(s1) - 1U); } - if (static_cast(s2)) { - mask |= 1U << (static_cast(s2) - 1U); + if (static_cast(s2)) { + mask |= 1U << (static_cast(s2) - 1U); } return mask; } - uint32_t check_mask(uint32_t base, bspwm_state s1, bspwm_state s2 = bspwm_state::NONE) { - uint32_t mask{0U}; - if (static_cast(s1)) { - mask |= 1U << (static_cast(s1) - 1U); + unsigned int check_mask(unsigned int base, bspwm_state s1, bspwm_state s2 = bspwm_state::NONE) { + unsigned int mask{0U}; + if (static_cast(s1)) { + mask |= 1U << (static_cast(s1) - 1U); } - if (static_cast(s2)) { - mask |= 1U << (static_cast(s2) - 1U); + if (static_cast(s2)) { + mask |= 1U << (static_cast(s2) - 1U); } return (base & mask) == mask; } @@ -92,7 +92,7 @@ namespace modules { {state::EMPTY, "label-focused-empty"}}; for (auto&& os : focused_overrides) { - uint32_t mask{make_mask(state::FOCUSED, os.first)}; + unsigned int mask{make_mask(state::FOCUSED, os.first)}; try { m_statelabels.emplace(mask, load_label(m_conf, name(), os.second)); } catch (const key_error& err) { @@ -219,7 +219,7 @@ namespace modules { auto value = !tag.empty() ? tag.substr(1) : ""; auto mode_flag = mode::NONE; - uint32_t workspace_mask{0U}; + unsigned int workspace_mask{0U}; if (tag[0] == 'm' || tag[0] == 'M') { m_monitors.emplace_back(factory_util::unique()); diff --git a/src/modules/xwindow.cpp b/src/modules/xwindow.cpp index a15a6c46..cf1d5e7c 100644 --- a/src/modules/xwindow.cpp +++ b/src/modules/xwindow.cpp @@ -18,7 +18,7 @@ namespace modules { */ active_window::active_window(xcb_connection_t* conn, xcb_window_t win) : m_connection(conn), m_window(win) { if (m_window != XCB_NONE) { - const uint32_t mask{XCB_EVENT_MASK_PROPERTY_CHANGE}; + const unsigned int mask{XCB_EVENT_MASK_PROPERTY_CHANGE}; xcb_change_window_attributes(m_connection, m_window, XCB_CW_EVENT_MASK, &mask); } } @@ -28,7 +28,7 @@ namespace modules { */ active_window::~active_window() { if (m_window != XCB_NONE) { - const uint32_t mask{XCB_EVENT_MASK_NO_EVENT}; + const unsigned int mask{XCB_EVENT_MASK_NO_EVENT}; xcb_change_window_attributes(m_connection, m_window, XCB_CW_EVENT_MASK, &mask); } } diff --git a/src/modules/xworkspaces.cpp b/src/modules/xworkspaces.cpp index 707db2f8..2209050b 100644 --- a/src/modules/xworkspaces.cpp +++ b/src/modules/xworkspaces.cpp @@ -122,8 +122,8 @@ namespace modules { for (auto&& monitor : m_monitors) { if (monitor->match(viewports[n])) { m_viewports.back()->name = monitor->name; - m_viewports.back()->pos.x = static_cast(monitor->x); - m_viewports.back()->pos.y = static_cast(monitor->y); + m_viewports.back()->pos.x = static_cast(monitor->x); + m_viewports.back()->pos.y = static_cast(monitor->y); m_viewports.back()->state = viewport_state::FOCUSED; m_viewports.back()->label = m_monitorlabel->clone(); m_viewports.back()->label->replace_token("%name%", monitor->name); @@ -212,19 +212,19 @@ namespace modules { } cmd.erase(0, len); - uint32_t new_desktop{0}; - uint32_t min_desktop{0}; - uint32_t max_desktop{0}; - uint32_t current_desktop{ewmh_util::get_current_desktop(m_ewmh.get())}; + unsigned int new_desktop{0}; + unsigned int min_desktop{0}; + unsigned int max_desktop{0}; + unsigned int current_desktop{ewmh_util::get_current_desktop(m_ewmh.get())}; for (auto&& viewport : m_viewports) { for (auto&& desktop : viewport->desktops) { if (min_desktop == 0) { min_desktop = desktop->index; - max_desktop = math_util::max(max_desktop, desktop->index); + max_desktop = math_util::max(max_desktop, desktop->index); } else { - min_desktop = math_util::min(min_desktop, desktop->index); - max_desktop = math_util::max(max_desktop, desktop->index); + min_desktop = math_util::min(min_desktop, desktop->index); + max_desktop = math_util::max(max_desktop, desktop->index); } } } @@ -232,12 +232,12 @@ namespace modules { if ((len = strlen(EVENT_CLICK)) && cmd.compare(0, len, EVENT_CLICK) == 0) { new_desktop = std::strtoul(cmd.substr(len).c_str(), nullptr, 10); } else if ((len = strlen(EVENT_SCROLL_UP)) && cmd.compare(0, len, EVENT_SCROLL_UP) == 0) { - new_desktop = math_util::min(max_desktop, current_desktop + 1); + new_desktop = math_util::min(max_desktop, current_desktop + 1); if (new_desktop == current_desktop) { new_desktop = min_desktop; } } else if ((len = strlen(EVENT_SCROLL_DOWN)) && cmd.compare(0, len, EVENT_SCROLL_DOWN) == 0) { - new_desktop = math_util::max(min_desktop, std::max(0U, current_desktop - 1)); + new_desktop = math_util::max(min_desktop, std::max(0U, current_desktop - 1)); if (new_desktop == current_desktop) { new_desktop = max_desktop; } diff --git a/src/utils/bspwm.cpp b/src/utils/bspwm.cpp index e5786057..570b1753 100644 --- a/src/utils/bspwm.cpp +++ b/src/utils/bspwm.cpp @@ -50,8 +50,8 @@ namespace bspwm_util { continue; } - const uint32_t value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; - const uint32_t value_list[2]{root, XCB_STACK_MODE_ABOVE}; + const unsigned int value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; + const unsigned int value_list[2]{root, XCB_STACK_MODE_ABOVE}; conn.configure_window_checked(win, value_mask, value_list); conn.flush(); diff --git a/src/utils/i3.cpp b/src/utils/i3.cpp index 3c32d099..bff3fbff 100644 --- a/src/utils/i3.cpp +++ b/src/utils/i3.cpp @@ -72,8 +72,8 @@ namespace i3_util { * Fixes the issue with always-on-top window's */ bool restack_to_root(connection& conn, const xcb_window_t win) { - const uint32_t value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; - const uint32_t value_list[2]{root_window(conn), XCB_STACK_MODE_ABOVE}; + const unsigned int value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; + const unsigned int value_list[2]{root_window(conn), XCB_STACK_MODE_ABOVE}; if (value_list[0] != XCB_NONE) { conn.configure_window_checked(win, value_mask, value_list); return true; diff --git a/src/x11/connection.cpp b/src/x11/connection.cpp index 9ba95c65..13ad293c 100644 --- a/src/x11/connection.cpp +++ b/src/x11/connection.cpp @@ -66,33 +66,33 @@ connection::~connection() { XCloseDisplay(m_display); } else { disconnect(); - std::for_each(m_visual.begin(), m_visual.end(), [=](pair p) { XFree(p.second); }); + std::for_each(m_visual.begin(), m_visual.end(), [=](pair p) { XFree(p.second); }); m_visual.clear(); } } -void connection::pack_values(uint32_t mask, const uint32_t* src, uint32_t* dest) { +void connection::pack_values(unsigned int mask, const unsigned int* src, unsigned int* dest) { for (; mask; mask >>= 1, src++) { if (mask & 1) { *dest++ = *src; } } } -void connection::pack_values(uint32_t mask, const xcb_params_cw_t* src, uint32_t* dest) { - pack_values(mask, reinterpret_cast(src), dest); +void connection::pack_values(unsigned int mask, const xcb_params_cw_t* src, unsigned int* dest) { + pack_values(mask, reinterpret_cast(src), dest); } -void connection::pack_values(uint32_t mask, const xcb_params_gc_t* src, uint32_t* dest) { - pack_values(mask, reinterpret_cast(src), dest); +void connection::pack_values(unsigned int mask, const xcb_params_gc_t* src, unsigned int* dest) { + pack_values(mask, reinterpret_cast(src), dest); } -void connection::pack_values(uint32_t mask, const xcb_params_configure_window_t* src, uint32_t* dest) { - pack_values(mask, reinterpret_cast(src), dest); +void connection::pack_values(unsigned int mask, const xcb_params_configure_window_t* src, unsigned int* dest) { + pack_values(mask, reinterpret_cast(src), dest); } connection::operator Display*() const { return m_display; } -Visual* connection::visual(uint8_t depth) { +Visual* connection::visual(unsigned char depth) { auto visual_it = m_visual.find(depth); if (visual_it == m_visual.end()) { XVisualInfo info{}; @@ -123,7 +123,7 @@ xcb_screen_t* connection::screen(bool realloc) { /** * Add given event to the event mask unless already added */ -void connection::ensure_event_mask(xcb_window_t win, uint32_t event) { +void connection::ensure_event_mask(xcb_window_t win, unsigned int event) { auto attributes = get_window_attributes(win); attributes->your_event_mask = attributes->your_event_mask | event; change_window_attributes(win, XCB_CW_EVENT_MASK, &attributes->your_event_mask); @@ -133,7 +133,7 @@ void connection::ensure_event_mask(xcb_window_t win, uint32_t event) { * Clear event mask for the given window */ void connection::clear_event_mask(xcb_window_t win) { - uint32_t mask{XCB_EVENT_MASK_NO_EVENT}; + unsigned int mask{XCB_EVENT_MASK_NO_EVENT}; change_window_attributes(win, XCB_CW_EVENT_MASK, &mask); } @@ -162,7 +162,7 @@ shared_ptr connection::make_client_message(xcb_atom_ * Send client message event */ void connection::send_client_message(const shared_ptr& message, xcb_window_t target, - uint32_t event_mask, bool propagate) const { + unsigned int event_mask, bool propagate) const { send_event(propagate, target, event_mask, reinterpret_cast(&*message)); flush(); } diff --git a/src/x11/draw.cpp b/src/x11/draw.cpp index de645a73..8c515d1c 100644 --- a/src/x11/draw.cpp +++ b/src/x11/draw.cpp @@ -14,7 +14,7 @@ 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, int16_t x, int16_t y, uint16_t w, uint16_t h) { + 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}); } } diff --git a/src/x11/ewmh.cpp b/src/x11/ewmh.cpp index e6b4fe34..e64de9a5 100644 --- a/src/x11/ewmh.cpp +++ b/src/x11/ewmh.cpp @@ -72,8 +72,8 @@ namespace ewmh_util { return str; } - uint32_t get_current_desktop(xcb_ewmh_connection_t* conn, int screen) { - uint32_t desktop{0}; + unsigned int get_current_desktop(xcb_ewmh_connection_t* conn, int screen) { + unsigned int desktop{0}; if (xcb_ewmh_get_current_desktop_reply(conn, xcb_ewmh_get_current_desktop(conn, screen), &desktop, nullptr)) { return desktop; } @@ -90,7 +90,7 @@ namespace ewmh_util { for (size_t n = 0; n < reply.desktop_viewport_len; n++) { viewports.emplace_back(position{ - static_cast(reply.desktop_viewport[n].x), static_cast(reply.desktop_viewport[n].y)}); + static_cast(reply.desktop_viewport[n].x), static_cast(reply.desktop_viewport[n].y)}); } return viewports; @@ -131,7 +131,7 @@ namespace ewmh_util { return win; } - void change_current_desktop(xcb_ewmh_connection_t* conn, uint32_t desktop) { + void change_current_desktop(xcb_ewmh_connection_t* conn, unsigned int desktop) { xcb_ewmh_request_change_current_desktop(conn, 0, desktop, XCB_CURRENT_TIME); } } diff --git a/src/x11/extensions/randr.cpp b/src/x11/extensions/randr.cpp index 2597dbcc..80eed695 100644 --- a/src/x11/extensions/randr.cpp +++ b/src/x11/extensions/randr.cpp @@ -34,8 +34,8 @@ namespace randr_util { /** * XRandR version */ - static uint32_t g_major_version = 0; - static uint32_t g_minor_version = 0; + static unsigned int g_major_version = 0; + static unsigned int g_minor_version = 0; /** * Query for the XRandR extension @@ -61,7 +61,7 @@ namespace randr_util { /** * Define monitor */ - monitor_t make_monitor(xcb_randr_output_t randr, string name, uint16_t w, uint16_t h, int16_t x, int16_t 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); @@ -208,7 +208,7 @@ namespace randr_util { auto reply = conn.get_output_property(mon->output, dst.atom, XCB_ATOM_NONE, 0, 4, 0, 0); if (reply->num_items == 1 && reply->format == 32 && reply->type == XCB_ATOM_INTEGER) { - int32_t value = *reinterpret_cast(xcb_randr_get_output_property_data(reply.get().get())); + int value = *reinterpret_cast(xcb_randr_get_output_property_data(reply.get().get())); dst.val = static_cast(value); } } diff --git a/src/x11/extensions/xkb.cpp b/src/x11/extensions/xkb.cpp index f875c119..1875c585 100644 --- a/src/x11/extensions/xkb.cpp +++ b/src/x11/extensions/xkb.cpp @@ -17,7 +17,7 @@ const keyboard::indicator& keyboard::get(const indicator::type& i) const { /** * Update indicator states */ -void keyboard::set(uint32_t state) { +void keyboard::set(unsigned int state) { for (auto& i : indicators) { i.second.enabled = state & i.second.mask; } @@ -33,14 +33,14 @@ bool keyboard::on(const indicator::type& i) const { /** * Set current group number */ -void keyboard::current(uint8_t group) { +void keyboard::current(unsigned char group) { current_group = group; } /** * Get current group number */ -uint8_t keyboard::current() const { +unsigned char keyboard::current() const { return current_group; } @@ -90,7 +90,7 @@ namespace xkb_util { /** * Get current group number */ - void switch_layout(connection& conn, xcb_xkb_device_spec_t device, uint8_t index) { + void switch_layout(connection& conn, xcb_xkb_device_spec_t device, unsigned char index) { xcb_xkb_latch_lock_state(conn, device, 0, 0, true, index, 0, 0, 0); xcb_flush(conn); } @@ -98,8 +98,8 @@ namespace xkb_util { /** * Get current group number */ - uint8_t get_current_group(connection& conn, xcb_xkb_device_spec_t device) { - uint8_t result{0}; + unsigned char get_current_group(connection& conn, xcb_xkb_device_spec_t device) { + unsigned char result{0}; auto reply = xcb_xkb_get_state_reply(conn, xcb_xkb_get_state(conn, device), nullptr); if (reply != nullptr) { result = reply->group; @@ -114,7 +114,7 @@ namespace xkb_util { vector get_layouts(connection& conn, xcb_xkb_device_spec_t device) { vector results; - uint32_t mask{XCB_XKB_NAME_DETAIL_GROUP_NAMES | XCB_XKB_NAME_DETAIL_SYMBOLS}; + unsigned int mask{XCB_XKB_NAME_DETAIL_GROUP_NAMES | XCB_XKB_NAME_DETAIL_SYMBOLS}; auto reply = xcb_xkb_get_names_reply(conn, xcb_xkb_get_names(conn, device, mask), nullptr); if (reply == nullptr) { @@ -155,7 +155,7 @@ namespace xkb_util { map get_indicators(connection& conn, xcb_xkb_device_spec_t device) { map results; - uint32_t mask{XCB_XKB_NAME_DETAIL_INDICATOR_NAMES}; + unsigned int mask{XCB_XKB_NAME_DETAIL_INDICATOR_NAMES}; auto reply = xcb_xkb_get_names_reply(conn, xcb_xkb_get_names(conn, device, mask), nullptr); if (reply == nullptr) { diff --git a/src/x11/graphics.cpp b/src/x11/graphics.cpp index 58f7648d..9e65f6c3 100644 --- a/src/x11/graphics.cpp +++ b/src/x11/graphics.cpp @@ -14,7 +14,7 @@ namespace graphics_util { * Create a basic window */ bool create_window( - connection& conn, xcb_window_t* win, int16_t x, int16_t y, uint16_t w, uint16_t h, xcb_window_t root) { + 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,14 @@ 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, uint16_t w, uint16_t 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, uint16_t w, uint16_t h, uint8_t 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); @@ -61,8 +61,8 @@ namespace graphics_util { try { xcb_params_gc_t params{}; - uint32_t mask = 0; - uint32_t values[32]; + unsigned int mask = 0; + unsigned int values[32]; XCB_AUX_ADD_PARAM(&mask, ¶ms, graphics_exposures, 1); connection::pack_values(mask, ¶ms, values); diff --git a/src/x11/tray_client.cpp b/src/x11/tray_client.cpp index 98cf0ccd..a8d0467a 100644 --- a/src/x11/tray_client.cpp +++ b/src/x11/tray_client.cpp @@ -8,7 +8,7 @@ POLYBAR_NS -tray_client::tray_client(connection& conn, xcb_window_t win, uint16_t w, uint16_t h) +tray_client::tray_client(connection& conn, xcb_window_t win, unsigned int w, unsigned int h) : m_connection(conn), m_window(win), m_width(w), m_height(h) { m_xembed = memory_util::make_malloc_ptr(); m_xembed->version = XEMBED_VERSION; @@ -19,11 +19,11 @@ tray_client::~tray_client() { xembed::unembed(m_connection, window(), m_connection.root()); } -uint16_t tray_client::width() const { +unsigned int tray_client::width() const { return m_width; } -uint16_t tray_client::height() const { +unsigned int tray_client::height() const { return m_height; } @@ -84,9 +84,9 @@ void tray_client::ensure_state() const { /** * Configure window size */ -void tray_client::reconfigure(int16_t x, int16_t y) const { - uint32_t configure_mask = 0; - uint32_t configure_values[7]; +void tray_client::reconfigure(int x, int y) const { + unsigned int configure_mask = 0; + unsigned int configure_values[7]; xcb_params_configure_window_t configure_params{}; XCB_AUX_ADD_PARAM(&configure_mask, &configure_params, width, m_width); @@ -101,7 +101,7 @@ void tray_client::reconfigure(int16_t x, int16_t y) const { /** * Respond to client resize requests */ -void tray_client::configure_notify(int16_t x, int16_t y) const { +void tray_client::configure_notify(short int x, short int y) const { auto notify = memory_util::make_malloc_ptr(); notify->response_type = XCB_CONFIGURE_NOTIFY; notify->event = m_window; @@ -114,7 +114,7 @@ void tray_client::configure_notify(int16_t x, int16_t y) const { notify->height = m_height; notify->border_width = 0; - uint32_t mask{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; + unsigned int mask{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; m_connection.send_event_checked(false, m_window, mask, reinterpret_cast(notify.get())); } diff --git a/src/x11/tray_manager.cpp b/src/x11/tray_manager.cpp index 47fc463a..06df063f 100644 --- a/src/x11/tray_manager.cpp +++ b/src/x11/tray_manager.cpp @@ -92,7 +92,7 @@ void tray_manager::setup(const bar_settings& bar_opts) { m_opts.height--; } - auto maxsize = conf.get(bs, "tray-maxsize", 16); + auto maxsize = conf.get(bs, "tray-maxsize", 16); if (m_opts.height > maxsize) { m_opts.spacing += (m_opts.height - maxsize) / 2; m_opts.height = maxsize; @@ -103,7 +103,7 @@ void tray_manager::setup(const bar_settings& bar_opts) { m_opts.orig_y = bar_opts.pos.y + bar_opts.borders.at(edge::TOP).size; // Apply user-defined scaling - auto scale = conf.get(bs, "tray-scale", 1.0f); + auto scale = conf.get(bs, "tray-scale", 1.0); m_opts.width *= scale; m_opts.height_fill *= scale; @@ -144,7 +144,7 @@ void tray_manager::setup(const bar_settings& bar_opts) { } // Add user-defined padding - m_opts.spacing += conf.get(bs, "tray-padding", 0); + m_opts.spacing += conf.get(bs, "tray-padding", 0); // Add user-defiend offset auto offset_x_def = conf.get(bs, "tray-offset-x", ""s); @@ -359,8 +359,8 @@ void tray_manager::reconfigure_window() { if (width > 0) { m_log.trace("tray: New window values, width=%d, x=%d", width, x); - uint32_t mask = 0; - uint32_t values[7]; + unsigned int mask = 0; + unsigned int values[7]; xcb_params_configure_window_t params{}; XCB_AUX_ADD_PARAM(&mask, ¶ms, width, width); @@ -379,7 +379,7 @@ void tray_manager::reconfigure_window() { void tray_manager::reconfigure_clients() { m_log.trace("tray: Reconfigure clients"); - uint32_t x = m_opts.spacing; + int x = m_opts.spacing; for (auto it = m_clients.rbegin(); it != m_clients.rend(); it++) { auto client = *it; @@ -447,8 +447,8 @@ void tray_manager::reconfigure_bg(bool realloc) { } if (realloc) { - vector image_data; - uint8_t image_depth; + vector image_data; + unsigned char image_depth; try { auto image_reply = @@ -560,7 +560,7 @@ void tray_manager::create_window() { m_tray = win << cw_flush(true); m_log.info("Tray window: %s", m_connection.id(m_tray)); - const uint32_t shadow{0}; + const unsigned int shadow{0}; m_connection.change_property(XCB_PROP_MODE_REPLACE, m_tray, _COMPTON_SHADOW, XCB_ATOM_CARDINAL, 32, 1, &shadow); } @@ -610,8 +610,8 @@ void tray_manager::restack_window() { try { m_log.trace("tray: Restacking tray window"); - uint32_t mask = 0; - uint32_t values[7]; + unsigned int mask = 0; + unsigned int values[7]; xcb_params_configure_window_t params{}; XCB_AUX_ADD_PARAM(&mask, ¶ms, sibling, m_opts.sibling); @@ -629,8 +629,8 @@ void tray_manager::restack_window() { * Set window WM hints */ void tray_manager::set_wm_hints() { - const uint32_t visual{m_connection.screen()->root_visual}; - const uint32_t orientation{_NET_SYSTEM_TRAY_ORIENTATION_HORZ}; + const unsigned int visual{m_connection.screen()->root_visual}; + const unsigned int orientation{_NET_SYSTEM_TRAY_ORIENTATION_HORZ}; m_log.trace("tray: Set window WM_NAME / WM_CLASS", m_connection.id(m_tray)); xcb_icccm_set_wm_name(m_connection, m_tray, XCB_ATOM_STRING, 8, 19, TRAY_WM_NAME); @@ -667,7 +667,7 @@ void tray_manager::set_tray_colors() { auto g = color_util::green_channel(m_opts.background); auto b = color_util::blue_channel(m_opts.background); - const uint32_t colors[12] = { + const unsigned int colors[12] = { r, g, b, // normal r, g, b, // error r, g, b, // warning @@ -741,8 +741,8 @@ void tray_manager::notify_clients_delayed() { void tray_manager::track_selection_owner(xcb_window_t owner) { if (owner != XCB_NONE) { m_log.trace("tray: Listen for events on the new selection window"); - const uint32_t mask{XCB_CW_EVENT_MASK}; - const uint32_t values[]{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; + const unsigned int mask{XCB_CW_EVENT_MASK}; + const unsigned int values[]{XCB_EVENT_MASK_STRUCTURE_NOTIFY}; m_connection.change_window_attributes(owner, mask, values); } } @@ -768,8 +768,8 @@ void tray_manager::process_docking_request(xcb_window_t win) { } try { - const uint32_t mask{XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK}; - const uint32_t values[]{ + const unsigned int mask{XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK}; + const unsigned int values[]{ XCB_BACK_PIXMAP_PARENT_RELATIVE, XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY}; m_log.trace("tray: Update client window"); @@ -801,7 +801,7 @@ void tray_manager::process_docking_request(xcb_window_t win) { /** * Calculate x position of tray window */ -int16_t tray_manager::calculate_x(uint16_t width) const { +int tray_manager::calculate_x(unsigned int width) const { auto x = m_opts.orig_x; if (m_opts.align == alignment::RIGHT) { x -= ((m_opts.width + m_opts.spacing) * m_clients.size() + m_opts.spacing); @@ -814,15 +814,15 @@ int16_t tray_manager::calculate_x(uint16_t width) const { /** * Calculate y position of tray window */ -int16_t tray_manager::calculate_y() const { +int tray_manager::calculate_y() const { return m_opts.orig_y; } /** * Calculate width of tray window */ -uint16_t tray_manager::calculate_w() const { - uint16_t width = m_opts.spacing; +unsigned int tray_manager::calculate_w() const { + unsigned int width = m_opts.spacing; size_t count{0}; for (auto&& client : m_clients) { if (client->mapped()) { @@ -836,14 +836,14 @@ uint16_t tray_manager::calculate_w() const { /** * Calculate height of tray window */ -uint16_t tray_manager::calculate_h() const { +unsigned int tray_manager::calculate_h() const { return m_opts.height_fill; } /** * Calculate x position of client window */ -int16_t tray_manager::calculate_client_x(const xcb_window_t& win) { +int tray_manager::calculate_client_x(const xcb_window_t& win) { for (size_t i = 0; i < m_clients.size(); i++) { if (m_clients[i]->match(win)) { return m_opts.spacing + m_opts.width * i; @@ -855,7 +855,7 @@ int16_t tray_manager::calculate_client_x(const xcb_window_t& win) { /** * Calculate y position of client window */ -int16_t tray_manager::calculate_client_y() { +int tray_manager::calculate_client_y() { return (m_opts.height_fill - m_opts.height) / 2; } diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 05c31113..86058351 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -17,14 +17,14 @@ window& window::operator=(const xcb_window_t win) { /** * 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(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(); } auto root = connection().screen()->root; auto copy = XCB_COPY_FROM_PARENT; - uint32_t values[16]{0}; + unsigned int values[16]{0}; connection::pack_values(mask, p, values); connection().create_window_checked(copy, *this, root, x, y, w, h, 0, copy, copy, mask, values); @@ -34,7 +34,7 @@ window window::create_checked(int16_t x, int16_t y, uint16_t w, uint16_t h, uint /** * Change the window event mask */ -window window::change_event_mask(uint32_t mask) { +window window::change_event_mask(unsigned int mask) { change_attributes_checked(XCB_CW_EVENT_MASK, &mask); return *this; } @@ -42,7 +42,7 @@ window window::change_event_mask(uint32_t mask) { /** * Add given event to the event mask unless already added */ -window window::ensure_event_mask(uint32_t event) { +window window::ensure_event_mask(unsigned int event) { connection().ensure_event_mask(*this, event); return *this; } @@ -50,9 +50,9 @@ window window::ensure_event_mask(uint32_t event) { /** * Reconfigure the window geometry */ -window window::reconfigure_geom(uint16_t w, uint16_t h, int16_t x, int16_t y) { - uint32_t mask{0}; - uint32_t values[7]{0}; +window window::reconfigure_geom(unsigned short int w, unsigned short int h, short int x, short int y) { + unsigned int mask{0}; + unsigned int values[7]{0}; xcb_params_configure_window_t params{}; XCB_AUX_ADD_PARAM(&mask, ¶ms, width, w); @@ -69,9 +69,9 @@ window window::reconfigure_geom(uint16_t w, uint16_t h, int16_t x, int16_t y) { /** * Reconfigure the window position */ -window window::reconfigure_pos(int16_t x, int16_t y) { - uint32_t mask{0}; - uint32_t values[2]{0}; +window window::reconfigure_pos(short int x, short int y) { + unsigned int mask{0}; + unsigned int values[2]{0}; xcb_params_configure_window_t params{}; XCB_AUX_ADD_PARAM(&mask, ¶ms, x, x); @@ -86,9 +86,9 @@ window window::reconfigure_pos(int16_t x, int16_t y) { /** * Reconfigure the windows ewmh strut */ -window window::reconfigure_struts(uint16_t w, uint16_t h, int16_t x, bool bottom) { - uint32_t none{0}; - uint32_t values[12]{none}; +window window::reconfigure_struts(unsigned short int w, unsigned short int h, short int x, bool bottom) { + unsigned int none{0}; + unsigned int values[12]{none}; if (bottom) { values[static_cast(strut::BOTTOM)] = h; @@ -125,7 +125,7 @@ void window::visibility_notify(xcb_visibility_t state) { notify->window = *this; notify->state = state; - uint32_t mask{XCB_EVENT_MASK_NO_EVENT}; + unsigned int mask{XCB_EVENT_MASK_NO_EVENT}; connection().send_event(false, *this, mask, reinterpret_cast(notify.get())); } diff --git a/src/x11/winspec.cpp b/src/x11/winspec.cpp index 6e2ecc40..975c0853 100644 --- a/src/x11/winspec.cpp +++ b/src/x11/winspec.cpp @@ -16,7 +16,7 @@ winspec::operator xcb_rectangle_t() const { } xcb_window_t winspec::operator<<(const cw_flush& f) { - uint32_t values[16]{0}; + unsigned int values[16]{0}; if (m_window == XCB_NONE) { m_window = m_connection.generate_id(); diff --git a/src/x11/wm.cpp b/src/x11/wm.cpp index 1aabdba2..58e26028 100644 --- a/src/x11/wm.cpp +++ b/src/x11/wm.cpp @@ -32,12 +32,12 @@ namespace wm_util { xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &pid); } - void set_wm_desktop(xcb_connection_t* conn, xcb_window_t win, uint32_t desktop) { - const uint32_t value_list[1]{desktop}; + void set_wm_desktop(xcb_connection_t* conn, xcb_window_t win, unsigned int desktop) { + const unsigned int value_list[1]{desktop}; xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, value_list); } - void set_wm_window_opacity(xcb_connection_t* conn, xcb_window_t win, uint64_t values) { + void set_wm_window_opacity(xcb_connection_t* conn, xcb_window_t win, unsigned long int values) { xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_WINDOW_OPACITY, XCB_ATOM_CARDINAL, 32, 1, &values); } } diff --git a/src/x11/xembed.cpp b/src/x11/xembed.cpp index 6728efdd..b426d9c4 100644 --- a/src/x11/xembed.cpp +++ b/src/x11/xembed.cpp @@ -15,7 +15,7 @@ namespace xembed { throw application_error("Invalid _XEMBED_INFO for window " + conn.id(win)); } - std::vector xembed_data{info.value().begin(), info.value().end()}; + std::vector xembed_data{info.value().begin(), info.value().end()}; data->xembed = _XEMBED; data->xembed_info = _XEMBED_INFO; diff --git a/tests/unit_tests/utils/color.cpp b/tests/unit_tests/utils/color.cpp index f644023a..a94e6bed 100644 --- a/tests/unit_tests/utils/color.cpp +++ b/tests/unit_tests/utils/color.cpp @@ -5,30 +5,30 @@ int main() { using namespace polybar; "rgb"_test = []{ - uint32_t color{0x123456}; - expect(color_util::alpha_channel(color) == 0); - expect(color_util::red_channel(color) == 0x12); - expect(color_util::green_channel(color) == 0x34); - expect(color_util::green_channel(color) == 0x3434); - expect(color_util::blue_channel(color) == 0x56); + unsigned int color{0x123456}; + expect(color_util::alpha_channel(color) == 0); + expect(color_util::red_channel(color) == 0x12); + expect(color_util::green_channel(color) == 0x34); + expect(color_util::green_channel(color) == 0x3434); + expect(color_util::blue_channel(color) == 0x56); }; "rgba"_test = []{ - uint32_t color{0xCC123456}; - expect(color_util::alpha_channel(color) == 0xCCCC); - expect(color_util::red_channel(color) == 0x1212); - expect(color_util::red_channel(color) == 0x12); - expect(color_util::green_channel(color) == 0x3434); - expect(color_util::blue_channel(color) == 0x5656); + unsigned int color{0xCC123456}; + expect(color_util::alpha_channel(color) == 0xCCCC); + expect(color_util::red_channel(color) == 0x1212); + expect(color_util::red_channel(color) == 0x12); + expect(color_util::green_channel(color) == 0x3434); + expect(color_util::blue_channel(color) == 0x5656); }; "hex"_test = [] { - uint32_t colorA{0x123456}; - expect(color_util::hex(colorA).compare("#123456") == 0); - uint32_t colorB{0xCC123456}; - expect(color_util::hex(colorB).compare("#cc123456") == 0); - uint32_t colorC{0x00ffffff}; - expect(color_util::hex(colorC).compare("#00ffffff") == 0); + unsigned int colorA{0x123456}; + expect(color_util::hex(colorA).compare("#123456") == 0); + unsigned int colorB{0xCC123456}; + expect(color_util::hex(colorB).compare("#cc123456") == 0); + unsigned int colorC{0x00ffffff}; + expect(color_util::hex(colorC).compare("#00ffffff") == 0); }; "simplify"_test = [] { diff --git a/tests/unit_tests/utils/math.cpp b/tests/unit_tests/utils/math.cpp index f7b48411..f338a98d 100644 --- a/tests/unit_tests/utils/math.cpp +++ b/tests/unit_tests/utils/math.cpp @@ -6,13 +6,13 @@ int main() { "min"_test = [] { expect(math_util::min(2, 5) == 2); expect(math_util::min(-8, -50) == -50); - expect(math_util::min(0, -5) == 0); + expect(math_util::min(0, -5) == 0); }; "min"_test = [] { expect(math_util::max(2, 5) == 5); expect(math_util::max(-8, -50) == -8); - expect(math_util::max(0, (1 << 8) - 5)); + expect(math_util::max(0, (1 << 8) - 5)); }; "cap"_test = [] { diff --git a/tests/unit_tests/x11/color.cpp b/tests/unit_tests/x11/color.cpp index 603b0452..8d400556 100644 --- a/tests/unit_tests/x11/color.cpp +++ b/tests/unit_tests/x11/color.cpp @@ -8,21 +8,21 @@ int main() { "color"_test = [] { color test{"#33990022"}; - expect(color_util::hex(test) == "#1E0006"); - expect(color_util::hex(test) == "#33990022"); + expect(color_util::hex(test) == "#1E0006"); + expect(color_util::hex(test) == "#33990022"); }; "channels"_test = [] { color test{"#eefb9281"}; - expect(color_util::alpha_channel(test) == 0xee); - expect(color_util::red_channel(test) == 0xfb); - expect(color_util::green_channel(test) == 0x92); - expect(color_util::blue_channel(test) == 0x81); + expect(color_util::alpha_channel(test) == 0xee); + expect(color_util::red_channel(test) == 0xfb); + expect(color_util::green_channel(test) == 0x92); + expect(color_util::blue_channel(test) == 0x81); }; "base"_test = [] { color test{"#eefb9281"}; - auto hex = color_util::hex(test); + auto hex = color_util::hex(test); expect(std::strtoul(&hex[0], 0, 16) == 0x0); }; @@ -34,17 +34,17 @@ int main() { expect(g_colorstore.size() == size_t{2}); auto c3 = color::parse("#200"); expect(g_colorstore.size() == size_t{2}); - expect((uint32_t)g_colorstore.find("#100")->second == (uint32_t)c1); + expect((unsigned int)g_colorstore.find("#100")->second == (unsigned int)c1); }; "predefined"_test = [] { - expect(color_util::hex(g_colorblack) == "#FF000000"); - expect(color_util::hex(g_colorwhite) == "#FFFFFFFF"); + expect(color_util::hex(g_colorblack) == "#FF000000"); + expect(color_util::hex(g_colorwhite) == "#FFFFFFFF"); }; "parse"_test = [] { - expect(color_util::hex(color::parse("#ff9900", g_colorblack)) == "#FFFF9900"); - expect(color_util::hex(color::parse("invalid", g_colorwhite)) == "#FFFFFFFF"); - expect(color_util::hex(color::parse("33990022", g_colorwhite)) == "#1E0006"); + expect(color_util::hex(color::parse("#ff9900", g_colorblack)) == "#FFFF9900"); + expect(color_util::hex(color::parse("invalid", g_colorwhite)) == "#FFFFFFFF"); + expect(color_util::hex(color::parse("33990022", g_colorwhite)) == "#1E0006"); }; }