Commit graph

142 commits

Author SHA1 Message Date
James Knight
1a70f3ab56 build: avoid git repository discovery when determining version
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>
2024-08-03 18:37:17 +02:00
James Knight
dd4691fc3b build: include swaybg version in version string when using git
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>
2024-08-03 18:37:17 +02:00
Manuel Stoeckl
469d9d4d77 Fix crash when new output added
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.
2024-05-21 18:28:45 +02:00
Manuel Stoeckl
4262e01989 Fix fractional scale detection
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.
2024-04-29 17:47:54 +02:00
Manuel Stoeckl
ade567683a Estimate output size with wp-fractional-scale-v1
And if available, use wp-viewporter to submit buffers whose size
exactly matches the "physical" pixel dimensions of the output.
2024-04-29 17:18:13 +02:00
Manuel Stoeckl
cde38d5e87 Decouple wl_buffer creation and wl_surface config
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.
2024-04-29 17:18:13 +02:00
Simon Ser
a48604c871 build: define _POSIX_C_SOURCE globally 2024-04-28 10:16:06 +02:00
Simon Ser
26719fbbe4 build: use cc.get_supported_arguments() for warning options 2024-04-28 10:14:53 +02:00
Simon Ser
dcb5ebc76a build: bump version to 1.2.1 2024-04-28 10:09:42 +02:00
Manuel Stoeckl
b4fda8146c Correct for image orientation when loading image
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.
2024-04-16 10:33:36 +02:00
Manuel Stoeckl
87ca82d887 Document option arguments in command line usage 2024-04-16 01:00:51 +02:00
Mike Kot (Михаил Кот)
80ed4b020a wayland-protocols min. version to 1.26
In Ubuntu 22.04, default wayland-protocols version is 1.25,
`single-pixel-buffer` feature is missing there
2024-01-13 22:08:28 +01:00
Manuel Stoeckl
eabc06e7eb Unify color validation and parsing functions
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.)
2023-12-20 16:17:23 +01:00
Sergei Trofimovich
435be14610 main.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

`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);
          |                                ^
2023-11-02 21:10:40 +01:00
Simon Ser
a67361ed48 build: drop intermediate protocols library 2022-12-04 17:45:04 +01:00
Simon Ser
2662ceb621 build: find native wayland-scanner program 2022-12-04 17:43:11 +01:00
Simon Ser
0e645c4583 build: bump to version 1.2.0 2022-12-04 17:40:47 +01:00
nerdopolis
dd072b8286 Fix build on Debian Stable 2022-11-27 19:15:15 -05:00
Manuel Stoeckl
848ff54d37 Use shm_open instead of mkstemp for anon files 2022-11-24 23:41:32 +01:00
Simon Ser
deed2edae1 Optimize solid color with single-pixel-buffer-v1
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/104
2022-09-16 14:07:02 +02:00
Manuel Stoeckl
c9608982d2 man: fix background color input format 2022-07-03 08:42:52 +02:00
Simon Ser
69c03f6731 Replace xdg_output with wl_output v4 2022-06-03 16:23:22 +02:00
Simon Ser
de777985ce build: stop using sh for scdoc 2022-03-11 09:23:25 +01:00
Simon Ser
cbdc42b19d build: stop using join_paths 2022-03-11 09:20:18 +01:00
Simon Ser
728a273d2e readme: drop mention of xdg-shell requirement
We don't actually need xdg-shell support.
2022-03-10 10:42:26 +01:00
Simon Ser
a0e86d8071 Check wl_display_roundtrip return value
References: https://github.com/swaywm/swaybg/issues/35
2022-03-10 10:30:06 +01:00
Simon Ser
06f93ddc01 build: bump version to 1.1.1 2022-03-10 10:23:40 +01:00
Manuel Stoeckl
94f41dafd9 Fix memory leak when using image tile mode
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.
2022-03-05 09:47:31 +01:00
Simon Ser
3874badf94 build: set check arg in run_command call
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
2022-03-05 09:44:43 +01:00
Jason Nader
e10d02c77e Add editorconfig 2021-11-19 09:20:51 +01:00
Manuel Stoeckl
5e2df3a600 Only render a new frame when the buffer size changes
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.
2021-10-01 09:15:35 +02:00
Simon Ser
96cf26d605 build: bump to v1.1 2021-07-19 13:27:09 +02:00
Simon Ser
836e9f3bc1 build: mark build-time deps as native 2021-07-19 13:21:26 +02:00
Simon Ser
28f0a33903 build: find wayland-scanner with pkg-config 2021-07-19 13:20:29 +02:00
Simon Ser
33bfdf9adb build: use add_project_arguments instead of configuration_data
No need to include config.h anymore.
2021-07-19 13:16:38 +02:00
Simon Ser
7df581dd4c build: don't align dep equal signs 2021-07-19 13:10:52 +02:00
Simon Ser
d48e0019af readme: mark git dep as optional 2021-07-19 13:10:35 +02:00
Simon Ser
600d811ca4 readme: append / to dirname in compilation instructions
Makes it more obvious that build/ is a directory, not a
sub-command.
2021-07-19 12:04:39 +02:00
Simon Ser
b20ec62368 readme: cleanup dep list 2021-07-19 12:04:20 +02:00
Simon Ser
0872937fc1 readme: update PGP key 2021-07-19 12:03:32 +02:00
Simon Ser
c5f2257190 ci: add .build.yml 2021-07-19 11:59:32 +02:00
Manuel Stoeckl
f71957fce7 Load images on every frame render
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.
2021-07-19 11:41:24 +02:00
Manuel Stoeckl
69827e97db Create/destroy a new shm buffer per frame
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.
2021-07-19 11:41:24 +02:00
Manuel Stoeckl
b9bf8d4b28 Deduplicate loads of the same image file
This reduces memory usage and startup time when different configs
load the same image.
2021-07-19 11:41:24 +02:00
Manuel Stoeckl
ccbd046b33 React only to most recent configure event
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.
2021-06-22 20:07:56 +02:00
Issam E. Maghni
3cb81c3573 cairo: Replace <cairo/cairo.h> by <cairo.h>
Same as https://github.com/swaywm/sway/pull/6262
2021-05-10 10:29:07 +02:00
Elyes HAOUAS
808a226ec6 Fix typo
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-04-12 21:28:15 +02:00
Seppe Soete
a8f109af90 Made the link in the manpage redirect to the swaybg project instead of sway. 2019-08-09 08:03:44 +09:00
Luca Weiss
25c6eaf15e readme: fix url to the releases 2019-05-04 15:08:26 +03:00
Caleb Bassi
cf62ace04b Default to all outputs when no output specified
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.
2019-04-26 11:27:16 -06:00