aboutsummaryrefslogtreecommitdiff
path: root/swaybar
AgeCommit message (Collapse)AuthorLines
2025-05-25swaybar: deduplicate mode and workspace rendering codeKonstantin Pospelov-86/+53
The render_workspace_button and render_binding_mode_indicator functions are almost the same. This commit extracts the common rendering code into a new render_box function.
2025-04-27Replace signal() with sigaction()Simon Ser-2/+3
The man page for signal(3) reads: > new applications should use sigaction() rather than signal()
2025-03-20stringop: fix has_prefix() arg order in config parsingPaul Riou-1/+1
has_prefix() expects the prefix to be the 2nd argument, not the first. The config parsing was broken when using `--input-device=`. Introduced by: 0c60d1581f7b12ae472c786b7dfe27a1c6ec9a47 "Use has_prefix() instead of strncmp() throughout"
2025-01-07Use has_prefix() instead of strncmp() throughoutSimon Ser-10/+12
This is safer than hardcoded string lengths.
2024-12-08swaybar: Handle opaque region properlyAlexander Orzechowski-6/+11
The background color can be set individually for the different elements of the bar. If any of the backgrounds have transparency, we have to bail out from advertising an opaque surface.
2024-11-10swaybar: Emit property changes for SNI watcherJoan Bruguera Micó-0/+12
Emit property change signals for the IsStatusNotifierHostRegistered and RegisteredStatusNotifierItems properties in StatusNotifierWatcher, so code relying on the PropertiesChanged signal, instead of signals such as StatusNotifierHostRegistered, can work properly. A library that is affected by this is the libappindicator-gtk3* library and it can cause tray icons to be missing after starting swaybar due to a race condition, as follows: * An application using libappindicator-gtk3 starts, e.g. nm-applet. * Some time later, swaybar starts. * swaybar creates the StatusNotifierWatcher. * libappindicator-gtk3 observes the new watcher, but it sees that IsStatusNotifierHostRegistered=false, so it falls back to the Freedesktop System tray protocol. * swaybar creates the StatusNotifierHost. At this point, libappindicator-gtk3 should "un-fallback" back to SNI. However, since swaybar does not emit the PropertiesChange signal on IsStatusNotifierHostRegistered, libappindicator-gtk3 doesn't get notified, and stays in fallback state forever. * As a result, nm-applet will not show in the swaybar tray. This race can be made reliable by inserting a 1-second long sleep here: https://github.com/swaywm/sway/blob/03483ff3707a358d935e451d39748e58c205ce8a/swaybar/tray/tray.c#L57 (*) Note that the libappindicator-gtk3 library has been mostly replaced by libayatana-appindicator, which is not affected by this. The affected version is still used by Arch Linux, source code at: https://bazaar.launchpad.net/~indicator-applet-developers/libappindicator/trunk/files/298
2024-09-28swaybar: Fix 100% cpu usage if dbus dies.Furkan Sahin-5/+12
Currently, swaybar does not gracefully die if it detects that the dbus connection was lost. Although it's not recommended to restart dbus without restarting the compositor, it can very easily happen. In the case it does, compositor's tray should not consume 100% cpu until it has to be force killed. apply suggestions just setting the bar to not running will call teardown and unref the dbus.
2024-02-23Define _POSIX_C_SOURCE globallySimon Ser-11/+0
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2023-11-23common: move load_image to swaybarManuel Stoeckl-1/+138
swaynag, swaymsg, and sway do not use this function and are unlikely to in the future.
2023-11-23common: rename load_background_image to load_imageManuel Stoeckl-1/+1
2023-07-31swaybar: Implement wp_cursor_shape_v1Alexander Orzechowski-10/+26
2023-07-08swaybar: handle wayland-cursor failuresManuel Stoeckl-0/+8
Updating the cursor is not essential, so this change prints a warning when wl_cursor_theme_load or wl_cursor_theme_get_cursor fail instead of crashing or exiting.
2023-06-27swaybar: don't set current workspace as not visiblellyyr-1/+1
When `wrap_scroll yes` is configured and there's only one workspace open, swaybar will mark it as not visible if the user scrolls on it and eventually incorrectly fail the `active->visible` assert. Fix this by making sure that new and current workspace aren't the same.
2023-06-25Use "default" XCursor instead of "left_ptr"Simon Ser-1/+1
"left_ptr" is the legacy XCursor name. "default" is the cursor spec name.
2023-06-23swaybar: remove the argument of StatusNotifierHostRegisteredHodong-1/+1
According to https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierWatcher/ there is no argument for the StatusNotifierHostRegistered signal.
2023-05-09swaybar: always subscribe to mode and workspaceMukundan314-6/+3
always subscribe to mode and workspace events, since we might need them after bar config updates even if we don't need them initially.
2023-04-14Use format_str() throughoutSimon Ser-33/+12
2023-04-02swaybar: Lift background clearing out of main rendering functionAlexander Orzechowski-13/+14
This avoids us from using a bogus background_color value that mutates as swaybar renders things and deciding opacity depending on that. Also remove a redundant full surface clear. Just directly write our desired background color.
2023-04-02swaybar: Set opaque region properlyAlexander Orzechowski-0/+2
The opaque region is set incorrectly if updated on-the-fly if switching from an opaque to a non opaque background.
2023-02-27sway{,bar}: use default font hint stylellyyr-2/+0
CAIRO_HINT_STYLE_FULL attempts to maximize contrast at the expense of fidelity, this makes most fonts that haven't been hand hinted, which makes up the majority of fonts out there, appear much worse. In the absence of explicitly set hint style, cairo will default to CAIRO_HINT_STYLE_SLIGHT, which attempts to improve contrast while retaining fidelity to the original shapes, which is what we want.
2023-01-03Use correct length for strncmp comparisonCarl Smedstad-1/+1
2022-11-26swaybar: Make hotspots block bar release bindingsJoan Bruguera-13/+29
The previous commit prioritized hotspots before bar bindings for press events, which matches i3's behaviour. However, since hotspots don't need to do any processing on release events, those were not handled, and simply fell through to `bindsym --release` bar bindings (if any). This is counter-intuitive, and doesn't match i3's behaviour. Instead in case a hotspot handles the press event, it should also handle the release event, doing nothing, but blocking the event from triggering a --release bar binding. E.g., in Sway, without this commit, this config. shows a text on tray clicks: bar { # ... bindsym --release button1 exec swaynag -m I_got_the_release_event. } But the same configuration in i3 (with i3-nagbar) doesn't show the text. Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-11-26swaybar: Prioritize hotspot events to bar bindingsJoan Bruguera-11/+9
This is consistent with i3bar's behaviour, and for example, allows binding a command to button1, while still being able to click on tray icons or other zones on the bar's status line which may have their own bindings. E.g., in Sway, without this commit, this config. makes tray icons unclickable: bar { # ... bindsym button1 exec swaynag -m You_clicked_the_tray._Want_some_help? } But the same configuration in i3 (with i3-nagbar) keeps tray items clickable. Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-11-25build: drop intermediate libraries for protocolsSimon Ser-2/+2
2022-07-01Reuse parsed PangoFontDescriptionHugo Osvaldo Barrera-24/+25
Avoids parsing the configured font each time text is rendered.
2022-03-14swaybar: set opaque regionSimon Ser-0/+9
When the background color is fully opaque, set the surface's opaque region to the whole surface.
2022-03-14swaybar: remove swaybar_output.input_regionSimon Ser-7/+3
No need to keep the region around, we can immediately destroy it after the wl_surface.set_input_region request.
2022-01-19tray: do not render passive itemsTobias Bengfort-0/+5
https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem/#org.freedesktop.statusnotifieritem.status
2022-01-07swaybar: fix tray item icon scaling, positioningNathan Schulte-7/+19
2022-01-07swaybar: fix tray_padding vs min-height re: scaleNathan Schulte-2/+2
Co-authored-by: xdavidwu <xdavidwuph@gmail.com>
2021-12-21swaybar: fix errno handling in status_handle_readableSimon Ser-1/+1
If getline fails once, it was not reset before the next getline call. errno is only overwritten by getline on error.
2021-12-13swaynag: remove xdg-output logicSimon Ser-1/+0
We can just get the output name from wl_output directly, now that wl_output version 4 exists.
2021-11-25swaybar: signal status command's process groupLudvig Michaelsson-4/+9
Make the status command a process group leader and change the kill(2) calls to target the new process group. Signals sent by swaybar will then be received by both the status command and its children, if any. While here, check the result of fork(2). Without this, children spawned by the status command may not receive the signals sent by swaybar. As a result, these children may be orphaned on reload. The issue could be shown by setting the bar to bar { status_command i3status | tee /tmp/i3status.out } which would leave orphaned processes for each reload of sway $ ps o pid,ppid,cmd | grep i3status | grep -v grep 43633 43624 sh -c i3status | tee /tmp/i3status.out 43634 43633 i3status 43635 43633 tee /tmp/i3status.out $ swaymsg reload $ ps o pid,ppid,cmd | grep i3status | grep -v grep 43634 1 i3status 43635 1 tee /tmp/i3status.out 43801 43788 sh -c i3status | tee /tmp/i3status.out 43802 43801 i3status 43803 43801 tee /tmp/i3status.out This fixes #5584.
2021-10-25refactor: use JSON_MAX_DEPTH everywhereJason Nader-1/+1
2021-10-08swaybar: fix cairo_font_options leakNathan Schulte-3/+2
2021-09-20swaybar: properly draw blocks with transparent black borderNathan Schulte-34/+40
while the draw itself is a no-op, alignment must still be accounted this requires more signalling about the blocks (border_set; was the border set?)
2021-09-15swaybar: properly draw urgent block right borderNathan Schulte-1/+1
introduced via #3287 -- https://github.com/swaywm/sway/pull/3287/files#diff-a1e918ce0bc71f4f7934767541319e724a51a34a5418ecdc286065e50921eda4L239 uncovered via #3394 -- https://github.com/swaywm/sway/pull/3394/files#diff-a1e918ce0bc71f4f7934767541319e724a51a34a5418ecdc286065e50921eda4R258
2021-09-13Rename pango_printf to render_textSimon Ser-6/+6
This avoids using the pango_ prefix, reserved for functions coming from the Pango library.
2021-09-12Simplify swaybar/swaynag scaling codeCaduser2020-99/+95
Use `cairo_scale` to set the scale factor, removing redundant multiplications by `output->scale`.
2021-07-26swaybar: log Wayland display errorsSimon Ser-0/+8
2021-07-26swaybar: exit cleanly when disconnected from IPCSimon Ser-0/+7
2021-05-10cairo: Replace <cairo/cairo.h> by <cairo.h>Issam E. Maghni-2/+2
For full context, read https://gitlab.freedesktop.org/cairo/cairo/-/issues/479 TL;DR, cairo’s pc file adds `/cairo` to CFLAGS. So namespace cairo shouldn’t be used.
2021-03-22swaybar: fail gracefully on tokener creation failTudor Brindus-1/+10
This commit adds missing error-handling to the creation of the tokener instance. The stack depth parameter is used to initialize an array that json-c prefaults ahead of time, causing INT_MAX to result in out of memory errors. Also drop the depth to 256 to prevent this OOM. Though this fix is not very satisfactory -- json-c could be made to not prefault -- it should do for now. At the very least, swaybar will not crash. Fixes #6126.
2021-03-21swaybar: use INT_MAX max JSON depth when parsing IPC responseTudor Brindus-3/+8
There's no inherent limit on the nesting Sway can generate, and the default used by `json_tokener_new`, 32, can plausibly be hit during regular usage. Fixes #6115.
2021-03-20swaybar: Use position from wl_pointer.enterKenny Levinsen-0/+2
Only wl_pointer.motion was used to update pointer position, which would cause issues if the pointer was not moved prior to wl_pointer.button. This also fixes touch input through wl_pointer emulation, which fires wl_pointer.button immediately after wl_pointer.enter. Copied from a similar fix made to swaynag. Closes: https://github.com/swaywm/sway/issues/6109
2021-03-17swaybar: silence missing IconThemePath messagePi-Yueh Chuang-2/+7
IconThemePath is not a standard property in XDG's StatusNotifierItem specification, so missing this property should not be logged as an error. This patch changes the log level to SWAY_DEBUG when swaybar queries the value of IconThemePath so that swaybar won't log the returned message as an error if IconThemePath does not exist. Closes: https://github.com/swaywm/sway/issues/6092
2021-03-07swaybar: use text subpixel antialias only where it would look goodFenveireth-35/+97
Closes #5605 Text Subpixel antialiasing is : - FreeType makes glyph bitmaps containing coverage percentage for each subpixel, instead of pixel - Then draw by performing the blend for each subpixel, instead of pixel (e.g. dual-source blending in opengl) And there's only one Alpha channel, so this extra coverage data can't leave Cairo to reach the compositor through there. Therefore, it can't work as intended if output text alpha != bar background alpha. Disable it for those cases, enable it elsewhere As for color emojis, they are RGBA bitmaps. If drawn with text alpha=1.0 and background alpha=1.0 (should be completely opaque bar), then with 'CAIRO_OPERATOR_SOURCE' then texels with alpha < 1.0 result in a blend with whatever's behind the bar, instead of the bar background
2021-02-04Make command line option lists constManuel Stoeckl-1/+1
2021-02-04Make Wayland request listeners static const when possibleManuel Stoeckl-4/+4
2021-01-16Changed fprintf(stdout,...) to printf(...) for more readable codeSpizzyCoder-1/+1