`determine_bar_visibility` stops and starts the status command process according to the bar’s visibility. If the bar was hidden during teardown, teardown would stall while waiting for the stopped status command process to exit.
This resumes a stopped status command during teardown and allows, for example, sway to reload or quit without leaving a swaybar instance behind each time.
Fixes#5536.
CONT before TERM as requested in review.
`$WAYLAND_SOCKET` is unset by `wl_display_connect` after it has
successfully connected to the wayland socket.
However, subprocesses spawned by swaybar (status-command) don't have
access to waybar's fds as $WAYLAND_SOCKET is O_CLOEXEC. This means any
status command which itself tries to connect to wayland will fail if
this environment variable is set.
Reorder display and status-command initialization so that this variable
is not set and add an assert so we can enforce this invariant in future.
For some reason my version of sway doesn't show workspace names:
$ swaymsg -t get_outputs
Output HDMI-A-1 '(null) (null) (null)' (inactive)
Output HDMI-A-2 '(null) (null) (null)' (inactive)
Which is weird, but it's no reason to crash swaybar. The field is
totally missing from the JSON, so it ends up doing strcmp(NULL, name)
which is undefined behavior.
See issue #5228. Currently, WL_OUTPUT_SUBPIXEL_NONE is ignored and
CAIRO_ANTIALIAS_SUBPIXEL is still set. This commit checks if subpixel is
set to none and if so, calls set_antialias with CAIRO_ANTIALIAS_GRAY.
This mirrors the functionality in Mako's
[PR261](https://github.com/emersion/mako/pull/261)
This removes any pending messages once the item is destroyed.
Furthermore, this installs SNI event calbacks asynchronously
in order to prevent sd-bus from bypassing pending messages.
24e8ba048a did not take scaling into account.
The hotspot size used pixel coordinates, the absolute coordinates were logical,
and the relative coordinates were completely wrong.
This commit makes all coordinates use logical values. If
`"float_event_coords":true` is sent in the handshake message, coordinates are
sent as floating-point values.
The "scale" field is an integer containing the scale value.
The function group_handler may get a nullptr as `new_group`. If that's
the case, return true, as if `new_group` was the empty string.
Also make the conversion to bool explicit when calling `strcmp`.
This is the first in a series of commits to refactor the color handling
in sway. This changes parse_color to return whether it was success and
no longer uses 0xFFFFFFFF as the fallback color. This also verifies that
the string actually contains a valid hexadecimal number along with
the length checks.
In the process of altering the calls to parse_color, I also took the
opportunity to heavily refactor swaybar's ipc_parse_colors function.
This allowed for several lines of duplicated code to be removed.
In case a tray icon cannot be found or does not have a desirable size,
swaybar retries the search again and again, which increases load on disk
and CPU. This commit solves it by storing target_size for each icon, so
that swaybar does not search for an icon of some size if it already tried to.
Fixes#3789.
Other components like workspace button, status line (error or plain
text) already render text at integer coords. This make status block
also render text at integer coords.
This adds complete support for the barconfig_update ipc event. This also
changes the bar command and subcommand handlers to correctly emit the
event. This makes it so all bar subcommands other than id and
swaybar_command are dynamically changeable at runtime. sway-bar.5 has
been updated accordingly
This corrects the description of border_{top,bottom,left,right} in the
block properties table in swaybar-protocol.7. The values should be an
integer denoting the width/height rather than a boolean denoting
whether to show them.
Note: since strtoul() has no real error return code (both 0 and
ULONG_MAX may be returned on both success and failure), set errno=0
before calling strtoul().
If the XCURSOR_THEME and/or XCURSOR_SIZE environment variables are
set, use the theme and size they define.
If they're not set, use the same defaults as before (system default
theme, size=24).
This allows swaybar to become visible when the mode changes (to any
mode other than the default). swaybar will be hidden again when the
modifier is pressed and released or when switching back to the default
mode.
This also applies the same logic to visible by urgency to hide swaybar
when the modifier is pressed and released.
These changes are to match i3's behavior.
The read_theme_file function used to return an invalid icon_struct in
some cases, for example when an empty index.theme file was read.
This makes sure the struct we're returning is always valid as per the
Icon Theme specification.
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
- Predicted status line can be negative, so corresponding variables should
not be unsigned. Changed to double as position is actually calculated as
double.
If the icon index.theme contained a key-value pair without a preceding
group header, entry_handler() would be called with a zero pointer and
lead to a segfault.
Set the error flag and break on such malformed files.
`len` will underflow but will overflow right after, so it's not as bad as it
may appear. Still better not to under/overflow at all.
Fixes https://github.com/swaywm/sway/issues/3862
This fixes a typo on the malloc line in ipc_send_workspace_command. The
plus one to the size for the null-terminator was outside of the malloc
call, which was causing the incorrect pointer to be freed later in the
function.
In addition to removing unused code, two minor problems are fixed:
(1) `resize set` and `resize adjust` did not error when given
too many arguments.
(2) `orientation` was incorrectly overridden to be 'U' for
scroll events in the swaybar tray `handle_click` function.
This commit mostly duplicates the wlr_log functions, although
with a sway_* prefix. (This is very similar to PR #2009.)
However, the logging function no longer needs to be replaceable,
so sway_log_init's second argument is used to set the exit
callback for sway_abort.
wlr_log_init is still invoked in sway/main.c
This commit makes it easier to remove the wlroots dependency for
the helper programs swaymsg, swaybg, swaybar, and swaynag.
This modifies `bar_cmd_tray_bindsym` to use `get_mouse_bindsym` for
parsing mouse buttons. This also introduces `bar_cmd_tray_bindcode`,
which will use `get_mouse_bindcode` for parsing mouse buttons. Like with
sway bindings, the two commands are encapsulated in a single file to
maximize shared code.
This also modifies tray bindings to work off of events codes rather than
x11 buttons, which allows for any mouse buttons to be used.
For `get_bar_config`, `event_code` has been added to the `tray_bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
This allows `bar output` and `bar tray_output` to specify an output
identifier. Output names should still work as well.
This parses the output identifier from the xdg_output description,
which wlroots currently sets to `make model serial (name)`. Since this
could change in the future, all identifier comparisons are guarded by
NULL-checks in case the description cannot be parsed to an identifier.
Adds the bar subcommand `status_padding <padding>` which allows setting
the padding used for swaybar. If `status_padding` is set to `0`, blocks
will be able to take up the full height of the bar.
This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing
mouse buttons. This also introduces `cmd_bar_bindcode`, which will use
`get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the
two commands are encapsulated in a single file with shared code.
This also modifies swaybar to operate off of event codes rather than x11
button numbers, which allows for any mouse button to be used.
This introduces two new IPC properties:
- For `get_bar_config`, `event_code` has been added to the `bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
- Likewise for `click_events`, `event` has been added and will include
the event code for the button clicked. If the event code can be mapped
to a x11 button, `button` will still be the x11 button number.
Otherwise, `button` will be `0`.
This fixes the rendering of borders and backgrounds for blocks. This
also makes the following changes:
* both borders and padding are scaled with the output
* both lines and rectangles are rendered without an antialiasing to
avoid bleeding outside the desired area
evdev-proto is installed by a dependency, so some files have been missed:
In file included from ../sway/input/cursor.c:3:
/usr/local/include/libevdev-1.0/libevdev/libevdev.h:30:10: fatal error: 'linux/input.h' file not found
#include <linux/input.h>
^~~~~~~~~~~~~~~
../swaybar/i3bar.c:3:10: fatal error: 'linux/input-event-codes.h' file not found
#include <linux/input-event-codes.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~
status->text should not be freed here. There are two scenarios:
* status->text has been set to an error by status_error. In this case
the value shouldn't be freed because it's always a reference to a
constant.
* status->text has been set to status->buffer because the bar is in
text protocol mode. In this case it's a double free because the
buffer is already freed after.
This fixes a few issues with swaybar's cursor scaling:
1. The cursor scale is now changed when the output scale changes
2. The cursor scale is no longer bound by the max output scale when
swaybar is launched
3. Related to the previous item, the cursor is no longer tiny on low
scale outputs after the max output scale has changed
This also bumps up `wl_compositor` to version 4 to allow usage of
`wl_surface_damage_buffer`.