Commit graph

90 commits

Author SHA1 Message Date
M Stoeckl 0af5b26e41 Fix dead stores found by scan-build
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.
2019-01-22 10:12:04 -05:00
Connor E 39cf477090 swaynag: Small graphical fix, add offset of +1 to X/Y. 2019-01-22 03:32:51 -05:00
M Stoeckl 4b1eaaf731 Removed unused wlroots dependency for sway(bg|bar|msg|nag)
Also remove direct libm dependency where unused.
2019-01-21 13:04:15 -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
emersion 07f4c1e3a9 swaynag: fix XDG_CONFIG_HOME handling 2019-01-19 09:07:08 +01:00
emersion bb2f007ad3
meson: remove rpath options 2019-01-18 08:26:44 +01:00
Connor E 70637b40fe Fixes for small existing bugs. 2019-01-16 13:02:26 +01:00
Connor E aa9d7d8ca1 Remove usage of VLAs. 2019-01-16 13:02:26 +01:00
Ian Fan 8729c65311 swaynag: handle empty $XDG_CONFIG_HOME better
Set config path to fallback instead of setting $XDG_CONFIG_HOME
2019-01-14 09:45:18 +00: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
Brian Ashworth eb527ac01a swaynag: remove double free of details button
If there are no arguments or invalid arguments given, swaynag will free
`swaynag.details.button_details` under the `cleanup` label in main. It
then called `swaynag_destroy`, which would attempt to free it again.

Since `swaynag.details.button_details` is either freed on line 106 of
main (when there is no detailed message) or added to `swaynag.buttons`
on line 103 of main, there is no reason to manually free it in
`swaynag_destroy`.

Although I cannot reproduce a double free on my system, for some reason,
it should have actually resulted in a double free in all code paths.
2018-12-17 09:21:14 +01:00
Brian Ashworth c8284176db swaynag: damage the cursor surface on update
When the cursor surface gets updated, it should be damaged.

This also bumps up `wl_compositor` to version 4 to be able to use
`wl_surface_damage_buffer`.
2018-12-15 09:51:44 +01:00
Ian Fan c8776fac42 Cleanup list code 2018-12-09 01:15:38 +00:00
Brian Ashworth 673da83260 Implement swaynag -B/--button-no-terminal
In `i3 4.16`, `i3-nagbar` introduces the flags `-B/--button-no-terminal`
to run the action directly instead of inside a terminal. This implements
the flags for swaynag for compatibility.

Since swaynag does not use an equivalent to `i3-sensible-terminal`, the
flags `-b/--button` only uses a terminal when the environment variable
`TERMINAL` is set, otherwise it acts the same as these new flags.
2018-11-27 23:34:51 -05:00
emersion 3a310f92ab
Replace _XOPEN_SOURCE with _POSIX_C_SOURCE
And make sure we don't define both in the same source file.
2018-11-25 17:19:43 +01:00
Connor E eda1bf769f More frees. 2018-11-13 14:42:00 +00:00
Ryan Dwyer 32ba8154b8 Sway clients: Exit gracefully when compositor is unavailable 2018-10-15 21:57:59 +10:00
Drew DeVault 7252c7f715 swaynag: s/Toggle Details/Toggle details/ 2018-10-07 14:37:53 -04:00
Dominique Martinet e5ece5f8b3 swaynag: fix use-after-free in wl_display_dispatch
When destroying swaynag from within wl_display_dispatch, we cannot
disconnect the display as that will free the queue's event_list.
Free it after running the loop instead.

Fixes this use-after-free:
==7312==ERROR: AddressSanitizer: heap-use-after-free on address 0x612000000110 at pc 0x000000412a9f bp 0x7ffd4e811760 sp 0x7ffd4e811750
READ of size 8 at 0x612000000110 thread T0
    #0 0x412a9e in wl_list_empty ../common/list.c:206
    #1 0x7f5b58f0d42f in dispatch_queue src/wayland-client.c:1572
    #2 0x7f5b58f0d42f in wl_display_dispatch_queue_pending src/wayland-client.c:1815
    #3 0x40f465 in swaynag_run ../swaynag/swaynag.c:390
    #4 0x407576 in main ../swaynag/main.c:123
    #5 0x7f5b58bb9412 in __libc_start_main ../csu/libc-start.c:308
    #6 0x404a3d in _start (/opt/wayland/bin/swaynag+0x404a3d)

