1
0
Fork 0
Commit graph

9536 commits

Author SHA1 Message Date
Jonas Ådahl
ce5a5789bb native: Release output device files that are unused
In order to make it possible to e.g. unload an unused DRM device, we
need to make sure that we don't keep the file descriptor open if we
don't need it; otherwise we block anyone from unloading the
corresponding module.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:10:30 +02:00
Jonas Ådahl
3c47661b78 egl: Add eglBindAPI helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
173d895d53 kms: Remove now unused API to get file descriptor
The last user switched to using MetaDeviceFile, so time to clean up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
10c4bc6e3f drm-buffer: Create from MetaDeviceFile instead of MetaKmsDevice
The DRM buffers aren't really tied to mode setting, so they shouldn't
need to have an associated mode setting device. Now that we have a
device file level object that can fill this role, port over
MetaDrmBuffer and friends away from MetaKmsDevice to MetaDeviceFile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
6613463f58 renderer/native: Decouple device file from MetaKmsDevice
Keep a private MetaDeviceFile instance for the GPU's managed by the
renderer. This is a step towards decoupling rendering from mode setting,
as well as on-demand holding of device file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
e567cb972d renderer/native: Get 'uses-monotonic' state from MetaKmsDevice
It's better suited to be handled by the MetaKmsDevice abstraction.

This eliminates the last caller of drmGetCaps() from outside
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
86c4369f41 renderer/native: Look up prefers-shadow cap via MetaKmsDevice
This eliminates the second last user of drmGetCap() from outside of
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
93f9c99cc5 kms/impl-device: Set universal plane client cap when opening file
This means it will be set again if the file is reopened.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
5502f956f5 device-file: Add tags
Tags are meant to make it possible for a device file opener to tag a
file if it has affected the state the file descriptor is in; e.g. if it
has enabled a DRM capability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
ceff2a93ca renderer/native: Create dummy offscreens if onscreens fail to allocate
This is less dramatic than aborting, and could in theory be a temporary
issue, so handle it by rendering into an offscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
db1d35c53d kms/mode: Recreate blob id each mode set
This simplifies the blob management and isn't that less efficient that
it matters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3c9ab768ec launcher: Remove now unused file management API
The open/close helpers for (maybe) restricted files has been replaced
with MetaDevicePool, so lets remove that functionality from here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
7ce266628e seat-impl: Open/close files via device pool
This replaces going through MetaLauncher to open/close restricted files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f6f9c093ba clutter/seat: Remove backend pointer
It was unused, and having a pointer to the MetaBackend in subtypes is
more useful, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
b4cf839e87 device-pool: Add way to open files read-only
Will be used by libinput's tablet device led device files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
a845a07a92 device-pool: Handle interrupted open()
Handle open() failing due to being interrupted by trying again until it
either succeeds, or fails due to some other error. This was an error
handling path taken when opening sysfs files; do the same here to not
potentially regress once we open sysfs files with the device pool.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3d882b6410 device-pool: Only fetch major/minor for taken devices
It's only when we take/release from/to logind we need these two
integers, so only retrieve them when that's done. Making this change
makes it possible to open devices that don't have these parameters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
e6421dc5da kms: Have the device impl open device files themself
This changes the way the KMS backends load; if we're headless, we always
use the dummy one and fail otherwise; in other cases, we first try the
atomic backend, and if that fails, fall back on the simple one.

The aim for this is to have the impl device open and close the device
when needed, using the device pool directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f3457b678c kms/device: Use device pool to open/close dri devices
This replaces the usage of MetaLauncher.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
ee8c252a8c native: Add device pool for tracking device file descriptors
This practically does the same thing as part of MetaLauncher, except
with added thread safety and caching. For example, opening the same file
a second time will return the same MetaDeviceFile, and only once all
acquired MetaDeviceFile's are released, will the file descriptor be
closed and control of the device released.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Carlos Garnacho
44af2c0d37 core: Be more careful around n_modes signedness
This is returned as an integer, which we deal with as an unsigned
integer. Deal with it as an integer all along, and skip safely
negative values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1920>
2021-07-07 18:37:54 +02:00
Carlos Garnacho
841ee0a227 backends/native: Fix logic error
ClutterInputDevice's get_group_n_modes() vfunc is meant to return
-1 for groups that are out of the known range, not within. Fix the
early return condition, and let the native backend return correctly
the number of modes for the given group.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1920>
2021-07-07 18:37:54 +02:00
Jonas Ådahl
8ca087fee9 kms/impl-device/simple: Pass the NULL to discard_page_flip() on shut-down
The second argument is an optional GError, not an impl device pointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1911>
2021-07-07 14:51:46 +00:00
Christian Rauch
258b85a5a7 tests: Add test for setting min/max wayland toplevel limits
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1716
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1795>
2021-07-06 09:11:10 +00:00
Jonas Ådahl
8c5b7ddc48 tests/wayland-test-driver: Add generic "sync point" request
This can be used by test cases to make sure the compositor tries
something after a known client state.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1716
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1795>
2021-07-06 09:11:10 +00:00
Jonas Ådahl
151c80d2ef tests: Move Wayland test driver helper protocol to its own file
While at it, make it a GObject so one can add signals to it.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1716
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1795>
2021-07-06 09:11:10 +00:00
Christian Rauch
aacdc0b6f1 wayland: Apply states without needing a newly attached buffer
Applying some states, such as the minimum and maximum toplevel size, do not
require a new buffer and can operate on the old buffer. Requiring a client
to commit a new buffer just to change such states prevents setting limits
on an already existing surface buffer.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1716
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1795>
2021-07-06 09:11:10 +00:00
Zander Brown
b3fb1ebaac meta: Drop meta_backend_set_numlock from header
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1916>
2021-07-05 23:01:13 +01:00
Michel Dänzer
8de0771aad screen-cast/area-src: Add before-paint watch to catch scanouts
Scanouts are taken away after painting. However, when we're
streaming, what we actually want is to capture whatever is
going to end up on screen - and that includes the scanout
if there's any.

Add a before-paint watch that only records new frames if a
scanout is set.

