Commit Graph

30 Commits

Author SHA1 Message Date
Kenny Levinsen f0ce906b73 wlr_gamma_control: Store gamma size when creating control
When a wlr_gamma_control client calls set_gamma, we allocate a LUT based
on the value returned from wlr_output_get_gamma_size at the time of the
call.

If the output is off and has no CRTC, such as if gamma changes in the
background while a display is disabled for idle reasons,
wlr_output_get_gamma_size returns 0. This leads to a zero-sized table,
which the drm backend interprets as a request to reset gamma tables to
their default.

Store the gamma size when the gamma control was created. Even if the
size changes, this is the size the client was sent and uses to create
the LUTs it sends.
2024-04-01 23:00:48 +02:00
Kenny Levinsen 2b1c0ffdd0 gamma-control-v1: Remove dead variable assignment 2024-02-22 23:12:41 +01:00
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Simon Ser 36376e2ddf gamma-control-v1: stop applying gamma LUTs implicitly
Make the compositor responsible for doing that, so that they can
properly integrate with their output commit sequence.
2023-06-08 18:47:46 +00:00
Simon Ser ec9b79ef19 gamma-control-v1: add wlr_gamma_control_v1_send_failed_and_destroy() 2023-06-08 18:47:46 +00:00
Simon Ser 026fc6eda0 gamma-control-v1: add wlr_gamma_control_v1_apply() 2023-06-08 18:47:46 +00:00
Simon Ser 6e635d2fd3 gamma-control-v1: add wlr_gamma_control_manager_v1_get_control() 2023-06-08 18:47:46 +00:00
Simon Ser 70c1a57248 gamma-control-v1: introduce set_gamma event 2023-06-08 18:47:46 +00:00
Kenny Levinsen 15f2f6642f gamma-control: Read ramps using pread
read advances the file description offset, and requires the client to
ensure that it is reset appropriately before the next gamma ramp
submission. As there is no event to indicate that wlroots finished
processing the new gamma ramp, this can result in a race between the
client seeking in the file and wlroots reading its content.

Use pread with a fixed offset instead.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3655
2023-06-05 11:55:59 +02:00
Simon Ser 38839ac536 gamma-control-v1: simplify get_gamma_control error handling
Allocate resources only after checking the request.
2023-03-06 13:23:51 +01:00
Simon Ser 9108717d5d gamma-control-v1: fix handling of duplicate control
When a new client comes in and tries to create a
zwlr_gamma_control_v1 object for an output which already has one,
we were destroying the old object and early-returning. The early
return causes the new object to not be set up properly: it's not
inserted in the list and doesn't get the gamma_size event.

Fix this by destroying the new object, and leave the old object
intact, which is what was the intent I think.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3605
2023-03-06 11:40:48 +01:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Simon Ser 4f80fab337 gamma-control-v1: schedule frame when resetting gamma LUT
Closes: https://github.com/swaywm/wlroots/issues/2632
2021-01-10 18:40:08 +01:00
Simon Ser c2db691cad gamma-control-v1: apply gamma LUT when output gets enabled
Closes: https://github.com/swaywm/wlroots/issues/2372
2020-11-03 17:47:04 +01:00
Simon Ser 30226eb1fb gamma-control-v1: fix use-after-free in gamma_control_handle_set_gamma
gamma_control_send_failed destroys gamma_control.
2020-08-05 18:18:11 +02:00
Ilia Bozhinov 0032954c75 make sure to fail setting gamma on disabled outputs 2020-08-03 12:05:35 +02:00
Simon Ser 347bdb6d9a output: make wlr_output_set_gamma atomic
wlr_output_set_gamma is now double-buffered and applies the gamma LUT on
the next output commit.
2020-05-14 20:09:28 +02:00
Simon Ser 7516a98167 Gracefully handle inert wl_output resources
Closes: https://github.com/swaywm/wlroots/issues/2088
2020-03-29 20:57:28 +02:00
Simon Ser 5cde35923c Simplify globals implementation by removing destructors
Some globals are static and it doesn't make sense to destroy them before
the wl_display. For instance, wl_compositor should be created before the
display is started and shouldn't be destroyed.

For these globals, we can simplify the code by removing the destructor
and stop keeping track of wl_resources (these will be destroyed with the
wl_display by libwayland).
2019-11-25 09:01:46 -05:00
Simon Ser ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
emersion f5ff702a69 gamma-control-v1: add missing destroy handler 2018-09-29 14:30:41 +02:00
Alexander Bakker 221d412824 Init the new destroy signals added by #1200 2018-08-27 18:21:36 +02:00
Alexander Bakker 20db29779e Add destroy signals to types that are destroyed by wl_display_destroy 2018-08-26 23:23:12 +02:00
emersion c3afe4f42e gamma-control-v1: improve error handling 2018-08-02 23:33:59 +01:00
emersion bbd0fbe573 gamma-control-v1: fix fds not closed 2018-08-02 23:33:59 +01:00
emersion 1705316fa7 gamma-control-v1: set O_NONBLOCK, improve error handling style 2018-08-02 23:33:59 +01:00
emersion 73b7111846 gamma-control-v1: reset gamma table when control is destroyed 2018-08-02 23:33:59 +01:00
emersion 6e8892d4d7 gamma-control-v1: don't insert control in the list before checking unicity 2018-08-02 23:33:59 +01:00
emersion a149c2370a Implement wlr-gamma-control-unstable-v1 2018-08-02 23:33:04 +01:00