When attempting to use Git to populate commit/branch information in a
version string, it is possible through repository discovery that it
uses Git information not relevant to project. For example, if
repository content is extract into an interim build location when using
an embedded build framework (e.g. Buildroot), the project will not have
its Git repository to refer to. When it cannot find its repository, it
will look into its parent folders and may find the Git repository of
another project and use its branch/commit information.
This commit provides an explicit path to the project's Git repository
when consider commit/branch information. This will prevent any
repository discovery from occurring.
Signed-off-by: James Knight <james.d.knight@live.com>
Update the version population to always include the swaybg fixed version
string in the final version.
Signed-off-by: James Knight <james.d.knight@live.com>
Calling get_buffer_size on a newly created swaybg_output, before a
config is assigned to a swaybg_output, is unnecessary and yields a
null pointer dereference.
The fractional scale protocol does not guarantee that a preferred
fractional scale value is provided before the surface is mapped.
Therefore, use the (integral) output scale value until a fractional
scale is available.
Also: wl_output.scale is not guaranteed to be sent if the initial
output scale is 1 (although Sway always sends it). Set the default
output scale value.
This commit introduces a new `draw_buffer` function which handles both
the creation of single-pixel and wl_shm buffers, and a `get_buffer_size`
to give the required buffer size in both cases. This reorganization
will it easier in the future to support shm buffers in conjunction
with wp_viewport, for use with wp_fractional_scale_v1.
JPEG and other image formats may include an EXIF orientation tag
which indicates in what orientation (rotation and mirroring)
the image should be displayed. libgdk-pixbuf does not correct for this
when loading an image, but provides a function to apply the transform
after the fact, which this commit uses.
Before this change, parse_color() and is_valid_color() behaved slightly
differently: parse_color() accepted both colors with and without alpha,
with optional leading #, while is_valid_color() forbade alpha and required
a leading # character. This commit merges the two functions into one
simpler function that forbids alpha and allows an optional leading #.
(Alpha values are forbidden because backgrounds should be opaque; a
leading # is optional to make shell scripts easier to write.)
`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
`swaybg` triggers it on `calloc()` calls where member size is used as
`1` (instead of member count):
../main.c:492:32: error: allocation of insufficient size '1' for type 'struct swaybg_output_config' with size '48' [-Werror=alloc-size]
492 | config = calloc(sizeof(struct swaybg_output_config), 1);
| ^
cairo_pattern_t and cairo_surface_t are both reference counted;
before this change, `pattern` being leaked kept alive an extra
reference to the image to which it referred, thereby leaking
the image as well.
Fixes the following Meson warning:
WARNING: You should add the boolean check kwarg to the run_command call.
It currently defaults to false,
but it will default to true in future releases of meson.
See also: https://github.com/mesonbuild/meson/issues/9300
The contents of the buffer associated to an output depend only
on the output config (which does not change at runtime), and the
buffer dimensions.
When the compositor changes the output scale, it often sends a
configure event which exactly compensates for the scale change,
so that the size of the buffer needed for the surface remains
the same. Thus no new frame needs to be rendered.
This change keeps the full-size cairo_surface_t objects unloaded
until they are needed to produce buffers for the outputs' surfaces.
This can slow down background rendering when output scales or sizes
change, or when a new output is created; in exchange, it significantly
reduces the amount of memory that swaybg must retain while it is
not rendering something.
To reduce peak memory usage, dirty outputs are redrawn drawn in batches
grouped by which image they use. This ensures at most one image is
loaded at a time.
Caching these actually increased memory usage after startup;
compositors like Sway tend to release the buffer on receipt (since
they have already copied the shm buffer to an OpenGL equivalent)
so the shm buffer is no longer needed after being used. Outputs
(when not in nested mode) are generally only configured/drawn once,
so there is no point in caching data for the future.
When outputs are dynamically resized, as can happen when sway
is run nested with its wayland or x11 backend, layer shell programs
receive a stream of configure events. In such cases, only rendering
a frame for the last configure event avoids wasted computation.
Before, `--output "*"` had to be specified on the cli before
any appearance options if trying to configure all outputs.
However, the manpage states that all outputs would be used by
default if none were specified.