Inspired by (and commit log mostly copied from) e6a13e5d57
("monitor-stream-src: Add before-paint watch to catch scanouts").

v2:
* Do not call stage_painted from before_stage_painted (Georges Basile
  Stavracas Neto)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1707
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1902>
2021-07-05 15:57:20 +00:00
Michel Dänzer
7bcbf6d5c7 screen-cast/area-src: Drop phase parameter from add_view_painted_watches
It was always META_STAGE_WATCH_AFTER_ACTOR_PAINT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1902>
2021-07-05 15:57:20 +00:00
Jonas Ådahl
9542c713ad window/wayland: Replace constraint side effect peeking with state checks
When the MetaWindow resize machinery for toplevels ended up in the
Wayland window implementation, we tried to avoid configuring
not-yet-mapped windows that just had its zero sized dimension pass
through the constraint machinery, resulting in a 1x1 sized window.

If we'd properly set up the min size metadata earlier, that 1x1 would
likely be the minimum size set of a window, which makes things harder to
predict when peeking at side effects.

However, what the side effect peeking intends to do, as documented in
the comment, was to figure out when the client hadn't committed any
buffer yet, i.e. during the initial map, and in those cases avoid
sending that nasty 1x1 size, resulting in silly window sizes. A more
robust way to detect this is instead checking when we shouldn't really
try resize things our own way, and in those cases early out as was done
before.

This means that, for a yet to me mapped window, we only ever want to
send an initial non-zero configuration when 1) it's initially maximized,
2) initially fullscreen, or 3) initially tiled in any way, as those are
the situations where the compositor is the one deciding the size.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1912>
2021-07-05 10:27:58 +00:00
Jonas Ådahl
80caf12461 tests/stacking: Add test for initially fixed size windows
E.g. map a window maximized or fullscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1912>
2021-07-05 10:27:58 +00:00
Jonas Ådahl
1d7920872d kms: Gracefully handle page flipping direct scanouts failing
When drmModePageFlip() or drmModeAtomicCommit() unexpectedly failed (e.g.
ENOSPC, which has been seen in the wild), this failure was not handled
very gracefully. The page flip listener for the scanout was left in the
MetaKmsUpdate, meaning when the primary plane composition was later page
flipped, two page flip listeners were added, one for the primary plane,
and one for the scanout. This caused the 'page-flipped' event to be
handled twice, the second time being fatal.

Handle this by making 'no-discard' listener flag be somewhat reversed,
and say 'drop-on-error', and then drop all 'drop-on-error' listeners
when a MetaKmsUpdate failed to be processed.

Also for a "preserve" flagged update, don't ever trigger "discard"
callbacks just yet, as preserved updates are used again for the primary
plane composition, in order to not miss e.g. CRTC gamma updates, or
cursor plane updates, which were added separately.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1809
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1910>
2021-07-02 13:29:54 +00:00
Christoph Trassl
4b0fd9ab76 input-mapper: Fix (libwacom) tablet mapping to monitor
Remove early return when using libwacom, so guess_candidates returns
monitor candidates for those devices, too.

Additionally, changing the output of an input requires removing the
input from its current output first.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1712
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1887>
2021-07-01 06:36:33 +02:00
JoseExposito
dc919998b1 wayland/pointer-gestures: Fix swipe cancellation
The cancel phase for swipe gestures was not being handled, hence,
Wayland "end" events where not sent to clients when the gesture was
cancelled.

A swipe gesture is cancelled when extra finger(s) are put down on the
touchpad in the middle of the gesture or when some, but not all, of the
fingers are put up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1857>
2021-06-15 22:22:30 +00:00
Jonas Ådahl
a0343b0abd renderer/native: Clear pending update list before repopulating
Before we did a simple copy, meaning the old list was overriden. Copy
was too eager, as it meant views without modes to set was waited for,
resulting in a dead lock. Instead only the relevant views were added to
the list for view which had pending updates needed. What was missed was
that the list was never cleared, meaning we just appended the new list
on top of the old, causing issues.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1846
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1843
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1844
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1895>
2021-06-12 21:09:55 +02:00
Jonas Ådahl
c0758c63b5 native: Properly ignore devices on init too
There is an udev rule marking whether a device should be ignored by
mutter or not, but it was only respected on hotplug events not on init,
partly defeating its purpose. Fix this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1892>
2021-06-09 19:21:44 +00:00
Carlos Garnacho
fcdda41def wayland: Make implicit grabs during popups be owner_events=TRUE
Getting crossing events is necessary between client surfaces while
there is a popup grab in effect (e.g. allow press-drag-release in
menus), we should only stick with the focus surface while the pointer
is outside any client surface.

This partially undoes commit 79050004b0 (or, at least, mutter no
longer fixes the bug it claimed to fix). This will be addressed in
gtk4.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1885>
2021-06-09 19:00:15 +00:00
Jonas Ådahl
8478db96f9 renderer-native: Don't attempt to queue mode sets on non-onscreen views
A view is only a 'CoglOnscreen' if it ends up on a CRTC, thus needs a
mode. Other views are for virtual monitors, and require no mode setting,
so exclude them from the pending mode set list.

This avoids a dead lock when we'll be waiting indefinitely for mode
setting on a virtual monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>
2021-06-09 17:40:34 +00:00
Jonas Ådahl
2a81c6d393 screen-cast: Clean up sessions on 'prepare-shutdown'
However, leave the remote desktop screen cast sessions to the remote
desktop manager to close.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>
2021-06-09 17:40:34 +00:00
Daniel van Vugt
ea626a5059 main: Avoid calling meta_wayland_compositor_get_default() on X11
Because it contains an assertion that will fail, and crash.
Started in 301d2c55c6.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1883>
2021-06-02 16:45:04 +08:00
Marco Trevisan (Treviño)
14c8f5f94c mutter-all.test: Run tests in a environment with display and bus set
The mutter tests require to run in a valid environment where a display
is available and a session bus, however currently we rely on the current
environment, and this may lead to unexpected behaviors.

So let's just ensure that a display is running through xvfb-run and
that a session bus is running in a temporary directory.

