1
0
Fork 0
Commit graph

10653 commits

Author SHA1 Message Date
Jonas Ådahl
da04ae4ca5 tests: Add duplicate color profile test case
This adds a copy of the calibration test profile and sets up a test to
first add it as a system profile, then setting up the XDG_DATA_HOME
directory so that the duplicate profile is detected, added, and later
discarded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
94e1f8702d color: Handle profiles not initializing succesfully
We might fail with some part of the color profile construction and
initialization. For example there might be a system wide profile with
the same ID as one we attempt to add from a local ICC directory. When
this happens, we should drop these profiles, and use the ones from the
system instead.

Profiles may fail to initialize for other reasons too, e.g.
unpredictable colord errors, or other I/O issues.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2429
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
20a98e6849 color-profile: Fix error check in finalize
We won't get G_IO_ERROR's but CD_CLIENT_ERROR's.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
166ad34423 color-profile: Don't try to remove the wrong profile on finalize
If our profile wasn't fully initialized, we'd try to clean it up, in an
attempt to handle race conditions by finding synchronously then cleaning
it up, but don't attempt this if the profile is ready, as that means we
didn't create one in the first place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
f94a5c7ff9 tests/dbusmock/colord: Fix system profile D-Bus path names
They had the username and userid in them, which they shouldn't.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
a2000a1132 tests/dbusmock/colord: Implement FindProfileById
It's used when cleaning up profiles on race conditions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
8a53020e80 tests/dbusmoc/colord: Return proper AlreadyExists error for profiles
This matches what colord does, and allows us to rely on checking error
codes both in production and in the test suite.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
3aecb1c262 color-profile: Rely on property on ICC for filename
This is instead of getting anything from the CdDevice. This avoids a
crash when CdDevice isn't successfully setup but something still tries
to look up the filename of the ICC profile.

This isn't a real bug fix for anything, but there is no reason having to
rely on CdDevice for this anyway, and as we don't really have control of
it, it's less reliable of containing something valid.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
be4e6484ae render-device: Unmake the EGLContext after checking whether hw accelerated
When creating a render device, we create a temporary EGLContext where we
then query the `GL_RENDERER` string to check whether the renderer is any
of the known software renderers. After we're done, we destroy the
context and move on.

This should be fine as according to specification eglDestroyContext(),
with the context being actually destroyed a bit later when it's no
longer current, but mesa, when running RK3399 (Pinebook Pro), this
results in a crash in a future eglMakeCurrent():

  #0 in dri_unbind_context () at ../src/gallium/frontends/dri/dri_context.c:266
  #1 in driUnbindContext () at ../src/gallium/frontends/dri/dri_util.c:763
  #2 in dri2_make_current () at ../src/egl/drivers/dri2/egl_dri2.c:1814
  #3 in eglMakeCurrent () at ../src/egl/main/eglapi.c:907
  ...

We can avoid this, however, by calling eglMakeCurrent() with
EGL_NO_CONTEXT on the EGLDisplay, prior to destroying, effectively
avoiding the crash, so lets do that.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7194
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2414
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2612>
2022-09-03 18:34:49 +02:00
Jonas Ådahl
b1a687ae57 tests/color: Test that we handle devices with no GAMMA_LUT
We should create the color device etc, but we shouldn't attempt to set
the GAMMA_LUT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
2022-09-03 14:41:36 +00:00
Jonas Ådahl
c724cb3720 tests/monitor-test-utils: Add way to make the GAMMA_LUT zero sized
This will be used to test devices that has no gamma capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
2022-09-03 14:41:36 +00:00
Jonas Ådahl
b29604c3f8 tests/color-management: Move some utility functions higher up
That means they'll be re-usable without having to declare them on top.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
2022-09-03 14:41:36 +00:00
Jonas Ådahl
255cd9a9ff color-device: Don't attempt to set GAMMA_LUT if LUT size is zero
This might happen on e.g. virtual machines. If we don't skip trying,
we'll end up crashing because we'll fail to create a look up table since
the size must be greater than zero to make any sense.

Fixes: baef39e603
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2415
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
2022-09-03 14:41:36 +00:00
Jonas Ådahl
1d4cdd1eb5 wayland/dma-buf: Always send modifiers when using surfaceless
We'll never scan out, which is why ADDFB2 is required otherwise, and we
won't enable the DMA buffer extension if
'EGL_EXT_image_dma_buf_import_modifiers' is missing, so send modifiers
in this case.

This also happens to avoid crashing when the GPU is null, since we'd
otherwise attempt to dereference it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Jonas Ådahl
44dae3e160 kms: Only force legacy mode setting when using EGLStream
EGLStream is incompatible with atomic mode setting, but nvidia-drm when
using libgbm is not, so lets only deny using atomic mode setting when
the render device is an EGLStream based one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Jonas Ådahl
58c3734d78 backend/native: Prepare render devices earlier than KMS
The type of render device used for a specific GPU affects the mode
setting backend that can be used, more specifically, when the render
device is an EGLStream based one, atomic mode setting isn't possible, as
page flipping is done via EGL, not via atomic mode setting commits.

Preparing the render devices before KMS devices means can make a more
informed decision whether to deny-list atomic mode setting for when
a certain GPU uses a EGLStream based render device instance.

