Commit Graph

273 Commits

Author SHA1 Message Date
Ryan Dwyer
32ba8154b8 Sway clients: Exit gracefully when compositor is unavailable 2018-10-15 21:57:59 +10: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
4dba7c084a swaybar: when hiding bar, save old height to be restored upon reshow
Previously, when the bar was hidden, the height would be set to 0.
This meant that if the bar was empty upon reshow, it would not render
since the height was still 0, which made it seem there was a problem.
Now, the height is not reset, but the width is, to indicate upon reshow
that the layer surface needed reconfiguring.
2018-10-14 13:33:12 +01:00
Ian Fan
a29ee77411 swaybar: send signal to status when hiding or showing bar 2018-10-14 13:33:12 +01:00
Ian Fan
f6f72cb949 swaybar: show hidden bar on urgency 2018-10-14 13:33:12 +01:00
Ian Fan
2f1fd80726 swaybar: show hidden bar on key event
Since wayland does not currently allow swaybar to create global
keybinds, this is handled within sway and sent to the bar using a custom
event, so as not to pollute existing events, called bar_state_update.
2018-10-14 13:33:12 +01:00
Ian Fan
bcc61e5147 swaybar: handle mode/hidden_state changes
As well as adding the hidden_state property to the bar config struct,
this commit handles barconfig_update events when the mode or
hidden_state changes, and uses a new function determine_bar_visibility
to hide or show the bar as required, using, respectively,
destroy_layer_surface, which is also newly added, and add_layer_surface,
which has been changed to allow dynamically adding the surface.
2018-10-14 13:33:12 +01:00
Ian Fan
55ca16f2d8 swaybar: streamline ipc handling
The received json is handled outside of the case statement, which will
allow better extensibility.
This commit also introduces the variable bar_is_dirty, the return value
signifying whether the bar requires rendering.
2018-10-14 13:33:12 +01:00
Ian Fan
fed11d1c7b swaybar: move mode & mode_pango_markup to bar struct
This distinguishes the binding mode from the distinct config mode, as
well as removing mode_pango_markup from the config struct where it
should not be present.
2018-10-14 13:33:12 +01:00
Ian Fan
a388ffa127 swaybar: only send initial workspace request if workspace buttons are enabled 2018-10-14 13:33:12 +01:00
Ian Fan
19f0bf3864 swaybar: add free_hotspots helper function 2018-10-14 13:33:12 +01:00
Ian Fan
a67fa8a05d swaybar: only subscribe to required events
This adds barconfig_update to the list of subscribed events, as well as
checking when the other events need to be subscribed to.
2018-10-14 13:33:12 +01:00
Ian Fan
d0b54e932b swaybar: save id upon startup
This adds an id property to the bar, which will be used to filter
barconfig_update events
2018-10-14 13:33:12 +01:00
Ian Fan
cd6917d4a8
Merge branch 'master' into bar-bindsym 2018-10-10 12:23:04 +00:00
Ryan Dwyer
fa8959532b Fix program name in version strings
When running swaymsg -v, the version returned is actually the version of
swaymsg itself, yet the message displayed was "sway version <version>".
This can create confusion if users update sway and swaymsg but don't
restart sway, then use swaymsg to check the version.

This patch changes the wording to be "swaymsg version <version>"
instead, and likewise for swaybar.

To get the version of a running sway instance, users should run swaymsg
-t get_version.
2018-10-10 18:34:50 +10:00
Brian Ashworth
d3f0e52784 bar-bindsym: address ianyfan's comments 2018-10-09 08:12:46 -04:00
Brian Ashworth
1c969e86f5 Implement bar bindsym 2018-10-09 08:12:46 -04:00
Ryan Dwyer
41bfd8c790 swaybar: allow null status_command
Sway sets a default status_command which runs date every second. This
patch removes this behaviour so the user can have a NULL status bar if
desired.