We also ensure to use the gsettings memory backend, even because by
setting TestEnvironment we ensure that no other env variable is leaked
to the test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1876>
2021-05-26 21:23:29 +02:00
Jonas Ådahl
e15b4b8fbe test-runner: Disconnect display-opened signal on destruction
When running multiple tests at once (with --all) as in the
installed-tests cases, we may open and close the display multiple times,
this leads to setting the alarm filter each time that the x11 display is
opened (causing a critical error) because we never disconnect from the
::x11-display-opened signal.

So disconnect from the signal on test destruction, to avoid this to be
emitted multiple times.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1876>
2021-05-26 20:32:39 +02:00
Carlos Garnacho
4ed05830e2 wayland: Close pipe file descriptors after use
Both ends were being leaked here, one directly, other through the
GIOChannel.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4302
(just maybe)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1870>
2021-05-25 16:31:07 +00:00
Jonas Ådahl
301d2c55c6 wayland: Make init and shutdown symmetric
We first initialized the Wayland infrastructure, then the display, but
on shutdown, we first teared down the Wayland infrastructure, then the
display.

Make things a bit more symmetric and tear down the display before
Wayland. This however means we need to tear down some things Wayland a
bit earlier than the rest. For now this is a separate function, but
eventually, it can be replaced with a signal shared by the backend's
'prepare-shutdown' signal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
dc97163bcd xwayland: Pass MetaWaylandCompositor pointer when initializing
This way we can initialize without having any way to retrieve it via
some global variable. This isn't needed now, but will be once Wayland
infrastructure initializiation is done in a single step.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
d03c194552 wayland/output: Use the passed compositor pointer
This is especially important as we might end up here when initializing
the Wayland infrastructure. Later that will be done in one step, meaning
the "get_default()" function will not work properly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
5bc8823701 xwayland: Don't fetch global when shutting down DND
It might not be there when shutting down, so get it from a more managed
place. Note that this isn't strictly needed right now, but eventually,
the MetaWaylandCompositor pointer will be cleared using a g_clear*()
helper, which clears the pointer before freeing the instance, which
wouldn't work here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
b578a534a3 clutter: Remove Wayland server helper
It's a wrapper around a similar Cogl API we don't use anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
14eba8bb8f wayland: Bind Wayland EGL display ourselves
This will allow us less awkward startup, where previously we had to
pre-initialize Wayland very early so Cogl could bind the Wayland display
when it initialized. Move things around so we bind the Wayland EGL
display when initializing the rest of Wayland infrastructure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
5c77b640d4 egl: Add helper for eglBindWaylandDisplayWL
Lets us untangle awkward Cogl setup dependencies.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
ebfeb106bc egl: Fly-by indentation fix
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
dcf953ad3b idle-monitor: Use G_DECLARE_FINAL_TYPE()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1859>
2021-05-18 13:19:36 +00:00
Jonas Ådahl
18d670e69f backends: Introduce MetaIdleManager
This object takes over the functionality of meta-idle-monitor-dbus.c,
meta-idle-monitor.c and meta-backend.c, all related to higher level
management of idle watches etc.

The idle D-Bus API is changed to be initialized by the backend instead
of MetaDisplay, as it's more of a backend functionality than what
MetaDisplay usually deals with.

It also takes over the work of implementing "core" idle monitors. The
singleton API is replaced with thin wrapper functions on the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1859>
2021-05-18 13:19:36 +00:00
Jonas Ådahl
389432de46 backend/x11-cm: Add missing chain-up to finalize()
Reported by @muktupavels.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1869>
2021-05-17 19:22:25 +02:00
Jonas Ådahl
243dd868b6 main: Move grab op macro to relevant file
It was in main-private.h for some reason, but only used in display.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
b0a73f04b7 main: Move rect related macro to util-private.h
No reason that it should be in main-private.h, lets place it in
util-private.h. This also mean we can remove main-private.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
c6329807c2 x11/session: Remove #if 0:ed out declaration
Not used, no idea what it was for, but it serves no purpose, so lets
remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
3bb6865912 stage/x11: Fix clutter backend variable naming
Being in backends/, `backend` tends to refer to a `MetaBackend`, so
avoid that naming convention for things that are not, e.g. clutter
backends.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
475296ee9a tests/clutter: Don't have tests take arguments
It just complicates things; we can't run them right now, so just get rid
of the runtime variability; just change the macros if you want to tweak
the test, would you be able to get it running.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
af501ac472 prefs: Make init function private
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
7b390b4c5b display: Don't have the display meta_quit() when closing
Instead only do that e.g. when we're being replaced; elsewhere let the
one intending to actually quit, do the quitting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
6558d43cd5 main: Let the X11 CM backend deal with selecting the display
It's specific to that backend, so do it there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
89053cc6f7 display: Make meta_display_open() report errors
Instead of just exit():ing, report the error, so the caller can decide
how to deal with the error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
c9992a2953 main: Initialize Wayland just before MetaDisplay
Wayland support is not really a "backend" thing, it just lacked a better
place to store its instance pointer. Eventually we'll have a better
place, but prepare for that by initializing it together with the more
similar subsystems.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
270f1cf7a5 tests/runner: Check compositor type instead of X11 policy
It's practically equivalent, and means we can soon ditch the global.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
6c1793b7d3 Rename MetaDisplayPolicy to MetaX11DisplayPolicy
This lack of X11 in the name was a bit confusing, since this is about
the X11 policy, not some policy of MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
f677e0cbfb display: Make the display handle its own prefs handlers
Two prefs were handled by display.c itself, and another in main.c.
Unscattter things a bit by moving the one in main.c to the others in
display.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
9cd99ee7ac main: Move away debug flag management to util.c
The rest of debug flag details are in util.c and util.h, make things
less scattered by moving the rest to util.c too.

