Commit Graph

94 Commits

Author SHA1 Message Date
Simon Ser fc640d5f6c Define _POSIX_C_SOURCE globally
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2024-02-23 17:43:19 +03:00
Sergei Trofimovich 020a572ed6 swaynag/config.c: fix build against gcc-14 (-Walloc-size)
`gcc-14` added a new `-Walloc-size` warning that makes sure that size of
an individual element matches size of a pointed type:

        https://gcc.gnu.org/PR71219

`sway` triggers it on `calloc()` calls where member size is used as
`1` (instead of member count):

    swaynag/config.c:169:65: error: allocation of insufficient size '1'
     for type 'struct swaynag_button' with size '48' [-Werror=alloc-size]
      169 | struct swaynag_button *button = calloc(sizeof(struct swaynag_button), 1);
2023-11-03 13:25:27 +01:00
Alexander Orzechowski df8aad9c5a swaynag: Implement wp_cursor_shape_v1 2023-07-31 10:34:11 +02:00
Simon Ser a34d785a26 swaynag: handle wayland-cursor failures
Same as 92244c87db ("swaybar: handle wayland-cursor failures")
but for swaynag.

Closes: https://github.com/swaywm/sway/issues/7671
2023-07-17 10:01:46 +02:00
Simon Ser 974a8629a8 Use "default" XCursor instead of "left_ptr"
"left_ptr" is the legacy XCursor name. "default" is the cursor
spec name.
2023-06-25 22:38:10 +02:00
Manuel Stoeckl 5e73acb431 swaynag: call swaynag_destroy on clean exit
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.
2023-01-16 10:47:42 -05:00
Simon Ser bd7466e1b7 swaynag: drop swaynag_type.font
It's too easy to have this go out of sync with font_description.
2022-12-22 17:42:33 +01:00
Simon Ser fd0af78e43 swaynag: fix NULL font description
The font description was only set if provided on the CLI. It was
left NULL for the defaults and when reading from the config file.

Closes: https://github.com/swaywm/sway/issues/7186
2022-12-22 17:42:33 +01:00
nerdopolis dca0bb5749 Fix build on Debian Stable 2022-11-28 23:42:41 +01:00
Simon Ser af8a5a8918 build: drop intermediate libraries for protocols 2022-11-25 10:51:20 +01:00
Hugo Osvaldo Barrera 80e386fd97 Reuse parsed PangoFontDescription
Avoids parsing the configured font each time text is rendered.
2022-07-01 13:05:58 +02:00
Greg Depoire--Ferrer 956b689d6a swaynag: move close_button up to fix SIGSEGV
When swaynag_parse_options encounters '--dismiss-button' (or its
shorthand '-s'), it sets the text of the first button in the
swaynag.buttons list, which is expected to exist and to be the dismiss
button, to the one passed by the user.

