aboutsummaryrefslogtreecommitdiff
path: root/swaynag/swaynag.c
AgeCommit message (Collapse)AuthorLines
2024-11-09swaynag: fix null dereference on scale changeManuel Stoeckl-1/+3
If cursor-shape-v1 is available, the old wl_cursor_theme path should not be used.
2024-02-23Define _POSIX_C_SOURCE globallySimon Ser-1/+0
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2023-07-31swaynag: Implement wp_cursor_shape_v1Alexander Orzechowski-5/+20
2023-07-17swaynag: handle wayland-cursor failuresSimon Ser-0/+8
Same as 92244c87dbb8 ("swaybar: handle wayland-cursor failures") but for swaynag. Closes: https://github.com/swaywm/sway/issues/7671
2023-06-25Use "default" XCursor instead of "left_ptr"Simon Ser-1/+1
"left_ptr" is the legacy XCursor name. "default" is the cursor spec name.
2023-01-16swaynag: call swaynag_destroy on clean exitManuel Stoeckl-4/+5
And fix the fallout of the swaynag_destroy having evolved without being tested: * wl_display_disconnect was called too early * `button_close` and `swaynag.details.button_details` needed to be heap allocated, since they are added to swaynag.buttons, and all entries of swaynag.buttons are freed in swaynag_destroy * To keep things simpler, disconnect the lifetime of the 'Toggle details' button text config setting from the button itself.
2022-03-15remove unnecessary strlen callNihal Jere-2/+2
2022-02-28swaynag: die on all allocation failuresNihal Jere-0/+9
2022-02-08Remove all sprintf callsSimon Ser-2/+3
Replace them with snprintf, which ensures buffer overflows won't happen.
2022-01-23swaynag: remove buffer destruction conditionKirill Primak-7/+2
An address of a variable can never be NULL, so checking it doesn't make sense; and `destroy_buffer()` can operate on already destroyed buffers anyway. Fixes #6780
2021-12-13swaynag: remove xdg-output logicSimon Ser-40/+19
We can just get the output name from wl_output directly, now that wl_output version 4 exists.
2021-09-13swaynag: fix pointer button events on scaled outputsxdavidwu-2/+2
sway#6504 simplified rendering code by setting scaling at cairo, but that also changed button position records into ones without scale multiplication, breaking button events. This fixes it by not multiplying scale on events handling as well.
2021-06-17swaynag: adds option to set wayland shell layerJames Edwards-Jones-1/+2
Uses --layer/-y set to overlay|top|bottom|background
2021-04-22Use execlp("sh") instead of execl("/bin/sh")Simon Ser-4/+4
This stops assuming the POSIX shell command is located in /bin.
2021-02-07swaynag: Use position from wl_pointer.enterKenny Levinsen-0/+2
Only wl_pointer.motion was used to update pointer position, which would cause issues if the pointer was not moved prior to wl_pointer.button. This also fixes touch input through wl_pointer emulation, which fires wl_pointer.button immediately after wl_pointer.enter. Closes: https://github.com/swaywm/sway/issues/5991
2021-02-04Make Wayland request listeners static const when possibleManuel Stoeckl-6/+6
2020-06-10swaynag: sway_abort on failure to properly registerLuke Drummond-1/+4
In case `wl_display_roundtrip` returns an error after registering for events, print a more user-friendly error message and exit. Previously, if the build did not have assertions enabled, this would likely result in a segfault. With assertions enabled, it's not user friendly to terminate with internal implementation information.
2020-06-09swaynag: allow specifying more buttons which execute and dismissGraham Christensen-0/+5
I don't love -z / -Z, but I figure this patch is far from being accepted for other reasons too.
2020-04-02swaynag: exit on wl_display_roundtrip errorDominique Martinet-1/+5
fixes loop when sway closes the socket in the middle of querying outputs, see #5138.
2020-03-29swaynag: fix segfault on exit when arguments are not correctDominique Martinet-2/+0
swaynag_destroy is called on all cleanup cases and needs the lists to be valid, just init them early
2020-01-05swaynag: Add multi-seat supportAndri Yngvason-34/+89
This also adds cleanup for all seat resources
2019-06-05check for empty string before calling strtoul() and check errnoDaniel Eklöf-2/+3
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().
2019-06-05swaybar/nag: use xcursor theme defined by XCURSOR_THEME/SIZEDaniel Eklöf-2/+12
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).
2019-04-14Spawn swaynag as a wayland clientBrian Ashworth-6/+17
This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done
2019-04-14swaynag: fix pointer managementBrian Ashworth-1/+5
Currently on master, swaynag will retrieve a pointer instance whenever the capabilities change and WL_SEAT_CAPBILITY_POINTER is set. The pointer instances were never being destroyed so swaynag received events multiple times due to having several instances of the pointer. This fixes it so if there is already a pointer instance, swaynag does not attempt to retrieve another. Additionally, if the pointer capability is removed, the pointer instance is destroyed.
2019-01-21Replace wlr_log with sway_logM Stoeckl-10/+10
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-16Fixes for small existing bugs.Connor E-1/+2
2019-01-16Remove usage of VLAs.Connor E-1/+2
2018-12-17swaynag: remove double free of details buttonBrian Ashworth-1/+0
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-15swaynag: damage the cursor surface on updateBrian Ashworth-1/+3
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-09Cleanup list codeIan Fan-3/+2
2018-11-27Implement swaynag -B/--button-no-terminalBrian Ashworth-2/+5
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-25Replace _XOPEN_SOURCE with _POSIX_C_SOURCEemersion-1/+1
And make sure we don't define both in the same source file.
2018-11-13More frees.Connor E-0/+1
2018-10-15Sway clients: Exit gracefully when compositor is unavailableRyan Dwyer-1/+5
2018-10-07swaynag: fix use-after-free in wl_display_dispatchDominique Martinet-4/+4
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-08-10swaynag: destroy old cursor theme when updatedIan Fan-0/+3
2018-08-05Fix compiler errors.Geoff Greer-0/+1
- 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-03Add missing stdlib.h includes to swaynagMarien Zwart-0/+1
2018-08-01swaynag: address some more of sircmpwn's commentsBrian Ashworth-20/+31
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-01swaynag: fix hidpiBrian Ashworth-47/+73
2018-08-01swaynag: allow more config optionsBrian Ashworth-2/+2
2018-08-01swaynag: fix output selectionBrian Ashworth-1/+2
2018-08-01swaynag: refactor {sway_,}nagbar to swaynagBrian Ashworth-0/+413