While at it, put the coredump:ability setting needed for being suid
there too, so we have a common place for initializing "debug utils".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
62ef293cdb main: Let session management code deal with DESKTOP_AUTOSTART_ID
No need to have that outside of meta_session_init().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Pascal Nowack
25e2839339 screencast: Fix transform_position(), when using fractional scaling
Commit 64c9c9c5b0 fixed monitor
screencasting, when fractional screencasting is enabled.
For the remote desktop usage, NotifyPointerMotionAbsolute() submits
the new mouse pointer position in addition to the stream, where the
mouse pointer was moved.
When not using fractional scaling, the mouse pointer position is
correct.
With the usage of fractional scaling, the mouse pointer position is
wrong, as the scale of the position is applied two times.

Fix this behaviour, by reverting the second scale by dividing by the
logical monitor scale, when fractional scaling is used.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1808
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1867>
2021-05-17 16:11:47 +02:00
Jonas Ådahl
4a057535e7 remote-desktop: Close sessions on prepare-shutdown
When finalizing, the MetaDisplay instance will already be gone, so to be
able to gracefully tear down the clipboard integration, make sure to
close sessions before the display is closed, i.e. on prepare-shutdown.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1853>
2021-05-11 16:18:13 +00:00
Olivier Fourdan
b03ccfff4d xwayland: Check the condition on displayfd ready
The callback on_displayfd_ready() would unconditionally set the return
value to TRUE, regardless of the condition.

Use the GIO condition to determine if there was data written and adjust
the return value accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1851>
2021-05-11 15:49:25 +00:00
Sebastian Keller
e423653017 xprops: Validate text properties that claim to be UTF8
Some clients such as mpv might set the WM_TITLE as a UTF8_STRING based
on some unconverted/unvalidated metadata that is not actually UTF8. This
would then be set as the title of a MetaWindow (in the absence of a
valid UTF8 _NET_WM_TITLE). The shell then tries to use this window title
for things like the overview or the window switcher where it would
trigger an UTF8 validation error and leave the shell in an unusable
state.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1794
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1850>
2021-05-11 15:20:17 +00:00
kirbykevinson
64c9c9c5b0 clutter: Make stage capture support fractional scaling
This commit adds scaling support to clutter_stage_capture_into, which
is currently used when screencasting monitors. This is supposed to
fix graphical issues that arise when using fractional scaling.

Fixes #1131

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1855>
2021-05-08 22:27:52 +07:00
Jonas Ådahl
a49dc78396 remote-desktop-session: Don't recreate virtual device over and over
In 'remote-desktop-session: Create virtual input devices on demand' the
intention was to create input devices on-demand, but during a
refactorization of the code, instead the virtual input device was
recreated over and over. Lets fix that.

Fixes: a0af52caf0
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1799
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1858>
2021-05-07 13:16:27 +00:00
Jonas Ådahl
4490d4524b xwayland: Handle shutting down without having started
We initialize, but might not start, e.g. when a test case just needs a
backend and doesn't start mutter. When cleaning up, we'll still try to
clean up Xwayland integration, and this commit handles cleaning up
without having made the mess.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1856>
2021-05-06 17:55:32 +02:00
Jonas Ådahl
1a43312b96 wayland: Tear down seat too when shutting down
The functionality was mostly there, but not hooked up to anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
9827687ca1 wayland/seat: Unset resource user data when disabling
We make objects inert when disabling the seat, but we requests may still
have effect. This is especially bad if disabling is followed by
destroying, but also means e.g. set_cursor() not doing an early out
after the pointer capability was disabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
8303752e32 wayland/keyboard: Don't free NULL anonymous file
Use g_clear_pointer() instead, as meta_anonymous_file_free() rightfully
doesn't like being passed NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
c614cc3e82 wayland: Terminate Xwayland when shutting down
This is less confusing to Xwayland than suddenly loosing the Wayland
socket connection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
799c6dcf2f main: Tear down Wayland support before MetaDisplay
MetaDisplay does a lot of things, and is a central part to anything
window management. To let Wayland units have an easier time tearing
down, make it so that the Wayland infrastructure is terminated before
MetaDisplay.

This also makes sure that X11 support is turned off, so that we don't
stumble upon Xwayland terminating due to the Wayland socket connection
being broken. Will mitigate that in a better way in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
b71f52ff32 xwayland: Set libX11 error handlers to no-ops before terminating
We might not be the only entity holding on to the X11 GdkDisplay,
meaning the X11 connection will stay alive indefinitely, e.g. if the gjs
context has some reference to it.

Avoid running into issues due to X11 connection errors by setting the
libX11 handlers to no-ops, so when we are terminating; that means the
GDK X11 connection can stay "alive" until its too late, and we'll just
silently ignore any connection errors that may happen due to the
lingering GDK display reference.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
c4a73e7950 backend: Cleanup renderer on shutdown
This removes left-over views, and related resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
abf2f17387 renderer: Cleanup views in dispose
The views needs to be cleaned up before things cleaned up on finalize
that they depend on existing, so do so in dispose().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
558cb4fac3 backend: Cleanup cursor tracker on shutdown
It keeps references to cursors, and cursors keep references to DRM
buffers. In order to be able to clean up on exit, explicitly destroy the
cursor tracker on shutdown.

We can't rely on GObject reference counting, as gjs might hold onto a
reference until it's garbage collected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
f1a120ca36 backend: Clean up GPU instances last
Various things, e.g, the renderer, the stage, either directly or
indirectly depends on GPU objects being alive during tear-down. Make it
so, by moving GPU cleanup after the other cleaning. This will allow
tearing down a couple of more objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
0a12f1c9c6 wayland: Clean up Wayland clients and display on shutdown
This will clean up Wayland related objects, e.g. surfaces and buffers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
22417b8a94 backend/native: Split up KMS shutdown in two phases
The first phase happens early, which discards pending page flips,
meaning the references held by those page flip closures are released.

