2019-10-27 15:25:12 +01:00
|
|
|
#include "components/bar.hpp"
|
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
#include <algorithm>
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
#include "components/config.hpp"
|
2016-12-20 05:05:43 +01:00
|
|
|
#include "components/renderer.hpp"
|
2016-11-27 00:46:41 +01:00
|
|
|
#include "components/screen.hpp"
|
2016-12-26 09:40:15 +01:00
|
|
|
#include "components/types.hpp"
|
2019-10-27 13:32:45 +01:00
|
|
|
#include "drawtypes/label.hpp"
|
2016-12-05 20:41:00 +01:00
|
|
|
#include "events/signal.hpp"
|
|
|
|
#include "events/signal_emitter.hpp"
|
2020-12-17 20:37:28 +01:00
|
|
|
#include "tags/dispatch.hpp"
|
2016-11-02 20:22:45 +01:00
|
|
|
#include "utils/bspwm.hpp"
|
|
|
|
#include "utils/color.hpp"
|
|
|
|
#include "utils/math.hpp"
|
|
|
|
#include "utils/string.hpp"
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
#include "utils/units.hpp"
|
2016-11-26 06:13:20 +01:00
|
|
|
#include "x11/atoms.hpp"
|
|
|
|
#include "x11/connection.hpp"
|
2017-01-24 08:49:27 +01:00
|
|
|
#include "x11/ewmh.hpp"
|
2016-12-26 10:27:30 +01:00
|
|
|
#include "x11/extensions/all.hpp"
|
2017-01-24 08:49:27 +01:00
|
|
|
#include "x11/icccm.hpp"
|
2016-12-05 20:41:00 +01:00
|
|
|
#include "x11/tray_manager.hpp"
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2017-09-05 23:35:29 -07:00
|
|
|
#if WITH_XCURSOR
|
|
|
|
#include "x11/cursor.hpp"
|
|
|
|
#endif
|
|
|
|
|
2016-11-02 20:22:45 +01:00
|
|
|
#if ENABLE_I3
|
|
|
|
#include "utils/i3.hpp"
|
|
|
|
#endif
|
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
using namespace signals::ui;
|
2022-01-22 22:00:26 +01:00
|
|
|
using namespace eventloop;
|
2016-11-20 23:04:31 +01:00
|
|
|
|
2016-12-09 09:02:47 +01:00
|
|
|
/**
|
|
|
|
* Create instance
|
|
|
|
*/
|
2022-01-22 22:00:26 +01:00
|
|
|
bar::make_type bar::make(loop& loop, bool only_initialize_values) {
|
2021-01-10 20:49:50 +01:00
|
|
|
auto action_ctxt = make_unique<tags::action_context>();
|
|
|
|
|
2016-12-09 09:02:47 +01:00
|
|
|
// clang-format off
|
2021-09-21 21:15:49 +02:00
|
|
|
return std::make_unique<bar>(
|
2022-03-20 19:09:45 +01:00
|
|
|
connection::make(),
|
|
|
|
signal_emitter::make(),
|
|
|
|
config::make(),
|
|
|
|
logger::make(),
|
|
|
|
loop,
|
|
|
|
screen::make(),
|
|
|
|
tags::dispatch::make(*action_ctxt),
|
|
|
|
std::move(action_ctxt),
|
|
|
|
only_initialize_values);
|
2016-12-09 09:02:47 +01:00
|
|
|
// clang-format on
|
|
|
|
}
|
|
|
|
|
2016-11-20 23:04:31 +01:00
|
|
|
/**
|
|
|
|
* Construct bar instance
|
2016-11-02 20:22:45 +01:00
|
|
|
*
|
2016-12-05 20:41:00 +01:00
|
|
|
* TODO: Break out all tray handling
|
2016-11-02 20:22:45 +01:00
|
|
|
*/
|
2022-01-22 22:00:26 +01:00
|
|
|
bar::bar(connection& conn, signal_emitter& emitter, const config& config, const logger& logger, loop& loop,
|
2022-03-07 15:12:42 +01:00
|
|
|
unique_ptr<screen>&& screen, unique_ptr<tags::dispatch>&& dispatch, unique_ptr<tags::action_context>&& action_ctxt,
|
|
|
|
bool only_initialize_values)
|
2016-12-05 20:41:00 +01:00
|
|
|
: m_connection(conn)
|
|
|
|
, m_sig(emitter)
|
|
|
|
, m_conf(config)
|
|
|
|
, m_log(logger)
|
2021-09-27 17:35:45 +02:00
|
|
|
, m_loop(loop)
|
2016-12-20 05:05:43 +01:00
|
|
|
, m_screen(forward<decltype(screen)>(screen))
|
2020-12-17 20:37:28 +01:00
|
|
|
, m_dispatch(forward<decltype(dispatch)>(dispatch))
|
2021-09-27 17:35:45 +02:00
|
|
|
, m_action_ctxt(forward<decltype(action_ctxt)>(action_ctxt)) {
|
2016-12-14 05:12:15 +01:00
|
|
|
string bs{m_conf.section()};
|
2016-12-05 20:41:00 +01:00
|
|
|
|
2022-08-28 15:15:48 +02:00
|
|
|
// m_tray = tray_manager::make(m_opts);
|
2022-04-15 23:50:04 +02:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
// Get available RandR outputs
|
2016-12-30 23:32:05 +01:00
|
|
|
auto monitor_name = m_conf.get(bs, "monitor", ""s);
|
|
|
|
auto monitor_name_fallback = m_conf.get(bs, "monitor-fallback", ""s);
|
2018-12-03 01:34:40 +01:00
|
|
|
m_opts.monitor_strict = m_conf.get(bs, "monitor-strict", m_opts.monitor_strict);
|
2018-12-03 01:21:20 +01:00
|
|
|
m_opts.monitor_exact = m_conf.get(bs, "monitor-exact", m_opts.monitor_exact);
|
2022-03-16 22:55:31 +01:00
|
|
|
auto monitors = randr_util::get_monitors(m_connection, m_opts.monitor_strict, false);
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
if (monitors.empty()) {
|
|
|
|
throw application_error("No monitors found");
|
2016-12-13 19:33:43 -08:00
|
|
|
}
|
|
|
|
|
2019-01-20 11:20:30 -08:00
|
|
|
// if monitor_name is not defined, first check for primary monitor
|
|
|
|
if (monitor_name.empty()) {
|
|
|
|
for (auto&& mon : monitors) {
|
|
|
|
if (mon->primary) {
|
|
|
|
monitor_name = mon->name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if still not found (and not strict matching), get first connected monitor
|
2018-12-03 01:34:40 +01:00
|
|
|
if (monitor_name.empty() && !m_opts.monitor_strict) {
|
2022-03-16 22:55:31 +01:00
|
|
|
auto connected_monitors = randr_util::get_monitors(m_connection, true, false);
|
2016-12-20 05:05:43 +01:00
|
|
|
if (!connected_monitors.empty()) {
|
|
|
|
monitor_name = connected_monitors[0]->name;
|
|
|
|
m_log.warn("No monitor specified, using \"%s\"", monitor_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-20 11:20:30 -08:00
|
|
|
// if still not found, get first monitor
|
2016-12-13 19:33:43 -08:00
|
|
|
if (monitor_name.empty()) {
|
2016-12-05 20:41:00 +01:00
|
|
|
monitor_name = monitors[0]->name;
|
|
|
|
m_log.warn("No monitor specified, using \"%s\"", monitor_name);
|
|
|
|
}
|
2016-11-21 16:14:40 +01:00
|
|
|
|
2019-01-20 11:20:30 -08:00
|
|
|
// get the monitor data based on the name
|
2018-12-03 01:21:20 +01:00
|
|
|
m_opts.monitor = randr_util::match_monitor(monitors, monitor_name, m_opts.monitor_exact);
|
2016-12-13 19:33:43 -08:00
|
|
|
monitor_t fallback{};
|
|
|
|
|
2019-10-27 15:25:12 +01:00
|
|
|
if (!monitor_name_fallback.empty()) {
|
2018-12-03 01:21:20 +01:00
|
|
|
fallback = randr_util::match_monitor(monitors, monitor_name_fallback, m_opts.monitor_exact);
|
2016-12-05 20:41:00 +01:00
|
|
|
}
|
2016-12-03 23:08:47 +01:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
if (!m_opts.monitor) {
|
2016-12-13 19:33:43 -08:00
|
|
|
if (fallback) {
|
|
|
|
m_opts.monitor = move(fallback);
|
2018-12-03 01:21:20 +01:00
|
|
|
m_log.warn("Monitor \"%s\" not found, reverting to fallback \"%s\"", monitor_name, m_opts.monitor->name);
|
2016-12-13 19:33:43 -08:00
|
|
|
} else {
|
|
|
|
throw application_error("Monitor \"" + monitor_name + "\" not found or disconnected");
|
|
|
|
}
|
2016-12-05 20:41:00 +01:00
|
|
|
}
|
2016-12-05 13:17:09 +01:00
|
|
|
|
2016-12-20 05:05:43 +01:00
|
|
|
m_log.info("Loaded monitor %s (%ix%i+%i+%i)", m_opts.monitor->name, m_opts.monitor->w, m_opts.monitor->h,
|
2016-12-05 20:41:00 +01:00
|
|
|
m_opts.monitor->x, m_opts.monitor->y);
|
2016-12-05 13:17:09 +01:00
|
|
|
|
2022-06-12 21:31:11 +07:00
|
|
|
m_opts.override_redirect = m_conf.deprecated(bs, "dock", "override-redirect", m_opts.override_redirect);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
2016-12-30 23:32:05 +01:00
|
|
|
m_opts.dimvalue = m_conf.get(bs, "dim-value", 1.0);
|
2016-12-16 06:44:55 +01:00
|
|
|
m_opts.dimvalue = math_util::cap(m_opts.dimvalue, 0.0, 1.0);
|
|
|
|
|
2017-09-08 16:45:16 -07:00
|
|
|
#if WITH_XCURSOR
|
2022-03-20 18:32:21 +01:00
|
|
|
m_opts.cursor_click = m_conf.get(bs, "cursor-click", ""s);
|
2017-09-08 16:45:16 -07:00
|
|
|
if (!m_opts.cursor_click.empty() && !cursor_util::valid(m_opts.cursor_click)) {
|
|
|
|
m_log.warn("Ignoring unsupported cursor-click option '%s'", m_opts.cursor_click);
|
|
|
|
m_opts.cursor_click.clear();
|
|
|
|
}
|
2022-03-20 18:32:21 +01:00
|
|
|
|
|
|
|
m_opts.cursor_scroll = m_conf.get(bs, "cursor-scroll", ""s);
|
2017-09-08 16:45:16 -07:00
|
|
|
if (!m_opts.cursor_scroll.empty() && !cursor_util::valid(m_opts.cursor_scroll)) {
|
|
|
|
m_log.warn("Ignoring unsupported cursor-scroll option '%s'", m_opts.cursor_scroll);
|
|
|
|
m_opts.cursor_scroll.clear();
|
|
|
|
}
|
2022-03-20 18:32:21 +01:00
|
|
|
#else
|
|
|
|
if (m_conf.has(bs, "cursor-click")) {
|
|
|
|
m_log.warn("Polybar was not compiled with xcursor support, ignoring cursor-click option");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_conf.has(bs, "cursor-scroll")) {
|
|
|
|
m_log.warn("Polybar was not compiled with xcursor support, ignoring cursor-scroll option");
|
|
|
|
}
|
2017-09-08 16:45:16 -07:00
|
|
|
#endif
|
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
// Build WM_NAME
|
2016-12-30 23:32:05 +01:00
|
|
|
m_opts.wmname = m_conf.get(bs, "wm-name", "polybar-" + bs.substr(4) + "_" + m_opts.monitor->name);
|
2016-12-05 20:41:00 +01:00
|
|
|
m_opts.wmname = string_util::replace(m_opts.wmname, " ", "-");
|
|
|
|
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
// Configure DPI
|
|
|
|
{
|
|
|
|
double dpi_x = 96, dpi_y = 96;
|
|
|
|
if (m_conf.has(m_conf.section(), "dpi")) {
|
|
|
|
dpi_x = dpi_y = m_conf.get<double>("dpi");
|
|
|
|
} else {
|
|
|
|
if (m_conf.has(m_conf.section(), "dpi-x")) {
|
|
|
|
dpi_x = m_conf.get<double>("dpi-x");
|
|
|
|
}
|
|
|
|
if (m_conf.has(m_conf.section(), "dpi-y")) {
|
|
|
|
dpi_y = m_conf.get<double>("dpi-y");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// dpi to be computed
|
|
|
|
if (dpi_x <= 0 || dpi_y <= 0) {
|
|
|
|
auto screen = m_connection.screen();
|
|
|
|
if (dpi_x <= 0) {
|
|
|
|
dpi_x = screen->width_in_pixels * 25.4 / screen->width_in_millimeters;
|
|
|
|
}
|
|
|
|
if (dpi_y <= 0) {
|
|
|
|
dpi_y = screen->height_in_pixels * 25.4 / screen->height_in_millimeters;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_opts.dpi_x = dpi_x;
|
|
|
|
m_opts.dpi_y = dpi_y;
|
|
|
|
|
|
|
|
m_log.info("Configured DPI = %gx%g", dpi_x, dpi_y);
|
|
|
|
}
|
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
// Load configuration values
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
|
2022-03-14 23:47:05 +01:00
|
|
|
m_opts.bottom = m_conf.get(bs, "bottom", m_opts.bottom);
|
2016-12-30 23:32:05 +01:00
|
|
|
m_opts.spacing = m_conf.get(bs, "spacing", m_opts.spacing);
|
2019-10-27 13:32:45 +01:00
|
|
|
m_opts.separator = drawtypes::load_optional_label(m_conf, bs, "separator", "");
|
2016-12-30 23:32:05 +01:00
|
|
|
m_opts.locale = m_conf.get(bs, "locale", ""s);
|
2017-03-21 14:49:33 +01:00
|
|
|
|
|
|
|
auto radius = m_conf.get<double>(bs, "radius", 0.0);
|
2020-10-21 09:02:52 +02:00
|
|
|
auto top = m_conf.get(bs, "radius-top", radius);
|
|
|
|
m_opts.radius.top_left = m_conf.get(bs, "radius-top-left", top);
|
|
|
|
m_opts.radius.top_right = m_conf.get(bs, "radius-top-right", top);
|
|
|
|
auto bottom = m_conf.get(bs, "radius-bottom", radius);
|
|
|
|
m_opts.radius.bottom_left = m_conf.get(bs, "radius-bottom-left", bottom);
|
|
|
|
m_opts.radius.bottom_right = m_conf.get(bs, "radius-bottom-right", bottom);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
auto padding = m_conf.get(bs, "padding", ZERO_SPACE);
|
2017-01-25 15:12:57 +01:00
|
|
|
m_opts.padding.left = m_conf.get(bs, "padding-left", padding);
|
|
|
|
m_opts.padding.right = m_conf.get(bs, "padding-right", padding);
|
|
|
|
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
auto margin = m_conf.get(bs, "module-margin", ZERO_SPACE);
|
2017-01-25 15:12:57 +01:00
|
|
|
m_opts.module_margin.left = m_conf.get(bs, "module-margin-left", margin);
|
|
|
|
m_opts.module_margin.right = m_conf.get(bs, "module-margin-right", margin);
|
2017-01-12 17:32:11 +01:00
|
|
|
|
2021-09-27 17:35:45 +02:00
|
|
|
m_opts.double_click_interval = m_conf.get(bs, "double-click-interval", m_opts.double_click_interval);
|
|
|
|
|
2016-12-27 04:15:01 +01:00
|
|
|
if (only_initialize_values) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
// Load values used to adjust the struts atom
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
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{});
|
2022-03-14 23:47:05 +01:00
|
|
|
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);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
|
|
|
// Load commands used for fallback click handlers
|
|
|
|
vector<action> actions;
|
2016-12-30 23:32:05 +01:00
|
|
|
actions.emplace_back(action{mousebtn::LEFT, m_conf.get(bs, "click-left", ""s)});
|
|
|
|
actions.emplace_back(action{mousebtn::MIDDLE, m_conf.get(bs, "click-middle", ""s)});
|
|
|
|
actions.emplace_back(action{mousebtn::RIGHT, m_conf.get(bs, "click-right", ""s)});
|
|
|
|
actions.emplace_back(action{mousebtn::SCROLL_UP, m_conf.get(bs, "scroll-up", ""s)});
|
|
|
|
actions.emplace_back(action{mousebtn::SCROLL_DOWN, m_conf.get(bs, "scroll-down", ""s)});
|
|
|
|
actions.emplace_back(action{mousebtn::DOUBLE_LEFT, m_conf.get(bs, "double-click-left", ""s)});
|
|
|
|
actions.emplace_back(action{mousebtn::DOUBLE_MIDDLE, m_conf.get(bs, "double-click-middle", ""s)});
|
|
|
|
actions.emplace_back(action{mousebtn::DOUBLE_RIGHT, m_conf.get(bs, "double-click-right", ""s)});
|
2016-12-05 20:41:00 +01:00
|
|
|
|
|
|
|
for (auto&& act : actions) {
|
|
|
|
if (!act.command.empty()) {
|
|
|
|
m_opts.actions.emplace_back(action{act.button, act.command});
|
2016-12-05 13:17:09 +01:00
|
|
|
}
|
2016-11-21 16:14:40 +01:00
|
|
|
}
|
|
|
|
|
2019-10-27 22:41:18 +01:00
|
|
|
const auto parse_or_throw_color = [&](string key, rgba def) -> rgba {
|
2017-01-20 02:32:52 +01:00
|
|
|
try {
|
2020-11-27 21:52:53 +01:00
|
|
|
rgba color = m_conf.get(bs, key, def);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are the base colors of the bar and cannot be alpha only
|
|
|
|
* In that case, we just use the alpha channel on the default value.
|
|
|
|
*/
|
2020-12-01 14:49:41 +01:00
|
|
|
return color.try_apply_alpha_to(def);
|
2017-01-20 02:32:52 +01:00
|
|
|
} catch (const exception& err) {
|
|
|
|
throw application_error(sstream() << "Failed to set " << key << " (reason: " << err.what() << ")");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-19 05:38:42 +01:00
|
|
|
// Load background
|
|
|
|
for (auto&& step : m_conf.get_list<rgba>(bs, "background", {})) {
|
|
|
|
m_opts.background_steps.emplace_back(step);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_opts.background_steps.empty()) {
|
|
|
|
m_opts.background = m_opts.background_steps[0];
|
|
|
|
|
|
|
|
if (m_conf.has(bs, "background")) {
|
|
|
|
m_log.warn("Ignoring `%s.background` (overridden by gradient background)", bs);
|
|
|
|
}
|
|
|
|
} else {
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.background = parse_or_throw_color("background", m_opts.background);
|
2017-01-19 05:38:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load foreground
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.foreground = parse_or_throw_color("foreground", m_opts.foreground);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
2017-01-19 05:38:42 +01:00
|
|
|
// Load over-/underline
|
2017-01-27 13:46:27 +01:00
|
|
|
auto line_color = m_conf.get(bs, "line-color", rgba{0xFFFF0000});
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
auto line_size = m_conf.get(bs, "line-size", ZERO_PX_EXTENT);
|
|
|
|
|
|
|
|
auto overline_size = m_conf.get(bs, "overline-size", line_size);
|
|
|
|
auto underline_size = m_conf.get(bs, "underline-size", line_size);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
m_opts.overline.size = units_utils::extent_to_pixel_nonnegative(overline_size, m_opts.dpi_y);
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.overline.color = parse_or_throw_color("overline-color", line_color);
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
m_opts.underline.size = units_utils::extent_to_pixel_nonnegative(underline_size, m_opts.dpi_y);
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.underline.color = parse_or_throw_color("underline-color", line_color);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
|
|
|
// Load border settings
|
2017-01-27 13:46:27 +01:00
|
|
|
auto border_color = m_conf.get(bs, "border-color", rgba{0x00000000});
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
auto border_size = m_conf.get(bs, "border-size", percentage_with_offset{});
|
2019-01-12 12:48:09 +02:00
|
|
|
auto border_top = m_conf.deprecated(bs, "border-top", "border-top-size", border_size);
|
|
|
|
auto border_bottom = m_conf.deprecated(bs, "border-bottom", "border-bottom-size", border_size);
|
|
|
|
auto border_left = m_conf.deprecated(bs, "border-left", "border-left-size", border_size);
|
|
|
|
auto border_right = m_conf.deprecated(bs, "border-right", "border-right-size", border_size);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
|
|
|
m_opts.borders.emplace(edge::TOP, border_settings{});
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
m_opts.borders[edge::TOP].size =
|
2022-03-03 22:19:37 +01:00
|
|
|
units_utils::percentage_with_offset_to_pixel_nonnegative(border_top, m_opts.monitor->h, m_opts.dpi_y);
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.borders[edge::TOP].color = parse_or_throw_color("border-top-color", border_color);
|
2016-12-05 20:41:00 +01:00
|
|
|
m_opts.borders.emplace(edge::BOTTOM, border_settings{});
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
m_opts.borders[edge::BOTTOM].size =
|
2022-03-03 22:19:37 +01:00
|
|
|
units_utils::percentage_with_offset_to_pixel_nonnegative(border_bottom, m_opts.monitor->h, m_opts.dpi_y);
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.borders[edge::BOTTOM].color = parse_or_throw_color("border-bottom-color", border_color);
|
2016-12-05 20:41:00 +01:00
|
|
|
m_opts.borders.emplace(edge::LEFT, border_settings{});
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
m_opts.borders[edge::LEFT].size =
|
2022-03-03 22:19:37 +01:00
|
|
|
units_utils::percentage_with_offset_to_pixel_nonnegative(border_left, m_opts.monitor->w, m_opts.dpi_x);
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.borders[edge::LEFT].color = parse_or_throw_color("border-left-color", border_color);
|
2016-12-05 20:41:00 +01:00
|
|
|
m_opts.borders.emplace(edge::RIGHT, border_settings{});
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
m_opts.borders[edge::RIGHT].size =
|
2022-03-03 22:19:37 +01:00
|
|
|
units_utils::percentage_with_offset_to_pixel_nonnegative(border_right, m_opts.monitor->w, m_opts.dpi_x);
|
2019-10-27 22:41:18 +01:00
|
|
|
m_opts.borders[edge::RIGHT].color = parse_or_throw_color("border-right-color", border_color);
|
2016-12-05 20:41:00 +01:00
|
|
|
|
|
|
|
// Load geometry values
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
auto w = m_conf.get(m_conf.section(), "width", percentage_with_offset{100.});
|
|
|
|
auto h = m_conf.get(m_conf.section(), "height", percentage_with_offset{0., {extent_type::PIXEL, 24}});
|
|
|
|
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{});
|
|
|
|
|
2022-03-03 22:19:37 +01:00
|
|
|
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);
|
Add units support (POINT, PIXEL, SPACE) (#2578)
* add units support (POINT, PIXEL, SPACE) for polybar
- add a size_with_unit struct
- add a geometry_format_values struct
- move dpi initialisation from renderer.cpp to bar.cpp
- add a string to size_with_unit converter
- add point support (with pt)
- add pixel support (with px)
* Fix unit test compilation
* clang-format
* Better names
The old names didn't really capture the purpose of the structs and
function.
space_type -> spacing_type
space_size -> spacing_val
size_type -> extent_type
geometry -> extent_val
geometry_format_values -> percentage_with_offset
* Remove parse_size_with_unit
No longer needed. The convert<spacing_val> function in config.cpp
already does all the work for us and always setting the type to pixel
was wrong.
In addition, line-size should not be of type spacing_val but extent_val.
* Cleanup
I tried to address most of my comments on the old PR
* Fix renderer width calculation
We can't just blindly add the x difference to the width because for
example the width should increase if x < width and the increase keeps
x < width.
Similarly, we can't just add the offset to the width.
* Rename geom_format_to_pixels to percentage_with_offset_to_pixel
* Cleanup
* Apply suggested changes from Patrick on GitHub
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/bar.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/config.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* Update src/components/builder.cpp
Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
* config: Use stod for parsing percentage
* Use stof instead of strtof
* units: Fix test edge cases
* Remove unnecessary clang-format toggle
* Use percentage_with_offset for margin-{top,bottom}
* Support negative extent values
* Rename unit to units and create a cpp file
* Move percentage_with_offset_to_pixel unit test to units
* Add unit tests for units_utils
* Clarify when and how negative spacing/extent is allowed
Negative spacing is never allowed and produces a config error.
Extents allow negative values in theory, but only a few use-cases accept
it.
Only the extent value used for the `%{O}` tag and the offset value in
percentage_with_offset can be negative. Everything else is capped below
at 0.
The final pixel value of percentage_with_offset also caps below at 0.
* Fix parsing errors not being caught in config
* Print a proper error message for uncaught exceptions
* Cleanup module::get_output
All changes preserve the existing semantics
* Stop using remove_trailing_space in module::get_output
Instead, we first check if the current tag is built, and only if it is,
the spacing is prepended.
* Remove unused imports
* Restore old behavior
If there are two tags and the second one isn't built (module::build
returns false), the space in between them is removed.
For example in the mpd module:
format-online = <toggle> <label-song> foo
If mpd is not running, the mpd module will return false when trying to
build the `<label-song>` tag. If we don't remove the space between
`<toggle>` and `<label-song>`, we end up with two spaces between
`<toggle>` and `foo`.
This change is to match the old behavior where at least one trailing
space character was removed from the builder.
* Add changelog entry
* Remove unused setting
* Use percentage with offset for tray-offset
Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
Co-authored-by: Joe Groocock <github@frebib.net>
2022-02-20 21:08:57 +01:00
|
|
|
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);
|
2016-11-22 03:01:50 +01:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
// Apply offsets
|
|
|
|
m_opts.pos.x = m_opts.offset.x + m_opts.monitor->x;
|
|
|
|
m_opts.pos.y = m_opts.offset.y + m_opts.monitor->y;
|
|
|
|
m_opts.size.h += m_opts.borders[edge::TOP].size;
|
|
|
|
m_opts.size.h += m_opts.borders[edge::BOTTOM].size;
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2022-03-14 23:47:05 +01:00
|
|
|
if (m_opts.bottom) {
|
2016-12-05 20:41:00 +01:00
|
|
|
m_opts.pos.y = m_opts.monitor->y + m_opts.monitor->h - m_opts.size.h - m_opts.offset.y;
|
2016-11-22 01:22:47 +01:00
|
|
|
}
|
2016-11-21 15:07:00 +01:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
if (m_opts.size.w <= 0 || m_opts.size.w > m_opts.monitor->w) {
|
2017-01-13 03:52:56 +01:00
|
|
|
throw application_error("Resulting bar width is out of bounds (" + to_string(m_opts.size.w) + ")");
|
2016-12-05 20:41:00 +01:00
|
|
|
} else if (m_opts.size.h <= 0 || m_opts.size.h > m_opts.monitor->h) {
|
2017-01-13 03:52:56 +01:00
|
|
|
throw application_error("Resulting bar height is out of bounds (" + to_string(m_opts.size.h) + ")");
|
2016-12-05 20:41:00 +01:00
|
|
|
}
|
2016-11-13 16:10:20 +01:00
|
|
|
|
2019-10-27 15:25:12 +01:00
|
|
|
m_log.info("Bar geometry: %ix%i+%i+%i; Borders: %d,%d,%d,%d", m_opts.size.w, m_opts.size.h, m_opts.pos.x,
|
|
|
|
m_opts.pos.y, m_opts.borders[edge::TOP].size, m_opts.borders[edge::RIGHT].size, m_opts.borders[edge::BOTTOM].size,
|
|
|
|
m_opts.borders[edge::LEFT].size);
|
2016-11-25 04:10:26 +01:00
|
|
|
|
2017-01-19 05:38:42 +01:00
|
|
|
m_log.trace("bar: Attach X event sink");
|
|
|
|
m_connection.attach_sink(this, SINK_PRIORITY_BAR);
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2017-01-19 05:38:42 +01:00
|
|
|
m_log.trace("bar: Attach signal receiver");
|
2016-12-21 04:50:43 +01:00
|
|
|
m_sig.attach(this);
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2016-11-04 18:54:33 +01:00
|
|
|
/**
|
2016-12-05 20:41:00 +01:00
|
|
|
* Cleanup signal handlers and destroy the bar window
|
2016-11-04 18:54:33 +01:00
|
|
|
*/
|
2016-12-05 20:41:00 +01:00
|
|
|
bar::~bar() {
|
|
|
|
m_connection.detach_sink(this, SINK_PRIORITY_BAR);
|
2016-12-21 04:50:43 +01:00
|
|
|
m_sig.detach(this);
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the bar settings container
|
|
|
|
*/
|
2022-03-14 22:11:46 +01:00
|
|
|
const bar_settings& bar::settings() const {
|
2016-11-12 12:56:39 +01:00
|
|
|
return m_opts;
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse input string and redraw the bar window
|
|
|
|
*
|
2022-02-20 21:40:48 +01:00
|
|
|
* @param data Input string
|
|
|
|
* @param force Unless true, do not parse unchanged data
|
2016-11-02 20:22:45 +01:00
|
|
|
*/
|
2017-01-09 14:27:55 +01:00
|
|
|
void bar::parse(string&& data, bool force) {
|
2019-10-01 17:06:06 +02:00
|
|
|
bool unchanged = data == m_lastinput;
|
|
|
|
|
|
|
|
m_lastinput = data;
|
|
|
|
|
2017-01-09 14:27:55 +01:00
|
|
|
if (force) {
|
|
|
|
m_log.trace("bar: Force update");
|
2017-04-21 18:15:18 +02:00
|
|
|
} else if (!m_visible) {
|
|
|
|
return m_log.trace("bar: Ignoring update (invisible)");
|
2019-10-01 17:06:06 +02:00
|
|
|
} else if (unchanged) {
|
2017-04-21 18:15:18 +02:00
|
|
|
return m_log.trace("bar: Ignoring update (unchanged)");
|
2016-11-25 13:55:15 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2017-01-25 23:36:34 +01:00
|
|
|
auto rect = m_opts.inner_area();
|
|
|
|
|
2022-08-27 23:02:34 +02:00
|
|
|
// TODO use legacy tray implementation
|
|
|
|
#if 0
|
2022-07-25 23:36:54 +02:00
|
|
|
if (m_tray && !m_tray->settings().detached && m_tray->settings().num_mapped_clients > 0 &&
|
2022-06-15 11:09:13 +02:00
|
|
|
m_tray->settings().tray_position != tray_postition::MODULE) {
|
|
|
|
auto tray_pos = m_tray->settings().tray_position;
|
2022-02-27 21:36:16 +01:00
|
|
|
auto traywidth = m_tray->settings().win_size.w;
|
2022-06-15 11:09:13 +02:00
|
|
|
if (tray_pos == tray_postition::LEFT) {
|
2017-01-25 23:36:34 +01:00
|
|
|
rect.x += traywidth;
|
|
|
|
rect.width -= traywidth;
|
2022-06-15 11:09:13 +02:00
|
|
|
} else if (tray_pos == tray_postition::RIGHT) {
|
2017-01-25 23:36:34 +01:00
|
|
|
rect.width -= traywidth;
|
2016-11-25 13:55:15 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
}
|
2022-08-27 23:02:34 +02:00
|
|
|
#endif
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2017-01-25 23:36:34 +01:00
|
|
|
m_log.info("Redrawing bar window");
|
|
|
|
m_renderer->begin(rect);
|
|
|
|
|
2016-11-21 15:07:00 +01:00
|
|
|
try {
|
2021-01-10 20:49:50 +01:00
|
|
|
m_dispatch->parse(settings(), *m_renderer, std::move(data));
|
2020-12-17 20:37:28 +01:00
|
|
|
} catch (const exception& err) {
|
2016-11-25 04:10:26 +01:00
|
|
|
m_log.err("Failed to parse contents (reason: %s)", err.what());
|
2016-11-02 20:22:45 +01:00
|
|
|
}
|
2016-11-21 15:07:00 +01:00
|
|
|
|
|
|
|
m_renderer->end();
|
2017-01-15 02:00:33 +01:00
|
|
|
|
2022-04-25 03:59:40 -07:00
|
|
|
m_dblclicks.clear();
|
|
|
|
for (auto&& action : m_opts.actions) {
|
|
|
|
if (static_cast<int>(action.button) >= static_cast<int>(mousebtn::DOUBLE_LEFT)) {
|
|
|
|
m_dblclicks.insert(action.button);
|
2017-01-15 02:00:33 +01:00
|
|
|
}
|
2022-04-25 03:59:40 -07:00
|
|
|
}
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2017-04-21 18:15:18 +02:00
|
|
|
/**
|
|
|
|
* Hide the bar by unmapping its X window
|
|
|
|
*/
|
|
|
|
void bar::hide() {
|
|
|
|
if (!m_visible) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
m_log.info("Hiding bar window");
|
2022-04-27 21:09:59 +02:00
|
|
|
m_visible = false;
|
|
|
|
reconfigure_struts();
|
2017-04-21 18:15:18 +02:00
|
|
|
m_sig.emit(visibility_change{false});
|
2022-03-16 23:11:19 +01:00
|
|
|
m_connection.unmap_window_checked(m_opts.x_data.window);
|
2017-04-21 18:15:18 +02:00
|
|
|
m_connection.flush();
|
|
|
|
} catch (const exception& err) {
|
|
|
|
m_log.err("Failed to unmap bar window (err=%s", err.what());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the bar by mapping its X window and
|
|
|
|
* trigger a redraw of previous content
|
|
|
|
*/
|
|
|
|
void bar::show() {
|
|
|
|
if (m_visible) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
m_log.info("Showing bar window");
|
|
|
|
m_sig.emit(visibility_change{true});
|
2022-03-15 21:48:19 +01:00
|
|
|
map_window();
|
2017-04-21 18:15:18 +02:00
|
|
|
m_connection.flush();
|
|
|
|
parse(string{m_lastinput}, true);
|
|
|
|
} catch (const exception& err) {
|
|
|
|
m_log.err("Failed to map bar window (err=%s", err.what());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the bar's visibility state
|
|
|
|
*/
|
|
|
|
void bar::toggle() {
|
|
|
|
if (m_visible) {
|
|
|
|
hide();
|
|
|
|
} else {
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-12 12:56:39 +01:00
|
|
|
/**
|
|
|
|
* Move the bar window above defined sibling
|
|
|
|
* in the X window stack
|
|
|
|
*/
|
2016-11-13 21:50:21 +01:00
|
|
|
void bar::restack_window() {
|
2016-11-12 12:56:39 +01:00
|
|
|
string wm_restack;
|
|
|
|
|
|
|
|
try {
|
2016-12-30 23:32:05 +01:00
|
|
|
wm_restack = m_conf.get(m_conf.section(), "wm-restack");
|
2016-11-12 12:56:39 +01:00
|
|
|
} catch (const key_error& err) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto restacked = false;
|
|
|
|
|
2021-04-02 00:48:48 +02:00
|
|
|
if (wm_restack == "generic") {
|
|
|
|
try {
|
2022-03-16 22:55:31 +01:00
|
|
|
auto children = m_connection.query_tree(m_connection.root()).children();
|
2022-03-16 23:11:19 +01:00
|
|
|
if (children.begin() != children.end() && *children.begin() != m_opts.x_data.window) {
|
2021-04-02 00:48:48 +02:00
|
|
|
const unsigned int value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE;
|
|
|
|
const unsigned int value_list[2]{*children.begin(), XCB_STACK_MODE_BELOW};
|
2022-03-16 23:11:19 +01:00
|
|
|
m_connection.configure_window_checked(m_opts.x_data.window, value_mask, value_list);
|
2021-04-02 00:48:48 +02:00
|
|
|
}
|
|
|
|
restacked = true;
|
|
|
|
} catch (const exception& err) {
|
|
|
|
m_log.err("Failed to restack bar window (err=%s)", err.what());
|
|
|
|
}
|
|
|
|
} else if (wm_restack == "bspwm") {
|
2022-03-16 23:11:19 +01:00
|
|
|
restacked = bspwm_util::restack_to_root(m_connection, m_opts.monitor, m_opts.x_data.window);
|
2016-11-12 12:56:39 +01:00
|
|
|
#if ENABLE_I3
|
2016-12-03 23:08:47 +01:00
|
|
|
} else if (wm_restack == "i3" && m_opts.override_redirect) {
|
2022-03-16 23:11:19 +01:00
|
|
|
restacked = i3_util::restack_to_root(m_connection, m_opts.x_data.window);
|
2016-12-03 23:08:47 +01:00
|
|
|
} else if (wm_restack == "i3" && !m_opts.override_redirect) {
|
|
|
|
m_log.warn("Ignoring restack of i3 window (not needed when `override-redirect = false`)");
|
2016-11-12 12:56:39 +01:00
|
|
|
wm_restack.clear();
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
m_log.warn("Ignoring unsupported wm-restack option '%s'", wm_restack);
|
|
|
|
wm_restack.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (restacked) {
|
|
|
|
m_log.info("Successfully restacked bar window");
|
|
|
|
} else if (!wm_restack.empty()) {
|
|
|
|
m_log.err("Failed to restack bar window");
|
|
|
|
}
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-12 12:56:39 +01:00
|
|
|
|
2021-10-04 23:46:38 +02:00
|
|
|
void bar::reconfigure_window() {
|
2019-10-16 00:30:10 +02:00
|
|
|
m_log.trace("bar: Reconfigure window");
|
|
|
|
restack_window();
|
|
|
|
reconfigure_geom();
|
|
|
|
reconfigure_struts();
|
|
|
|
reconfigure_wm_hints();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reconfigure window geometry
|
|
|
|
*/
|
|
|
|
void bar::reconfigure_geom() {
|
2022-03-16 23:11:19 +01:00
|
|
|
window win{m_connection, m_opts.x_data.window};
|
2019-10-16 00:30:10 +02:00
|
|
|
win.reconfigure_geom(m_opts.size.w, m_opts.size.h, m_opts.pos.x, m_opts.pos.y);
|
|
|
|
}
|
|
|
|
|
2016-11-13 11:30:27 +01:00
|
|
|
/**
|
2016-12-03 18:38:33 +01:00
|
|
|
* Reconfigure window position
|
|
|
|
*/
|
|
|
|
void bar::reconfigure_pos() {
|
2022-03-16 23:11:19 +01:00
|
|
|
window win{m_connection, m_opts.x_data.window};
|
2016-12-03 18:38:33 +01:00
|
|
|
win.reconfigure_pos(m_opts.pos.x, m_opts.pos.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reconfigure window strut values
|
2016-11-13 11:30:27 +01:00
|
|
|
*/
|
2016-12-03 18:38:33 +01:00
|
|
|
void bar::reconfigure_struts() {
|
2022-07-25 23:36:54 +02:00
|
|
|
window win{m_connection, m_opts.x_data.window};
|
2022-04-27 21:09:59 +02:00
|
|
|
if (m_visible) {
|
2022-07-25 23:36:54 +02:00
|
|
|
auto geom = m_connection.get_geometry(m_connection.root());
|
2022-04-27 21:09:59 +02:00
|
|
|
int h = m_opts.size.h + m_opts.offset.y;
|
2016-11-13 21:50:21 +01:00
|
|
|
|
2022-04-27 21:09:59 +02:00
|
|
|
// Apply user-defined margins
|
|
|
|
if (m_opts.bottom) {
|
|
|
|
h += m_opts.strut.top;
|
|
|
|
} else {
|
|
|
|
h += m_opts.strut.bottom;
|
|
|
|
}
|
2016-11-13 21:50:21 +01:00
|
|
|
|
2022-04-27 21:09:59 +02:00
|
|
|
h = std::max(h, 0);
|
2022-03-14 23:47:05 +01:00
|
|
|
|
2022-04-27 21:09:59 +02:00
|
|
|
int correction = 0;
|
2022-03-14 23:47:05 +01:00
|
|
|
|
2022-04-27 21:09:59 +02:00
|
|
|
// Only apply correction if any space is requested
|
|
|
|
if (h > 0) {
|
2022-03-14 23:47:05 +01:00
|
|
|
/*
|
2022-04-27 21:09:59 +02:00
|
|
|
* Strut coordinates have to be relative to root window and not any monitor.
|
|
|
|
* If any monitor is not aligned at the top or bottom
|
2022-03-14 23:47:05 +01:00
|
|
|
*/
|
2022-04-27 21:09:59 +02:00
|
|
|
if (m_opts.bottom) {
|
|
|
|
/*
|
|
|
|
* For bottom-algined bars, the correction is the number of pixels between
|
|
|
|
* the root window's bottom edge and the monitor's bottom edge
|
|
|
|
*/
|
|
|
|
correction = geom->height - (m_opts.monitor->y + m_opts.monitor->h);
|
|
|
|
} else {
|
|
|
|
// For top-aligned bars, we simply add the monitor's y-position
|
|
|
|
correction = m_opts.monitor->y;
|
|
|
|
}
|
2022-03-14 23:47:05 +01:00
|
|
|
|
2022-04-27 21:09:59 +02:00
|
|
|
correction = std::max(correction, 0);
|
|
|
|
}
|
|
|
|
win.reconfigure_struts(m_opts.size.w, h + correction, m_opts.pos.x, m_opts.bottom);
|
|
|
|
} else {
|
|
|
|
// Set struts to 0 for invisible bars
|
|
|
|
win.reconfigure_struts(0, 0, 0, m_opts.bottom);
|
2016-11-15 02:17:21 +01:00
|
|
|
}
|
2016-12-03 18:38:33 +01:00
|
|
|
}
|
2016-11-13 11:30:27 +01:00
|
|
|
|
2016-12-03 18:38:33 +01:00
|
|
|
/**
|
|
|
|
* Reconfigure window wm hint values
|
|
|
|
*/
|
|
|
|
void bar::reconfigure_wm_hints() {
|
2022-03-16 23:11:19 +01:00
|
|
|
const auto& win = m_opts.x_data.window;
|
2017-01-24 08:49:27 +01:00
|
|
|
|
2016-11-22 01:22:47 +01:00
|
|
|
m_log.trace("bar: Set window WM_NAME");
|
2017-01-24 08:49:27 +01:00
|
|
|
icccm_util::set_wm_name(m_connection, win, m_opts.wmname.c_str(), m_opts.wmname.size(), "polybar\0Polybar", 15_z);
|
2016-11-12 12:56:39 +01:00
|
|
|
|
2017-01-11 05:00:23 +01:00
|
|
|
m_log.trace("bar: Set window _NET_WM_WINDOW_TYPE");
|
2017-01-24 08:49:27 +01:00
|
|
|
ewmh_util::set_wm_window_type(win, {_NET_WM_WINDOW_TYPE_DOCK});
|
2016-11-12 12:56:39 +01:00
|
|
|
|
2016-11-22 01:22:47 +01:00
|
|
|
m_log.trace("bar: Set window _NET_WM_STATE");
|
2017-01-24 08:49:27 +01:00
|
|
|
ewmh_util::set_wm_state(win, {_NET_WM_STATE_STICKY, _NET_WM_STATE_ABOVE});
|
2016-11-12 12:56:39 +01:00
|
|
|
|
2016-11-22 01:22:47 +01:00
|
|
|
m_log.trace("bar: Set window _NET_WM_DESKTOP");
|
2017-01-24 08:49:27 +01:00
|
|
|
ewmh_util::set_wm_desktop(win, 0xFFFFFFFF);
|
2016-11-12 12:56:39 +01:00
|
|
|
|
2016-11-22 01:22:47 +01:00
|
|
|
m_log.trace("bar: Set window _NET_WM_PID");
|
2017-01-24 08:49:27 +01:00
|
|
|
ewmh_util::set_wm_pid(win);
|
2022-02-21 21:23:52 +01:00
|
|
|
|
|
|
|
icccm_util::set_wm_size_hints(m_connection, win, m_opts.pos.x, m_opts.pos.y, m_opts.size.w, m_opts.size.h);
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-12 12:56:39 +01:00
|
|
|
|
2016-12-03 20:26:29 +01:00
|
|
|
/**
|
|
|
|
* Broadcast current map state
|
|
|
|
*/
|
|
|
|
void bar::broadcast_visibility() {
|
2022-03-16 23:11:19 +01:00
|
|
|
auto attr = m_connection.get_window_attributes(m_opts.x_data.window);
|
2016-12-03 20:26:29 +01:00
|
|
|
|
2016-12-05 20:41:00 +01:00
|
|
|
if (attr->map_state == XCB_MAP_STATE_UNVIEWABLE) {
|
2017-04-21 18:15:18 +02:00
|
|
|
m_sig.emit(visibility_change{false});
|
2016-12-05 20:41:00 +01:00
|
|
|
} else if (attr->map_state == XCB_MAP_STATE_UNMAPPED) {
|
2017-04-21 18:15:18 +02:00
|
|
|
m_sig.emit(visibility_change{false});
|
2016-12-05 20:41:00 +01:00
|
|
|
} else {
|
2017-04-21 18:15:18 +02:00
|
|
|
m_sig.emit(visibility_change{true});
|
2016-12-03 20:26:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-15 21:48:19 +01:00
|
|
|
void bar::map_window() {
|
2022-04-27 21:09:59 +02:00
|
|
|
m_visible = true;
|
|
|
|
|
2022-03-15 21:48:19 +01:00
|
|
|
/**
|
|
|
|
* First reconfigures the window so that WMs that discard some information
|
|
|
|
* when unmapping have the correct window properties (geometry etc).
|
|
|
|
*/
|
|
|
|
reconfigure_window();
|
|
|
|
|
|
|
|
m_log.trace("bar: Map window");
|
2022-03-16 23:11:19 +01:00
|
|
|
m_connection.map_window_checked(m_opts.x_data.window);
|
2022-03-15 21:48:19 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Required by AwesomeWM. AwesomeWM does not seem to respect polybar's position if WM_NORMAL_HINTS are set before
|
|
|
|
* mapping. Additionally updating the window position after mapping seems to fix that.
|
|
|
|
*/
|
|
|
|
reconfigure_pos();
|
|
|
|
}
|
|
|
|
|
2021-09-27 17:35:45 +02:00
|
|
|
void bar::trigger_click(mousebtn btn, int pos) {
|
|
|
|
tags::action_t action = m_action_ctxt->has_action(btn, pos);
|
|
|
|
|
|
|
|
if (action != tags::NO_ACTION) {
|
|
|
|
m_log.trace("Found matching input area");
|
|
|
|
m_sig.emit(button_press{m_action_ctxt->get_action(action)});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto&& action : m_opts.actions) {
|
|
|
|
if (action.button == btn && !action.command.empty()) {
|
|
|
|
m_log.trace("Found matching fallback handler");
|
|
|
|
m_sig.emit(button_press{string{action.command}});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_log.info("No matching input area found (btn=%i)", static_cast<int>(btn));
|
|
|
|
}
|
|
|
|
|
2016-12-16 10:23:54 +01:00
|
|
|
/**
|
|
|
|
* Event handler for XCB_DESTROY_NOTIFY events
|
|
|
|
*/
|
|
|
|
void bar::handle(const evt::client_message& evt) {
|
2022-03-16 23:11:19 +01:00
|
|
|
if (evt->type == WM_PROTOCOLS && evt->data.data32[0] == WM_DELETE_WINDOW && evt->window == m_opts.x_data.window) {
|
2016-12-16 10:23:54 +01:00
|
|
|
m_log.err("Bar window has been destroyed, shutting down...");
|
|
|
|
m_connection.disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for XCB_DESTROY_NOTIFY events
|
|
|
|
*/
|
|
|
|
void bar::handle(const evt::destroy_notify& evt) {
|
2022-03-16 23:11:19 +01:00
|
|
|
if (evt->window == m_opts.x_data.window) {
|
2016-12-16 10:23:54 +01:00
|
|
|
m_connection.disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-16 06:44:55 +01:00
|
|
|
/**
|
|
|
|
* Event handler for XCB_ENTER_NOTIFY events
|
|
|
|
*
|
|
|
|
* Used to brighten the window by setting the
|
|
|
|
* _NET_WM_WINDOW_OPACITY atom value
|
|
|
|
*/
|
|
|
|
void bar::handle(const evt::enter_notify&) {
|
|
|
|
if (m_opts.dimmed) {
|
2022-01-22 20:35:37 +01:00
|
|
|
m_dim_timer.start(25, 0, [this]() {
|
2016-12-21 04:50:43 +01:00
|
|
|
m_opts.dimmed = false;
|
|
|
|
m_sig.emit(dim_window{1.0});
|
|
|
|
});
|
2022-01-22 20:35:37 +01:00
|
|
|
} else if (m_dim_timer.is_active()) {
|
|
|
|
m_dim_timer.stop();
|
2016-12-16 06:44:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for XCB_LEAVE_NOTIFY events
|
|
|
|
*
|
|
|
|
* Used to dim the window by setting the
|
|
|
|
* _NET_WM_WINDOW_OPACITY atom value
|
|
|
|
*/
|
|
|
|
void bar::handle(const evt::leave_notify&) {
|
2021-09-27 17:35:45 +02:00
|
|
|
// Only trigger dimming, if the dim-value is not fully opaque.
|
|
|
|
if (m_opts.dimvalue < 1.0) {
|
|
|
|
if (!m_opts.dimmed) {
|
2022-01-22 20:35:37 +01:00
|
|
|
m_dim_timer.start(3000, 0, [this]() {
|
2021-09-27 17:35:45 +02:00
|
|
|
m_opts.dimmed = true;
|
|
|
|
m_sig.emit(dim_window{double(m_opts.dimvalue)});
|
|
|
|
});
|
|
|
|
}
|
2016-12-16 06:44:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-02 21:45:45 -07:00
|
|
|
/**
|
|
|
|
* Event handler for XCB_MOTION_NOTIFY events
|
|
|
|
*
|
|
|
|
* Used to change the cursor depending on the module
|
|
|
|
*/
|
|
|
|
void bar::handle(const evt::motion_notify& evt) {
|
|
|
|
m_log.trace("bar: Detected motion: %i at pos(%i, %i)", evt->detail, evt->event_x, evt->event_y);
|
2017-09-05 23:35:29 -07:00
|
|
|
#if WITH_XCURSOR
|
2022-03-20 18:32:21 +01:00
|
|
|
int motion_pos = evt->event_x;
|
2019-10-27 15:25:12 +01:00
|
|
|
// scroll cursor is less important than click cursor, so we shouldn't return until we are sure there is no click
|
|
|
|
// action
|
2017-09-02 21:45:45 -07:00
|
|
|
bool found_scroll = false;
|
2021-01-10 20:49:50 +01:00
|
|
|
const auto has_action = [&](const vector<mousebtn>& buttons) -> bool {
|
|
|
|
for (auto btn : buttons) {
|
2022-03-20 18:32:21 +01:00
|
|
|
if (m_action_ctxt->has_action(btn, motion_pos) != tags::NO_ACTION) {
|
2021-01-10 20:49:50 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2022-03-20 19:09:45 +01:00
|
|
|
if (!m_opts.cursor_click.empty() && has_action({mousebtn::LEFT, mousebtn::MIDDLE, mousebtn::RIGHT,
|
|
|
|
mousebtn::DOUBLE_LEFT, mousebtn::DOUBLE_MIDDLE, mousebtn::DOUBLE_RIGHT})) {
|
|
|
|
change_cursor(m_opts.cursor_click);
|
2021-01-10 20:49:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-20 19:09:45 +01:00
|
|
|
if (!m_opts.cursor_scroll.empty() && has_action({mousebtn::SCROLL_DOWN, mousebtn::SCROLL_UP})) {
|
|
|
|
change_cursor(m_opts.cursor_scroll);
|
2021-01-10 20:49:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-06 15:18:56 -07:00
|
|
|
const auto find_click_area = [&](const action& action) {
|
2019-10-27 15:25:12 +01:00
|
|
|
if (!m_opts.cursor_click.empty() &&
|
|
|
|
!(action.button == mousebtn::SCROLL_UP || action.button == mousebtn::SCROLL_DOWN ||
|
|
|
|
action.button == mousebtn::NONE)) {
|
2022-03-20 19:09:45 +01:00
|
|
|
change_cursor(m_opts.cursor_click);
|
2017-09-02 21:45:45 -07:00
|
|
|
return true;
|
2019-10-27 15:25:12 +01:00
|
|
|
} else if (!m_opts.cursor_scroll.empty() &&
|
|
|
|
(action.button == mousebtn::SCROLL_UP || action.button == mousebtn::SCROLL_DOWN)) {
|
2017-09-02 21:45:45 -07:00
|
|
|
if (!found_scroll) {
|
2019-10-27 15:25:12 +01:00
|
|
|
found_scroll = true;
|
2017-09-02 21:45:45 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto&& action : m_opts.actions) {
|
|
|
|
if (!action.command.empty()) {
|
|
|
|
m_log.trace("Found matching fallback handler");
|
2022-03-20 19:09:45 +01:00
|
|
|
if (find_click_area(action)) {
|
2017-09-02 21:45:45 -07:00
|
|
|
return;
|
2022-03-20 19:09:45 +01:00
|
|
|
}
|
2017-09-02 21:45:45 -07:00
|
|
|
}
|
|
|
|
}
|
2022-03-20 18:32:21 +01:00
|
|
|
|
2019-10-27 15:25:12 +01:00
|
|
|
if (found_scroll) {
|
2022-03-20 19:09:45 +01:00
|
|
|
change_cursor(m_opts.cursor_scroll);
|
2017-09-02 21:45:45 -07:00
|
|
|
return;
|
|
|
|
}
|
2022-03-20 18:32:21 +01:00
|
|
|
|
2022-03-20 19:09:45 +01:00
|
|
|
m_log.trace("No matching cursor area found");
|
|
|
|
change_cursor("default");
|
|
|
|
return;
|
2017-09-05 23:35:29 -07:00
|
|
|
#endif
|
2017-09-02 21:45:45 -07:00
|
|
|
}
|
|
|
|
|
2016-11-02 20:22:45 +01:00
|
|
|
/**
|
|
|
|
* Event handler for XCB_BUTTON_PRESS events
|
|
|
|
*
|
|
|
|
* Used to map mouse clicks to bar actions
|
|
|
|
*/
|
2016-11-13 21:50:21 +01:00
|
|
|
void bar::handle(const evt::button_press& evt) {
|
2016-12-14 10:09:39 +01:00
|
|
|
m_log.trace("bar: Received button press: %i at pos(%i, %i)", evt->detail, evt->event_x, evt->event_y);
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2021-09-27 17:35:45 +02:00
|
|
|
mousebtn btn = static_cast<mousebtn>(evt->detail);
|
|
|
|
int pos = evt->event_x;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For possible double-clicks we need to delay the triggering of the click by
|
|
|
|
* the configured interval and if in that time another click arrives, we
|
|
|
|
* need to trigger a double click.
|
|
|
|
*/
|
2022-01-22 22:00:26 +01:00
|
|
|
const auto check_double = [this](TimerHandle& handle, mousebtn btn, int pos) {
|
2022-01-22 20:35:37 +01:00
|
|
|
if (!handle.is_active()) {
|
|
|
|
handle.start(m_opts.double_click_interval, 0, [=]() { trigger_click(btn, pos); });
|
2021-09-27 17:35:45 +02:00
|
|
|
} else {
|
2022-01-22 20:35:37 +01:00
|
|
|
handle.stop();
|
2021-09-27 17:35:45 +02:00
|
|
|
trigger_click(mousebtn_get_double(btn), pos);
|
2016-12-20 13:03:46 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-25 03:59:40 -07:00
|
|
|
mousebtn double_btn = mousebtn_get_double(btn);
|
|
|
|
bool has_dblclick = m_dblclicks.count(double_btn) || m_action_ctxt->has_action(double_btn, pos) != tags::NO_ACTION;
|
|
|
|
|
2017-01-15 02:00:33 +01:00
|
|
|
// If there are no double click handlers defined we can
|
|
|
|
// just by-pass the click timer handling
|
2022-04-25 03:59:40 -07:00
|
|
|
if (!has_dblclick) {
|
2021-09-27 17:35:45 +02:00
|
|
|
trigger_click(btn, pos);
|
|
|
|
} else if (btn == mousebtn::LEFT) {
|
|
|
|
check_double(m_leftclick_timer, btn, pos);
|
|
|
|
} else if (btn == mousebtn::MIDDLE) {
|
|
|
|
check_double(m_middleclick_timer, btn, pos);
|
|
|
|
} else if (btn == mousebtn::RIGHT) {
|
|
|
|
check_double(m_rightclick_timer, btn, pos);
|
2016-12-20 13:03:46 +01:00
|
|
|
} else {
|
2021-09-27 17:35:45 +02:00
|
|
|
trigger_click(btn, pos);
|
2016-12-05 13:17:09 +01:00
|
|
|
}
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for XCB_EXPOSE events
|
|
|
|
*
|
|
|
|
* Used to redraw the bar
|
|
|
|
*/
|
2016-11-13 21:50:21 +01:00
|
|
|
void bar::handle(const evt::expose& evt) {
|
2022-03-16 23:11:19 +01:00
|
|
|
if (evt->window == m_opts.x_data.window && evt->count == 0) {
|
2022-08-28 15:15:48 +02:00
|
|
|
// if (m_tray->running()) {
|
|
|
|
// broadcast_visibility();
|
|
|
|
// }
|
2016-12-05 20:41:00 +01:00
|
|
|
|
2016-11-12 12:56:39 +01:00
|
|
|
m_log.trace("bar: Received expose event");
|
2017-01-19 05:38:42 +01:00
|
|
|
m_renderer->flush();
|
2016-11-12 12:56:39 +01:00
|
|
|
}
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Event handler for XCB_PROPERTY_NOTIFY events
|
|
|
|
*
|
2016-11-12 20:31:39 +01:00
|
|
|
* - Emit events whenever the bar window's
|
|
|
|
* visibility gets changed. This allows us to toggle the
|
2016-11-02 20:22:45 +01:00
|
|
|
* state of the tray container even though the tray
|
2016-11-12 20:31:39 +01:00
|
|
|
* window restacking failed. Used as a fallback for
|
|
|
|
* tedious WM's, like i3.
|
2016-11-02 20:22:45 +01:00
|
|
|
*/
|
2016-11-13 21:50:21 +01:00
|
|
|
void bar::handle(const evt::property_notify& evt) {
|
2017-01-19 05:38:42 +01:00
|
|
|
#ifdef DEBUG_LOGGER_VERBOSE
|
2016-11-12 12:56:39 +01:00
|
|
|
string atom_name = m_connection.get_atom_name(evt->atom).name();
|
2016-12-03 20:26:29 +01:00
|
|
|
m_log.trace_x("bar: property_notify(%s)", atom_name);
|
2016-11-12 12:56:39 +01:00
|
|
|
#endif
|
2016-11-04 18:54:33 +01:00
|
|
|
|
2022-03-16 23:11:19 +01:00
|
|
|
if (evt->window == m_opts.x_data.window && evt->atom == WM_STATE) {
|
2016-12-03 20:26:29 +01:00
|
|
|
broadcast_visibility();
|
2016-11-13 21:50:21 +01:00
|
|
|
}
|
|
|
|
}
|
2016-11-02 20:22:45 +01:00
|
|
|
|
2017-08-31 18:26:38 +02:00
|
|
|
void bar::handle(const evt::configure_notify&) {
|
|
|
|
// The absolute position of the window in the root may be different after configuration is done
|
|
|
|
// (for example, because the parent is not positioned at 0/0 in the root window).
|
|
|
|
// Notify components that the geometry may have changed (used by the background manager for example).
|
|
|
|
m_sig.emit(signals::ui::update_geometry{});
|
|
|
|
}
|
|
|
|
|
2022-06-15 11:09:13 +02:00
|
|
|
void bar::start(const string& tray_module_name) {
|
2017-01-19 05:38:42 +01:00
|
|
|
m_log.trace("bar: Create renderer");
|
2022-08-27 23:02:34 +02:00
|
|
|
m_renderer = renderer::make(m_opts, *m_action_ctxt);
|
2022-03-16 23:11:19 +01:00
|
|
|
|
|
|
|
m_opts.x_data.window = m_renderer->window();
|
|
|
|
m_opts.x_data.visual = m_renderer->visual();
|
|
|
|
m_opts.x_data.depth = m_renderer->depth();
|
2017-01-19 05:38:42 +01:00
|
|
|
|
|
|
|
// Subscribe to window enter and leave events
|
|
|
|
// if we should dim the window
|
|
|
|
if (m_opts.dimvalue != 1.0) {
|
2022-03-16 23:11:19 +01:00
|
|
|
m_connection.ensure_event_mask(m_opts.x_data.window, XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW);
|
2017-01-19 05:38:42 +01:00
|
|
|
}
|
2019-10-27 15:25:12 +01:00
|
|
|
if (!m_opts.cursor_click.empty() || !m_opts.cursor_scroll.empty()) {
|
2022-03-16 23:11:19 +01:00
|
|
|
m_connection.ensure_event_mask(m_opts.x_data.window, XCB_EVENT_MASK_POINTER_MOTION);
|
2017-09-02 21:45:45 -07:00
|
|
|
}
|
2022-03-16 23:11:19 +01:00
|
|
|
m_connection.ensure_event_mask(m_opts.x_data.window, XCB_EVENT_MASK_STRUCTURE_NOTIFY);
|
2017-01-19 05:38:42 +01:00
|
|
|
|
2022-03-16 23:11:19 +01:00
|
|
|
m_log.info("Bar window: %s", m_connection.id(m_opts.x_data.window));
|
2017-01-19 05:38:42 +01:00
|
|
|
|
2022-03-15 21:48:19 +01:00
|
|
|
map_window();
|
2017-01-19 05:38:42 +01:00
|
|
|
|
2017-08-31 18:26:38 +02:00
|
|
|
// With the mapping, the absolute position of our window may have changed (due to re-parenting for example).
|
|
|
|
// Notify all components that depend on the absolute bar position (such as the background manager).
|
|
|
|
m_sig.emit(signals::ui::update_geometry{});
|
|
|
|
|
2017-01-19 05:38:42 +01:00
|
|
|
m_log.trace("bar: Draw empty bar");
|
2017-01-25 23:36:34 +01:00
|
|
|
m_renderer->begin(m_opts.inner_area());
|
2017-01-19 05:38:42 +01:00
|
|
|
m_renderer->end();
|
|
|
|
|
2017-01-12 16:12:54 +01:00
|
|
|
m_log.trace("bar: Setup tray manager");
|
2022-08-28 15:15:48 +02:00
|
|
|
// m_tray->setup(tray_module_name);
|
2017-01-19 05:38:42 +01:00
|
|
|
|
2017-01-12 16:12:54 +01:00
|
|
|
broadcast_visibility();
|
|
|
|
}
|
|
|
|
|
2017-01-12 16:34:14 +01:00
|
|
|
bool bar::on(const signals::ui::dim_window& sig) {
|
2017-01-01 20:29:38 +01:00
|
|
|
m_opts.dimmed = sig.cast() != 1.0;
|
2022-03-16 23:11:19 +01:00
|
|
|
ewmh_util::set_wm_window_opacity(m_opts.x_data.window, sig.cast() * 0xFFFFFFFF);
|
2016-12-21 04:50:43 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-05 23:35:29 -07:00
|
|
|
#if WITH_XCURSOR
|
2022-03-20 19:09:45 +01:00
|
|
|
void bar::change_cursor(const string& name) {
|
|
|
|
// This is already the same cursor, no need to update
|
2022-03-20 20:03:51 +01:00
|
|
|
if (m_cursor == name) {
|
2022-03-20 19:09:45 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-03-20 20:03:51 +01:00
|
|
|
m_cursor = name;
|
2022-03-20 19:09:45 +01:00
|
|
|
|
2022-03-16 23:11:19 +01:00
|
|
|
if (!cursor_util::set_cursor(m_connection, m_connection.screen(), m_opts.x_data.window, name)) {
|
2022-03-20 19:11:03 +01:00
|
|
|
m_log.warn("Failed to create cursor context for cursor name '%s'", name);
|
2017-09-02 21:45:45 -07:00
|
|
|
}
|
|
|
|
m_connection.flush();
|
|
|
|
}
|
2017-09-05 23:35:29 -07:00
|
|
|
#endif
|
2017-09-02 21:45:45 -07:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS_END
|