This also means we need to translate mode setting devices to render node
devices when creating the render device itself, as doing it later when
creating the mode setting device is already too late.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Jonas Ådahl
1a0bd44694 backend: Hook up to the parent constructed()
Doing an early out in a constructed() is a bit awkward, and unexpected,
and makes it tricky to call the parents constructed() method (which we
didn't), so clean that up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Carlos Garnacho
7a1beb817d backends: Expose InputMapping D-Bus path to determine tablet mapping
Currently, the peripheral "output" setting will be unset if Mutter is
deciding automatically the mapped output of a tablet device. In that
case, gnome-control-center will have a hard time figuring out itself
the better output to show the tablet calibration UI, unless it's hand
held by Mutter.

Add this private D-Bus interface so that gnome-control-center can look
up the output as determined by Mutter to bring the missing harmony
between both. This interface consists of a simple method to get the
mapped output for a input device node.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2605>
2022-09-02 18:34:36 +00:00
Jonas Ådahl
60b382c4e3 x11/session: Set the context as client data on connection watch
It was already assumed to be the context, but we never set it as such,
so things just crashed instead. Now when we set it up correctly,
hopefully that won't happen anymore.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2406
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2267
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5078
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2609>
2022-09-02 17:52:41 +00:00
Jonas Ådahl
b1cc591ef5 tests: Extract D-Bus runner as reusable python module
The D-Bus runner used by tests, including installed tests, is made to be
reusable from GNOME Shell. To do this, install it and the templates in
the pkgdatadir (e.g. /usr/share/mutter-APIVERSION/tests/), generate a
custom runner for the installed tests that uses the installed script and
templates, and change the non-installed original runner to use the
non-installed templates.

The end goal is to reuse the D-Bus session runner and templates used for
mutter when test running GNOME Shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1354>
2022-09-02 17:18:43 +00:00
Simon McVittie
4bc5833144 Consistently pass timestamp as uint64 when creating MetaStartupSequence
Passing the wrong type to a varargs function can cause a mismatch
between marshalling and unmarshalling on the stack, particularly on
32-bit architectures. This results in a build-time test failure.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2065
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2182>
2022-09-02 15:21:27 +00:00
Sebastian Wick
449327093e backends: Implement gamma LUT virtual function for MetaCrtcDummy
Fixes a crash in the nested backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2606>
2022-09-02 14:53:56 +00:00
Alessandro Bono
33dc8ca187 window: Notify about size-change when changing monitor
When moving to another monitor the window size may change in some
cases. While unconditionally notifying a size change is not always
correct, it animates the window when moved to another monitor in
GNOME Shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2558>
2022-09-02 13:12:09 +00:00
Erico Nunes
932351c2bb backends: Set up swap_region without damage history
Following the EGL_KHR_swap_buffers_with_damage specification, the
surface damage used by eglSwapBuffersWithDamage does not need to
contain the damage history.
Rework that to initialize swap_region earlier, before appending the
damage history.
This may help optimizing the composition process in some cases (at least
on X11 when EGL_KHR_swap_buffers_with_damage is available) by not
accumulating additional regions as damaged unnecessarily.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2241>
2022-09-02 11:06:04 +00:00
Alessandro Bono
db0f12135e output-xrand: Plug a memory leak
Fixes: 99d84ae1cc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2608>
2022-09-02 09:51:47 +00:00
Carlos Garnacho
a9ae43ff43 wayland: Ignore text_input requests from unfocused clients
This is what the protocol says we should do, and even though normally
an out of focus client should not have any reason to create IM requests,
there is a bit of a grey area around focus changes, as both the client
losing focus and the client gaining focus may respectively try to
disable/enable in an undetermined order.

Anyways, since in that situation the client losing focus is not aware
of the requests being ignored, the serial should always be incremented
in order not to break accounting of .done/.commit for that specific
client.

Fixes the IM focus being possibly "lost" after changing focus between
clients, if the race condition turned the odds in that direction.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2585>
2022-09-02 09:19:42 +00:00
Daniel van Vugt
cc729def90 monitor-config-store: Format <rate> using the C locale (. decimal point)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2602>
2022-09-02 08:43:00 +00:00
Bilal Elmoussaoui
02110976dc workspace: Mark a string as translatable
This also replaces the wording as a desktop is no longer used to refer
to a workspace

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2375>
2022-09-02 08:04:31 +00:00
Bilal Elmoussaoui
7902fa3f9f core: Make sound player feature optional
Mutter can play sounds in some contexts and also provides an API
for libmutter users to do so using libcanberra internally.

In some specific use cases of Mutter, we would like to not depend
on libcanberra and not have any sound playing feature by default.

The changes keeps the sound player API but make it no-op if the
sound_player feature is disabled to not make it possible to break
a gnome-shell build.

See https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2270
for relevant discussion

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2375>
2022-09-02 08:04:31 +00:00
Daniel van Vugt
f94189d4eb clutter/utils: Remove magic numbers from fixed point calculations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2587>
2022-09-02 07:33:26 +00:00
Alberts Muktupāvels
3c50a9f8aa output-xrandr: Fix memory leak
Introduced in 99d84ae1cc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2589>
2022-09-02 07:02:30 +00:00
Jonas Ådahl
eb764e0f0d barrier/x11: Let the seat bind the input events for us
Without doing this, the events bound by the X11 barrier manager will get
overridden by the ones later bound by the seat.

Fixes: 0debb24e12
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2394
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2604>
2022-09-02 06:35:00 +00:00
Jonas Ådahl
73bb333000 backend: Remove unused barrier vfunc
It was added in error, and has been unused since its introduction. Lets
correct the error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2604>
2022-09-02 06:35:00 +00:00
Sebastian Keller
3e22eb35ed color-store: Fix two small leaks in init_profile_directory
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2603>
2022-09-01 21:39:38 +00:00
Sebastian Keller
48ff211762 color-store: Fix small file path leak in ensure_device_profile
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2603>
2022-09-01 21:39:38 +00:00
Sebastian Keller
57c7d75c43 color-device: Don't wrongly use Unknown vendor in ICC profile from EDID
If the vendor_name was previously successfully determined, we would end
up in the else case, overwriting it with "Unknown vendor" and leaking
the previous vendor_name.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2603>
2022-09-01 21:39:37 +00:00
Jonas Ådahl
9aa9cacb3d color-device: Pass calibration state separately when creating profile
This allows using two separate ICC profiles for one "color profile",
which is necessary to properly support color transform
calibration profiles from an EFI variable.

These types of profiles are intended to be applied using the color
transformation matrix (CTM) property on the output, which makes the
presented output match sRGB. In order to avoid color profile aware
clients making the wrong assumption, we must set the profile exposed
externally to be what is the expected perceived result, i.e. sRGB, while
still applying CTM from the real ICC profile.

The separation is done by introducing a MetaColorCalibration struct,
that is filled with relevant data. For profiles coming from EFI, a
created profile is practically an sRGB one, but the calibration data
comes from EFI, while for other profiles, the calibration data and the
ICC profile itself come from the same source.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2568>
2022-09-01 21:09:28 +00:00
Jonas Ådahl
5b251bd8a7 color-device: Add API to set test efivar path
This will be used by tests to set the special efivar calibration
profile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2568>
2022-09-01 21:09:28 +00:00
Robert Mader
2a87eb6226 renderer-view: Use common helper function to transform matrices
To deduplicate some code. Tested with all eight possible values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2468>
2022-09-01 20:40:35 +00:00
Robert Mader
d3b81d70f0 stage-impl: Use onscreen framebuffer for scanout
We may want to use scanout even if the default framebuffer
of the stage view is an offscreen, for example when a Wayland
client provides pre-rotated buffers. The caller is responsible
to ensure this is correct - we already asserted on that before.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2468>
2022-09-01 20:40:35 +00:00
Robert Mader
3c79eb56b9 compositor/native: Allow scanout for offscreen rotated views
If a stage view uses an offscreen framebuffer exclusively for
rotation and a Wayland client provides pre-rotated buffers,
we should try to use scanout.
This saves us one copy more than scanout in the onscreen case,
i.e. two fullscreen copies in total.

Offscreen rotation is notably used for all 90/270 degree rotations
at the moment, as using display hardware for them is apparently
more complex than for x-/y-flips and can even have detrimental
effects on power consumption.

This can be tested with `weston-simple-egl`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2468>
2022-09-01 20:40:35 +00:00
Jonas Ådahl
39e01d8700 color-manager/x11: Set color transformation matrix
As was done in gsd-color, set the "CTM" of the output. This is only done
in X11, as it was only ever implemented for X11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2166>
2022-09-01 19:09:21 +02:00
Jonas Ådahl
17c99edfe0 x11: Add X11 color manager subclass
This is used as part of the X11 backend to updated X11 root window
properties according to the ICC Profiles in X Specification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2166>
2022-09-01 19:09:21 +02:00
Jonas Ådahl
1adbb686bc tests/color: Add test for night light
This mocks gsd-colord to enable night ligth at a given temperature. The
test then verifies that the result exactly matches that of the gamma
ramps gsd-color generated for the same temperature and ICC profile.

There are two types of profiles tested; ones with VCGT, i.e. calibrated
profiles, and ones without. These are tested as the VCGT affects how the
gamma curve looks, while the non-VCGT profiles all only rely on
the blackbody temperature to generate a gamma ramp.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
ceedc0e5fb color: Emit signal when device is updated
Will be emitted when a device updated its color state. Will be used by
an X11 color manager implementation, and tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
99d0c37d32 tests/color: Auto cleanup devices after tests
This helps making the test cases smaller, skipping irrelevant repetitive
cleanup after each test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
a232eb263f backend/test: Add support for gamma getting/setting
The set gamma is just stored in the object, nothing else. It's
initialized to a linear gamma ramp from 0 to UINT16_MAX for each color
channel.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
b7d3c9e3c5 color-device: Maybe update brightness from profile when updating
Some profiles have brightness metadata that also needs to be applied.
Make sure this happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
71009779c8 color-manager: Update gamma LUTs when needed
This means on
  - hotplugs
  - color temperature changes
  - service availability (gsd-color, gsd-power)
  - when color devices become ready
  - when color devices change

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
baef39e603 color-device: Add API to update gamma LUTs
This will generate a gamma LUT from the profile and apply it to the
monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
3e1a3faa28 color-profile: Add gamma LUT generators
More or less copied from gnome-settings-daemon. The look up tables are
either calculated based on the VCGT (Video Card Gamma Table) and the
blackbody color for a given temperature, or the blackbody color for a
given temperature alone, if no VCGT is available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
69df2a368d color-store: Monitor for non-EDID color profiles
This means that e.g. custom profiles or calibrated profiles will be
added and registered with colord. This does not use CdIccStore for two
reasons: don't want to generate duplicate entries for auto-generated
EDID or EFI profiles, and we want to store profiles as MetaColorProfile.
It also happens to be the case that CdIcc does synchronous I/O, which
should be avoided everywhere except on startup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
22064055be color-profile: Add API to get file path
Each color profile has a corresponding ICC profile saved on the file
system. The getter returns a file path for that ICC profile file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
16149d7c25 color-manager: Keep track of temperature
It will be used to generate gamma look up tables depending on
temperature.

The temperature comes from org.gnome.SettingsDaemon.Color and
depends on the current night light state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
b3fa4a6cd8 color-manager: Add API to set brightness
It uses the org.gnome.SettingsDaemon.Power.Screen D-Bus API. Currently
brightness set if the proxy is not ready are ignored; whether the
brightness value should be cached and set once it appears or whether
color profiles should be reapplied is yet to be decided.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
7b71ec8ff0 color-device: Add new 'changed' signal for when the device changes
What triggers emission right now is the assigned profile changing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
985292c109 color-profile: Add getter for brightness profile
Will be used to set brightness from a color profile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
b59dc05b22 crtc: Get/set gamma via helper struct
Instead of passing 4 arguments (red, green and blue arrays as well as a
size), always pass them together in a new struct MetaGammaLut. Makes
things slightly less tedious.

The KMS layer still has its own variant, but lets leave it as that for
now, to keep the KMS layer "below" the cross backend CRTC layer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
9dda79b281 monitor-manager: Move gamma LUT manipulation API to MetaCrtc
In practice, for KMS backend CRTC's, we cache the gamma in the monitor
manager instance, so that anyone asking gets the pending or up to date
value, instead of the potentially not up to date value if one queries
after gamma was scheduled to be updated, and before it was actually
updated.

While this is true, lets still move the API to the MetaCrtc type; the
backend specific implementation can still look up cached values from the
MetaMonitorManager, but for users, it becomes less cumbersome to not
have to go via the monitor manager.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
0a0fb2fda9 color: Create color profile for assigned profile
We created device profiles, that we manage the lifetime of in colord,
but color devices can be assigned profiles other than the ones it was
created for. For example, this can include the standard sRGB profile
provided by colord.

To achieve this, keep track of the default profile of the CdDevice as
the "assigned" color profile of the device. Given this profile
(CdProfile), construct a MetaColorProfile that can then be interacted
with as if it was generated by ourself.

The assigned profile (default profile in colord terms) does nothing
special so far, but will later be used to determine how to apply CRTC
gamma ramps etc.

The sRGB.icc file used in the tests was copied from colord. It was
stated in the repository that it has no known copyright restrictions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
cc84a45b56 color-profile: Create colord profiles
This works similiarly to how MetaColorDevice works, by creating them
asynchronously then signalling the 'ready' signal when done. Also
similarly to MetaColorDevice, the on-demand sync cleanup on finalize is
added, to avoid race conditions when hotplugs happens very rapidly,
e.g. in tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
60d0394468 tests/mock/colord: Add profile mock support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
062abe01b3 color: Generate and store ICC profiles from EDID or EFI
Just as gsd-color does, generate color profiles. This can either be done
from EFI, if available and the color device is associated with a built
in panel, or from the EDID. If no source for a profile is found, none is
created.

The ICC profiles are also stored on disk so that they can be read by
e.g. colord. The on disk stored profiles will only be used for storing,
not reading the profiles, as the autogenerated ones will no matter what
always be loaded to verify the on disk profiles are up to date. If a on
disk profile is not, it will be replaced. This is so that fixes or
improvements to the profile generation will be made available despite
having run an older version earlier.

After generating, add some metadata about the generated file itself
needed by colord, i.e. file MD5 checksum and the file path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
7a242ff1a1 monitor: Add API to check color transform support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
083b788c74 color-manager: Maintain a lcms context
Will be used from other color related units later on. This also adds an
explicit dependency on LCMS2.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
f4be29eec7 tests: Add rudimentary color device test
Tests that test case EDID is setup correctly, and that color devices for
monitors are created.

tests/color: Add hotplugging tests

Checks that changing the number of connected monitors reflects the
number of current color devices, and that we end up with the correct end
state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
8826b29329 color-manager: Add ready state
Ready means it has established the connection to colord and can operate.
Will be used by tests to make sure tests don't fail due to race
conditions when connecting to colord.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
41ebf3b1bf color-device: Add getter for the associated monitor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
6403cfe170 color-manager: Add API to get the color device for a monitor
There is a 1-on-1 mapping between these two entities, so add a getter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
b8ddf7ad8b monitor: Add getter for EDID info struct
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
9ece224718 output: Keep the EDID struct with the other output info
Will be used later to retrieve other EDID details, e.g. for color
management.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
43cd70089e color-manager: Set up a D-Bus proxy to org.gnome.SettingsDaemon.Color
gsd-color provides this API, which exposes details about the night light
state. Currently, gsd-color also turns this state into CRTC gamma
changes, but this will eventually change, and this is a preparation for
this.

The proxy isn't yet used for anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
0dc6d76371 tests/kvm: Forward MUTTER_DEBUG to the virtual machine
This helps debugging the tests running using KVM.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
3fe01ffc4a color-manager: Take over color device management from gsd-color
Previously, gsd-color handled adding color devices. It got information
about those via the GnomeRR API, which is part of libgnome-desktop.
libgnome-desktop itself got this information from the
org.gnome.Mutter.DisplayConfig.GetResources() D-Bus method, implemented
by mutter.

Now, mutter itself will add all the monitor color devices itself,
without having to go via gsd-color.

We sometimes need to delete colord devices synchronously, in certain
race conditions when we add and remove devices very quickly (e.g. in
tests). However, we cannot use libcolord's 'sync' API variants, as it
has a nested takes-all main loop as a way to invoke the sync call. This
effectively means we end up sometimes not return from this function in a
timely manner, causing wierd issues.

Instead, create our own sync helper, that uses a separate context that
we temporarly push as the thread-default one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
4fe743e03b dbus-runner: Add colord mocking
This will be needed for adding colord integration without breaking
testing.

The test context is altered to make sure any left over color devices are
cleaned up before starting. This means it becomes possible to run a test
case multiple times without having to restart meta-dbus-runner.py.

Note: Don't use os.getlogin() to get the current username; as that
requires a controlling terminal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
67e7140c25 monitor-manager: Move PNP lookup to MetaBackend
It's not really about monitors, even though it is used for monitors.
Lets shrink MetaMonitorManager a bit moving it to the backend.

While at it, stop leaking it too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
7ee60e1143 monitor: Don't only use 'winsys ID' to check sameness
What determines whether one MetaMonitor is the same as the other should
be whether the actual monitor is the same. The way to check this is
comparing the EDID vendor/product/serial fields. Whene these are
incomplete, fall back on the 'winsys ID'.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
ccb6a7e84f monitor: Allow vendor/product/serial to return NULL
Same applies to MetaOutput. The reason for this is to make it possible
to more reliably know when there was EDID telling us about these
details. This will be used for colord integration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
f939a7ca29 tests/monitor-unit-tests: Make serials more unique
We fairly consistently had multiple monitors with the whole
vendor,product,serial tuple identical. If we start relying on making
monitors a bit more unique, e.g. for colord integration, we need to make
two monitors connected distinguishable in order for tests to properly
reflect reality and excercise the correct colord integration paths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
972e393fc0 monitor: Add API to check whether the monitor is virtual or not
As for the types of monitor, X11 and KMS are currently assumed to always be
physical, while the virtual ones are assumed to be virtual. In theory
X11 ones could be virtual, but lets not bother. KMS ones can be virtual
in the case of virtual KMS, but we typically use that for testing as if
it was physical, so lets leave it as such.

Will later be used to feed correct information to colord.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
f8dbea27f8 monitor: Add API to set GAMMA LUT
It's effectively a for-each for every active CRTC of the monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
c6c3f340ec monitor: Add API to get GAMMA LUT size
Will be used to generate look up tables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
8446cd9f4f monitor: Add getter for EDID MD5 checksum
Will be used for colord device matching.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
15bbded86b monitor-manager/native: Bail if gamma LUT size differs
Don't attempt to set a CRTC GAMMA LUT with a different size than what is
already there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
b6aea1318d util: Add 'color' debug topic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
20a91aa4e9 backend: Add color manager skeleton
Create a color manager type that eventually will be the high level
manager of color related behavior, such as ICC profiles and
color "temperature" a.k.a. night light.

For now, it's only an empty shell. It's also constructed by the actual
backend, as at a later point, the X11 and native color management
implementations will differ.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2141>
2022-09-01 14:31:40 +00:00
Jonas Ådahl
c7954be56e tests/wayland/test-driver: Unset resource user data on finalize
Client connections may linger after the test driver is teared down;
handle this gracefully by unsetting the user data on the wl_resource,
and make the resource destructor a no-op, instead of where it would
otherwise remove itself from the resource list. This fixes this crash
seen in CI:

Received signal 11 (SIGSEGV)
 #0  g_list_remove() at ../glib/glist.c:596
 #1  test_driver_destructor() at ../src/tests/meta-wayland-test-driver.c:219
 #2  destroy_resource() at ../src/wayland-server.c:730
 #3  for_each_helper() at ../src/wayland-util.c:416
 #4  wl_map_for_each() at ../src/wayland-util.c:430
 #5  wl_client_destroy() at ../src/wayland-server.c:889
 #6  wl_display_destroy_clients() at ../src/wayland-server.c:1482
 #7  meta_wayland_compositor_prepare_shutdown() at ../src/wayland/meta-wayland.c:441
 #8  meta_context_dispose() at ../src/core/meta-context.c:667
 #9  g_object_unref() at ../gobject/gobject.c:3863
 #9  g_object_unref() at ../gobject/gobject.c:3780
 #10 glib_autoptr_clear_GObject() at /usr/include/glib-2.0/gobject/gobject-autocleanups.h:29
 #10 glib_autoptr_clear_MetaContext() at ../src/meta/meta-context.h:32
 #10 glib_autoptr_cleanup_MetaContext() at ../src/meta/meta-context.h:32
 #10 main() at ../src/tests/wayland-unit-tests.c:707
 #11 __libc_start_call_main() in /usr/lib64/libc.so.6
 #12 __libc_start_main() in /usr/lib64/libc.so.6
 #13 _start() in /builds/GNOME/mutter/build/src/tests/mutter-wayland-unit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2601>
2022-09-01 08:39:48 +00:00
Mario Limonciello
96aa0fb853 output/kms: Add more heuristics to decide when to offer fallback modes
If the panel is connected via eDP and supports more than one mode
at different resolutions don't try to add more.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2586>
2022-08-31 08:15:57 +00:00
Daniel van Vugt
bb1ffb0887 shaped-texture: Don't clear mipmaps during painting
This reverts an attempt at saving texture memory that was introduced
recently in 16fa2100. It was misguided because the same texture may be
needed in the next frame if a window has multiple previews visible on
screen at once (gnome-shell's overview). Keeping the mipmaps around
seems to reduce the peak render times of the overview by roughly 5%-10%.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2598>
2022-08-30 14:50:26 +00:00
Daniel van Vugt
8e2085dad9 backends/native: Add xlnx to the atomic deny list
Although its atomic KMS support seems to work at first, mode sets to
anything other than the Xilinx preferred max resolution of 2048x1280
would result in a hang. The xlnx kernel driver is given:
`DRM_MODE_ATOMIC_ALLOW_MODESET | DRM_MODE_PAGE_FLIP_EVENT`
and it does complete the mode set without error, but page flip events
never arrive and so you're frozen on the first frame.

Revert to legacy KMS which has no such problem with non-default modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2596>
2022-08-26 18:39:12 +08:00
Carlos Garnacho
9d558e334c wayland: Unlink surface listener when freeing token
If the token ended up consumed and freed, we might leave a dangling
destroy listener after freeing the token struct.

Fixes: ed516dde89 (wayland: Add destruction listener to activation token surface)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2594>
2022-08-25 11:15:01 +02:00
Jonas Dreßler
84396baafb stage: Mark stage as active on wayland when it has key-focus
The "activate" and "deactivate" signals on ClutterStage are used by
Cally to track the key-focus when the user is interacting with shell UI.
key-focus only gets tracked while the stage is activated.

Wayland has no concept of the stage receiving focus or not, so right now
the activation state is bound to whether there's a focus_window in
meta_display_sync_wayland_input_focus(). Since display->focus_window is
set pretty much all the time, this effectively binds activation state to
whether the stage holds a grab or not. This is almost good enough, but
it misses cases where key-focus is on the stage without a grab, for
example when keyboard-navigating the panel after using Ctrl+Alt+Tab.

It seems to make more sense to bind the activation state to whether
key-focus is set to an actor or to NULL, so let's do that instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2329>
2022-08-24 10:00:22 +00:00
Carlos Garnacho
ed516dde89 wayland: Add destruction listener to activation token surface
In the timespan between an activation token being created and the
token being used by the activated application, the surface that started
the activation request may end up destroyed/disposed.

In that case, the token would be left with a stale surface pointer,
maybe causing crashes later on. Set up a destroy notification listener
so that we do know to unset the token surface if that situation arises,
this will result in Mutter not considering the token activatable, thus
maybe issuing the "Application needs attention" notification if the
activated surface did not immediately get focus. In any case this is
better than a compositor crash.

A typical situation where this may happen is "Open With..." dialogs,
since those don't live long after launching the application.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2390
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2592>
2022-08-23 22:56:42 +02:00
Carlos Garnacho
9c402bd091 wayland: Ensure to remove destroy listener for MetaWaylandBuffer
Avoid the chance of invalid memory access by leaving the wl_listener
behind when handling the destroy notification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2588>
2022-08-23 17:06:07 +00:00
Carlos Garnacho
f4f39d3a2c wayland: Ensure to unlink destroy listeners for subsurfaces
There is some surface tracking going on here, and all notify handlers
are possibly leaving the linked wl_listener behind. Ensure it is unlinked
in all destroy notification functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2588>
2022-08-23 17:06:07 +00:00
Carlos Garnacho
51064c1b4e wayland: Ensure to unlink destroy listeners after destruction
This is missed in some wl_listeners added
through wl_resource_add_destroy_listener(). Ensure this is done consistently
for all notify functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2588>
2022-08-23 17:06:07 +00:00
Daniel van Vugt
0cfd0c3a8c monitor-store-unit-tests: Verify <maxbpc> XML is stored correctly
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:13 +00:00
Daniel van Vugt
26a9dd7f88 monitor-unit-tests: Add a basic set-and-get test for max_bpc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:13 +00:00
Daniel van Vugt
cc203e241d monitor-test-utils: Add max_bpc field
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
03336788fb monitor-config-store: Add parsing support for "maxbpc" in monitors.xml
For example:

  <monitor>
    ...
    <maxbpc>8</maxbpc>
  </monitor>

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
d39137c631 monitor-manager-xrandr: Changing "max bpc" changes output assignment
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
99d84ae1cc output-xrandr: Add support for the "max bpc" KMS connector property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
978cbe2da4 onscreen-native: Set max_bpc with mode sets
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
f19b350c94 output-kms: Add max_bpc support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
4eef54f80a monitor-config-manager: Add a max_bpc field to MetaMonitorConfig
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
a907cef905 monitor: Add function meta_monitor_get_max_bpc()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
6ff0d600c3 output: Add max_bpc support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
e0e10c29d9 monitor-manager-private: Add max_bpc to MetaOutputAssignment
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
b6dbb686e2 kms-impl-device-simple: Apply META_KMS_CONNECTOR_PROP_MAX_BPC
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
0cc4815837 kms-impl-device-atomic: Apply META_KMS_CONNECTOR_PROP_MAX_BPC
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
2b561a369c kms-update: Add function meta_kms_update_set_max_bpc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
33ee155630 kms-connector: Add "max bpc" property
This limits the bits-per-channel colour depth of the signal that
the connector is allowed to output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
f765437410 kms-types: Add type MetaKmsRange
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Daniel van Vugt
f760b47a3c kms-impl-device: Remember the min/max values for a DRM_MODE_PROP_RANGE
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
2022-08-19 17:07:12 +00:00
Simon McVittie
64a67aa00b backend/native: Don't warn on EACCES if headless
Since commit 1bf70334 "tests/runner: Make test runner use the headless
backend", tests are run with the native backend in headless mode, which
will attempt to open each GPU and show a warning (fatal during tests)
if it cannot.

However, in headless mode we might not be logged in on any seat (for
example we might be logged in via ssh instead), which means we might
legitimately not have permission to use any GPUs, even if they exist.
Downgrade the warning to a debug message in this case.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2381
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2584>
2022-08-19 16:07:23 +00:00
Daniel van Vugt
a2636ce2df tests: Expect <rate> to always have three decimal places (rounded)
At least when the XML is written by mutter it will have three decimal
places. We don't enforce any precision requirements when reading the
XML.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2465>
2022-08-19 15:28:56 +00:00
Daniel van Vugt
8711d44991 monitor-config-store: Only save 3 decimal places of <rate>
Because elsewhere we already ignore precision beyond that. It's also
easier to read rounded to 3 places than 15 decimal places.

  59.996623992919922  ->  59.997

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2465>
2022-08-19 15:28:56 +00:00
Daniel van Vugt
8e5f5fbe54 monitor-config-manager: Only report Hz to 3 decimal places
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2465>
2022-08-19 15:28:56 +00:00
Daniel van Vugt
b5169f2567 output-kms: Change SYNC_TOLERANCE from 1% to 0.001Hz
1% of 60Hz is 0.6Hz so it was losing the usual two decimal places
precision you would expect as a minimum. Now we use three to be sure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2465>
2022-08-19 15:28:56 +00:00
Daniel van Vugt
f6e24c6293 monitor: Generate mode IDs with 3 decimal places for Hz
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2465>
2022-08-19 15:28:56 +00:00
Jonas Ådahl
9c1cd66d41 tests/kvm/virtme-runner: Add more logging
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
2022-08-19 15:40:00 +02:00
Jonas Ådahl
b50353ba23 Add 'catch' option
The catch option makes test run via 'catch'[1], which will log
backtraces whenever an abort or segmentation fault happens in any of the
subprocesses. The aim is to enable this when running in CI to help
debugging crashes that only tend to happen in CI.

While it's possible to wrap the whole meson command in 'catch', doing so
doesn't cover the KVM tests, so this option is added instead that covers
both cases.

[1] https://gitlab.gnome.org/jadahl/catch/

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
2022-08-19 15:39:31 +02:00
Jonas Ådahl
510a938069 tests/pointer-constraints: Destroy client after test
Otherwise the client might exit non-cleanly due to a broken pipe.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
2022-08-19 15:02:38 +02:00
Jonas Ådahl
9988dc344d tests/test-client: Wait for processs to exit before shutting down
This makes sure the client has exited cleanly before the Wayland server
is teared down, causing the client to potentially end up with a broken
pipe.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
2022-08-19 15:02:38 +02:00
Jonas Ådahl
d2c4914546 tests/dbus-runner: Don't consume options after '--'
This allows passing arguments to test cases that conflict with
meta-dbus-runner.py.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
2022-08-19 15:02:25 +02:00
Jonas Ådahl
22a46d4f7b tests/kvm: Allow passing multi argument test cases
This means we can wrap the test case in another executable, or pass
arguments to test case executables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
2022-08-19 14:58:10 +02:00
Jonas Ådahl
2df9ccd598 tests/kvm: Pass test executable last
This is in preparation to pass an arbitrary command with arguments.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
2022-08-19 14:58:10 +02:00
Florian Müllner
d371c18035 tests/kvm: Disable -Werror when building kernel image
We aren't kernel developers, and we won't fix any new warnings
that appear after a compiler update, in particular when building
a CI image.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2430>
2022-08-18 15:02:12 +00:00
Simon McVittie
2b06e1bbad tests: Give mutter-test-runner the RUNPATH to find Clutter
Until recently, mutter-test-runner called into libraries that
indirectly depend on (mutter's fork of) Clutter, but did not actually
call into Clutter itself. Commit 1bf70334 "tests/runner: Make test
runner use the headless backend" gave it a direct call into Clutter,
which means the runtime linker will fail unless the executable's
RUNPATH is sufficient to find Clutter.

For future-proofing, do the same for the other test executables.

Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2389
Signed-off-by: Simon McVittie <smcv@debian.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2581>
2022-08-17 17:14:26 +01:00
Steev Klimaszewski
642791673c Update meta connector types enum
This adds the 4 new connector types that mutter didn't know about from
drm_mode.h in the kernel.

Noticed because mutter kept crashing when plugging in a USB-C adapter to
use an external monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2577>
2022-08-17 08:37:35 +00:00
Salman Malik
e2d4da8562 screen-cast-stream: Embed the wayland output name to streams
If a screencast session is screencasting from multiple monitors,
it is not possible to distinguish which stream (or PipeWire stream
node id) belongs to which connected monitor (such information may be useful
to the caller e.g. caller might want to embed the stream in a window
and name it after the monitor connector, for example). This change adds
optional metadata for monitor streams to also return the wayland output
name with the stream.

Ideally, this metadata should equip the caller to get more information about
display from the following Wayland interfaces:

https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output
https://wayland.app/protocols/xdg-output-unstable-v1

Related:
- https://github.com/flatpak/xdg-desktop-portal/pull/832
- https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/merge_requests/48

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2540>
2022-08-15 17:01:27 +00:00
Florian Müllner
dcd3bccae5 monitor-manager: Expose :night-light-supported property
We currently only expose this information over D-Bus, but now
gnome-shell needs it as well for the corresponding quick settings
toggle.

We don't want to talk D-Bus to ourselves, so make the information
available as a property as well.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5752

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2576>
2022-08-15 12:50:32 +00:00
Jonas Ådahl
6de2e0a320 tests: Add test for remembering configured monitor scales
Tests that switching using the same API used by the key binding
remembers the monitor scale from previous configurations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2479>
2022-08-15 10:00:25 +00:00
Jonas Ådahl
3dca01a06c monitor-config-manager: Use scale from past configs when generating
When we e.g. generate switch configs (i.e. the ones from pressing the
Super+P or the switch-config key on laptops), try a bit harder to find a
"good" monitor scale.

With "good", it means pick a scale that was used in a previous
configuration. In practice, this means that if you for example have
configured your external monitor to use a specific scale, then pressed
e.g. "built in only", and then switched back to e.g. "external only" or
"linear", the generated configuration will use the scale that was
previously configured.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2479>
2022-08-15 10:00:25 +00:00
Jonas Ådahl
4580bca664 monitor: Add mode spec helper checking resolution similarness
If two modes are roughly the same, they should probably use the same UI
scaling factor. I.e. for the same monitor, if a 4K mode was configured to
have a certain scaling factor, and we generate a new configuration with
a similar sized 4K mode, we should re-use the scale previously
configured; however if we e.g. go from a 4K mode to a FHD mode, we
shouldn't.

This allows implementing better hueristics when using the switch-config
feature, where we'd be less likely to loose the for a certain monitor
mode combination previously configured scaling factor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2479>
2022-08-15 10:00:25 +00:00
Jonas Ådahl
71bf31da83 monitor-config-manager: Use helper to calculate mirroring scale
This will eventually help with better hueristics for finding a good
scale. It currently doesn't change much, but the helper will later gain
more functionality that will also help when coming up with mirroring
configs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2479>
2022-08-15 10:00:25 +00:00
Jonas Ådahl
8698b4a493 monitor-config-manager: Mark the mirroring logical monitor as primary
The resulting logical monitor was eventually marked as primary anyway,
but without the config being marked as such, various primary properties
was not set e.g. the one on the MetaOutput. Also, tests would fail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2479>
2022-08-15 10:00:25 +00:00
Jonas Ådahl
5fb4a2c286 monitor-config-manager: Fix layout size with scaled mirroring
The dimension of the logical monitor layout was not scaled according to
the scale, meaning generated mirror monitor configurations were broken.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2479>
2022-08-15 10:00:25 +00:00
Jonas Ådahl
b2ba653dd9 monitor-config-manager: Put logical monitor size scaling into helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2479>
2022-08-15 10:00:25 +00:00
Carlos Garnacho
0d47b467f6 wayland: Fix thinko in paired tablet loop filter
This condition is inverted of how it should be. Since pad focus relies
on grouped devices lookups (e.g. pads not grouped with a tablet do not
focus surfaces), this fixes issues in pad focus and event propagation to
wayland clients.

Fixes: fff3654941 - wayland: Check input device capabilities in tablet seats
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2573>
2022-08-13 00:39:54 +02:00
Jonas Ådahl
aa7653bed7 tests: Test hotplugs when having unmapped Wayland window
This checks that an unmapped but created Wayland window correctly handle
monitor changes. This is specifically added to test an edge case causing
a crash with the following backtrace:

```
  ...
   4) 0x00007ffff78a2a6b in g_assertion_message_expr ()
   5) 0x00007ffff7defd5b in meta_window_update_for_monitors_changed () at ../src/core/window.c:3745
   6) 0x00007ffff7899758 in g_slist_foreach () at ../glib/gslist.c:885
   7) 0x00007ffff7dbe562 in meta_display_foreach_window () at ../src/core/display.c:3185
   8) 0x00007ffff7dbe5fd in on_monitors_changed_internal () at ../src/core/display.c:3210
   9) 0x00007ffff796f4ff in g_closure_invoke () at ../gobject/gclosure.c:830
  10) 0x00007ffff7981316 in signal_emit_unlocked_R () at ../gobject/gsignal.c:3740
  11) 0x00007ffff7987699 in g_signal_emit_valist () at ../gobject/gsignal.c:3495
  12) 0x00007ffff7987bc2 in g_signal_emit () at ../gobject/gsignal.c:3551
  13) 0x00007ffff7d89915 in meta_monitor_manager_notify_monitors_changed () at ../src/backends/meta-monitor-manager.c:3517
  ...
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
5f96194e9e window/wayland: Always update the monitor when updating
If the window didn't have a size, it would still have a monitor, and
when we are asked to update, we must update, as the old monitor might
not be kept around, leaving us vulnerable to use after free.

Avoid not updating the monitor by using the stored IDs (preferred, or
previous) to find suitable logical monitors, with the primary monitor
being the last fallback unless we're completely headless.

This fixes the assert

  !window->monitor ||
  g_list_find (meta_monitor_manager_get_logical_monitors (monitor_manager),
               window->monitor)

in meta_window_update_for_monitors_changed() being hit when a Wayland
window has been created, but not mapped, when a hotplug happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
4ed9653757 window: Add monitor finder using stored IDs
This will be used to find new monitors on e.g. "winsys ID" of previous
monitors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
cf848c577e window: Get backend from context when updating monitors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
24965a78da window: Make monitor from rect finder helper more clearly named
The function finds a suitable logical monitor given the window
rectangle; this wasn't all that clear from the name
"calculate_main_logical_monitor".

This is in preparation for finding a new logical monitor using things
other than the geometry of the window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
a25081ffb5 tests/respect-constraints: Explicitly set monitor size
The test depends on a certain monitor size; make sure to set that up
front.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
e743334fe0 tests/runner: Add 'sync_shown' command
This command will block until a previously asynchronously shown window
is shown. E.g.

show w/1 async
... do stuff ..
sync_shown w/1

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
5c26d786f5 tests/runner: Add 'resize_monitor' metatest command
This will allow tests to change monitor resolution. The first argument
is the monitor ID; there is always one monitor added by default, and it
has the id 0. It's currently not possible to add more monitors, so
passing '0' is the only valid way to resize monitors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
06d9ed3da7 tests/runner: Recreate the virtual monitor for each test
This ensures that the virtual monitor has an expected initial state each
test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Jonas Ådahl
532c63e96c tests/runner: Make test runner use the headless backend
Using the headless backend means we can use virtual monitors, which
means we can unblock add support for hotplugging via metatests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00