The second phase happens late, after other units depending on the KMS
abstraction, have been cleaned up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
1af874fca6 kms/impl-device/atomic: Discard pending page flip datas on finalize
This is so page flip listeners can clean up any references attached to a
page flip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
7c924a562f kms/impl-simple: Clean up pending page flip datas on finalize
They might be holding on to references, so lets keep track of them and
clean up on finalize.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
2ed4e8c906 kms-impl/simple: Discard pending flips when finalizing
Removing the reference isn't enough, the callbacks needs to be invoked
so the buffer state machinery gets notified about the page flips being
discarded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4dec1f5ddf kms/impl-simple: Add helper for dispatching page flip datas
Instead of a invoke helper, and a clear helper, use a single dispatch
helper that does both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
c29f8c8b73 onscreen/native: Complete buffer swap also if we discarded
We already swapped the front buffer, and even if it didn't get
presented, we should still swap our representation of the state, to not
get into a confused buffer tracking state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4cb6033a27 onscreen/native: Simplyify notify_view_crtc_presented()
We don't really need to fetch the rendering mode, as we'd only ever call
a function that is effectively a no-op if render modes it isn't relevant
to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
b731eb29b5 kms: Remove idle flush callback when flushing
We might flush in other places than the idle callback; in this case, we
don't need the idle callback anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
023dd13d6c onscreen/native: Get backend pointer from GPU
If we clean things up during destruction, the singleton pointer to the
backend is already gone; get it from a better place instead, to not
crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
d077baadbb renderer/native: Destory EGL context on GPU data tear down
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Carlos Garnacho
63d969537f backends: Drop MetaInputSettings::seat property
This is now entirely unused, and it's dubious it should ever
be again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1849>
2021-05-05 19:07:26 +00:00
Carlos Garnacho
7ba1448e5b clutter: Move pointer a11y settings management from MetaInputSettings
All pointer a11y is a fabrication of Clutter backend-independent
code, with the help of a ClutterVirtualInputDevice and with some
UI on top.

On the other hand, MetaInputSettings is a backend implementation
detail, this has 2 gotchas:
- In the native backend, the MetaInputSettings (and pointer a11y
  with it) are initialized early, before the ClutterSeat core
  pointer is set up.
- Doing this from the MetaInputSettings also means another dubious
  access from the input thread into main thread territory.

Move the pointer a11y into ClutterSettings, making this effectively
backend-independent business, invariably done from the main thread
and ensured to happen after seat initialization.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1765
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1849>
2021-05-05 19:07:26 +00:00
Florian Müllner
d4a042b88d native: Fix compiler warning
cogl_context is only used when building with EGLDevice support,
resulting in an "unused variable" warning otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1852>
2021-05-05 10:32:28 +02:00
Robert Mader
96f2da9fb0 wayland/data-device: Clear existing data device resource from list
Compositor behaviour when calling `wl_data_device_manager_get_data_device`
for the same seat multiple times is not very clearly defined in
the spec and both Mutter and Weston currently don't handle
the DnD case properly.

While Weston handles DnD only for the last created data device,
Mutter, because of some internal reshuffling, ends up toggling
between two devices.

Properly handling this case requires some bigger changes. So
in order to behave predictable and in line with Weston,
only take the last created data device into account while
still keeping the previous created ones around.

The main affect client here is Firefox, which gets very
confused by the toggling behaviour and becomes more stable
with this patch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1841>
2021-04-30 22:38:39 +02:00
Jonas Ådahl
8989c42d40 backend/native: Add udev rule to ignore vkms devices
Virtual Kernel Mode Setting (vkms) is a virtual /dev/dri/card* device
not backed by any actual hardware. It's intended for testing purposes,
e.g. to run tests suites with a reproducable setup, or in continuous
integration pipelines.

Currently mutter don't have any tests that can run on top of vkms, but
will eventually get that. To prepare for the ability to do that, and
having said kernel module loaded without causing wierd issues with any
active session, add an udev rule that tells mutter to ignore any vkms
device.

Otherwise, when vkms is loaded, mutter would detect it, assume it's a
regular monitor, configure it as such, thus add a region of the stage
that ends up nowhere, which isn't very helpful. It might also conflict
with running actual tests that need to interact with vkms if the active
session has taken control of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
4af0f05603 udev: Move device tag detection into helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
eaf75f0706 udev: Don't only check 'platform' device for KMS modifier tag
Only checking the 'platform' device missed the tags added for i915 and
others, meaning the multi head configurations yet again started to fail
due to default modifier behavior is incompatible with multi many head
configurations.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1769
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1774
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1843>
2021-04-29 18:48:24 +00:00
Jonas Ådahl
c5e4d7db45 native: Invalidate CRTC gamma when resuming or leaving power save
With atomic mode setting, commits don't work when CRTCs aren't enabled,
which they aren't when we're power saving. This means the gamma state
fails to being update. To fix night light and for whatever other reason
gamma ramps was changed during power saving by marking the CRTC gamma
state as invalid when leaving power saving, as well as when resuming.
This means that the next frame will append the CRTC gamma state to the
KMS commit.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1755
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1835>
2021-04-29 18:04:04 +00:00
Jonas Ådahl
a0af52caf0 remote-desktop-session: Create virtual input devices on demand
This avoids triggering heuristics based on available input device types;
e.g. hiding the cursor when connecting a touchscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1800>
2021-04-29 17:24:08 +00:00
Jonas Ådahl
efd9af1183 output/kms: Add back common modes on non-single mode outputs
But this time, filter out modes that exceed a roughly calculated maximum
bandwidth. This should avoid e.g. setting a 60 Hz 4K mode, when 4K is
limited to 30 Hz, but lower resolutions supporting 60 Hz.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4155
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1834>
2021-04-27 16:12:18 +00:00
Carlos Garnacho
b4a7f35146 backends/native: Unref/unset key repeat GSource when cleared
This GSource is not being properly unref nor the variable holding it
cleared. This on one hand leaks the GSource memory, on the other hand
may trigger warnings in keyboard_repeat() as the source may be
(reentrantly) cleared, yet we don't exit early as
seat_impl->repeat_source is never NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1839>
2021-04-27 08:37:38 +00:00
Robert Mader
7d3e2c5f9c shaped-texture: Fix damage propagation for rotated transforms with viewport
When a viewport source rect or destination size is set, `stex->dst_width`
gives us the the cropped and/or scaled size. At this step, we need the
uncropped/unscaled size however.

