diff --git a/CHANGELOG.md b/CHANGELOG.md index f17d1b90..b2dfc20e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.6.1] - 2022-03-05 +### Build +- Fixed compiler warning in Clang 13 ([`#2613`](https://github.com/polybar/polybar/pull/2613)) +- Fixed compiler error in GCC 12 ([`#2616`](https://github.com/polybar/polybar/pull/2616), [`#2614`](https://github.com/polybar/polybar/issues/2614)) +- Fixed installation of docs when some are not generated (man, html...) ([`#2612`](https://github.com/polybar/polybar/pull/2612)) +- Fix `LDFLAGS` not being respected ([`#2619`](https://github.com/polybar/polybar/pull/2619)) + +### Fixed +- `tray-offset-x`, `tray-offset-y`, `offset-x`, and `offset-y` were mistakenly capped below at 0 ([`#2620`](https://github.com/polybar/polybar/pull/2620)) +- `custom/script`: Polybar shutdown being stalled by hanging script ([`#2621`](https://github.com/polybar/polybar/pull/2621)) +- `polybar-msg`: Wrong hint when using deprecated `hook` ([`#2624`](https://github.com/polybar/polybar/pull/2624)) + ## [3.6.0] - 2022-03-01 ### Breaking - We added the backslash escape character (\\) for configuration values. This means that the literal backslash character now has special meaning in configuration files, therefore if you want to use it in a value as a literal backslash, you need to escape it with the backslash escape character. The parser logs an error if any unescaped backslashes are found in a value. This affects you only if you are using two consecutive backslashes in a config value, which will now be interpreted as a single literal backslash. ([`#2354`](https://github.com/polybar/polybar/issues/2354)) @@ -151,7 +163,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Empty color values are no longer treated as invalid and no longer produce an error. -[Unreleased]: https://github.com/polybar/polybar/compare/3.6.0...HEAD +[Unreleased]: https://github.com/polybar/polybar/compare/3.6.1...HEAD +[3.6.1]: https://github.com/polybar/polybar/releases/tag/3.6.1 [3.6.0]: https://github.com/polybar/polybar/releases/tag/3.6.0 [3.5.7]: https://github.com/polybar/polybar/releases/tag/3.5.7 [3.5.6]: https://github.com/polybar/polybar/releases/tag/3.5.6 diff --git a/README.md b/README.md index fa2614d7..2695b618 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ A fast and easy-to-use tool for creating status bars. **Polybar** aims to help users build beautiful and highly customizable status bars for their desktop environment, without the need of having a black belt in shell scripting. -![sample screenshot](doc/_static/default.png) +![default configuration screenshot](doc/_static/default.png) ## Table of Contents @@ -33,8 +33,7 @@ for their desktop environment, without the need of having a black belt in shell * [Contributing](#contributing) * [Getting started](#getting-started) * [Installation](#installation) - * [Configuration](#configuration) - * [Running](#running) + * [First Steps](#first-steps) * [Community](#community) * [Contributors](#contributors) * [Donations](#donations) @@ -128,35 +127,8 @@ If you are using **Fedora**, you can install [polybar](https://src.fedoraproject If you can't find your distro here, you will have to [build from source](https://github.com/polybar/polybar/wiki/Compiling). -### Configuration - -Details on how to setup and configure the bar and each module have been moved to [the wiki](https://github.com/polybar/polybar/wiki/Configuration). - -#### Install the example configuration - -For a normal installation, polybar will install the example config to -`/usr/share/doc/polybar/config` or ` /usr/local/share/doc/polybar/config` -(depending on your install parameters) - -From there you can copy it to `~/.config/polybar/config` to get started (make -sure to backup any existing config file there). - -**Note:** This example file is meant to showcase available modules and -configuration options. -Running it as-is will work but many modules will likely not start because they -require machine-specific configuration and many of the font icons will not show -up because they require a very specific [font -configuration](https://github.com/polybar/polybar/wiki/Fonts). -We encourage you to use it as a reference when building -your own configuration. - -#### Launch the example bar -~~~ sh -$ polybar example -~~~ - -### Running -[See the wiki for details on how to run polybar](https://github.com/polybar/polybar/wiki). +### First Steps +[See the wiki for details on how to run and configure polybar](https://github.com/polybar/polybar/wiki). ## Community Want to get in touch? diff --git a/cmake/01-core.cmake b/cmake/01-core.cmake index 7f8d55ef..e490e831 100644 --- a/cmake/01-core.cmake +++ b/cmake/01-core.cmake @@ -15,7 +15,7 @@ option(BUILD_POLYBAR "Build the main polybar executable" ${DEFAULT_ON}) option(BUILD_POLYBAR_MSG "Build polybar-msg" ${DEFAULT_ON}) option(BUILD_TESTS "Build testsuite" OFF) option(BUILD_DOC "Build documentation" ${DEFAULT_ON}) -option(BUILD_CONFIG "Generate sample configuration" ${DEFAULT_ON}) +option(BUILD_CONFIG "Generate default configuration" ${DEFAULT_ON}) option(BUILD_SHELL "Generate shell completion files" ${DEFAULT_ON}) include(CMakeDependentOption) diff --git a/cmake/05-summary.cmake b/cmake/05-summary.cmake index c15f3674..5f71936f 100644 --- a/cmake/05-summary.cmake +++ b/cmake/05-summary.cmake @@ -26,7 +26,7 @@ colored_option(" testsuite" BUILD_TESTS) colored_option(" documentation" BUILD_DOC) colored_option(" html" BUILD_DOC_HTML) colored_option(" man" BUILD_DOC_MAN) -colored_option(" sample config" BUILD_CONFIG) +colored_option(" default config" BUILD_CONFIG) colored_option(" shell files" BUILD_SHELL) if (BUILD_LIBPOLY) diff --git a/cmake/cxx.cmake b/cmake/cxx.cmake index fa6776af..ecc0194f 100644 --- a/cmake/cxx.cmake +++ b/cmake/cxx.cmake @@ -108,4 +108,4 @@ string(REPLACE ";" " " cxx_flags_str "${cxx_flags}") string(REPLACE ";" " " cxx_linker_flags_str "${cxx_linker_flags}") # TODO use target_link_options once min cmake version is >= 3.13 -set(CMAKE_EXE_LINKER_FLAGS "${cxx_linker_flags_str}") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${cxx_linker_flags_str}") diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 27d86b6d..abecc6bf 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -49,10 +49,12 @@ endforeach() # Dummy target that depends on all documentation targets add_custom_target(doc ALL DEPENDS ${doc_targets}) -install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ +if (BUILD_DOC_HTML) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc PATTERN ".buildinfo" EXCLUDE) +endif() install(FILES ${CMAKE_SOURCE_DIR}/CHANGELOG.md DESTINATION ${CMAKE_INSTALL_DOCDIR} @@ -62,14 +64,17 @@ install(FILES ${CMAKE_CURRENT_LIST_DIR}/config.ini DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples COMPONENT doc) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.1 +if (BUILD_DOC_MAN) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar-msg.1 + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar-msg.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.5 + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5 COMPONENT doc) +endif() + diff --git a/doc/man/polybar.1.rst b/doc/man/polybar.1.rst index 6df7eeba..7f9bacd5 100644 --- a/doc/man/polybar.1.rst +++ b/doc/man/polybar.1.rst @@ -8,7 +8,7 @@ SYNOPSIS DESCRIPTION ----------- Polybar aims to help users build beautiful and highly customizable status bars for their desktop environment, without the need of having a black belt in shell scripting. -If the *BAR* argument is not provided and the configuration file only contains one bar definition, Polybar will display this bar. +If the *BAR* argument is not provided and the configuration file only contains one bar definition, polybar will display this bar. OPTIONS ------- diff --git a/doc/user/ipc.rst b/doc/user/ipc.rst index b278ce36..9b1219bd 100644 --- a/doc/user/ipc.rst +++ b/doc/user/ipc.rst @@ -40,6 +40,19 @@ enabled. .. note:: IPC messages are only sent to polybar instances running under the same user as ``polybar-msg`` is running as. + Concretely, ``polybar`` and ``polybar-msg`` use the + ``$XDG_RUNTIME_DIR`` environment variable in accordance with the `XDG + Base Directory Specification`_ to determine where to find the socket + to communicate. + + If ``polybar`` and ``polybar-msg`` don't have the same value for + ``$XDG_RUNTIME_DIR``, they will likely not be able to communicate. + The variable may not be set if you use ``su`` or ``sudo`` to execute + ``polybar-msg`` as a different user, often a full user session is + required. + + .. _XDG Base Directory Specification: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html + The ```` argument is either :ref:`action ` or :ref:`cmd `. The allowed values for ```` depend on the type. diff --git a/include/cairo/context.hpp b/include/cairo/context.hpp index a937cd72..f0be75bc 100644 --- a/include/cairo/context.hpp +++ b/include/cairo/context.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "cairo/font.hpp" #include "cairo/surface.hpp" @@ -117,9 +118,12 @@ namespace cairo { context& operator<<(const rounded_corners& c) { cairo_new_sub_path(m_c); - cairo_arc(m_c, c.x + c.w - c.radius.top_right, c.y + c.radius.top_right, c.radius.top_right, -90 * degree, 0 * degree); - cairo_arc(m_c, c.x + c.w - c.radius.bottom_right, c.y + c.h - c.radius.bottom_right, c.radius.bottom_right, 0 * degree, 90 * degree); - cairo_arc(m_c, c.x + c.radius.bottom_left, c.y + c.h - c.radius.bottom_left, c.radius.bottom_left, 90 * degree, 180 * degree); + cairo_arc( + m_c, c.x + c.w - c.radius.top_right, c.y + c.radius.top_right, c.radius.top_right, -90 * degree, 0 * degree); + cairo_arc(m_c, c.x + c.w - c.radius.bottom_right, c.y + c.h - c.radius.bottom_right, c.radius.bottom_right, + 0 * degree, 90 * degree); + cairo_arc(m_c, c.x + c.radius.bottom_left, c.y + c.h - c.radius.bottom_left, c.radius.bottom_left, 90 * degree, + 180 * degree); cairo_arc(m_c, c.x + c.radius.top_left, c.y + c.radius.top_left, c.radius.top_left, 180 * degree, 270 * degree); cairo_close_path(m_c); return *this; @@ -142,7 +146,8 @@ namespace cairo { cairo_rel_line_to(m_c, 0, segment.w); break; } - cairo_arc_negative(m_c, segment.x, segment.y, segment.radius - segment.w, segment.angle_to * degree, segment.angle_from * degree); + cairo_arc_negative(m_c, segment.x, segment.y, segment.radius - segment.w, segment.angle_to * degree, + segment.angle_from * degree); cairo_close_path(m_c); return *this; } @@ -360,9 +365,9 @@ namespace cairo { std::deque> m_points; int m_activegroups{0}; - private: - const double degree = M_PI / 180.0; + private: + const double degree = M_PI / 180.0; }; -} // namespace cairo +} // namespace cairo POLYBAR_NS_END diff --git a/include/ipc/msg.hpp b/include/ipc/msg.hpp index 9cc9b508..1b37022d 100644 --- a/include/ipc/msg.hpp +++ b/include/ipc/msg.hpp @@ -2,6 +2,8 @@ #include "common.hpp" +#include + POLYBAR_NS /** diff --git a/include/modules/date.hpp b/include/modules/date.hpp index ee5c5a79..296ec276 100644 --- a/include/modules/date.hpp +++ b/include/modules/date.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -44,6 +45,6 @@ namespace modules { std::atomic m_toggled{false}; }; -} // namespace modules +} // namespace modules POLYBAR_NS_END diff --git a/include/modules/fs.hpp b/include/modules/fs.hpp index 2de51340..c67663ce 100644 --- a/include/modules/fs.hpp +++ b/include/modules/fs.hpp @@ -1,7 +1,5 @@ #pragma once -#include - #include "components/config.hpp" #include "modules/meta/timer_module.hpp" #include "settings.hpp" @@ -74,6 +72,6 @@ namespace modules { // used while formatting output size_t m_index{0_z}; }; -} // namespace modules +} // namespace modules POLYBAR_NS_END diff --git a/include/modules/github.hpp b/include/modules/github.hpp index a45701f5..bb70bf8c 100644 --- a/include/modules/github.hpp +++ b/include/modules/github.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "modules/meta/timer_module.hpp" #include "settings.hpp" #include "utils/http.hpp" @@ -37,6 +39,6 @@ namespace modules { bool m_empty_notifications{false}; std::atomic m_offline{false}; }; -} // namespace modules +} // namespace modules POLYBAR_NS_END diff --git a/include/utils/units.hpp b/include/utils/units.hpp index 9066ed42..9e2ee414 100644 --- a/include/utils/units.hpp +++ b/include/utils/units.hpp @@ -21,7 +21,8 @@ namespace units_utils { string extent_to_string(extent_val extent); - unsigned percentage_with_offset_to_pixel(percentage_with_offset g_format, double max, double dpi); + int percentage_with_offset_to_pixel(percentage_with_offset g_format, double max, double dpi); + unsigned percentage_with_offset_to_pixel_nonnegative(percentage_with_offset g_format, double max, double dpi); spacing_type parse_spacing_unit(const string& str); spacing_val parse_spacing(const string& str); diff --git a/include/x11/tray_manager.hpp b/include/x11/tray_manager.hpp index 06370b9b..2a388f91 100644 --- a/include/x11/tray_manager.hpp +++ b/include/x11/tray_manager.hpp @@ -40,9 +40,6 @@ class background_manager; class bg_slice; struct tray_settings { - tray_settings() = default; - tray_settings& operator=(const tray_settings& o) = default; - alignment align{alignment::NONE}; bool running{false}; int rel_x{0}; diff --git a/src/adapters/net_nl.cpp b/src/adapters/net_nl.cpp index 0a72601a..b62f45bc 100644 --- a/src/adapters/net_nl.cpp +++ b/src/adapters/net_nl.cpp @@ -1,9 +1,10 @@ -#include "adapters/net.hpp" - #include #include #include +#include + +#include "adapters/net.hpp" #include "utils/file.hpp" POLYBAR_NS @@ -166,8 +167,8 @@ namespace net { m_essid.clear(); if (bss[NL80211_BSS_INFORMATION_ELEMENTS] != nullptr) { - // Information Element ID from ieee80211.h - #define WLAN_EID_SSID 0 +// Information Element ID from ieee80211.h +#define WLAN_EID_SSID 0 auto ies = static_cast(nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS])); auto ies_len = nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]); @@ -226,6 +227,6 @@ namespace net { m_signalstrength.max = hardware_max - hardware_min; } } -} // namespace net +} // namespace net POLYBAR_NS_END diff --git a/src/adapters/script_runner.cpp b/src/adapters/script_runner.cpp index ac8dd041..ce8fef73 100644 --- a/src/adapters/script_runner.cpp +++ b/src/adapters/script_runner.cpp @@ -96,16 +96,35 @@ script_runner::interval script_runner::run() { auto cmd = command_util::make_command(exec); try { - cmd->exec(true, m_env); + cmd->exec(false, m_env); } catch (const exception& err) { m_log.err("script_runner: %s", err.what()); throw modules::module_error("Failed to execute command, stopping module..."); } - m_exit_status = cmd->get_exit_status(); int fd = cmd->get_stdout(PIPE_READ); assert(fd != -1); - bool changed = io_util::poll_read(fd) && set_output(cmd->readline()); + + bool changed = false; + + bool got_output = false; + while (!m_stopping && cmd->is_running() && !io_util::poll(fd, POLLHUP, 0)) { + /** + * For non-tailed scripts, we only use the first line. However, to ensure interruptability when the module shuts + * down, we still need to continue polling. + */ + if (io_util::poll_read(fd, 25) && !got_output) { + changed = set_output(cmd->readline()); + got_output = true; + } + } + + if (m_stopping) { + cmd->terminate(); + return 0s; + } + + m_exit_status = cmd->wait(); if (!changed && m_exit_status != 0) { clear_output(); diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 72716579..b1f63bb4 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -221,8 +221,10 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const // Load values used to adjust the struts atom auto margin_top = m_conf.get("global/wm", "margin-top", percentage_with_offset{}); auto margin_bottom = m_conf.get("global/wm", "margin-bottom", percentage_with_offset{}); - m_opts.strut.top = units_utils::percentage_with_offset_to_pixel(margin_top, m_opts.monitor->h, m_opts.dpi_y); - m_opts.strut.bottom = units_utils::percentage_with_offset_to_pixel(margin_bottom, m_opts.monitor->h, m_opts.dpi_y); + m_opts.strut.top = + units_utils::percentage_with_offset_to_pixel_nonnegative(margin_top, m_opts.monitor->h, m_opts.dpi_y); + m_opts.strut.bottom = + units_utils::percentage_with_offset_to_pixel_nonnegative(margin_bottom, m_opts.monitor->h, m_opts.dpi_y); // Load commands used for fallback click handlers vector actions; @@ -295,19 +297,19 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const m_opts.borders.emplace(edge::TOP, border_settings{}); m_opts.borders[edge::TOP].size = - units_utils::percentage_with_offset_to_pixel(border_top, m_opts.monitor->h, m_opts.dpi_y); + units_utils::percentage_with_offset_to_pixel_nonnegative(border_top, m_opts.monitor->h, m_opts.dpi_y); m_opts.borders[edge::TOP].color = parse_or_throw_color("border-top-color", border_color); m_opts.borders.emplace(edge::BOTTOM, border_settings{}); m_opts.borders[edge::BOTTOM].size = - units_utils::percentage_with_offset_to_pixel(border_bottom, m_opts.monitor->h, m_opts.dpi_y); + units_utils::percentage_with_offset_to_pixel_nonnegative(border_bottom, m_opts.monitor->h, m_opts.dpi_y); m_opts.borders[edge::BOTTOM].color = parse_or_throw_color("border-bottom-color", border_color); m_opts.borders.emplace(edge::LEFT, border_settings{}); m_opts.borders[edge::LEFT].size = - units_utils::percentage_with_offset_to_pixel(border_left, m_opts.monitor->w, m_opts.dpi_x); + units_utils::percentage_with_offset_to_pixel_nonnegative(border_left, m_opts.monitor->w, m_opts.dpi_x); m_opts.borders[edge::LEFT].color = parse_or_throw_color("border-left-color", border_color); m_opts.borders.emplace(edge::RIGHT, border_settings{}); m_opts.borders[edge::RIGHT].size = - units_utils::percentage_with_offset_to_pixel(border_right, m_opts.monitor->w, m_opts.dpi_x); + units_utils::percentage_with_offset_to_pixel_nonnegative(border_right, m_opts.monitor->w, m_opts.dpi_x); m_opts.borders[edge::RIGHT].color = parse_or_throw_color("border-right-color", border_color); // Load geometry values @@ -316,8 +318,8 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const auto offsetx = m_conf.get(m_conf.section(), "offset-x", percentage_with_offset{}); auto offsety = m_conf.get(m_conf.section(), "offset-y", percentage_with_offset{}); - m_opts.size.w = units_utils::percentage_with_offset_to_pixel(w, m_opts.monitor->w, m_opts.dpi_x); - m_opts.size.h = units_utils::percentage_with_offset_to_pixel(h, m_opts.monitor->h, m_opts.dpi_y); + m_opts.size.w = units_utils::percentage_with_offset_to_pixel_nonnegative(w, m_opts.monitor->w, m_opts.dpi_x); + m_opts.size.h = units_utils::percentage_with_offset_to_pixel_nonnegative(h, m_opts.monitor->h, m_opts.dpi_y); m_opts.offset.x = units_utils::percentage_with_offset_to_pixel(offsetx, m_opts.monitor->w, m_opts.dpi_x); m_opts.offset.y = units_utils::percentage_with_offset_to_pixel(offsety, m_opts.monitor->h, m_opts.dpi_y); diff --git a/src/modules/fs.cpp b/src/modules/fs.cpp index d792bd72..e13ef443 100644 --- a/src/modules/fs.cpp +++ b/src/modules/fs.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "drawtypes/label.hpp" #include "drawtypes/progressbar.hpp" @@ -206,6 +207,6 @@ namespace modules { return true; } -} // namespace modules +} // namespace modules POLYBAR_NS_END diff --git a/src/polybar-msg.cpp b/src/polybar-msg.cpp index 44dd22b9..f1a9c127 100644 --- a/src/polybar-msg.cpp +++ b/src/polybar-msg.cpp @@ -141,7 +141,7 @@ static std::pair parse_message(deque args) { fprintf(stderr, "Warning: Using IPC hook commands is deprecated, use the hook action on the ipc module: %s %s \"%s\"\n", exec, - ipc_type.c_str(), ipc_payload.c_str()); + "action", ipc_payload.c_str()); } } diff --git a/src/utils/units.cpp b/src/utils/units.cpp index 5bb201cd..5030be8a 100644 --- a/src/utils/units.cpp +++ b/src/utils/units.cpp @@ -39,11 +39,14 @@ namespace units_utils { /** * Converts a percentage with offset into pixels */ - unsigned int percentage_with_offset_to_pixel(percentage_with_offset g_format, double max, double dpi) { + int percentage_with_offset_to_pixel(percentage_with_offset g_format, double max, double dpi) { int offset_pixel = extent_to_pixel(g_format.offset, dpi); - return static_cast( - std::max(0, math_util::percentage_to_value(g_format.percentage, max) + offset_pixel)); + return static_cast(math_util::percentage_to_value(g_format.percentage, max) + offset_pixel); + } + + unsigned percentage_with_offset_to_pixel_nonnegative(percentage_with_offset g_format, double max, double dpi) { + return std::max(0, percentage_with_offset_to_pixel(g_format, max, dpi)); } extent_type parse_extent_unit(const string& str) { diff --git a/tests/unit_tests/utils/units.cpp b/tests/unit_tests/utils/units.cpp index d2aec33b..814546be 100644 --- a/tests/unit_tests/utils/units.cpp +++ b/tests/unit_tests/utils/units.cpp @@ -6,7 +6,6 @@ using namespace polybar; using namespace units_utils; - namespace polybar { bool operator==(const extent_val lhs, const extent_val rhs) { return lhs.type == rhs.type && lhs.value == rhs.value; @@ -24,9 +23,9 @@ namespace polybar { * value represents the format string. The max value is always 1000 and dpi is always 96 */ class GeomFormatToPixelsTest : public ::testing::Test, - public ::testing::WithParamInterface> {}; + public ::testing::WithParamInterface> {}; -vector> to_pixels_no_offset_list = { +vector> to_pixels_no_offset_list = { {1000, percentage_with_offset{100.}}, {0, percentage_with_offset{0.}}, {1000, percentage_with_offset{150.}}, @@ -36,34 +35,33 @@ vector> to_pixels_no_offset_list = { {1, percentage_with_offset{0., extent_val{extent_type::PIXEL, 1}}}, }; -vector> to_pixels_with_offset_list = { +vector> to_pixels_with_pixels_list = { {1000, percentage_with_offset{100., ZERO_PX_EXTENT}}, {1010, percentage_with_offset{100., extent_val{extent_type::PIXEL, 10}}}, {990, percentage_with_offset{100., extent_val{extent_type::PIXEL, -10}}}, {10, percentage_with_offset{0., extent_val{extent_type::PIXEL, 10}}}, {1000, percentage_with_offset{99., extent_val{extent_type::PIXEL, 10}}}, - {0, percentage_with_offset{1., extent_val{extent_type::PIXEL, -100}}}, + {-90, percentage_with_offset{1., extent_val{extent_type::PIXEL, -100}}}, }; -vector> to_pixels_with_units_list = { +vector> to_pixels_with_points_list = { {1013, percentage_with_offset{100., extent_val{extent_type::POINT, 10}}}, {987, percentage_with_offset{100., extent_val{extent_type::POINT, -10}}}, {1003, percentage_with_offset{99., extent_val{extent_type::POINT, 10}}}, {13, percentage_with_offset{0., extent_val{extent_type::POINT, 10}}}, - {0, percentage_with_offset{0, extent_val{extent_type::POINT, -10}}}, }; INSTANTIATE_TEST_SUITE_P(NoOffset, GeomFormatToPixelsTest, ::testing::ValuesIn(to_pixels_no_offset_list)); -INSTANTIATE_TEST_SUITE_P(WithOffset, GeomFormatToPixelsTest, ::testing::ValuesIn(to_pixels_with_offset_list)); +INSTANTIATE_TEST_SUITE_P(WithPixels, GeomFormatToPixelsTest, ::testing::ValuesIn(to_pixels_with_pixels_list)); -INSTANTIATE_TEST_SUITE_P(WithUnits, GeomFormatToPixelsTest, ::testing::ValuesIn(to_pixels_with_units_list)); +INSTANTIATE_TEST_SUITE_P(WithPoints, GeomFormatToPixelsTest, ::testing::ValuesIn(to_pixels_with_points_list)); static constexpr int MAX_WIDTH = 1000; static constexpr int DPI = 96; TEST_P(GeomFormatToPixelsTest, correctness) { - unsigned exp = GetParam().first; + int exp = GetParam().first; percentage_with_offset geometry = GetParam().second; EXPECT_DOUBLE_EQ(exp, percentage_with_offset_to_pixel(geometry, MAX_WIDTH, DPI)); } @@ -83,17 +81,6 @@ TEST(UnitsUtils, extent_to_pixel) { EXPECT_EQ(0, extent_to_pixel_nonnegative({extent_type::POINT, -36}, 96)); } -TEST(UnitsUtils, percentage_with_offset_to_pixel) { - EXPECT_EQ(1100, percentage_with_offset_to_pixel({100, {extent_type::PIXEL, 100}}, 1000, 0)); - EXPECT_EQ(1048, percentage_with_offset_to_pixel({100, {extent_type::POINT, 36}}, 1000, 96)); - - EXPECT_EQ(900, percentage_with_offset_to_pixel({100, {extent_type::PIXEL, -100}}, 1000, 0)); - EXPECT_EQ(952, percentage_with_offset_to_pixel({100, {extent_type::POINT, -36}}, 1000, 96)); - - EXPECT_EQ(0, percentage_with_offset_to_pixel({0, {extent_type::PIXEL, -100}}, 1000, 0)); - EXPECT_EQ(100, percentage_with_offset_to_pixel({0, {extent_type::PIXEL, 100}}, 1000, 0)); -} - TEST(UnitsUtils, parse_extent_unit) { EXPECT_EQ(extent_type::PIXEL, parse_extent_unit("px")); EXPECT_EQ(extent_type::POINT, parse_extent_unit("pt")); diff --git a/version.txt b/version.txt index cbddfc9f..cdba9da6 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ # Polybar version information # Update this on every release # This is used to create the version string if a git repo is not available -3.6.0 +3.6.1