I had to swap swaybar's event_loop_poll and wl_display_flush so that it
would map the initial surface.
2018-10-08 22:23:55 +10:00
emersion
d50f54fa42 swaybar: fix binding to wl_pointer multiple times 2018-10-06 19:13:44 +02:00
Ian Fan
65593f49bc swaybar: add leading comma to click event JSON 2018-10-02 14:05:51 +01:00
Arkadiusz Hiler
eed0bc3ebd Add support for installing binaries with DT_RPATH
It's better to use DT_RPATH dynamic section of the elf binary to store
the paths of libraries to load instead of overwriting LD_LIBRARY_PATH
for the whole environment, causing surprises. This solution is much more
transparent and perfectly suitable for running contained installations
of wayland/wlroots/sway.

The code unsetting the LD_LIBRARY_PATH/LD_PRELOAD was also deleted as
it's a placebo security at best - we should trust the execution path
that leads us to running sway, and it's way too late to care about those
variables since we already started executing our compositor, thus we
would be compromised anyway.
2018-09-30 15:37:01 +03:00
Arkadiusz Hiler
1e70f7b19e Turn funcs() into funcs(void)
If they really do not take undefined number of arguments.
2018-09-30 14:09:05 +03:00
Ian Fan
02dfeea54c swaybar: synchronize rendering to output frames 2018-09-30 10:07:33 +01:00
Ian Fan
25e1f32738 swaybar: trim function prototypes 2018-09-28 14:09:33 +01:00
Ian Fan
751bb4a376 swaybar: move i3bar definitions into separate file 2018-09-28 13:54:58 +01:00
Ian Fan
bcd2a8fe12 swaybar: remove unused focused_output property 2018-09-28 13:54:58 +01:00
Ian Fan
312d009f65 swaybar: fail if bar id is invalid 2018-09-28 13:48:59 +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
Geoff Greer
c495164f60 swaybar, swaylock, & tree/container: Set cairo font options to render text and lines with subpixel hinting (if available). 2018-09-22 11:34:21 -07: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
Brian Ashworth
04862e2121
Merge branch 'master' into swaybar-hotplug 2018-09-21 15:28:53 -04:00
Ian Fan
a2326661e1 swaybar: log invalid i3bar json 2018-09-21 15:10:47 +01:00
Ian Fan
ccdec2a329 swaybar: reset tokener if json is incomplete
If the tokener parses incomplete json, it sets its error value to
json_tokener_continue. This means that extra json should be provided,
but the code was providing the entire object again. In the interest of
simplicity, the tokener is reset so that buffer_pos always points to the
start of the current object.
2018-09-21 15:09:54 +01:00
Ian Fan
dbda5d35eb swaybar: update buffer_pos when moving object to start of buffer 2018-09-21 14:33:49 +01:00
emersion
8a5ff5a4db swaybar: don't wl_display_roundtrip on each frame
This was the source of numerous bugs, from hotplug events not being
received to segfaults because wl_display_roundtrip was making the
bar process unplug events while blocking in an iteration over all
outputs.
2018-09-20 19:31:03 +02:00
emersion
82f1393cbb swaybar: handle hotplugging
Don't kill and respawn swaybars on hotplug.
2018-09-20 18:37:51 +02:00
Ian Fan
47a66da5de swaybar: only free tokener when using i3bar protocol 2018-09-18 18:06:19 +01:00
Ian Fan
5912325d5c swaybar: add debugging statements for handling i3bar json 2018-09-18 16:10:34 +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
babd9618b9 swaybar: only create i3bar block hotspot if click events are enabled 2018-09-18 11:36:33 +01:00
Ian Fan
87c93d6ad9 swaybar: send trailing comma with click event json 2018-09-18 11:36:33 +01:00
Ian Fan
9932c6a1f1 swaybar: fix empty function prototypes 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
emersion
012df55be5 swaybar: use output names instead of output indexes 2018-09-17 16:04:09 +02:00
Ian Fan
e32e86b65d bar: remove i3bar_block_free in favour of i3bar_block_unref 2018-09-14 21:06:54 +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