Note: this is only ever relevant if buffer transform and viewport are
used together - otherwise the values are the same.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1836>
2021-04-21 20:29:14 +02:00
Jonas Dreßler
99abb086fb window-actor-x11: Invalidate paint volume when shadow changes
The shadow size is factored into the paint volume MetaWindowActorX11
returns in its get_paint_volume() vfunc override, so we should
invalidate the paint volume every time that shadow might change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1829>
2021-04-19 17:56:08 +00:00
Robert Mader
2ded9c4bf2 shaped-texture: Apply viewport and rotation in right order
When using buffer transforms and viewports together, we currently
apply the transformation (read: rotation) first, resulting in
wrong buffer coordinates for viewport source rects.

Flip the order in whitch we apply our matrix transformations.

This can be tested e.g. via:
`weston-simple-damage --use-viewport --transform=flipped-180`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1832>
2021-04-19 15:03:05 +02:00
Robert Mader
6e00e5e6e7 wayland/subsurface: Avoid placement ops for detached subsurfaces
If a subsurface first gets reordered and afterwards detached from
the parent before the parent surface got commited, we currently
would end up reattaching the subsurface to its previous parent.

While clients should avoid this behaviour, it's legit according
to the spec.

We already prevent similar cases where the subsurface is destroyed -
extend that check to detaching, which includes the destroy case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1831>
2021-04-19 11:55:49 +00:00
Robert Mader
f7768874e5 window-actor/wayland: Cleaner subsurface reordering
Currently when reordering subsurfaces, we un- and reparent all child
actors of the window actor. This is unnecessarily wasteful and
triggers bugs in clutter. While the underlying issue should be fixed
eventually, simply reorder the actors with the tools clutter provides
us with, avoiding those bugs and likely being faster as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1831>
2021-04-19 11:55:49 +00:00
Aaron Plattner
cf8efb5827 x11: Skip sending redundant CTM change requests
The X server generates a property change notification whenever it processes a
property change request, even if the value of the property is not changing. This
triggers libgdk to probe all display outputs, which can be slow depending on
which display driver and hardware are in use.

 #0  0x00007f8e4d5e91a0 in XRRUpdateConfiguration () at /usr/lib/libXrandr.so.2
 #1  0x00007f8e505208da in _gdk_x11_screen_size_changed (screen=0x5566e4b7e080, event=0x7ffe0e44bd60) at ../gdk/x11/gdkscreen-x11.c:1199
 #2  0x00007f8e505066d1 in gdk_x11_display_translate_event (translator=0x5566e4b5b110, display=0x5566e4b5b110, event=0x7f8dec001b20, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkdisplay-x11.c:1201
 #3  0x00007f8e505135a0 in _gdk_x11_event_translator_translate (translator=0x5566e4b5b110, display=0x5566e4b5b110, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkeventtranslator.c:51
 #4  0x00007f8e50512c97 in gdk_event_source_translate_event (event_source=0x5566e4b764a0, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkeventsource.c:243
 #5  0x00007f8e50512f57 in _gdk_x11_display_queue_events (display=0x5566e4b5b110) at ../gdk/x11/gdkeventsource.c:341
 #6  0x00007f8e50497644 in gdk_display_get_event (display=0x5566e4b5b110) at ../gdk/gdkdisplay.c:442
 #7  0x00007f8e5051301f in gdk_event_source_dispatch (source=0x5566e4b764a0, callback=0x0, user_data=0x0) at ../gdk/x11/gdkeventsource.c:363
 #8  0x00007f8e516ecf9c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
 #9  0x00007f8e51740a49 in  () at /usr/lib/libglib-2.0.so.0
 #10 0x00007f8e516ec503 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
 #11 0x00007f8e508ef5fd in meta_run_main_loop () at ../src/core/main.c:928
 #12 0x00007f8e508ef60e in meta_run () at ../src/core/main.c:943
 #13 0x00005566e450842a in  ()
 #14 0x00007f8e50649b25 in __libc_start_main () at /usr/lib/libc.so.6

When GNOME is animating a display fade when the night light feature is toggled
on or off, it sends a lot of change requests for the CTM property in the
process, which triggers a lot of display probes from gdk. In the case of the
night light feature, the CTM itself is not actually changing, so these requests
are redundant. Fix this by caching the CTM value in the MetaOutputXrandr and
skipping the server requests if it's not being changed.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3978
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1816>
2021-04-14 18:03:35 -07:00
Aaron Plattner
aa498dc27a x11: Rename atom to ctm_atom
This makes it clearer exactly what atom this is referring to.

Feedback from https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1816#note_1081588

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1816>
2021-04-14 18:02:00 -07:00
Jonas Ådahl
90eab42867 input-settings/native: Check mapping mode in input thread
When we set the matrix, we checked the device mapping mode in the main
thread, then passed along the calculated matrix to the input thread for
application. This could however be racy, as the mapping mode is managed
in the input thread. Fix this by sending the unaltered matrix, having
the input thread checking the mapping mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1806>
2021-04-14 19:16:22 +00:00
Jonas Ådahl
efde781747 input-settings: Make set_matrix() vfunc take const float array pointer
It shouldn't alter it, or take ownership, so clarify that by making it
constant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1806>
2021-04-14 19:16:22 +00:00
Jonas Ådahl
e956078052 kms/connector: Properly predict connectors turning off
The connector state wasn't properly predicted, as it earlied out if
the connector wasn't part of a mode set connector list.

Instead use the old CRTC to check whether it was used in any mode set,
and whether the connector was part of any new mode set, to predict
whether the connector is inactive or active.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1821>
2021-04-14 18:44:57 +00:00
Jonas Ådahl
4b78c8d84f renderer/native: Fix disabling monitors on otherwise unchanged device
When a device only had mode sets which turned off monitors, not enabling
anything, there would be no KMS update created and posted, and the
active monitors would remain on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1821>
2021-04-14 18:44:57 +00:00
Jonas Ådahl
14f6869381 onscreen/native: Make sure to reset the EGL context after dGPU blit
On hybrid graphics system, the primary path used to transfer the stage
framebuffer onto the dedicated GPU's video memory preparing for scanout,
is using the dedicated GPU to glBlitFramebuffer() the content from the
iGPU texture onto the scanout buffer.