0x612000000110 is located 208 bytes inside of 320-byte region [0x612000000040,0x612000000180)
freed by thread T0 here:
    #0 0x7f5b594ab480 in free (/lib64/libasan.so.5+0xef480)
    #1 0x40faff in swaynag_destroy ../swaynag/swaynag.c:454
    #2 0x40cbb4 in layer_surface_closed ../swaynag/swaynag.c:82
    #3 0x7f5b583e1acd in ffi_call_unix64 (/lib64/libffi.so.6+0x6acd)

previously allocated by thread T0 here:
    #0 0x7f5b594aba50 in __interceptor_calloc (/lib64/libasan.so.5+0xefa50)
    #1 0x7f5b58f0c902 in wl_display_connect_to_fd src/wayland-private.h:236

(you need a wayland compiled with asan, my wl_list hack, or running
with valgrind to see this trace)
2018-10-07 16:35:10 +09: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
Ryan Dwyer 9215ca0f01 Align titles to baseline
This does the following:

* Adds a baseline argument to get_text_size (the baseline is the
distance from the top of the texture to the baseline).
* Stores the baseline in the container when calculating the title
height.
* Takes the baseline into account when calculating the config's max font
height.
* When rendering, pads the textures according to the baseline so they
line up.
2018-09-08 16:25:07 +10:00
Brian Ashworth f0d21c46dd Fix bad-free in swaynag 2018-08-20 15:06:12 -04:00
Ian Fan 6e7052fc44 swaynag: destroy old cursor theme when updated 2018-08-10 18:34:23 +01:00
Geoff Greer 208831aec6 Fix compiler errors.
- Some platforms don't expose kill() unless _POSIX_C_SOURCE is defined.
- fork(), execl(), and setsid() need unistd.h on some platforms.

Basically, this fixes some platform-specific build errors.
2018-08-05 00:24:44 -07:00
Marien Zwart 4df8858873 Add missing stdlib.h includes to swaynag 2018-08-03 19:24:44 +10:00
Brian Ashworth 26c5ef18ba swaynag: don't drop \n for first line 2018-08-01 22:55:20 -04:00
Brian Ashworth 41d858b439 swaynag: add blank lines after headings in scdocs 2018-08-01 22:47:54 -04:00
Brian Ashworth 1e7fbe493e swaynag: swaybar like default colors 2018-08-01 22:47:54 -04:00
Brian Ashworth 4f5cf330c8 swaynag: address some more of sircmpwn's comments
Fixes segfauls for any case where swaynag->outputs was not inititalized
including -h/--help, -v/--version, and invalid arguments.

Sets sane defaults for colors not given. Any color not given will
fallback to the default color values for type error.

Adds support for a hidpi cursor
2018-08-01 22:47:54 -04:00
Brian Ashworth 0ef3988438 swaynag: fix hidpi 2018-08-01 22:47:54 -04:00
Brian Ashworth e01acb6097 swaynag: allow more config options 2018-08-01 22:47:54 -04:00
Brian Ashworth ca40298af4 swaynag: add math to meson.build 2018-08-01 22:47:54 -04:00
Brian Ashworth 894d57f192 swaynag: fix output selection 2018-08-01 22:47:54 -04:00
Brian Ashworth a6145914c6 swaynag: refactor {sway_,}nagbar to swaynag 2018-08-01 22:47:54 -04:00
Brian Ashworth 6124d0f9a2 swaynag: split config into own file and fix optind 2018-08-01 22:47:54 -04:00
Drew DeVault 58f3fa74ae Disable pango markup for extended message 2018-08-01 22:47:54 -04:00
Drew DeVault 37709917b1 Set output to NULL if not specified
This opens nagbar on the active output.
2018-08-01 22:47:54 -04:00
Brian Ashworth 8463a2896a swaynag: implement config file support 2018-08-01 22:47:54 -04:00
Brian Ashworth a4f7bf23b2 Address first round review for swaynag 2018-08-01 22:47:54 -04:00