Commit graph

48 commits

Author SHA1 Message Date
Luke Drummond c22caa54a8 swaybar: ensure correct init order for status_line
`$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.
2020-06-12 14:45:40 +02:00
Hristo Venev 7affe5c1bd swaybar: fix i3bar relative coordinates when scaling is used
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.
2020-02-10 18:58:09 +01:00
Brian Ashworth 1fd2c6ba49 swaybar: complete barconfig_update event handling
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
2019-09-04 16:48:50 -10:00
Connor E 2f2a887377 Revert "More frees."
This reverts commit eda1bf769f.
2019-02-01 11:52:37 +00:00
Jan Beich ba96983bf0 Make json-c include respect pkg-config --cflags
json-c.pc contains `Cflags: -I${includedir}/json-c`, so `<json-c/json.h>`
won't be found unless the parent directory is searched by default.
2019-01-23 21:50:06 -05:00
M Stoeckl 1211a81aad Replace wlr_log with sway_log
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.
2019-01-21 12:59:42 +01:00
Ian Fan a82b8a3c14 Remove readline.c
All occurrences of read_line have been replaced by getline.
peek_line has been absorbed into detect_brace.
2019-01-01 09:01:25 +00:00
Mack Straight 828060af73 swaybar: fix double free
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.
2018-12-31 01:19:14 -05:00
Connor E eda1bf769f More frees. 2018-11-13 14:42:00 +00:00
Ryan Dwyer 6921fdc6d6 Remove timerfd from loop implementation
timerfd doesn't work on the BSDs, so this replaces it with a timespec
for the expiry and uses a poll timeout to check the timers when needed.
2018-10-15 00:26:27 +10:00
Ryan Dwyer 4056c09e13 Move swaybar's event loop to common directory and refactor
* The loop functions are now prefixed with `loop_`.
* It is now easy to add timers to the loop.
* Timers are implemented using pollfd and timerfd, rather than manually
checking them when any other event happens to arrive.
2018-10-15 00:26:27 +10:00
Ian Fan a29ee77411 swaybar: send signal to status when hiding or showing bar 2018-10-14 13:33:12 +01:00
Ian Fan 751bb4a376 swaybar: move i3bar definitions into separate file 2018-09-28 13:54:58 +01:00
sghctoma 315b2bf100 Replace getdelim to make swaybar work on FreeBSD
This commit fixes a segfault in swaybar on FreeBSD that was caused by
using getdelim with EOF as delimiter on an infinite stream. The FreeBSD
implementation handles the "no more data, delimiter not found, and EOF
not reached" scenario as an error, so it can't be used to read the
output of status command. This commit replaces the getline/getdelim
calls with reading all available data from the stream in one go.
2018-09-26 20:38:16 +02:00
Ian Fan a4d346627c swaybar: explicitly check return value of getdelim
This prevents an signed-to-unsigned conversion error on buffer_index if
getdelim fails and returns -1, which caused swaybar to try to search the
header for the array and immediately failing
2018-09-22 11:02:47 +01:00
Ian Fan 47a66da5de swaybar: only free tokener when using i3bar protocol 2018-09-18 18:06:19 +01:00
Ian Fan 7882ac66ef swaybar: rewrite i3bar protocol handling
This now correctly handles an incoming json infinite array by shifting
most of the heavy listing to the json-c parser, as well as sending
multiple statuses at once. It also removes the struct
i3bar_protocol_state and moves its members into the status_line struct,
allowing the same buffer to be used for both protocols.
2018-09-18 11:36:33 +01:00
Ian Fan 8cbce77e1d swaybar: rewrite protocol determination
This now uses the getline function to receive the header, replacing
read_line_buffer, which has been deleted since it is otherwise unused.
Furthermore, once the protocol has been determined, the current status
is handled immediately to be shown (though this has not been added for
the i3bar protocol since it has not yet been rewritten to handle this).
2018-09-18 11:36:33 +01:00
Ian Fan 70245c2cd5 swaybar: rewrite text protocol handling
This now uses getline to correctly handle multiple or long statuses. It
also removes the struct text_protocol_state and moves its members into
the status_line struct.
2018-09-18 11:36:33 +01:00
Ian Fan 952453480f swaybar: invalidate file descriptors upon closing 2018-09-18 11:36:33 +01:00
Ian Fan 4cb28de89f swaybar: remove block links upon exit 2018-09-18 11:36:33 +01:00
Ian Fan 2eaef80206 i3bar: count references to blocks
This prevents blocks from being destroyed before their hotspots are destroyed,
in case it is used for a pending click event that fires between the bar
receiving a new status, which destroys the block, and the bar rendering the new
status, which destroys the hotspot; this problem can be easily produced by
scrolling on a block that immediately causes a new status to be sent, with
multiple outputs
2018-09-12 08:28:28 +01:00
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
emersion aa36899d8a
Fix a bunch of swaybar memory leaks 2018-04-24 22:28:55 +01:00
Scott Anderson 0d67d56c2a Set _POSIX_C_SOURCE properly 2018-04-15 15:50:39 +12:00
Drew DeVault f366ef373e Fix #1709 2018-04-03 11:17:34 -04:00
Drew DeVault 333dbcbe72 Render i3bar blocks 2018-04-02 11:09:23 -04:00
Drew DeVault ee85c91831 Demarcate i3bar JSON into individual updates 2018-04-02 11:09:23 -04:00
Drew DeVault f3fbf19312 Do some small cleanup
- Fix workspace events (security config isn't in use so it wasn't being
  sent)
- Kill status bar process when swaybar exits
- Don't rearrange windows on every layer surface commit
2018-03-29 22:11:08 -04:00
Drew DeVault 0464a9910d Clean up status line on exit 2018-03-29 22:11:08 -04:00
Drew DeVault 0d0ab7c5ce Implement status line
Does not yet support i3bar json protocol
2018-03-29 22:11:08 -04:00
Drew DeVault cab1352801 Start port of swaybar to layer shell
This starts up the event loop and wayland display and shims out the
basic top level rendering concepts. Also includes some changes to
incorporate pango into the 1.x codebase properly.
2018-03-29 22:11:08 -04:00
Joona Romppanen 675e4b7de7 Removed trailing comma from swaybar click event json 2017-10-28 17:35:48 +03:00
Johannes Lundberg 5a63f0f57b Fix build on FreeBSD adjusting/removing _XOPEN_SOURCE declaration. 2017-10-14 20:38:33 +02:00
akokshar@redhat.com 2b927685ca styling fixes 2017-08-30 08:16:17 +02:00
akokshar@redhat.com 39df3aed82 styling fixes 2017-08-29 17:33:06 +02:00
akokshar@redhat.com d873d09f23 style fixes 2017-08-29 15:55:30 +02:00
akokshar@redhat.com 65022e1cbf click_events as documented at https://i3wm.org/docs/i3bar-protocol.html 2017-08-29 11:19:43 +02:00
Drew DeVault 9aed9d9359 UnGNUify the codebase 2017-03-10 23:41:24 -05:00
Drew DeVault 416417a54c Reorganize includes 2016-09-01 08:18:37 -04:00
Zandr Martin 98aa59fdda
implement solid color rendering for swaybg 2016-07-30 18:50:13 -05:00
Mikkel Oscar Lyderik 11f0b4539d Use i3bar format for markup field.
In the i3bar protocol the value of the markup field is a string: "pango"
or "none" rather than a bool. This patch makes swaybar compatible with
that.

http://i3wm.org/docs/i3bar-protocol.html
2016-04-24 10:26:55 +02:00
Drew DeVault 84fae94ab9 Flesh out pango markup implementation 2016-04-17 11:36:03 -04:00
Mikkel Oscar Lyderik ed227f5664 swaybar: move headers to include/bar 2016-01-24 15:55:58 +01:00
Mikkel Oscar Lyderik aa6ad09183 swaybar: rename state to bar 2016-01-24 14:22:19 +01:00
Mikkel Oscar Lyderik 6140f9c42c swaybar: Move swaybar_teardown to free_state 2016-01-24 14:22:19 +01:00
Mikkel Oscar Lyderik fcc47cb3bd swaybar: move ipc stuff to ipc.{h,c} 2016-01-24 14:22:19 +01:00
Mikkel Oscar Lyderik a6349a2444 swaybar: feactor render, statusline 2016-01-24 14:22:19 +01:00