After we have done this, we reset the current EGL context back to the
one managed by cogl. What we failed to do, however, was to reset the
current EGL context when we inhibited the actual page flip due to having
entered power save mode.

When we later started to paint again, Cogl thought the current EGL
context was still the correct one, but in fact it was the one used for
the iGPU -> dGPU blit, causing various EGL surface errors, and as a side
effect, eventually hitting an assert.

Fix this by making sure we reset to the Cogl managed EGL context also
for this case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
60a998bdbc onscreen/native: Release buffer before destroying EGLSurface
Destroying the EGLSurface frees the underlying container structs. When
we call gbm_surface_release_buffer() with a gbm_surface the EGLSurface
was created from, doing that after the EGLSurface was destroyed results
in attempts to access freed memory. Fix this by releasing any buffer
first, followed by destroying the EGLSurface, and lastly, the
gbm_surface.

This was not a problem prior to CoglOnscreen turning into a GObject, as
in that case, the dispose-chain was not setup correctly, and the
EGLSurface destruction was done in the native backend implementation.

This also changes a g_return_if_fail() to a g_warn_if_fail(), as if we
hit the unexpected case, we still need to call up to the parent dispose
vfunc to not cause critical issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Jonas Ådahl
abbbe8f755 onscreen/native: Remove redundant EGLSurface cleanup
It's handled by CoglOnscreenEgl's dispose() implementation. It was
failed to be invoked in the past because the old non-GObject web of
vtables were not setup correctly, meaning the old generic EGL layer of
the CoglOnscreen de-init was never invoked.

When the type inheritence was cleaned up, this mistake was not cleaned
up, so do that now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>
2021-04-14 17:42:32 +00:00
Olivier Fourdan
a2a161eb1e window/x11: Keep buffer size if resize is not allowed
Mutter would deny the application the right to resize itself during an
interactive resize, to avoid the user and the client to fight for the
size.

When the client is not allowed to resize, it would use the client rect
rather than the buffer rect.

As a result, the client window with client side decorations would
quickly shrink to its minimum size.

Use the buffer rect instead, so that the size really remains the same.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1674

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1777>
2021-04-14 16:51:21 +00:00
Olivier Fourdan
cc928ba7d2 window/x11: Allow window resize while moving
Commit f2328f11 would ignore any ConfigureRequest from X11 clients while
there is an interactive user operation in progress.

Yet, the user should be allowed to move a window while the X11 client is
resizing it, as the two operations are not intrinsically incompatible.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1674

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1777>
2021-04-14 16:51:21 +00:00
Jonas Ådahl
91117bb052 monitor-manager: Don't include generated code in header file
Meson doesn't seem to handle depending on generated headers, at least
when those headers are pulled in indirectly via another header file.

Luckily, we don't actually need to include the generated D-Bus boiler
plate in meta-monitor-manager-private.h, since the MetaMonitorManager
type no longer is based on the D-Bus service skeleton.

So, by moving the inclusion of the generated D-Bus header file into
meta-monitor-manager.c, we should hopefully get rid of the sporadic
build issues.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1682
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1819>
2021-04-14 16:22:24 +00:00
Jonas Ådahl
4c7a846dc8 output/kms: Only add common modes for single mode connectors
If there was only a single mode, add the common modes to provide options
to select other resolutions than the built in default. This avoids
issues where the connector listed multiple supported modes, but where
the common modes added would exceed the possible bandwidth. We could
probably make an attempt to filter out more modes from the common mode
list to avoid these issues, but it's likely that the driver already
lists suitable modes, meaning there is no point in adding the common
modes.

The common modes were initially added[0] to add modes to connectors with
a single bundled mode, so we shouldn't regress the original bug fix.

[0] https://bugzilla.gnome.org/show_bug.cgi?id=744544

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1232
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1824>
2021-04-14 15:15:52 +00:00
Jonas Ådahl
1f3c5bd316 kms/impl-device-atomic: Remove useless warning
No much use having a "g_return_if_fail (expr);" when we "if (expr)
return;" just above.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
dc35514fb4 renderer: Switch open coded list clearing to g_clear_list()
The same for MetaRendererNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
1a7f4d49f3 renderer/native: Remove unused function parameter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
a40b040cd6 seat-native: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
c822c799e4 kms/impl-device: Fix some argument naming mistakes
It was left-overs from when the MetaKmsImpl was not per device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
8867b11e19 launcher: Use gnome.gdbusgen and add prefix to generated API
This is more in line with how generated D-Bus boilerplate work, lets
stay consistent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1820>
2021-04-14 12:53:25 +00:00
Jonas Ådahl
da3baba980 backend/native: Only disable KMS modifiers for i915
The intel DRM driver is known for not being able to handle multi head
setups when KMS modifiers are enabled, due to the implicitly selected
modifiers, while being more suitable for single head setups, cause
bandwidth issues when a certain number of monitor times resolution and
refresh rate is configured.

We don't yet support automatically finding a combination of modifiers
that work, and have because of this disabled KMS modifiers unless the
driver actually needs it.

Lets flip this configuration the other way around, changing the current
udev rule to decide wen to *disable* KMS modifier support, as it so that
only the Intel driver has this problem, while on the other hand, there
several drivers that requires modifiers to function at all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1792>
2021-04-14 07:14:24 +00:00
Aleksandr Mezin
90e3d9782d Revert "wayland/window: Correct detection whether to send configure"
It breaks more than it fixes.

After commit [1] Shell doesn't trigger the original issue [2] anymore.

[1]: ba0b9239d3
[2]: https://gitlab.gnome.org/GNOME/mutter/-/issues/1627

This reverts commit 236e9ec68f.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1804>
2021-04-14 06:36:09 +00:00
Carlos Garnacho
f92232ae4f backends/native: Check whether views are scaled via MetaViewportInfo
The input thread is in deep water doing the meta_is_*() check itself,
as that pokes the MetaMonitorManager managed by the main thread. Use
the getter from the MetaViewportInfo instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1793>
2021-04-13 10:32:14 +00:00
Carlos Garnacho
24dbfbfcf2 backends: Store whether views are scaled in MetaViewportInfo
We need to pass this info from the main thread, as that pokes the
MetaMonitorManager underneath. Store it in the MetaViewportInfo
so that the input thread can use this information.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1793>
2021-04-13 10:32:14 +00:00
Robert Mader
a09c914230 wayland/actor-surface: Call ensure_size_valid() on shaped-texture
Use the new API to make sure the shaped texture has a valid size
during the next layout phase.

