summaryrefslogtreecommitdiff
path: root/main.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-10-21add monitor specificaion support in nirimasteraxtloss1-0/+8
2024-10-20Only submit opaque (XRGB8888) buffersManuel Stoeckl1-1/+1
This lets the compositor avoid needing to clear and blend the pixels behind the background surface made by swaybg.
2024-10-20Set default background color to blackManuel Stoeckl1-21/+11
This ensures that the background is always opaque. This is a significant change; before, if no background color was specified, images were drawn onto an initially transparent buffer, leaving some of the content behind swaybg visible if the image was alpha transparent or if the 'fit' or 'center' scaling modes were used and the image aspect ratio did not match, or the image was not large enough. As the purpose of a wallpaper/background program is to draw the pixels behind all other interface items, this transparency is neither a required nor a very useful behavior. Sway version >= 1.9 by default clears frames with black, so this change should have no visible impact. Users of other compositors may need to adjust their images or specify the --color flag.
2024-05-21Fix crash when new output addedManuel Stoeckl1-6/+8
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-04-29Fix fractional scale detectionManuel Stoeckl1-1/+2
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-29Estimate output size with wp-fractional-scale-v1Manuel Stoeckl1-1/+38
And if available, use wp-viewporter to submit buffers whose size exactly matches the "physical" pixel dimensions of the output.
2024-04-29Decouple wl_buffer creation and wl_surface configManuel Stoeckl1-48/+74
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-28build: define _POSIX_C_SOURCE globallySimon Ser1-1/+0
2024-04-16Document option arguments in command line usageManuel Stoeckl1-4/+4
2023-12-20Unify color validation and parsing functionsManuel Stoeckl1-30/+19
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-11-02main.c: fix build against gcc-14 (-Walloc-size)Sergei Trofimovich1-2/+2
`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); | ^
2022-09-16Optimize solid color with single-pixel-buffer-v1Simon Ser1-0/+40
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/104
2022-06-03Replace xdg_output with wl_output v4Simon Ser1-96/+54
2022-03-10Check wl_display_roundtrip return valueSimon Ser1-1/+4
References: https://github.com/swaywm/swaybg/issues/35
2021-10-01Only render a new frame when the buffer size changesManuel Stoeckl1-1/+25
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-07-19Load images on every frame renderManuel Stoeckl1-16/+39
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-19Create/destroy a new shm buffer per frameManuel Stoeckl1-9/+8
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-19Deduplicate loads of the same image fileManuel Stoeckl1-14/+64
This reduces memory usage and startup time when different configs load the same image.
2021-06-22React only to most recent configure eventManuel Stoeckl1-4/+19
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-05-10cairo: Replace <cairo/cairo.h> by <cairo.h>Issam E. Maghni1-1/+1
Same as https://github.com/swaywm/sway/pull/6262
2019-04-26Default to all outputs when no output specifiedCaleb Bassi1-14/+4
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-25Split swaybg into a standalone projectDrew DeVault1-14/+31
2019-04-04swaybg: one instance for all outputsBrian Ashworth1-127/+325
This makes it so there will only be one swaybg instance running instead of one per output. swaybg's cli has been changed to a xrandr like interface, where you select an output and then change properties for that output and then select another output and repeat. This also makes it so swaybg is only killed and respawned when a background changes or when reloading.
2019-01-21Replace wlr_log with sway_logM Stoeckl1-7/+7
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-17swaybg: use wl_surface_damage_bufferemersion1-2/+2
2019-01-17swaybg: use output names instead of output indexesemersion1-33/+108
2018-10-15Sway clients: Exit gracefully when compositor is unavailableRyan Dwyer1-1/+6
2018-09-23swaybg: fix increasingly smaller bg on hotplugBrian Ashworth1-0/+4
render_background_image alters the scale that cairo uses. Depending on the image mode, resolution, and image size, this may cause the surface to be rendered increasingly smaller. By calling cairo_save and cairo_restore, any changes to the cairo settings by the function are not kept as a side effect. The surface that swaybg uses is also now cleared before rendering a frame. This is needed to avoid artifacts on resolution or scale changes with certain combinations of image modes, resolutions, and image sizes. This was also part of the increasingly smaller background visual since it made it so it was not obvious the region being rendered to was smaller and caused an increasing number of smaller images to be appear for each hotplug.
2018-08-08Allow a fallback color to be specified for swaybgBrian Ashworth1-1/+12
This allows for a color to be set when the wallpaper does not fill the entire output. If specified, the fallback color is also used when the image path is inaccessible.
2018-07-14swaybar/bg: Fix crash on DPMS offminus1-0/+3
When turning off displays via DPMS, swaybar and swaybg still tried to render, but did not get a valid buffer, causing them to crash.
2018-07-09Update for swaywm/wlroots#1126emersion1-3/+3
2018-05-07swaybg: remove assertions with side-effectsemersion1-5/+8
2018-04-04Initial swaylock portDrew DeVault1-20/+8
2018-04-04Move swaybg background rendering into common/Drew DeVault1-107/+6
swaylock will use it too
2018-04-03swaybg: rename w{width,height} to buffer_{width,height}emersion1-15/+16
2018-04-03swaybg: add HiDPI supportemersion1-6/+42
2018-04-03swaybg: set an empty input regionemersion1-0/+5
2018-03-30Set exclusive zone to -1 for swaybgDrew DeVault1-0/+1
2018-03-28Address review commentsDrew DeVault1-31/+13
2018-03-28Refactor configure/ack configure/commit flowDrew DeVault1-10/+5
2018-03-28s/scaling_mode/background_mode/gDrew DeVault1-24/+24
Since it now includes SOLID_COLOR this is a more appropriate name.
2018-03-28Implement image backgroundsDrew DeVault1-2/+112
2018-03-28Add solid-color rendering to swaybgDrew DeVault1-0/+187
2018-03-28Add client protocols and swaybg skeletonDrew DeVault1-182/+7
2017-07-03swaybg: check that background can be loadedLinus Heckemann1-0/+8
2016-09-05Add client support for HiDPIDrew DeVault1-15/+19
This adds HiDPI support to swaybar, swaybg, and swaylock.
2016-07-30implement solid color rendering for swaybgZandr Martin1-95/+121
2016-07-17Turn swaybg into a shell surfaceDrew DeVault1-0/+1
2016-07-14Revert "swaybg: Make swaybg a shell surface"David Eklov1-1/+0
This reverts commit 99bda4afe27d9e5723ab6b0ebe5eabb0caaa8eeb. It turned out that code to handle swaybg as shell surface was broken so we don't want to make swaybg a shell surface until this has been fixed.
2016-07-04swaybg: Make swaybg a shell surfaceDavid Eklov1-0/+1