Commit 4780afb68b ("swaynag: statically
allocate button_close, and move declaration") moved the list
initialization to after swaynag_parse_options is called which made that
code fail.

For example, the command 'swaynag --dismiss-button Dismiss' crashes and
'swaynag --message Message --button Yes "" --dismiss-button Dismiss'
shows the wrong buttons.

Move it back to before swaynag_parse_options is called.
2022-06-05 19:05:26 +02:00
Nihal Jere c85d9af2b6 swaynag: combine consecutive declaration/assignments 2022-05-07 15:57:18 +02:00
Nihal Jere e8028be839 swaynag: improve robustness when loading config 2022-05-07 15:57:18 +02:00
Nihal Jere 5d924f2b12 swaynag: do error checking and rename read_from_stdin
read_from_stdin not only read from stdin, but trimming trailing
newlines, so rename it to reflect this.
2022-05-07 15:57:18 +02:00
Nihal Jere 1e79088a72 remove unnecessary strlen call 2022-03-15 11:40:32 +01:00
Nihal Jere 78758ef369 swaynag: remove redundant status variables in main
Instead, we just use `status` for all failures.
2022-03-15 11:40:32 +01:00
Nihal Jere 20729a6a5e swaynag: remove unnecessary zero of swaynag struct
Global variables are initialized to 0.
2022-03-15 11:40:32 +01:00
Nihal Jere 4780afb68b swaynag: statically allocate button_close, and move declaration
Every swaynag has a close button, so it doesn't make sense to
allocate it dynamically. The declaration is moved later to when
it is actually needed.
2022-03-15 11:40:32 +01:00
Nihal Jere 0babfce4b5 swaynag: allocate button_details with details
They are used together, so it doesn't make sense to allocate them
separately.
2022-03-15 11:40:32 +01:00
Nihal Jere 061ffc30ea swaynag: die on all allocation failures 2022-02-28 11:24:13 -05:00
Simon Ser f707f583e1 Remove all sprintf calls
Replace them with snprintf, which ensures buffer overflows won't
happen.
2022-02-08 09:20:13 -05:00
Kirill Primak cd1ee0e172 swaynag: remove buffer destruction condition
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
2022-01-23 10:41:57 -05:00
Simon Ser 57a7b3998e swaynag: remove xdg-output logic
We can just get the output name from wl_output directly, now that
wl_output version 4 exists.
2021-12-13 20:17:20 -06:00
xdavidwu 806b59eca3 swaynag: fix pointer button events on scaled outputs
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-09-13 14:46:01 +02:00
Simon Ser 3f7a04df22 Rename pango_printf to render_text
This avoids using the pango_ prefix, reserved for functions coming
from the Pango library.
2021-09-13 14:22:51 +02:00
Caduser2020 57ae751655 Simplify swaybar/swaynag scaling code
Use `cairo_scale` to set the scale factor, removing redundant
multiplications by `output->scale`.
2021-09-12 09:05:12 +02:00
James Edwards-Jones d13090be54 swaynag: adds option to set wayland shell layer
Uses --layer/-y set to overlay|top|bottom|background
2021-06-17 11:47:49 +02:00
sergio 92ba229094 details-gackground typo fix 2021-05-28 17:18:36 +02:00
Issam E. Maghni d45623c2db cairo: Replace <cairo/cairo.h> by <cairo.h>
For full context, read
https://gitlab.freedesktop.org/cairo/cairo/-/issues/479
TL;DR, cairo’s pc file adds `/cairo` to CFLAGS.
So namespace cairo shouldn’t be used.
2021-05-10 10:28:32 +02:00
Simon Ser 7beeb9e61b Use execlp("sh") instead of execl("/bin/sh")
This stops assuming the POSIX shell command is located in /bin.
2021-04-22 23:12:49 +02:00
Kenny Levinsen 63420a2caa swaynag: Use position from wl_pointer.enter
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-07 20:18:53 -05:00
Manuel Stoeckl 169b90f90b Make command line option lists const 2021-02-04 09:49:06 +01:00
Manuel Stoeckl 8f2cd3236f Make Wayland request listeners static const when possible 2021-02-04 09:49:06 +01:00
SpizzyCoder 7cf25d3b98 Changed fprintf(stdout,...) to printf(...) for more readable code 2021-01-16 20:24:41 +01:00
Mustafa Abdul-Kader eb1c09030e swaynag: add details background option
Adds a new config option for details background for swaynag

issue/#5673
2020-09-14 22:13:01 -04:00
oliver-giersch a543fa35ff swaynag: adds option to separately specify the text color for buttons 2020-09-04 18:17:42 +02:00
Antonin Décimo bbf7b92fe4 Fix incorrect format specifiers 2020-07-30 22:02:42 -04:00
Luke Drummond 62a530513c swaynag: sway_abort on failure to properly register
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-10 15:50:31 +02:00
Graham Christensen a974300652 swaynag: allow specifying more buttons which execute and dismiss
I don't love -z / -Z, but I figure this patch is far from being
accepted for other reasons too.
2020-06-09 00:00:14 +02:00
Dominique Martinet 284dcb2dc7 swaynag: exit on wl_display_roundtrip error
fixes loop when sway closes the socket in the middle of querying outputs,
see #5138.
2020-04-02 23:27:57 +02:00
Dominique Martinet 484f7677b0 swaynag: fix segfault on exit when arguments are not correct
swaynag_destroy is called on all cleanup cases and needs the lists to be valid,
just init them early
2020-03-29 11:17:32 +02:00
Andri Yngvason 4c29a53386 swaynag: Add multi-seat support
This also adds cleanup for all seat resources
2020-01-05 19:57:05 +01:00
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
Martin Michlmayr 3dcfa2ee90 Fix markup syntax in man pages 2019-08-31 22:50:39 +09:00
Daniel Eklöf b4b274cdce check for empty string before calling strtoul() and check errno
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-05 14:40:29 -04:00
Daniel Eklöf 900d3287f9 swaybar/nag: use xcursor theme defined by XCURSOR_THEME/SIZE
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-06-05 14:40:29 -04:00
Drew DeVault 236ca63419 swaybg: split into standalone project
The new upstream is https://github.com/swaywm/swaybg

This commit also refactors our use of gdk-pixbuf a bit, since the only
remaining reverse dependency is swaybar tray support.
2019-04-25 18:44:28 +03:00
Brian Ashworth 9099adbbe6 swaynag: revamp type configs
This revamps the type configs for swaynag. All sizing attributes for
swaynag are now `ssize_t` instead of `uint32_t` to allow for a default
value of `-1`, which allows for `0` to be a valid value. Additionally,
the initialization of the type configs has been changed from a simple
calloc to use a new function `swaynag_type_new`. `swaynag_type_new`
calloc's the memory, checks for an allocation failure, sets the name,
and all sizes to -1. The layering order has also been changed to
default, general config, type config, and as highest priority command
line arguments. Finally, `swaynag_type_merge` has been modified to
handle the layering and sizing changes.
2019-04-20 09:14:41 -06:00
Brian Ashworth 6961bf2e4c Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and
swaybg are already done
2019-04-14 12:41:59 +03:00