Commit Graph

31 Commits

Author SHA1 Message Date
Brian Ashworth
97f9f0b699 parse_color: return success + drop fallback color
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.
2019-12-28 10:07:25 +01:00
v44r
204e1f4712 Rebase #1636 against current master 2019-01-31 15:37:57 +01: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
Brian Ashworth
02bbefda20 bar_cmd_tray_bind: Use mouse button helpers
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`.
2019-01-16 11:12:45 +01:00
Brian Ashworth
3d6440ec26 bar_cmd_bind: utilize mouse button helpers
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`.
2019-01-10 12:43:10 -05:00
Hristo Venev
24e8ba048a Add relative coordinates in JSON for i3bar click events
Compatibility with i3 commit 161db6f17d734ac9deb0a20e81b78d4b2a92ce68.
2018-12-04 12:49:21 +02:00
Ian Fan
499150a91b swaybar: separate input code to new file 2018-10-18 14:19:00 +01:00
Ian Fan
65593f49bc swaybar: add leading comma to click event JSON 2018-10-02 14:05:51 +01:00
Ian Fan
751bb4a376 swaybar: move i3bar definitions into separate file 2018-09-28 13:54:58 +01: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
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
87c93d6ad9 swaybar: send trailing comma with click event json 2018-09-18 11:36:33 +01: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
minus
bfcfabee2b swaybar: Fix scroll handling on workspace buttons
As well as ignoring scroll events on status elements when click_events
is enabled.
Previously, using the scroll wheel on a workspace button would switch to
that workspace instead of scrolling through them. Clicks and scrolling
on status elements would always be processed by swaybar, too. So in case
you were using scrolling as volume control on a status item, swaybar
would additionally scroll through your workspaces.
2018-07-19 21:15:01 +02:00
Peter Rice
e43c20134a remove unnecessary parens 2018-07-17 19:04:04 -04:00
Peter Rice
79a998849b make hotspot callback take an x11 button id 2018-07-16 18:55:04 -04: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
Bruno Pinto
9bc4565a59
Fix memory leak on swaybar
Code from @NilsBrause

Ref #1820
2018-04-20 01:58:30 +01:00
Drew DeVault
ac3be29517 Fix some more bugs 2018-04-09 08:07:54 -04:00
Ryan Dwyer
bac65078a2 Fix buffer issues in swaybar status line. 2018-04-09 17:25:39 +10:00
Drew DeVault
f366ef373e Fix #1709 2018-04-03 11:17:34 -04:00
Drew DeVault
c507727ad2 Fix use-after-free with block hotspots 2018-04-02 11:53:56 -04:00
Drew DeVault
0cbd2a4f49 Send click events for i3bar blocks 2018-04-02 11:09:23 -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