This is needed here because, quoting the previous commit:

When the texture size is invalidated using `invalidate_size()`, the new
size will only get calculated the next time `update_size()` is
called. This happens e.g. in `meta_shaped_texture_get_preferred_size()`
via `ensure_size_valid()`.

`update_size()` can chain up to `clutter_content_invalidate_size()`
as well as emitting a `size-changed` signal. If this happens during
layout, the result is a 'change the layout conditions during layout'
issue, causing heavy breakage in e.g. the Shell overview.

To fix this, expose `ensure_size_valid()` as API so callers can make
sure the texture has a valid size without creating redundant size
invalidations calls.

Note that if a buffer with a new size is attached we already trigger
`update_size()` explicitely, avoiding such situations.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1718

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1799>
2021-03-29 15:47:25 +00:00
Robert Mader
5772c27e04 shaped-texture: Expose ensure_size_valid() API
When the texture size is invalidated using `invalidate_size()`, the new
size will only get calculated the next time `update_size()` is
called. This happens e.g. in `meta_shaped_texture_get_preferred_size()`
via `ensure_size_valid()`.

`update_size()` can chain up to `clutter_content_invalidate_size()`
as well as emitting a `size-changed` signal. If this happens during
layout, the result is a 'change the layout conditions during layout'
issue, causing heavy breakage in e.g. the Shell overview.

To fix this, expose `ensure_size_valid()` as API so callers can make
sure the texture has a valid size without creating redundant size
invalidations calls.

Note that if a buffer with a new size is attached we already trigger
`update_size()` explicitely, avoiding such situations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1799>
2021-03-29 15:47:25 +00:00
Robert Mader
50ba52b1b5 shaped-texture: Use G_APPROX_VALUE to compare viewport source rects
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1799>
2021-03-29 15:47:25 +00:00
Robert Mader
1bfd932f15 region-utils: Fix typo in crop_and_scale() fastpath
Fixes 09b1bbb1cf

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1786>
2021-03-29 15:17:48 +00:00
Robert Mader
52547cb9ea shaped-texture: Viewport update calculation fixes
If only a viewport destination size is set, the noop viewport has
to take the buffer scale into account.

If a viewport source but no viewport destination size is set, the
destination size is that of the viewport source, not of the whole
texture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1786>
2021-03-29 15:17:48 +00:00
Carlos Garnacho
1d82e0f236 core: Drop X11 error trap from pointer warping code
This code is backend-agnostic, and should not do anything special
about X11. Drop these error traps, and let the backend deal with
the possible errors.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1725
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1807>
2021-03-29 13:54:06 +02:00
Carlos Garnacho
1b1f852086 backends/x11: Add traps around XIPointerWarp call
This is left up to higher level code, which is not too nice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1807>
2021-03-29 13:52:31 +02:00
Carlos Garnacho
4bee25d8e6 wayland: Cancel selection data sources that are set while unfocused
If a client is naive enough to assume that it can set the selection while
it has got no surfaces, mutter will simply ignore the request and leave
the selection unchanged.

This is good and the expected behavior, however the poor client that did
this will enter in an inconsistent state where it "claimed" the selection,
but nobody told it that the wl_data_source is not current.

So, when the client is focused the next time, it will receive wl_data_offers
as usual, but it will still think all the time that it is owning the
selection. In the case of GTK, that takes client-side shortcuts, so any
attempted paste will still bring back the client-side aborted selection.

To fix this, cancel the selection right away if it happened while unfocused,
the client will be able to undo its own failed selection, and not assume
that future offers are its own.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1469
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1772>
2021-03-23 17:07:31 +00:00
Daniel van Vugt
3555f65b75 wayland-dma-buf: Add support for DRM_FORMAT_ABGR2101010
It seems to be the preferred format of the Mesa V3D driver on
Raspberry Pi 4. If the compositor doesn't advertise it then Mesa will
fallback from `zwp_linux_dmabuf_v1` to `wl_drm`, incorrectly. Meaning
it will keep using a buffer with modifiers on an interface that does
not have modifiers.

Add support for `DRM_FORMAT_ABGR2101010`. It works, and prevents Mesa
from taking its broken fallback path.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1520
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1798>
2021-03-23 16:40:40 +00:00
Carlos Garnacho
dc9481973d core: Drop "volatile" from static GTypes in manual registration
As documented in g_once_init_enter(): "While @location has a volatile qualifier,
this is a historical artifact and the pointer passed to it should not be
volatile.". And effectively this now warns with modern glibc.

Drop the "volatile" qualifier from these static variables as it's expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1785>
2021-03-22 10:47:51 +00:00
Olivier Fourdan
1f1bf4cd9d xwayland: Check permissions on /tmp/.X11-unix
For Xwayland, mutter creates the sockets in the standard /tmp/.X11-unix
directory.

Yet, if that directory already exists, it may have been created by
another user with full control over the created socket.

To avoid that issue, if the directory /tmp/.X11-unix already exists,
check that the permissions are as we expect, i.e. the directory belongs
to either root or the user herself, is writable and has the sticky bit.

Thanks to fabian@ritter-vogt.de for reporting that issue.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1708

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1787>
2021-03-18 17:43:02 +01:00
Olivier Fourdan
7b5e855032 xwayland: Use defines for X11 directory and path
Rather than repeating the same strings for X11 directory and path all
around the code, use a define.

No functional change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1787>
2021-03-18 17:43:02 +01:00
Robert Mader
2ef6490323 wayland/surface: Do not free placement ops of cached state
The list gets freed in `meta_wayland_surface_state_clear()`
if the pointer is still set.

Fixes ba8499f9ec

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1783>
2021-03-15 12:49:45 +00:00