1
0
Fork 0
Commit graph

10927 commits

Author SHA1 Message Date
Michel Dänzer
416285d1b7 wayland/dma-buf: Add meta_wayland_dma_buf_fds_for_wayland_buffer
And call it from meta_wayland_buffer_realize. This makes dma-buf fds
available for EGL image type buffers as well.

v2:
* Move buffer->dma_buf.dma_buf assignment value to next line.
  (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880>
2022-12-01 09:40:38 +01:00
Sebastian Keller
f0fd013262 window/wayland: Calculate bottom and right frame extents
The bottom and right frame extents were never calculated and thus always
remained 0. This did not lead to any obvious problems until 6cbc5180
which started relying on those to calculate the buffer rect. This
resulted for example in window screenshots being cut off at the bottom
right corner of the window rather than the buffer.

Fixes: 6cbc5180
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6050
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2720>
2022-11-26 15:04:00 +01:00
msizanoen1
992e169d84 wayland/pointer-gestures: Fix crash in get_*_gesture after pointer is destroyed
Properly handle cases where the pointer object has already been
destroyed to prevent the compositor from crashing with a null pointer
dereference when a client invokes a get_*_gesture method after the
pointer object is destroyed e.g. when the current login session is not on
foreground.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2237
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2690>
2022-11-25 15:40:12 +00:00
Jonas Ådahl
db1000e264 plugin-manager: Don't try to starte effect when shutting down
Add internal state (starting, running, stopping), and use this instead
of MetaDisplay struct fields to determine whether to start animations.

This fixes issues when we try to animate things when shutting down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2716>
2022-11-25 10:26:52 +00:00
Jonas Ådahl
c1982218e1 context: Add 'started' and 'prepare-shutdown' signals
The backend is changed to listen to 'prepare-shutdown' and forward, but
the 'started' signal will be used later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2716>
2022-11-25 10:26:52 +00:00
Jonas Ådahl
8bc375005c kms/connector: Don't query the kernel twice when updating
On hotplug, the events we receive from the kernel are async, and
connectors in the kernel come and go as they please. In practice, this
means that calling drmModeGetConnector() twice more or less directly
after each other, there is no guarantee that the latter call will return
anything if the former did.

When updating the connector in response to hotplugs, we'd first update
the list of existing connectors, and following that, query each and
every one again for their current state, to update our internal
representation; only the former handled drmModeGetConnector() returning
NULL, meaning if unlucky, we'd end up doing a null pointer dereference
when trying to update the state.

Handle this by querying the kernel for the current connector state only
once per connector, updating the list of connectors and their
corresponding state at the same time.

Fixes the following crash:

    #0 meta_kms_connector_read_state at ../src/backends/native/meta-kms-connector.c:684
    #1 meta_kms_connector_update_state at ../src/backends/native/meta-kms-connector.c:767
    #2 meta_kms_impl_device_update_states at ../src/backends/native/meta-kms-impl-device.c:916
    #3 meta_kms_device_update_states_in_impl at ../src/backends/native/meta-kms-device.c:267
    #4 meta_kms_update_states_in_impl at ../src/backends/native/meta-kms.c:604
    #5 update_states_in_impl at ../src/backends/native/meta-kms.c:620
    #6 meta_kms_run_impl_task_sync at ../src/backends/native/meta-kms.c:435
    #7 meta_kms_update_states_sync at ../src/backends/native/meta-kms.c:641
    #8 handle_hotplug_event at ../src/backends/native/meta-kms.c:651
    #9 on_udev_hotplug at ../src/backends/native/meta-kms.c:668

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2131269
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2709>
2022-11-24 16:18:22 +00:00
Corentin Noël
66dcef7ac1 window-actor: Add several (nullable) annotations
Many getters might return a NULL value, let's reflect this in the annotations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2715>
2022-11-24 15:16:13 +01:00
Peter Hutterer
8206208a22 backends: Fix a typo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2714>
2022-11-24 12:25:29 +00:00
Jonas Ådahl
ec82b6e869 keybindings: Use proper enum type in MetaKeyHandler
This simplifies inspecting runtime state using gdb.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2714>
2022-11-24 12:25:29 +00:00
Jonas Ådahl
990a10fe78 barrier/native: Fix coding style
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2714>
2022-11-24 12:25:29 +00:00
Jonas Ådahl
ecaf091eb4 x11-display: Use autoptr during construction
This simplifies error paths, as they don't need to unref.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2714>
2022-11-24 12:25:29 +00:00
Jonas Ådahl
28cbc213d0 x11/cm: Stop using intermediate bypass_clutter variable
There is no need to use the 'bypass-*' method of event processing in the
changed function since in all cases the 'bypass-*' variable was set, any
following event processing functions would ignore the event anyway.
Simplify things a bit by just returning TRUE if the event is consumed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2714>
2022-11-24 12:25:29 +00:00
Jonas Dreßler
1816f21e21 window: Avoid focusing during workspace changes
We can land inside meta_window_focus() in the middle of changing the
window workspace, because some signal handler of MetaWorkspace's
"window-removed" signal triggers a focus. This can cause a crash in
`g_assert (link)` when updating the MRU list because we still think
we're on the old workspace when actually we are already removed from
this workspaces MRU list.

To avoid crashes like this, bail out of meta_window_focus() when we're
in the middle of a workspace change.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5368

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2691>
2022-11-24 12:09:23 +00:00
Jonas Dreßler
098c627f11 window: Move all single-bit booleans to the end of the struct
It's a bad idea to have data like this in the middle of a struct, as it
will easily cause everything behind it to be badly aligned and thus
increase memory access times.

So move all those bitfield booleans to the end of the struct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2691>
2022-11-24 12:09:23 +00:00
Jonas Ådahl
1645171d4b seat/impl: Wait for pointer constraining when updating viewports
It is generally assumed here and there that the pointer at all point in
time is within some logical monitor, if there is any logical monitor to
be within.

With the input thread, this was for a short amount of time not reliable,
resulting in crashes in combination with hotplugging or suspend/resume,
where monitors come and go quickly.

What happens is that the pointer at first is within a logical monitor,
but when that logical monitor is removed, while the new monitor
viewports are handed to the input thread, the constraining happens
asynchronously, meaning there is a time between between the new
viewports are sent, and before clutter_seat_query_state() starts
reporting the constrained position.

If a new client mapped a maximized window during this short time frame,
we'd crash with

    #0 meta_window_place at ../src/core/place.c:883
    #1 place_window_if_needed at ../src/core/constraints.c:562
    #2 meta_window_constrain at ../src/core/constraints.c:310
    #3 meta_window_move_resize_internal at ../src/core/window.c:3869
    #4 meta_window_force_placement at ../src/core/window.c:2120
    #5 xdg_toplevel_set_maximized at ../src/wayland/meta-wayland-xdg-shell.c:429
    #6 ffi_call_unix64 at ../src/x86/unix64.S:105
    #7 ffi_call_int at ../src/x86/ffi64.c:672
    #8 wl_closure_invoke at ../src/connection.c:1025
    #9 wl_client_connection_data at ../src/wayland-server.c:437

The fix for this is to make sure that the viewports are updated and
pointers constrained synchronously, i.e. the main thread will wait until
after the input thread is done constraining before continuing.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2147502
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2711>
2022-11-24 11:28:55 +01:00
Jonas Ådahl
eb7abdacd8 plugin/default: Autostart localed when querying keyboard layout
Otherwise it's required that systemd-localed is already running, which
is unlikely, since it will auto-terminate by default.

Fixes: 562024f746
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2710>
2022-11-24 01:16:31 +00:00
Bilal Elmoussaoui
74bb480753 sound player: Don't unref undefined fields
If the sound player feature is disabled, none of those fields are
instantiated which causes the crash reported in #2451

Also switch to using g_clear_pointer while we are at it

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/2451

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2706>
2022-11-23 10:37:19 +01:00
Jonas Dreßler
260ea37312 tests/clutter/conform: Add a test for event delivery
Add a test for everything related to event delivery. The first test we
add here is making sure we don't regress on the bug fixed with commit
edc226a04d.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2697>
2022-11-22 20:31:42 +00:00
Jonas Dreßler
0d0a6ece32 tests/backend-test: Wait for stage update in add and remove_device
We put a DEVICE_ADDED or DEVICE_REMOVED event into Clutters event queue
here, so we should also wait for Clutter to process events once.

Just putting an event into the queue doesn't mean it gets processed
immediately (especially when the commit after this one is applied), so
wait for a stage update here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2697>
2022-11-22 20:31:42 +00:00
Bilal Elmoussaoui
bb5af3a6bd g-i: Drop unneeded since/stability annotations
They are no longer useful since the merge of cogl inside mutter

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2708>
2022-11-22 13:32:52 +01:00
Bilal Elmoussaoui
7bf07d2980 core/window: Implement GInitable
Currently, we will notify the display about a new window being created
during the constructed phase of the GObject. During this time,
property-change notifications are frozen by GObject, so we'll emit a few
::notify signals only after the window-created signal, although
the actual property change happened before that.

This caused confusion in gnome-shell code where a notify::skip-taskbar =
true emission was seen when the property already was true inside a
window-created handler before.

In order to fix that that, we notify the window creation
post-construction
of the GObject on GInitable.init vfunc

Details
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6119#note_1598983
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6119

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2703>
2022-11-22 11:29:38 +01:00
Bilal Elmoussaoui
5aa104c48d xwayland: Correct the flag of the surface property
As the surface is cleaned up when the window is dropped, marking it
as construct property more correct & mark it as static_strings while at
it.

Fixes a regression caused by
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2703>
2022-11-22 11:27:17 +01:00
Jonas Ådahl
425e80adc2 display: Freeze stack when closing X11 display
If two X11 windows were the last two, we'd remove them from the stack
while unmanaging them. That'd hit an assert in
meta_stack_tracker_restack_managed(), resulting in the following crash
when Xwayland exited unexpectedly with two or more X11 windows being the
only windows on the stack:

  #1  g_assertion_message() at ../glib/gtestutils.c:3256
  #2  g_assertion_message_expr() at ../glib/gtestutils.c:3282
  #3  meta_stack_tracker_restack_managed() at ../src/core/stack-tracker.c:1210
  #4  on_stack_changed() at ../src/core/stack.c:142
  #5  _g_closure_invoke_va() at ../gobject/gclosure.c:895
  #6  g_signal_emit_valist() at ../gobject/gsignal.c:3456
  #7  g_signal_emit() at ../gobject/gsignal.c:3606
  #8 meta_stack_changed() at ../src/core/stack.c:265
  #9 meta_stack_remove() at ../src/core/stack.c:324
 #10 meta_window_unmanage() at ../src/core/window.c:1542
 #11 meta_x11_display_unmanage_windows() at ../src/x11/meta-x11-display.c:111
 #12 meta_x11_display_dispose() at ../src/x11/meta-x11-display.c:141
 #13 g_object_run_dispose() at ../gobject/gobject.c:1448
 #14 meta_display_shutdown_x11() at ../src/core/display.c:831

The added test specifically checks that this scenario is handled
gracefully.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2143637
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2704>
2022-11-21 16:30:06 +00:00
Jonas Ådahl
dec3c49e5a tests/test-client: Handle alarm event processing automatically
Instead of having users of the test client manually deal with alarm
filters, let the test client automatically add itself as filters. This
changes the MetaX11Display a bit, to handle an array of filters instead
of a single filter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2704>
2022-11-21 16:30:05 +00:00
Florian Müllner
c4f43b65ed build: Replace deprecated meson functions
The `dep.get_<type>_variable()` methods have been deprecated in
favor of the generic `dep.get_variable()` method.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2702>
2022-11-19 02:21:05 +01:00
Jonas Ådahl
db2387d7f8 tests/clutter: Use a 800x600 10 Hz virtual monitor
This matches what CI did, and will hopefully help make some tests that
rely on timings less flaky.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2701>
2022-11-18 19:46:09 +01:00
Jonas Ådahl
22d08501a8 cursor-renderer/native: Fix cursor sprite CRTC scale
The CRTC cursor sprite scale was incorrectly assumed to be always 1.0
when using the default not-scale-monitor-framebuffer mode. This is
harmless in most cases, as most clients provide HiDPI capable cursors,
but for the ones that didn't, we'd end up drawing their cursors
unscaled, when using the cursor planes.

Fix this by using the "texture scale" which is what is intended for
this.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2477
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2698>
2022-11-18 11:26:30 +00:00
Jonas Ådahl
a1d14a6176 cursor-renderer/native: Don't put opaque buffers in cursor plane
Cursor planes tend to be ARGB8888 and support no other format (ideally
we should not hard code this, but un-hard-coding that is for another
day), and if we put e.g. a XRGB8888 buffer in there, it'll either result
in the gbm_bo allocation failing (it doesn't allow USE_CURSOR with any
other format) or mode setting failing if using  dumb buffers directly.
In the former case, we'll fall back to OpenGL indefinitely, and in the
latter, we'll have failed mode sets as long as we try to set the invalid
cursor buffer as the cursor plane.

Change things to process all buffers that are not ARGB8888 using the
scale/rotate machinery we already have, turning XRGB8888 into ARGB8888.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2477
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2698>
2022-11-18 11:26:30 +00:00
Bilal Elmoussaoui
6b77532a23 window: Move surface property to it subclasses
As we have specific window types per display server,
having it in the parent class makes building without wayland
harder to achieve

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
2022-11-17 11:30:56 +00:00
Bilal Elmoussaoui
c3a01e4e18 core: Untangle meta_window_shared_new
The constructor used to take Wayland/X11 specific types which makes
building without Wayland/X11 not possible.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2418>
2022-11-17 11:30:56 +00:00
Jonas Ådahl
58e89b3a5d tests/clutter: Use the headless backend
One test depends on a pointer event having been emitted so that the
stage has a focused pointer; make sure that has happened.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2699>
2022-11-17 10:25:37 +00:00
Jonas Ådahl
b15be5e287 backend/native: Don't assume passed error points to anything
It's common practice to not require a non-NULL error passed to `GError
**error` arguments, so do not make that assumption here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2699>
2022-11-17 10:25:37 +00:00
Sebastian Wick
d6d6dc65c1 window-actor/wayland: Do not crash when there is no monitor
When all monitors are blanking or after suspending there might not be
any monitors temporarily. We can't draw a black background when we don't
know the size of the monitor it's fullscreen on but it's fine because
there actually is no monitor.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2508
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2695>
2022-11-15 22:46:30 +01:00
Sebastian Krzyszkowiak
e331e38a19 shaped-texture: Reset pipelines after setting a texture with new size
Attaching a new buffer with a different size than the old one means
that the viewport needs to be recalculated.

Not doing this caused the viewport to be incorrectly applied when
viewport_src_rect remained the same after attaching such buffer.
Pipeline reset usually happens when applying a new viewport,
but it doesn't happen when the viewport values remain the same.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2689>
2022-11-13 18:02:30 +00:00
Robert Mader
7e838b1115 wayland/outputs: Implement wl_output v4
This version adds the name and description events already present
in xdg_output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2692>
2022-11-10 13:45:05 +01:00
Robert Mader
1b1eed0dbd wayland/outputs: Implement wl_output v3
This version adds a release event, allowing clients to tell the
server that it can clean up the related wl_resource.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2692>
2022-11-10 13:45:05 +01:00
Carlos Garnacho
e43234f464 backends: Use Clutter API to get dimensions at MetaInputMapper
We can now ask the ClutterInputDevice about its physical size, instead
of resorting to udev.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
b040964025 backends/x11: Implement get_dimensions() in X11 input devices
We can get the information from X11 itself, so do the calculations to return
the device physical size.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
21fb6cc412 backends/native: Implement get_dimensions() in native devices
We already poked the libinput device size, so use that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
a37bec258c backends: Drop MetaInputSettings vfunc to figure out trackballs
These now have a capability, so we don't need this vfunc anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
23c931ff18 backends/x11: Avoid usage of udev in MetaInputSettingsX11
Use device capabilities instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
7dd25b62ed backends/native: Avoid direct udev usage in MetaInputSettingsNative
Use device capabilities to figure out whether configuration applies to
a device or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
46643b895c backends: Use capabilities to figure out trackballs in MetaInputSettings
Port these configuration methods to use capabilities, instead of using the
internal vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
5471b866b3 backends/x11: Set trackball/trackpoint capabilities
Use gudev to detect these capabilities in input devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
Carlos Garnacho
d274d4359f backends/native: Set up trackball/trackpoint capabilities
Use udev to detect these features in input devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
2022-11-09 10:46:55 +00:00
John Wudrick
d889aad7cf window: Update ongoing edge resistance flags with input
Fix a recent regression where edge resistance flags where no
longer updated during the move/resize operation.

Fixes: bd6b14a843 (window: Throttle window move grab updates)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2492
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2687>
2022-11-08 05:01:49 +00:00
Jonas Ådahl
ac093dc651 wayland/xdg-shell: Send xdg_popup.popup_done when position invalid
A client may provide a positioner that places the window outside of its
parent. This isn't allowed, according to spec, so we hide the window and
log a warning. This, however, leads these affected clients with an
incorrect view of what is mapped or not, meaning it becomes harder to
recover.

Fix this by sending xdg_popup.done when we hide the popup due to an
invalid position. Don't error out the client, let the bug slide, as
that's a less jarring experience for existing applications that
reproduce this than being disconnected, which practically feels like a
crash.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2408
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2645>
2022-11-06 13:06:37 +00:00
Jonas Dreßler
28982ade94 gesture-tracker: Never reject sequences in Wayland sessions
In constrast to x11, Wayland has sane handling for touch events and
allows the compositor to handle a touch event while the clients are
already seeing it. This means we don't need the REJECTED state on
Wayland, since we can also grab sequences after the client has seen
them.

So disallow moving sequences to the REJECTED state on Wayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2508>
2022-11-04 19:09:56 +00:00
Jonas Dreßler
fc1b4ae149 gesture-tracker: Only track actions which are actually enabled
Tracking disabled actions doesn't make sense, these will never recognize
anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2508>
2022-11-04 19:09:56 +00:00
Robert Mader
d313c8f4fe Revert "wayland/pointer-constraints: Fix window check on subsurfaces"
This reverts commit 50288d1ead.

The fix is uncomplete and causes crashes under certain circumstances.
As we are close to the next point release let's revert it for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2685>
2022-11-03 13:17:40 +01:00
Jonas Ådahl
ec18a1d7ae tests/dbus-runner: Add way to launch custom services
This will be used by CI to launch wireplumber inside the D-Bus session
started by meta-dbus-runner.py.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
2022-11-01 21:04:21 +00:00
Jonas Ådahl
562024f746 plugin/default: Don't load properties when getting locale proxy
This cuts away between 7 and 40 ms from the startup of tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
2022-11-01 21:04:21 +00:00
Jonas Ådahl
1efb93e145 profiler: Allow enable tracing via env var
This is helpful to e.g. trace e.g. launching.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
2022-11-01 21:04:21 +00:00
Jonas Ådahl
ca2057da9a Move MetaProfiler from the backend to core
It's not really a backend thing, and we'll want to profile e.g. loading
the backend too, so create it very early and destroy it very late and
let MetaContextMain own it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2678>
2022-11-01 21:04:21 +00:00
Robert Mader
50288d1ead wayland/pointer-constraints: Fix window check on subsurfaces
`get_window()` is not implemented by the subsurface role, returning
`NULL`, breaking constrains for subsurfaces.
While the `get_window()` behaviour could change in the future, for now
use `get_toplevel_window()` which does what we need here while avoiding
possible regressions.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2223
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2681>
2022-11-01 17:04:16 +01:00
Łukasz Spintzyk
c57a500ccb backend/native: Create MetaRenderDevice on_gpu_added when it does not exists
Fixes GNOME/mutter#2481

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2676>
2022-11-01 11:13:38 +01:00
Salman Malik
986d3be7ac virtual-stream: Paint stage properly with/without cursor
This change ensures that when the painted stage is
written out to the buffer, it respects the clients
desire to either desire to either embed the cursor
in the view or not.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2142
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2629>
2022-10-24 19:38:08 +00:00
Salman Malik
abc8555463 virtual-stream: Fix always embedded cursor
This change fixes the issue where the cursor is always
embedded in the frames even when the client has requested
the cursor information be sent as metadata in the stream.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2629>
2022-10-24 19:38:08 +00:00
msizanoen1
b61b0478f7 xwayland: Always require X11 authentication
This reverts commit eac227a203.

Currently, Flatpak applications can bypass the X11 permission setting
and access the X server through abstract sockets because X11 authentication
is not enforced for the current user ID.

Fix this by always requiring X11 authentication for Xwayland. This also
means applications without XAUTHORITY set to the file with Mutter's
Xwayland credentials cannot connect to X, including apps launched from
VT or SSH.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2633>
2022-10-21 14:06:28 +00:00
Sebastian Keller
184055b2bb window/x11: Ignore the _NET_WM_BYPASS_COMPOSITOR = 1 hint
We already detect all the cases that allow a window to be properly
unredirected. Using this hint to bypass some of those checks only causes
windows that can not be unredirected properly to get unredirected
regardless.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2434
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2651>
2022-10-21 12:58:07 +00:00
Sebastian Keller
46fc94b67f surface-actor-x11: Only unredirect fullscreen windows for full damage
When deciding if a window should be unredirected because it was causing
fullscreen damage in the past, it was not considered whether the window
is still fullscreen. This could result in a floating window being
unredirected if it was chosen for unredirection because of
_NET_WM_BYPASS_COMPOSITOR = 1 and was previously fullscreened for >= 100
frames, long enough to change does_full_damage, before getting
unfullscreened.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2434
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2651>
2022-10-21 12:58:07 +00:00
Jonas Ådahl
cefa4044d1 Revert "wayland-keyboard: Don't send pressed keys on enter"
Back in 2014 sending pressed keys to Wayland clients caused issues,
because at least Xwayland didn't handle that gracefully, causing issues
like ghost-pressed keys. A way it was reproduced was quickly alt-tab:ing
to and from a Firefox window, which would cause the File menu bar
incorrectly appearing.

While this was reported to the Xwayland component back then, it was,
probably by mistake, assumed to be an issue in mutter, and mutter
stopped sending pressed key events on enter.

The following year, Xwayland was eventually fixed, but the work around
in mutter has been kept around until it was again noticed as an
inconsistency between compositor implementations.

Lets remove the work around, and follow the spec, again.

This reverts commit c39f18c2d4.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2457
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2657>
2022-10-19 15:19:34 +00:00
Jonas Ådahl
ed8275ec33 wayland/seat: Don't double-disable input classes
We'd set the capabilities to 'none', meaning all previously enabled
device classes would be disabled. That means we shouldn't re-disable
them directly after.

This ensures '..disable()' is only called once for every '..enable()'.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2657>
2022-10-19 15:19:34 +00:00
Jonas Ådahl
bd6b14a843 window: Throttle window move grab updates
There is no point in moving a window at the input event refresh rate,
when the end result will only be used once per update, thus, throttle
the move done during grabs to once per stage update.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2233
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2652>
2022-10-18 18:12:03 +00:00
Jonas Ådahl
11a50fffa2 window: Throttle resize-grab updates to stage updates
With high frequency mouse devices, we would send very many configure
events per each update cycle, which had the end result that some clients
constantly re-allocating and redrawing their buffers far too often, if
they did this in direct response to xdg_toplevel configure events.

Lets throttle the interactive resize updates to stage updates, to avoid
having these clients doing the excessive buffer reallocation.

This also removes some old legacy X11 client resize throttling, that
throttled a bit arbitrarily on 25 resizes a second; it is probably
enough to throttle on stage updates for these clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2652>
2022-10-18 18:12:03 +00:00
José Expósito
5fa1a8cf42 backends/native: Send lores scroll in the middle of the detent
Some mice send a value slightly lower than 120 for some detents. The
current approach waits until a value of 120 is reached before sending a
low-resolution scroll event.

For example, the MX Master 3 sends a value of 112 in some detents:

              detent                   detent
    |                        |                       |
                        ^    ^                    ^
                        112  REL_WHEEL            224

As illustrated, only one event was sent but two were expected. However,
sending the low-resolution scroll event in the middle plus the existing
heuristics to reset the accumulator solve this issue:

              detent                   detent
    |                        |                       |
                ^          ^             ^          ^
                REL_WHEEL  112           REL_WHEEL  224

Send low-resolution scroll events in the middle of the detent to solve
this problem.

Fix https://gitlab.gnome.org/GNOME/mutter/-/issues/2469

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2668>
2022-10-18 17:28:32 +00:00
José Expósito
92a90774a4 virtual-input-device/native: Emit discrete scroll when the source is a wheel
Previously, when scroll was received in a remote session, it was handled
as continuous scroll.

This generated issues with clients without high-resolution scroll
support as the code path in charge of accumulating scroll until 120 is
reached was not used and therefore discrete scroll events were not being
generated.

Handle scroll generated in a remote session as discrete scroll when the
source is CLUTTER_SCROLL_SOURCE_WHEEL to fix this issue.

Fix https://gitlab.gnome.org/GNOME/mutter/-/issues/2473

Fixes: 9dd6268d13 ("wayland/pointer: Send high-resolution scroll data")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2664>
2022-10-18 08:16:11 +00:00
Max Zhao
87e1d72cd4 wayland: Fix null pointer deference in meta_get_first_subsurface_node.
In fcfe90aa, multiple for loops were replaced with
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE.

However, this substitution was not side-effect free, and introduced a
null-pointer dereference risk as shown in the example below:

Old:

    for (n = g_node_first_child (surface->subsurface_branch_node);
         n;
         n = g_node_next_sibling (n))
      {
        if (G_NODE_IS_LEAF (n))
          continue;

        meta_wayland_surface_update_outputs_recursively (n->data);
      }

n is checked for NULL during each loop in the condition expression.
Therefore, when `G_NODE_IS_LEAF (n)` is called, `n` is guaranteed not to
be NULL. Note also that g_node_first_child is also NULL-safe since it
performs a NULL check internally.

New:

    META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface)
      meta_wayland_surface_update_outputs_recursively (subsurface_surface);
    =
    for (GNode *G_PASTE(__n, __LINE__) = meta_get_first_subsurface_node ((surface)); \
     (subsurface = (G_PASTE (__n, __LINE__) ? G_PASTE (__n, __LINE__)->data : NULL)); \
     G_PASTE (__n, __LINE__) = meta_get_next_subsurface_sibling (G_PASTE (__n, __LINE__)))

In the new logic `subsurface` is still checked for NULL in the loop
condition. However, in the new loop init:

    ...
    meta_get_first_subsurface_node (MetaWaylandSurface *surface)
    ...

    n = g_node_first_child (surface->subsurface_branch_node);
    if (!G_NODE_IS_LEAF (n))
    ...

The above implementation performs a `G_NODE_IS_LEAF` call, which
performs a dereference on `n`, without first checking for NULLs.

This NULL dereference triggers the following gnome-shell crash:

    Core was generated by `/usr/bin/gnome-shell'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  meta_get_first_subsurface_node (surface=0x55d589623450) at ../src/wayland/meta-wayland-surface.h:399
    #1  pointer_can_grab_surface (pointer=0x7f6dc4012700, surface=0x55d589623450) at ../src/wayland/meta-wayland-pointer.c:1306
    #2  0x00007f6ddb94d509 in meta_wayland_pointer_can_grab_surface (pointer=<optimized out>, surface=surface@entry=0x55d589623450, serial=serial@entry=996) at ../src/wayland/meta-wayland-pointer.c:1321
    #3  0x00007f6ddb950d05 in meta_wayland_seat_get_grab_info (seat=seat@entry=0x55d586c24f20, surface=0x55d589623450, serial=996, require_pressed=require_pressed@entry=0, x=x@entry=0x0, y=y@entry=0x0)
        at ../src/wayland/meta-wayland-seat.c:467

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2655>
2022-10-17 12:38:21 +00:00
Jonas Ådahl
a331d4e45a window: Type check some wm functions
These might get called from JS, so avoid crashing on bogus calls.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5952
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2661>
2022-10-17 11:41:55 +00:00
Robert Mader
4079afe0c7 surface-actor-wayland: Fix assumption in get_current_primary_view
Unlike the multi-view path, the optimized/single-view one doesn't check
if the surface-actor is really present on the view. That is the case
whenever it's hidden - e.g. when the window is minimized.

Fixes 3b7137cb35

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2662>
2022-10-15 21:45:10 +02:00
Daniel van Vugt
100c02e514 drm-buffer: Clarify misleading error message on drmModeAddFB2 failure
The real error is more likely to do with the drmModeAddFB2 failure than
the format not being compatible with drmModeAddFB.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2379
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2656>
2022-10-13 16:06:57 +08:00
Jonas Ådahl
21cddbae95 tests/wayland-fullscreen: Also test toggling fullscreen
This tests that unfullscreen makes the black background disappear, and
that fullscreening again makes it re-appear.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
19df8888fb tests/wayland-fullscreen: Check surface size
In the test in question, it should be smaller than the window geometry,
since the black background makes the window geomerty larger than the
surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Sebastian Wick
6db67c3f21 tests: Add ref-test for Wayland fullscreen client
The ref-test makes sure the actual content is centered and everything
not covered by the actual content is black.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
bb19fe2bd4 tests: Add Wayland fullscreen test client
Fullscreen Wayland toplevel surfaces don't need to respect the
configured size in which case the window content get centered on a black
background which covers the whole monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Sebastian Wick
909616b208 window-actor/wayland: Draw black background for fullscreen windows
Fullscreen Wayland toplevel surfaces don't need to respect the
configured size in which case it should be shown centered on the monitor
with a black background. The black background becomes part of the window
geometry.

The surface container is responsible for correctly culling the surfaces
and making sure the surface actors are removed from the actor tree to
avoid destroying them.

The window actor culling implementation assumes all surfaces to be direct
children of said actor. The introduction of the surface_container actor
broke that assumption. This implements the culling interface in
MetaWindowActorWayland which is aware of the actor surface_container and
fullscreen state.

v2: Fix forwarding culling to surface even if there is a background.
v2: Don't alter passed geometry.
v2: Update window geometry code documentation to reflect these changes.
v2: Only use constrained rect if we're acked fullscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Sebastian Wick
0034b54877 window-actor: Move culling logic into child classes
Prepare for adding Wayland specific culling logic to the
MetaWindowActorWayland class by moving all the logic to the non-abstract
classes, since there will be no reason to keep the logic in
MetaWindowActor around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
8832a5a1c2 window/wayland: Keep track of last acked configuration
This is helpful to know what current state a window actually have, in
contrast to the state in MetaWindow (e.g. MetaWindow::fullscreen) which
is the intended state, be it current or not yet so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
6cbc518089 window/wayland: Update buffer and frame rect in the same place
First make sure we call 'move_resize()' in all cases where the size or
position can change, then move the updating of the buffer rect to the
same place as we update the frame rect. This means keeping track of
surface size changes, in addition to geometry changes, and calling
finish_move_resize() whenever any of those changes, in addition to
acknowledged configurations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
5be8c50746 window-actor: Rename confusing variable name
A "window rect" in most places refers to the rectangle the window
corresponds to when it comes to window management. MetaWindow::rect also
refers to this window management related rectangle. However in the
geometry sync functions, it instead called what was to be the rectangle
the actor should have as "window rect", which is arguably a bit
confusing. Fix this by renaming it "actor_rect" so that it becomes clear
that it's the rectangle the actor should get on the stage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Sebastian Wick
c6b4b33570 window-actor: Make meta_window_actor_get_image fastpath reachable
MetaWindowActor previously peeked at the number of child Actors to
determine the number of surfaces. The following commit rearranged the
tree such that MetaWindowActorWayland always has two Actors. This change
lets the subclass determine if the main surface describes the whole
window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
47c8063b30 window/wayland: Calculate position also for acked fullscreen configs
An acked fullscreen window also need to have its position updated in
response to a configure ack, so that it's moved to the right position
(e.g. correct monitor).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
2a62e690a2 window/wayland: Use scale for configured rect in configuration
When a window configuration is constructed for a Wayland surface it
contains a position, size and a scale. The scale is the geometry scale
for the configuration, i.e. before the size is sent the passed dimension
is divided with the passed scale.

When moving between monitors with different scales, if we use the
existing geometry scale, this means we will send a configure event with
incorrect dimensions. Fix this by calculating the scale used in the
configuration given the rect we're configuring with as this will mean
the correct size will be sent to the client.

v2: Removed the fullscreen condition. Don't know why it was added to
begin with.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
f4645b0a37 window: Make the caller decide when to constrain
There were some magic conditions that decided when
meta_window_constrain() was to be called or not. Reasoning about and
changing these conditions were complicated, and in practice the caller
knows when constraining should be done. Lets change things by adding a
'constrain' flag to the move-resize flags that makes this clearer. This
way we can, if needed, have better control of when a window is
constrained or not without leaking that logic into the generic
to-constrain-or-not expression.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>
2022-10-10 18:16:51 +00:00
Jonas Ådahl
2c8adb1966 output/kms: Don't attemp to add common modes on connectors without modes
We have no way to sanely add safe modes if there are no modes we can
compare with, thus don't try.

Fixes the following crash:

 #0 are_all_modes_equally_sized at ../src/backends/native/meta-output-kms.c:284
 #1 maybe_add_fallback_modes at ../src/backends/native/meta-output-kms.c:310
 #2 init_output_modes at ../src/backends/native/meta-output-kms.c:347
 #3 meta_output_kms_new at ../src/backends/native/meta-output-kms.c:414
 #4 init_outputs at ../src/backends/native/meta-gpu-kms.c:332
 #5 meta_gpu_kms_read_current at ../src/backends/native/meta-gpu-kms.c:368
 #6 meta_gpu_kms_new at ../src/backends/native/meta-gpu-kms.c:403
 #7 create_gpu_from_udev_device at ../src/backends/native/meta-backend-native.c:461
 #8 init_gpus at ../src/backends/native/meta-backend-native.c:551
 #9 meta_backend_native_initable_init at ../src/backends/native/meta-backend-native.c:632

Fixes: 877cc3eb7d44e2886395151f763ec09bea350444
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2127801
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2646>
2022-09-29 14:29:43 +00:00
Sebastian Wick
88504b96d0 tests/color: Test EDIDs with bogus data
Make sure the profile creation fails without crashing and that the
device still becomes ready when we fail to create a profile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2627>
2022-09-29 13:41:17 +00:00
Sebastian Wick
19837796fe color-device: Clear pending flags always when finished
Even if the task was cancelled or an error occured.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2627>
2022-09-29 13:41:17 +00:00
Sebastian Wick
a8259240ae color-device: Don't create profiles from obvious garbage data
This just checks for any chromaticity being zero and gamma being in
range but we could do a better job at detecting bad data in the future.

Also check the return value of cmsCreateRGBProfileTHR which can be NULL.

Fixes gnome-shell#5875

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2627>
2022-09-29 13:41:17 +00:00
Sebastian Wick
2476a8cedd color-device: Return early if the deivce becomes ready due to an error
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2627>
2022-09-29 13:41:17 +00:00
Sebastian Wick
ed554615f8 color-device: Always become ready no matter if we succeeded or not
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2627>
2022-09-29 13:41:17 +00:00
Carlos Garnacho
1023592f8a wayland: Cancel active pointer gestures with wl_pointer.leave
There may be an active pointer gesture at the time of a focus change, in
which case we should cancel it. Add the plumbing so that happens, by
looking at the active MetaWaylandPointerClient gesture.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5199
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2640>
2022-09-29 12:36:43 +00:00
Carlos Garnacho
57074463ab wayland: Add pointer gesture cancellation internal API
This is ATM unused, but will be used to trigger cancellation of
any active gesture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2640>
2022-09-29 12:36:43 +00:00
Carlos Garnacho
bbf57d092c wayland: Keep track of active pointer gestures
Only one of them may be active at a time, so track the type
of active gesture so it can get properly cancelled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2640>
2022-09-29 12:36:43 +00:00
Carlos Garnacho
b85f85d665 wayland: Refactor pointer gesture .end emission event
We will want to trigger this from multiple places for cancellation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2640>
2022-09-29 12:36:43 +00:00
Michel Dänzer
efc4fa333c backend/native: Sending modifiers to clients can be disabled via udev
Using the new udev tag "mutter-device-disable-client-modifiers".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2637>
2022-09-22 08:32:02 +00:00
Michel Dänzer
0b7de744a0 wayland/dma-buf: Use meta_renderer_native_send_modifiers
Do not send modifiers if meta_renderer_native_send_modifiers says not to
(and we use scanout).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2637>
2022-09-22 08:32:02 +00:00
Michel Dänzer
00ffe0b454 kms/device: Add flag to disable sending DRM modifiers to clients
So far the new flag can only be set via the new environment variable
MUTTER_DEBUG_SEND_KMS_MODIFIERS, and doesn't have any effect yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2637>
2022-09-22 08:32:02 +00:00
Jonas Ådahl
6601c3b02a tests: Add partial-overlapping scanout test
Make sure that if we wiggle a scan-out capable surface a bit, it won't
scan out if it's not exactly in the right position. Do this by first
making the window not fullscreen, then moving it back and forth,
verifying the correct scanout state for each presented frame.

This test addition reproduces the issue described in
https://gitlab.gnome.org/GNOME/mutter/-/issues/2387.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2624>
2022-09-20 18:47:06 +00:00
Jonas Ådahl
85ef0d1a46 compositor-view/native: Check that the actor covers the the view
If we have a window that match the size (i.e. will pass the "fits
framebuffer" low level check), that doesn't mean it matches the
position. For example, if we have two monitors 2K monitors, with two 2K
sized windows, one on monitor A, and one on monitor both monitor A and
B, overlapping both, if the latter window is above the former, it'll end
up bing scanned out on both if it ends up fitting all the other
requirements.

Fix this by checking that the paint box matches the stage view layout,
as that makes sure the actor we're painting isn't just partially on the
right view.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2387
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2624>
2022-09-20 18:47:06 +00:00
Jonas Ådahl
41f488a65c tests/wayland-unit: Move out sync point wait helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2624>
2022-09-20 18:47:06 +00:00
Sebastian Wick
73695995a7 stage: Paint the untransformed swap region
Painting the swap region with CLUTTER_DEBUG_PAINT_DAMAGE_REGION happens
on the view framebuffer, so don't transform the region we paint to the
onscreen.

Fixes the swap region painting on rotated monitors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2590>
2022-09-20 17:49:10 +00:00
Sebastian Wick
c89bae8594 tests/stacking: Alt+Tab focus+stacking test for globally active input
Gnome-shell uses meta_display_focus_default_window() when shell elements
loose focus which is the case with Alt+Tab window switching. Globally
active input clients don't immediately gain focus though so if
meta_display_focus_default_window focuses a wrong window stacking and
focus don't behave as expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
7ac982d0d2 tests/stacking: Test always-on-top stacking and focus
Adds the command make_above to set and unset always-on-top behavior of a
window and tests stacking and focus when activating other windows and
switching workspaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
ed7a9af62a tests/stacking: Add workspace management commands
New commands to set the number of workspaces, activate a workspace, with
and without focus, move windows to specific workspaces, and check the
stacking on a specific workspace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
b4b9a7c90f core: Move remaining default focus window handling to workspace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
3a96ef023b core: Focus on most recently focused window when switching workspaces
When switching workspaces we previously focused on whatever window is on
top of the stack. If a window is marked as "always on top" then it would
always receive focus when switching workspaces.

Fixes #2240
Fixes gnome-shell#5162
Fixes #178
Fixes #678

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
deae8aa7b1 core/window: Update workspace MRU list earlier
We want to use the workspace MRU list to decide the default focus but
Globally Active Input clients don't call
meta_window_set_focused_internal and therefore don't update the MRU
list. Move the update to meta_window_focus instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
f336911d8f default-plugin: Use stopped instead of completed signal
The completed signal is only emitted if the timeline actually completed
but when an actor is destroyed or removed from its parent the timeline
is stopped and not completed.

The workspace switch effect removes window actors from the window group
which destroys the timeline so on_$EFFECT_effect_stopped is never
called and the pointer to the timeline is dangling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
bc6af4f1c8 default-plugin: Kill workspace switch animation on shutdown
The workspace switch animation moves the WindowActors out of the
WindowGroup so if we shut down while the animation is playing the
WindowActors will have queued a destroy but will be disposed only after
the compositor is destroyed, leaving the WindowActor with a dangling
pointer.

Fix the issue by killing the workspace switch animation on shutdown.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2489>
2022-09-20 17:14:53 +00:00
Sebastian Wick
89b8edcc6f monitor: Keep the dbus night-light-supported property in sync
Fixes #2424

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2623>
2022-09-19 15:13:12 +00:00
Jonas Ådahl
6edb399b2b x11-display: Keep track ourself if we're restarting
We still set the global state, so that e.g. GNOME Shell can continue
consuming it, but it looks a bit awkward to rely on a global state
inside a single function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
fc8a4afc45 Remove meta_is_stage_views_enabled()
This is an old relic from when ClutterStageView was being added, and
tests were somewhat prepared to be able to test the "X11 style" of
things, with the nested backend some how managing to emulate that.

Lets drop that stuff, it isn't used by the test suite, and isn't useful
anyway; if we want to test X11 configurations, we should use the actual
X11 backend, which didn't make use of this anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
d517f3ae61 feedback-actor: Make the other properties static strings
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
a9740074ca util: Remove left-over declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
c1215f4213 window-actor/wayland: Add missing config.h
The lack of this resulted in some surprises in header file macro
processing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
bde4280f48 startup-notification/x11: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
dad384376a wayland/data-device: Clean up coding style a bit
There were a few very long lines, it partly didn't follow function
argument alignment and used glib types instead of stdint types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:01 +00:00
Jonas Ådahl
c676beea6c xwayland: Move "code like" declarations to the bottom
They'll be closer to the code but still after the "boring" declarations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:00 +00:00
Jonas Ådahl
81cc440f47 window/x11: Minor coding style cleanup
Break up a long somewhat unreadable line.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:00 +00:00
Jonas Ådahl
b9c3e2b01e x11-display: Fly-by coding style fix
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:00 +00:00
Jonas Ådahl
b8cdc91c19 x11-display: Clean up GdkDisplay opening
It exposed unnecessary public and private API, and used a global static
variable instead of a return value, none which was necessary. Remove
both API and use a return value for communicating to the caller.

This doesn't remove a public symbol, lets do that for GNOME 44.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:00 +00:00
Jonas Ådahl
af65a01057 barrier: Make type derivable again
This was used gala to implement hot corners, and the way the barrier API
works, there isn't really any practical reasons to not make it
derivable, since the backend is a separate type and object.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2626>
2022-09-15 12:27:52 +00:00
Jonas Ådahl
cc9d2065e1 Revert "barrier: Get rid of private instance struct"
This reverts commit 4095c2431c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2626>
2022-09-15 12:27:52 +00:00
Daniel van Vugt
a1873e0c4f core/events: Don't update the cursor renderer on motion under X11
Doing so was unnecessary and seemed to cause feedback to Xorg resulting
in heavy stuttering and random freezes.

We do however keep the call to `meta_cursor_tracker_invalidate_position`
so as to not undo the intention of 9bdf4b35.

Suggested by Carlos Garnacho.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5861 and
       https://launchpad.net/bugs/1989582

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2625>
2022-09-15 11:59:09 +00:00
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
Jonas Ådahl
10a2787a71 tests/runner: Remove support running tests as an X11 WM
This hasn't worked for a while, since the test always runs the nested
backend, meaning it's a Wayland compositor. To unblock testing window
management in combination to monitor changes, lets remove the
unreachable X11 WM paths, so that we can start using virtual monitors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-11 11:32:42 +00:00
Florian Müllner
811f280817 build: Add missing include
util-private.h includes glib-i18n-lib.h, which requires GETTEXT_PACKAGE
to be defined. The define comes from config.h,
but that cannot be included in headers, so we have to make sure
that any source file that pulls in util-private.h (or a header
that includes it) includes config.h first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2566>
2022-08-10 20:28:40 +02:00
Daniel van Vugt
2a725f0bd9 cursor-renderer-native: Don't retry forever after GBM cursor functions fail
This avoids flooding the log with every cursor change:
```
(gnome-shell:19923): libmutter-WARNING **: 10:15:23.404: Realizing HW cursor failed: Failed to allocate gbm_bo: Invalid argument

(gnome-shell:19923): libmutter-WARNING **: 10:15:23.450: Realizing HW cursor failed: Failed to allocate gbm_bo: Invalid argument

(gnome-shell:19923): libmutter-WARNING **: 10:15:23.451: Realizing HW cursor failed: Failed to allocate gbm_bo: Invalid argument
```

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2354
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2520>
2022-08-10 15:35:55 +00:00
Daniel van Vugt
c430731436 output-xrandr: Less line wrapping
To silence CI warnings from check-code-style.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2511>
2022-08-10 14:41:46 +00:00
Daniel van Vugt
9d7cebd8e6 monitor-manager: Remove struct member indentation
To silence CI warnings from check-code-style.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2511>
2022-08-10 14:41:46 +00:00
Daniel van Vugt
5476feeaf2 monitor-config-store: Parentheses for correct indentation
To silence check-code-style complaints in CI, but also for consistency
(other cases already have parentheses).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2511>
2022-08-10 14:41:46 +00:00
Daniel van Vugt
3d044c351e monitor-config-store: Remove whitespace to silence check-code-style warning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2511>
2022-08-10 14:41:46 +00:00
Daniel van Vugt
8019714b5d texture-mipmap: Fix some leaks and tidy up
Seems we were leaking mipmap->mipmap_texture and mipmap->fb.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2562>
2022-08-10 11:52:39 +00:00
Corentin Noël
5356bc865f main: Add meta-context to the header
The meta_restart function now requires it.

Fixes f772b4cde6

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2559>
2022-08-10 10:47:51 +00:00
Michel Dänzer
23526a99c7 x11-display: Unset GDK_BACKEND environment variable
mutter needs GDK to use the x11 backend. It already calls
gdk_set_allowed_backends ("x11") for this purpose; however, if
GDK_BACKEND=wayland (or any other non-x11 backend possibly) happened to
be in the environment, GDK would fail to initialize at all. This would
result in mutter not registering as X11 window manager, and all X11
clients hanging.

Big thanks to Olivier Fourdan for figuring this out!

v2:
* Restore original value of GDK_BACKEND environment variable after
  initializing GDK.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2022283
Bug: https://bugs.debian.org/1008992
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2496>
2022-08-10 08:34:48 +00:00
Jonas Ådahl
30daad4da5 cogl/pipeline/vertend/glsl: Move out unit test to its own file
Fix a memory leak while at it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
2c72032668 tests/cogl/unit: Run most tests with all drivers
All tests but one (so far) will in one way or the other depend on what
driver is used, so run the tests on all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
07f8edde22 cogl/pipeline/opengl: Move out unit test to separate file
Also rename the suffix to "-glsl" to not confuse OpenGL with GLES2
since this test covers both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
16a7f77701 cogl/pipeline-state: Move out working unit test to separate file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
ae0f6c549f cogl/pipeline-state: Move out failing test to its own file
This test is a known failure, so mark it as such. It's stored in its own
file since keeping it in the same as the passing test isn't markable
using meson.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
57382b6aff test/cogl/unit: Allow marking known failures
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
4905a55f64 cogl/pipeline-cache: Move unit test to its own file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
d0861c8ae2 cogl: Move out bitmask unit test to separate file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
9a9e7e471c tests/cogl: Add unit test framework
It consists of only a macro and build description logic.

Adds a macro for simpler tests that doesn't require a context; unit
tests requiring a context should use the same framework as conform
tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
4ebaa433ee cogl: Remove now empty conform test suite
All working tests have already migrated to the test suite using mutter;
move the old unported tests over too, and remove the conform test
framework, as it is no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:13 +00:00
Jonas Ådahl
5d40a5eeea tests/cogl: Migrate fence test
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:12 +00:00
Jonas Ådahl
2b43ff5963 tests/cogl: Migrate texture rg test
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:12 +00:00
Jonas Ådahl
e7f535a21d tests/cogl: Migrate pipeline shader state test
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:12 +00:00
Jonas Ådahl
94744061de tests/cogl: Migrate texture no allocate test
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:12 +00:00
Jonas Ådahl
d066fb5380 tests/cogl: Migrate pipeline cache unrefs texture test
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:12 +00:00
Jonas Ådahl
68dcde0bdb tests/cogl: Migrate copy/replace texture test
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2555>
2022-08-08 21:59:12 +00:00