Commit Graph

1087 Commits

Author SHA1 Message Date
patrick96
7acd4c703c
xcb: Cleanup value packing 2022-04-16 00:16:48 +02:00
patrick96
ba0e478026
Cleanup tray position handling 2022-04-16 00:16:44 +02:00
patrick96
3244b10ce3
Make tray window a bar subwindow
Currently requires a dirty workaround to prevent tray icons with
different depths from crashing
2022-04-16 00:13:53 +02:00
patrick96
18485d00c2
Cleanup tray code 2022-04-16 00:00:30 +02:00
raffael0
4961a7dcfc
feat(tray): Position using a module (#2595)
Closes: #1526
Closes: #314

* debug log

* semi-working prototype. works on the left and the center but not on the right

* fixes formatting

* fixes tests

* - fixed tray_width_change signal
- implements suggestions

* - fixes error with tray positioning

* - tries to fix tests. Does not work

* - fixes tests

* - implemented suggestions

* reverted formatting in comake and doc

* - changed unique_ptr to const reference

* - fixed formatting errors in code

* - actually fixed formatting(ran clang-format)

* - implemented suggestions

* - Added CHANGELOG.md entry(not sure about wording)

* - removed bar_settings from tray_manager::setup

* - fixed issue from rebase

* - fixed issue with tests from rebase

* implemented suggestions

* Update CHANGELOG.md

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2022-04-15 23:50:04 +02:00
patrick96
973b1fa3d3 feat(text): Add standard format with label
Closes #1331
Closes #1342
Fixes #2673
2022-04-04 12:01:06 +02:00
patrick96
49b18fb3b7
Merge branch 'hotfix/3.6.2' 2022-04-03 20:11:19 +02:00
Maxim Kolesnikov
41d41ca8df
fix(script): output timing inconsistencies (#2667)
Fixes #2650
2022-04-03 13:11:13 +02:00
Farseen
a2c1392c12
feat(pulseaudio): define reverse-scroll option (#2664)
* pulseaudio: define reverse-scroll option

When we enable natural scrolling option in libinput,
it sends scroll down event when we swipe up on the touchpad.
This makes the pulseaudio module feel weird.
This option fixes that.

* Update CHANGELOG.md

Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com>
2022-04-02 23:45:54 +02:00
indev
36d19d372d fix(script): do not hide failing scripts with constant output 2022-04-02 23:24:05 +02:00
patrick96
abfc6b7f91 fix(xworkspaces): Crash if number of desktops too small
Fixes #2660
2022-03-23 14:21:26 +01:00
patrick96
f2ce3a45c5 controller: Print when modules are loaded. 2022-03-23 14:21:26 +01:00
patrick96
ff6ac9fefc Make ewmh_connection act as xcb_ewmh_connection_t*
This way, we don't have to explicitly get the xcb_ewmh_connection_t
pointer from the object and can simply derference the ewmh instance
itself.
2022-03-21 21:37:12 +01:00
patrick96
9b7bfae33d Make exceptions in X event handlers non-fatal 2022-03-20 20:18:00 +01:00
patrick96
d018adcf91 Move current cursor value to bar class
It doesn't really belong to bar_settings
2022-03-20 20:18:00 +01:00
patrick96
f77a725751 Print XCB event ID if error occurs
Makes it much easier to debug from error messages.
2022-03-20 20:18:00 +01:00
patrick96
b8a7b6a605 Cleanup cursor code 2022-03-20 20:18:00 +01:00
patrick96
3f89d73374 fix mouseover error when only one cursor is defined
If only cursor-click or cursor-scroll is defined, but not the other, the
bar could try to set the cursor to the empty string which resulted in an
error.
2022-03-20 20:18:00 +01:00
patrick96
cea9949be1 Warning when cursor is defined without xcursor support 2022-03-20 20:18:00 +01:00
patrick96
b05b3a4c74 xworkspaces: Deal with disappearing windows
Because the X server is asynchronous, there is no guarantee that after
reading _NET_CLIENT_LIST, all windows still exist.
For that reason we need to handle XCB_WINDOW errors appropriately.
2022-03-20 18:31:02 +01:00
patrick96
8173eaf90a fix: Positioning in awesomeWM
Since polybar sets WM_NORMAL_HINTS, awesomeWM for some reason no longer
respect the position set by polybar before mapping.

reconfiguring the window position once again after mapping the window,
again positions it correctly.
2022-03-15 22:09:36 +01:00
patrick96
4556a4a7a8 fix: Support negative struts
Fixed #2642
2022-03-15 00:11:46 +01:00
patrick96
705845e5d3 Comment units functions 2022-03-14 22:58:01 +01:00
patrick96
11a644548b builder: Use unordered_set for attribute activations 2022-03-14 22:58:01 +01:00
patrick96
e904b408d1 fix(builder): ignored offsets
The builder::offset function returned immediately if a valid extent was
passed instead of when an invalid one was passed.
2022-03-14 22:58:01 +01:00
patrick96
6fdc3114f3 builder: Never enable over/underline without color
You cannot make polybar emit only the %{+o} tag without a color so that
codepath was unused.
2022-03-14 22:58:01 +01:00
patrick96
325ef4c3b3 Cleanup builder
Removes unused methods and fields
2022-03-14 22:58:01 +01:00
Frank Großgasteiger
638a57379b
Redraw tray on wallpaper change, only if transparent (#2604)
The tray manager of polybar listens on multiple atoms for the background of the root window. On change of these atoms, it will redraw its window-background and message its tray-client to redraw also.

On fast changes of of background, this leads to immense messaging and eventual flickering of the systray.

This patch tries to soften the issue in a way, that tray-window and its client will only redraw, if the bar has transparency. If not, there should be no reason to redraw on wallpaper-change.

* Redraw on background change only if transparent

* Replace tab with spaces
2022-03-07 19:16:07 +01:00
indev
5b2de60353 feat(script): add repeat interval for script failure and exec-if 2022-03-07 15:44:55 +01:00
patrick96
50eac859fd Cleanup use of pointers in util code 2022-03-06 18:28:26 +01:00
patrick96
8ddf9d2cdf Stop using unique_ptr for on_exit 2022-03-06 18:28:26 +01:00
patrick96
b66f920308 Cleanup xcb stuff 2022-03-06 18:28:26 +01:00
patrick96
1a4ad828c6
Merge branch 'hotfix/3.6.1' 2022-03-05 14:30:38 +01:00
patrick96
f37124f5af renderer: Enforce valid alignment
No renderer_interface function (except change_alignment) should be
called with a NONE alignment in the context.
2022-03-05 13:37:28 +01:00
patrick96
fdaecdb113 tests: Use fake renderer for dispatch test 2022-03-05 13:37:28 +01:00
Nathanaël Houn
8820cc73cd Fix hint message when using deprecated polybar-msg hook 2022-03-05 09:41:00 +01:00
patrick96
c655adea93 fix(script): Prevent stalling during shutdown
If a script module is waiting on a non-tailed script to finish, polybar
cannot shut down until the script has terminted.
To remedy this, we use the same polling loop as for tailed scripts which
checks if it needs to terminate after every iteration.
2022-03-03 23:51:41 +01:00
patrick96
0b24080336 fix: Allow negative values for tray and bar offset 2022-03-03 22:44:35 +01:00
patrick96
24e079afef build: Add missing includes
Fixes #2614
Ref: https://gcc.gnu.org/gcc-12/porting_to.html
2022-03-02 15:09:52 +01:00
Maxim Kolesnikov
f5bfbccfc8
feat(script): add formatting for script failure (#2596)
Closes #2588

* feat(script): add formatting for script failure

* refactor: address review comments

* doc: add changelog entry

* refactor: minor cleanup
2022-02-23 15:01:28 +01:00
patrick96
dc46251571 fix: Handling for actions with negative offsets
If any action block contains a negative offset, it can cause text to be
theoretically be rendered outside of the block, making that text not
clickable.
To fix this, we ensure that an action block starts at the lowest
observed position while the block is open and ends at the highest
observed position while it is open.

Fixes #1814
2022-02-22 18:00:58 +01:00
patrick96
74067c52c3 fix: Set WM_SIZE_HINTS to fix position in openbox
When polybar is remapped (either through IPC or something like xdo
show), openbox positions it somewhere on the screen using the same
positioning algorithm as it would for regular windows.

If the position and size is set in the WM_SIZE_HINTS atom, openbox will
respect the position and size declared by the window.

Fixes #2021
2022-02-21 21:40:33 +01:00
patrick96
59a581a39e Emit error when workspace mapping has invalid format
Closes #2024
2022-02-21 20:04:12 +01:00
patrick96
ae7686d24b fix(battery): Replace tokens for all labels
Otherwise we have to replicate the fallback logic for LOW -> DISCHARGING
in multiple places.

Fixes #2379
2022-02-21 17:54:19 +01:00
Patrick Ziegler
62da14e30d
Use @ for doxygen commands (#2597) 2022-02-20 21:40:48 +01:00
Patrick Ziegler
ce93188a4a
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
Prateek Sunal
ab915fb724
feat(net): %netspeed% token to show combined up+download speed (#2590)
Closes #1083 

* Add netspeed parameter (#1083)

* Update net.cpp

* Update net.hpp

* Update network.cpp

* Update CHANGELOG.md
2022-02-06 21:12:38 +01:00
patrick96
69a2bf211a polybar-msg: Better error messages
If a single connection fails, other connections are kept intact.
2022-01-29 17:57:41 +01:00
patrick96
a8035a7f68 Add extra space to polybar-msg error message 2022-01-29 17:57:41 +01:00
patrick96
28af6bb493 Fix race condition when creating socket folder
If two processes call `mkdir` at the same time, the second one will fail
and wrongly assume the folder wasn't created properly.

We now first check if the folder really doesn't exist and we also catch
any IPC initialization errors and disable IPC instead of crashing the
whole bar.
2022-01-25 00:24:22 +01:00