1
0
Fork 0
Commit graph

10565 commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
ca0e467a3b tests/interactive: Drop test-cogl-image-convert
This test exercises a form of image conversion that isn't exposed in
the new CoglTexture2D APIs, which is about to be removed. Drop this
test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:25:11 -03:00
Georges Basile Stavracas Neto
da8353dbcd tests/interactive: Replace most CoglHandles by CoglTextures
There are 2 remaining CoglHandles, but they're for shaders, which
actually return CoglHandle as part of the API signature.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:25:11 -03:00
Georges Basile Stavracas Neto
9f3191fe9c tests/interactive: Drop empty test_coglbox_finalize
All of them were devoid of code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:25:11 -03:00
Georges Basile Stavracas Neto
dbae8d7aa7 tests/interactive: Make TestCoglbox final
This cleans up a lot of boilerplate code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:25:11 -03:00
Georges Basile Stavracas Neto
83e0553534 tests/interactive: Cleanup tabs
I also sneaked in some code style fixes on the lines that were
touched. Judge me freely, it's all for the greater good.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
2022-05-31 16:25:11 -03:00
Jonas Ådahl
f772b4cde6 restart: Make API that needs context take a context
This allows avoiding looking up old singletons.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2446>
2022-05-31 16:42:46 +00:00
Jonas Ådahl
81860229ba restart: Don't pass error as unused user data
We passed the pointer to a GError * as user data on an async I/O call.
The callback function didn't make use of it, so it was never written to,
thus remained NULL, thus was dead code. Remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2446>
2022-05-31 16:42:46 +00:00
Jonas Ådahl
83ed7b7dfd xwayland: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
e939d5b89a tests: Check that X11 selections handle Xwayland disappearing
It works by using an X11 client to set the clipboard content, using a
mimetype that on purpose is not handled by the clipboard manager. The
test then makes sure we don't crash when trying to transfer data from
the old X11 selection source.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
7e8bddccb5 tests/async-waiter: Keep track of X11 display it was created with
The Xwayland server can go away at any time; when this happen we might
have a test client running, and for it to tear down more nicely, make
sure to avoid trying to clean up X11 resources on the old X11 display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
82d9ef7a55 x11/input-selection-stream: Handle Xwayland going away
Xwayland can disappear at any time, for example during a new_async() or
read_async() call. When we eventually finalize the stream, the X11
display it was created for is gone, thus can't clean up the X11
resources. Handle this by making the MetaX11Display pointer a weak
pointer, and ignore cleaning up if it disappeared. This is fine since
the X11 server it created those resources one is gone already.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
6c0a917832 selection: Return an error if trying to transfer from NULL source
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
c9e7cf4ea1 xwayland: Add API to send signal to the Xwayland process
Will be used for test cases to fake-crash the Xwayland process.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
bdb34401c5 xwayland: Only warn on X IO errors when X11 is mandatory
This avoids warnings when we're just slightly unlucky when Xwayland went
away due to inactivity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:55 +00:00
Jonas Ådahl
e1033951ef wayland: Add getter for XWayland manager object
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:54 +00:00
Jonas Ådahl
c575696acc tests/test-client: Add clipboard-set command
To be used for clipboard testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:54 +00:00
Jonas Ådahl
9930b5d7ca x11/selection: Unset selection ownership on shutdown
This makes sure we don't accidentally try to paste from past Xwayland
connection instances.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2364>
2022-05-31 12:00:54 +00:00
Jonas Ådahl
a2ebd10f04 kms/crtc: Determine gamma support given the gamma length
The property doesn't necessarily exist when using drivers that doesn't
support atomic mode setting, and the way it worked will break night
light and other gamma related features. This makes things use the gamma
length; if it is higher than 0, it definitely supports it one way or the
other, i.e. GAMMA_LUT with the atomic backend, and drmModeCrtcSetGamma()
with the legacy/simple backend.

Fixes: 364572b95c
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2287
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2435>
2022-05-28 18:29:13 +00:00
Jonas Ådahl
9001fa9717 kms/crtc: Always read the gamma state
It doesn't depend on whether the CRTC is active or not, so always read
it. This is also useful to know whether a CRTC supports gamma, before it
is being turned on, without relying on the existance of properties.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2435>
2022-05-28 18:29:13 +00:00
Florian Müllner
d04a197723 x11/events: Do not handle enter/leave during grabs
The COMPOSITOR_GRAB event route has effectively been replaced by
ClutterGrabs, which are no longer covered by the existing check.

So check for grabs as well to restore the old behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
f73ad1d8d2 display: Remove META_EVENT_ROUTE_COMPOSITOR_GRAB
Nothing sets the value anymore since the port to ClutterGrab, and
we just removed the last code references.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
75856043d4 display: Bypass focus window during grabs
This is what the old COMPOSITOR_GRAB check effectively did (by
returning the grab_window, which is only set during window grab
operations).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
937651cf0e display: Remove another COMPOSITOR_GRAB check
The event-route is never set to COMPOSITOR_GRAB nowadays, so the
condition will never be met.

Furthermore, it is expected that ClutterGrabs only happen when
events are routed normally, so the remaining NORMAL check should
already fully cover the old COMPOSITOR_GRAB case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
022f47ebfe events: Remove obsolete COMPOSITOR_GRAB check
We already bypass wayland if there is a ClutterGrab, so the case
that used to be covered by the event-route check is already handled,
and we can just remove the obsolete check.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Florian Müllner
fabad0be9c wayland: Remove unnecessary COMPOSITOR_GRAB checks
Since the new ClutterGrab API replaced the old plugin-modal hook,
the event-route is never set to COMPOSITOR_GRAB.

The code in question already checks whether the stage has a grab,
so we can just remove old checks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2436>
2022-05-28 10:25:29 +00:00
Carlos Garnacho
50e89e3760 core: Avoid focusing window in presence of Clutter grabs
This is the same circumstance than the event_route not being NORMAL,
since events may or may not eventually reach the window. It should not
attempt to get focus out of the stage in that situation. This used
to be covered by META_EVENT_ROUTE_COMPOSITOR_GRAB, but this is no longer
set when ClutterGrab came in to replace it.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4858
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2433>
2022-05-28 09:04:48 +00:00
Jonas Ådahl
1e95710c52 x11-display: Init event mask after taking manager selection
Initializing the event mask, SubstructureRedirectMask in particular,
before taking the manager selection fails with BadAccess. Fix this by
initializing said mask after taking the manager selection.

This fixes `--replace`.

Fixes: eb4307c350
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2432>
2022-05-27 18:26:01 +02:00
Jonas Ådahl
a24b14e302 x11-display: Make some init calls more compact
Makes more of the function fit on the screen, without making readability
any subjectively worse.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2432>
2022-05-27 10:49:57 +02:00
Bilal Elmoussaoui
a81b2a49ed meson: Split x11 option into backend/xwayland
Allow disabling either the xwayland or backend implementation of x11.
Meson options were not added as this is more of a groundwork than the
actual implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2354>
2022-05-25 16:42:04 +02:00
Bilal Elmoussaoui
b27234cfef startup/x11: Fix compiling without startup-notification
If startup_notification is disabled, linking against sn would fail

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2425>
2022-05-25 10:38:25 +00:00
Sebastian Keller
bc9762eebb display: Properly store later ID when adding window to queue
The code is already trying to avoid creating new laters when there
already is one for the queue type, but this wasn't working because the
ID of the later was never stored after creating a new one. This would
then result in as many laters as meta_display_queue_window() was called
and all of them would run the handler function, even if only the first
one had a non-empty window queue.

Similarly this was causing the later to not be removed if the window
queue got empty after meta_display_unqueue_window().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Sebastian Keller
b289c8f01e window: Ensure window-visibility-updated is emitted when flushing queue
Currently the signal is getting emitted accidentally, because even when
removing a window from the queue, the later handler of that queue will
still get run due to a bug. This bug is going to get fixed in the next
commit, but some things might depend on the signal getting emitted when
the visibility of a window has changed.

This change affects the behavior in two ways. First the signal is now
emitted immediately rather than from an idle. And second it now
correctly includes the window in the should_show or should_hide list.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Sebastian Keller
2a3c964e64 display: Add method to flush a single window from the queues
This can be used when a state change needs to be applied immediately for
a specific window and will be used in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Sebastian Keller
f493a78641 display: Fix typo in trace message
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2414>
2022-05-25 09:50:07 +00:00
Fernando Monteiro
d4bdd8b56f wayland: Remove Gtk primary selection protocol
This has been replaced for primary selection protocol from
wayland-protocols.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2184>
2022-05-18 20:15:08 +00:00
Fernando Monteiro
11bc19fbe8 wayland: Drop xdg-shell v6 protocol
There is no need to have this protocol as we already
have support for the xdg-shell stable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2207>
2022-05-18 19:29:08 +00:00
Sebastian Keller
bb76d6fcc3 compositor: Update topmost window actor after visibility changes
The compositor currently only updates the topmost window actor that is
visible to it after stacking changes. The visibility of a window actor
to the compositor however might only change via the display idle queue
after the stacking changes. This could then lead to the topmost window
actor being assumed to be NULL on Wayland after switching from an empty
workspace or when opening the first window on an empty workspace. The
result of this is direct scanout being disabled in these cases.

To fix this also trigger the update when the visibility of windows
changes.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2269
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2413>
2022-05-17 13:42:07 +00:00
Sebastian Keller
0bc142ec1b compositor: Split out a function to update the topmost window actor
This allows this to be used from outside the restacking code in the
follow-up commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2413>
2022-05-17 13:42:07 +00:00
Sebastian Keller
54ba64b9f2 window-actor/wayland: Only use scanout for opaque non-fullscreen windows
This could for example happen with the client window created by the
desktop-icons-ng extension which spans the entire desktop, but is not a
fullscreen window and uses transparency

On Wayland only opaque surfaces or transparent surfaces of fullscreen
windows can be used for direct scanout.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2263
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2409>
2022-05-17 10:34:20 +00:00
Sebastian Keller
dc43bb9f68 window-actor/x11: Don't use direct scanout if the window is not opaque
Some windows span the entire screen but still use transparency, such as
the desktop window of Nemo. When these windows were used for direct
scanout, the transparent areas would turn black and nothing else would
be rendered.

In addition to checking the surface for opaqueness, for X11 windows also
the window actor itself has to be checked, because its opacity might
have been changed via _NET_WM_WINDOW_OPACITY.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2263
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2409>
2022-05-17 10:34:20 +00:00
Sebastian Keller
9c8948fc04 window-actor: Add API to get the surface actor candidate for scanout
This replaces the API to get the topmost surface actor with an API to
get the surface actor that could be a candidate for direct scanout. The
advantage of this is that it allows X11 and Wayland specific
restrictions for these actors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2409>
2022-05-17 10:34:20 +00:00
Jonas Ådahl
75ec27966d wayland/buffer: Only query Wayland EGL buffer if display bound
It's not allowed to call eglQueryWaylandBuffer() if the call to
eglBindWaylandDisplay() failed, and will result in an assert being hit
in mesa if called.

Avoid that by keeping track whether we succeeded to bind, and only
attempt to realize a legacy EGL wl_buffer if binding succeeded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2415>
2022-05-17 10:09:27 +00:00
Bilal Elmoussaoui
c861101ae6 backend: Check if the gsettings scheme exists
Mutter makes use of a gsettings scheme that comes from
gnome-settings-daemon to check for the screen orientation.
In use cases where gnome-settings-daemon is not available,
this would lead to a crash as the key doesn't exists

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2398>
2022-05-17 11:24:07 +02:00
Jonas Ådahl
8fdb80a718 monitor-manager: Add NightLightSupported property to DisplayConfig
This checks whether it's possible to set a CRTC GAMMA_LUT, which is what
is necessary to implement night light.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2310>
2022-05-17 08:42:25 +00:00
Jonas Ådahl
f64259ceae tests/wayland: Draw surface with shared helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
9b97c9b4d4 tests/wayland/xdg-toplevel-bounds: Port to WaylandDisplay
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
2c2aa7acc3 tests/wayland/xdg-activation: Port to WaylandDisplay
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
a7161e1132 tests/wayland/subsurface-reparenting: Port to WaylandDisplay
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
e32b9956fe tests/wayland/subsurface-remap-toplevel: Port to WaylandDisplay
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
1562bcc6fd tests/wayland/subsurface-parent-unmapped: Port to WaylandDisplay
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
08acf51423 tests/wayland-display: Emit sync event signal from test driver
This is for hooking up sync events from the compositor side test case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
d5367f7332 tests/wayland: Make display helper a GObject
This is in preparation for adding signals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
b0528dcd53 tests/wayland: Port xdg-shell action tests to WaylandDisplay
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
d58bd948a8 tests/wayland/subsurfaces: Use helper to manage display
Adds a _free() function since the display is reopened multiple times and
cleaned up in between.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Jonas Ådahl
a936219983 tests/xdg-apply-limits: Move out generic display management
This is meant to be used by other test clients, in order to reduce the
amount of code duplication that currently exists in the test cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
2022-05-17 08:03:29 +00:00
Marco Trevisan (Treviño)
c93e402a89 monitor-manager: Ensure monitors settings after backend has been updated
The monitors settings such as the privacy screen property is propagated
to the monitors via kms updates, however during initialization and
on monitors changes, we end up clearing the pending KMS updates because
such settings are added to the queue before the backend has fully
initialized the monitors, and this may lead to discarding all the
pending updates, including the one we've just planned.

To avoid this, move settings applications after we've both initialized
the backend and notified it about changes.

Also avoid to try set the settings during actual initialization, but
delay that after post-init.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2372>
2022-05-11 18:13:46 +00:00
Jonas Ådahl
8ec8a26717 display: Unmanage windows before compositor
Prior to 'compositor: Destroy actors when unmanaging', window actors
were destroyed when the compositor object was destroyed, long after the
windows were unmanaged, however, when this instead changed to happen
when unmanaging, with the original goal to avoid having these actors try
to interact with the disposed MetaCompositor instance, it caused an
issue where window actors would be indirectly destroyed as a side effect
of their parents being destroyed, which caused some fallout in the logic
handling window-close animation tracking, which relies on
meta_window_actor_queue_destroy() being called before a window actor is
actually destroyed.

Fix this by unmanaging windows before unmanaging the compositor.

From an X11 point of view, this should be harmless, since all it really
do is call XCompositeUnredirectSubwindows().

For the native backend and the common behavior, all unmanaging the
compositor instance does is destroy clutter actors, so doing so after
window actors were already cleaned up should not be a problem, as this
was the case before too.

Fixes: 35ac3a096d
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5330
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2403>
2022-05-11 15:37:23 +00:00
Dor Askayo
40edfbcbeb tests/screen-cast: Avoid undefined behavior with GSource
Follow the existing convention in Mutter and avoid downcasting
custom GSource structs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2406>
2022-05-11 15:01:31 +00:00
Dor Askayo
61c9e344e4 screen-cast/src: Avoid undefined behavior with GSource
Follow the existing convention in Mutter and avoid downcasting
custom GSource structs.

This fixes the following warning:
    ../src/backends/meta-screen-cast-stream-src.c:1301:20: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
     1301 |   g_clear_pointer ((GSource **) &priv->pipewire_source, g_source_destroy);
    /usr/include/glib-2.0/glib/glib-typeof.h:36:36: note: in definition of macro ‘glib_typeof’
       36 | #define glib_typeof(t) __typeof__ (t)
          |                                    ^
    ../src/backends/meta-screen-cast-stream-src.c:1301:3: note: in expansion of macro ‘g_clear_pointer’
     1301 |   g_clear_pointer ((GSource **) &priv->pipewire_source, g_source_destroy);
          |   ^~~~~~~~~~~~~~~

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2406>
2022-05-11 15:01:31 +00:00
Kazuki Hashimoto
38314fe5fd util: Fix compilation when !WITH_VERBOSE_MODE
Fixes the following linker error:

`meta_add_verbose_topic':
<artificial>:(.text+0x372f): undefined reference to `ensure_logfile'

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2405>
2022-05-07 11:53:41 +09:00
Bilal Elmoussaoui
97fc21adc1 core: Drop zenity show_dialog
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Bilal Elmoussaoui
4dee531b68 x11/sm: Drop the zenity confirmation dialog
Quoting Ray Strode:
we don't expose a way to explicitly save the session in gnome anymore
afaik, and I don't think it's going to show on log out because
I believe we use the FORCE flag from the log out dialog.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Bilal Elmoussaoui
749b9be98a core: Drop the default close dialog implementation
If the MetaPlugin doesn't implement it, we don't show anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Bilal Elmoussaoui
0e092ad6b3 default-plugin: Drop default confirm display dialog
Mostly to drop the 1/3 use cases of zenity on mutter and usually
shells built on top of Mutter should implement that vfunc

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
2022-05-06 16:13:45 +02:00
Sebastian Keller
c3210b0ab2 Revert "workspace: Use existing focus_window when asked to focus default window"
This reverts commit d0de671c1d.

The change introduced a regression when focusing java/swing windows.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5395
Reopens: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5162
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2402>
2022-05-04 23:29:39 +02:00
Jonas Ådahl
5404eb34f8 kms/impl/simple: Make sure cursor buffers have fb ids
'kms/impl-device/simple: Get the buffer handle from MetaDrmBuffer'
changed how fb ids are generated, but it only made it fully work with
atomic mode setting. For legacy/simple mode setting, it only handled the
primary plane buffer, not the hardware cursor.

Fix this by making sure the fb id is generated also in the legacy mode
setting case.

Fixes: ea39142da2
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2250
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2397>
2022-05-03 21:45:19 +00:00
Bilal Elmoussaoui
03929ca01f build: Fix building without Wayland
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2400>
2022-05-03 16:47:02 +02:00
Sebastian Keller
5e5480e620 x11/window: Update _NET_WM_DESKTOP when a window becomes all-workspace
When an X11 window becomes an all-workspace window its `workspace` is
set to NULL before `meta_window_x11_current_workspace_changed()` is
called. The latter then checks for `workspace` being NULL (which also
happens when unmanaging) and then returns early. So this does not update
`_NET_WM_DESKTOP` to 0xFFFFFFFF. Instead it remains at the workspace the
window was on before. This was causing programs like `wmctrl` to switch
to this old workspace when activating such a window.

Fix this by checking if the window is unmanaging instead.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2242
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2387>
2022-05-02 16:35:58 +00:00
Carlos Garnacho
f361e8032c wayland: Avoid repeated NULL preedit string updates
Simply signal preedit string changes from/to NULL once, in order
to avoid unwanted activity in the client side. We do still need to
send the preedit once each .done event, if there is one, in order
to behave according to the protocol when it matters the most.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2395>
2022-04-30 15:10:17 +00:00
Jonas Ådahl
b1be1e86e9 screen-cast: Always wait for an update before sending cursor-only frames
With the unthrottled input emission, we ended up often getting the
cursor updates long before any damage had been posted, meaning that if
you moved around the mouse pointer where the mouse had a high enough
refresh rate, we'd effectively stall the screen cast stream by only
sending cursor updates and nothing else.

Fix this by scheduling an update when we get a cursor update, then
sending a cursor-only frame after any damage and relayout has been
processed, but only if there is no queued damage that will cause an
actual repaint.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2393>
2022-04-29 20:51:25 +00:00
Jonas Ådahl
c5410b61d2 screen-cast/window/src: Fix signal handler types
Should be gulong, not unsigned long.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2393>
2022-04-29 20:51:25 +00:00
Robert Mader
aa8d2d6fff wayland/dma-buf: Remove redundant error check
`meta_egl_*` functions are assumed to set an error on failure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2386>
2022-04-29 20:27:56 +00:00
Robert Mader
c8095b4306 wayland/dma-buf: Only advertise supported formats
Analogous to how we use `eglQueryDmaBufModifiersEXT()` to query
supported modifiers, use `eglQueryDmaBufFormatsEXT()` to ensure
we only advertise formats supported by both the compositor and the
driver.

If there is no overlap, don't advertise `zwp_linux_dmabuf_v1` at
all.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2386>
2022-04-29 20:27:56 +00:00
Jonas Ådahl
2cfd4f325b cursor-renderer/native: Support allocating dumb buffers
This makes it possible to allocate HW cursor without a gbm_device, e.g.
when using EGLStream/EGLDevice.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1980
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2275>
2022-04-29 19:35:35 +00:00
Jonas Ådahl
42ed40ac52 cursor-renderer/native: Move buffer creation to helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2275>
2022-04-29 19:35:35 +00:00
Jonas Ådahl
ea39142da2 kms/impl-device/simple: Get the buffer handle from MetaDrmBuffer
This avoids buffer implementation specific code where it shouldn't
matter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2275>
2022-04-29 19:35:35 +00:00
Jonas Ådahl
22d11eb9cb drm-buffer: Keep track of handle as well
This handle is used by the legacy KMS API; lets avoid having to have GBM
specific code where this is done by letting the MetaDrmBuffer API, that
already has this information, expose it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2275>
2022-04-29 19:35:35 +00:00
Jonas Ådahl
d19700604b compositor/dnd: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Jonas Ådahl
b2eec49873 screen-cast: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Jonas Ådahl
5da8e5a9d5 barrier: Remove _ prefix in various places
It's not a convention used anywhere else anymore, lets remove the
prefixes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Jonas Ådahl
1a5647e00c barrier: Some coding style cleanup
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Jonas Ådahl
36de8baf55 display: Get the backend from the context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Jonas Ådahl
dd6afb28ff util: Avoid overriding 'message' in meta_topic()
We'd put the message in a variable called `message`. If something passed
to meta_topic() was called `message`, it'd end up being `NULL` in the
log entry. Avoid this by making the local message variable a bit more
"on topic".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Jonas Ådahl
70ab4b6519 build: Make each executable/library have their own log domain
This helps reading log output during, as it's otherwise often unclear
whether a log entry came from a test client or mutter itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2391>
2022-04-29 18:58:38 +00:00
Carlos Garnacho
cd0c47a25a clutter: Shuffle handling of IM reset on button presses
Unfortunately we cannot do this generically since the target of the
button/touch press does matter, e.g. tapping on the OSK, or clicking
the IBus candidates window. These situations should not trigger a
reset.

So be more selective about the situations where button/touch presses
trigger an IM reset, in the case of ClutterText these are still clicks
inside the actor, for Wayland's text-input it is when clicking the
surface that has text_input focus.

For all other situations where clicking anywhere else might make
sense to trigger an IM reset are covered by the focus changing paths,
that also ensure a reset before changing focus between surfaces/actors.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1961
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Carlos Garnacho
39ff8d15e2 wayland: Reset ClutterInputFocus on focus changes
Focus changes should trigger an IM reset, as some engines do want
to maybe commit the preedit string before changing focus. In addition,
we do not want the preedit string to be able to move between
windows/applications.

Ensure that the commit string is committed when the IM deems so, and
ensure we send a .done event disntinct to the .leave event, so that
the client doesn't miss the commit.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2030
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2384>
2022-04-23 15:04:30 +02:00
Jonas Ådahl
358df1c569 screen-cast/src: Always allow MemFd buffer types to be selected
Just because the PipeWire client can handle DMA buffers, doesnt mean we
should not advertise support for MemFd.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2383>
2022-04-22 12:08:04 +00:00
Jonas Ådahl
2b4a24132b screen-cast: Test allocate DMA buffer with implicit API
DMA buffers might be allocatable, but it doesn't mean the driver doesn't
fail when we try to allocate a buffer with an implicit modifier. Using
the proprietary NVIDIA driver for example, it will fail. Lets catch this
up front and avoid advertising DMA buffer support when we know it won't
work.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2383>
2022-04-22 12:08:04 +00:00
Carlos Garnacho
f5f49dfa46 wayland: Always acknowledge state changing .commit() events with .done()
As of currently, we only emit .done() on actual changes coming from the
ClutterInputMethod/ClutterInputFocus. With the recent changes in the
interpretation of serials, it becomes more important now that the
compositor acknowledges every .commit done by the client, in order to
keep them feeding future IM state updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2365>
2022-04-22 11:39:44 +00:00
Carlos Garnacho
be2a1d85a5 wayland: Always update preedit with text_input.done()
Compensate the protocol statelessness with our ClutterInputFocus
statefulness. This becomes more necessary now, since sending
consecutive .done() events is now considered acceptable behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2365>
2022-04-22 11:39:44 +00:00
Sebastian Wick
43ae37a93e backends/native: Update cursor also when scaled or transformed
MetaCursorRendererNative only updates the cursor state when the
underlying texture changes. The cursor scale and transform do not
trigger updates. This results in wrong cursor orientations on rotated
displays. Use both texture changes and scale and transformation changes
to figure out when to update the cursor state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2363>
2022-04-21 11:23:15 +00:00
Carlos Garnacho
91ae72acdf core: Account ClutterStage grabs on Wayland key focus synchronization
When switching between the existence and not of a stage ClutterGrab, we
would correctly attempt to synchronize key focus from the perspective of
the Wayland clients.

But this synchronization should do its own checks about existing stage
grabs before determining a client window has key focus or not.

Add that check, so that grabs correctly unfocus the keyboard in Wayland
clients, in addition to pointers and touch.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2194
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2366>
2022-04-20 14:38:23 +00:00
Łukasz Spintzyk
ad838ec540 renderer/native: Restore EGL state after creating secondary GPU state
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2347>
2022-04-20 09:30:04 +00:00
Daniel van Vugt
af7e116b94 cursor-renderer/native: Remove unused DRM_CAP_CURSOR_{WIDTH,HEIGHT}
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2361>
2022-04-20 08:28:06 +00:00
Daniel van Vugt
be9deeba09 crtc/kms: Don't add gamma to the update if unsupported by the CRTC
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2197
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2360>
2022-04-19 07:58:31 +00:00
Daniel van Vugt
364572b95c kms/crtc: Add function meta_kms_crtc_has_gamma
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2360>
2022-04-19 07:58:31 +00:00
Daniel van Vugt
cc20584032 kms/crtc: Add debug logging of supported vs unsupported properties
Unsupported properties are particularly common in an Nvidia/hybrid
setup so we don't want to make it a warning that's always visible.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2360>
2022-04-19 07:58:31 +00:00
Daniel van Vugt
e3cba9f2d8 kms/crtc: Fix typo s/proporties/properties/
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2360>
2022-04-19 07:58:31 +00:00
Jonas Ådahl
8c656a7f40 startup-notification: Fix some introspection annotations
This avoids a bunch of warnings and fixes a transfer annotation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2374>
2022-04-13 12:03:27 +02:00
Daniel van Vugt
14ab0238d0 stage/x11: Remove trailing whitespace
To avoid check-code-style warnings in other MRs that touch this file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2373>
2022-04-13 14:35:59 +08:00
Daniel van Vugt
dd94c448e9 kms/device: Disable modifiers when !DRM_CAP_ADDFB2_MODIFIERS
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2210
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2359>
2022-04-08 16:20:34 +00:00
Daniel van Vugt
11e6100226 kms/impl-device: Add addfb2_modifiers to MetaKmsDeviceCaps
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2359>
2022-04-08 16:20:34 +00:00
Jonas Ådahl
9d0f612de1 shaped-texture: Paint with the right layer snippet
When we get passed a "snippet" to the shaped texture, it's added as a
pipeline layer snippet to change how the source texture is sampled. When
we draw from a texture tower however we have allocated regular textures
which doesn't need any special layer snippet, so create separate
pipelines for those that doesn't use that snippet.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2278>
2022-04-07 07:28:44 +00:00
Jonas Ådahl
d4ffaf291f shaped-texture: Pass along the snippet to the texture tower
The snippet is used make sure the right source is sampled in the shader.
This wasn't done in the texture tower, meaning the textures from the
tower were not correct.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/528
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2278>
2022-04-07 07:28:44 +00:00
Corentin Noël
c2b8582e0f startup-notification: Specify the actual type in the "changed" signal
Allows to have type checks and the introspection to be aware of the actual type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2362>
2022-04-05 14:05:23 +02:00
Corentin Noël
9132f984ce mutter: Add missing nullable annotation when possible
Add missing (nullable) annotation when a possible NULL return value is expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2362>
2022-04-05 14:05:23 +02:00
Corentin Noël
50c91bca75 cursor-tracker: Add missing annotation to meta_cursor_tracker_get_pointer
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2362>
2022-04-05 14:05:22 +02:00
Daniel van Vugt
9a23ed98e7 onscreen/native: Fix typo in log message "the the"
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2357>
2022-04-04 17:36:37 +08:00
Jonas Ådahl
47375897a5 wayland/shm: Add support for ABGR8888 and XBGR8888 formats
This avoids shuffling bits for clients drawing in these formats.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2200
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2352>
2022-03-30 14:43:10 +00:00
Olivier Fourdan
eb4307c350 x11: Set WM_S0 last
With Xwayland on demand, a number of maintenance X11 applications need
to be run first, before Xwayland starts accepting requests from the
normal clients, as soon as the WM_S0 selection is acquired by mutter.

On startup, mutter also sets a number of X11 properties that can be
queried by X11 clients.

Unfortunately, mutter acquires the WM_S0 selection before setting those
properties, so mutter and the first regular X11 client will race on
startup.

As a result, the X11 properties set by mutter on startup may not be
available to the very first X11 client when Xwayland starts.

To avoid that issue, make sure to take the WM_S0 selection last when
opening the display.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2176
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2336>
2022-03-30 14:15:03 +00:00
Olivier Fourdan
de8927e075 xwayland: Init DnD on every Xwayland start
Currently, meta_xwayland_shutdown_dnd() is called from the handler
on_x11_display_closing() triggered from the signal "x11-display-closing"
hooked up from meta_xwayland_init_display().

Once the signal has been triggered, on_x11_display_closing() removes the
signal handler, disconnecting from the signal.

As meta_xwayland_init_display() is called from meta_display_new() which
is issued only once, the signal handler is not restored again.

As a result, meta_xwayland_shutdown_dnd() is not called anymore after
Xwayland has been restarted, but meta_xwayland_init_dnd() will check and
assert that the manager's DND object is NULL.

Basically, restarting Xwayland more that once will trigger an assertion
failure in mutter. That's even more of a problem with autoclose-xwayland
where Xwayland is expected to terminate when there is no meaningful X11
client remaining, which can happen multiple times during the lifetime
of a user session.

To make sure that meta_xwayland_init_display() is called for every new
instance of Xwayland, simply keep the signal hooked in place by not
disconnecting it when triggered.

This reverts commit 9a10b8ff94.

Even though, originally, this issue was first introduced with commit
b4fe1fdd95 ("xwayland: Make setup/teardown
a bit more symmetrical") which didn't actually kept 'x11-display-setup'
and 'x11-display-closing' connected.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2168
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2339>
2022-03-30 13:51:26 +00:00
Sebastian Wick
1760dcb0d7 window: Check fullscreen status when window changes monitor
For wayland meta_window_move_to_monitor sends a configure to the client
without actually moving the window, yet and the
meta_display_queue_check_fullscreen call won't detect any changes.
Checking for fullscreen in meta_window_update_monitor fixes the problem
because it is called whenever the window actually changed the monitor it
is on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2325>
2022-03-30 13:01:29 +00:00
Daniel van Vugt
8354289650 onscreen/native: Fall back if COPY_MODE_SECONDARY_GPU fails to init
This can happen if we've got a GBM driver that is incomplete or
buggy for any reason. Currently this includes the Nvidia driver
when used as a secondary GPU, and as soon as they fix that it will
use the fast path instead.

Falling back means we can still use it as a KMS device with all rendering
done on the primary GPU instead. Just like a DisplayLink.

It's slow, but at least the screens all light up now and you get a
usable desktop. Surprisingly it's still a better experience than using
Xorg, maybe because we can flip the outputs independently with the
native backend.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2166,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2182,
       https://launchpad.net/bugs/1959888,
       https://launchpad.net/bugs/1964037

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2341>
2022-03-30 12:36:05 +00:00
Daniel van Vugt
41bfabad96 onscreen/native: Don't try rendering on a secondary GPU without EGL
We rather confusingly still call a secondary display card that is
GPU-less (DisplayLink or other basic KMS device) a "secondary GPU",
so just because secondary_gpu_state is non-NULL doesn't mean we
can use it for rendering. The clearest indication of this is when
there is no EGL surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2341>
2022-03-30 12:36:05 +00:00
Carlos Garnacho
861c4b8535 core: Port to input device capabilities in pad mapper
Check for tablets and pad devices using capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
286562ea53 backends: Update MetaInputSettings to apply settings based on capabilities
Since devices may be multiple things now, check all capabilities in order
to ensure all aspects of the device are correctly configured.

This change does the following observations:
- Devices that have TOUCHPAD | POINTER capabilities prefer the 'touchpad'
  settings path. The regular pointer settings path is left for all
  non-touchpads.
- Devices that are both a tablet and a touchscreen prefer the tablet
  relocatable schema. This works for both aspects as the touchscreen
  schema is a subset of the tablet one.

Other than that it's a rather boring, even if verbose search and replace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
fff3654941 wayland: Check input device capabilities in tablet seats
Instead of looking for tablets and pads based on input device type,
check capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
844a729fa9 wayland: Set wayland seat capabilities based on input device capabilities
Instead of looking at device types, which might be incomplete.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2154
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
1f3fb8441f backends/native: Assign capabilities to input devices
These are extracted from the individual libinput_devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Carlos Garnacho
842295838f backends/native: Make function to determine ClutterInputDeviceType private
We do not need to open code the ClutterInputDeviceType fetching from a
libinput_device, since we already created a native ClutterInputDevice that
has the right type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2331>
2022-03-30 12:06:52 +00:00
Jonas Dreßler
d0de671c1d workspace: Use existing focus_window when asked to focus default window
We use meta_workpace_focus_default_window() to sync the input focus back
to a window after it was on shell UI, this is not really necessary on
Wayland, but it is on X11. What this function does internally is ask
MetaWindowStack about the topmost window and focus+raise that window.

In gnome-shell we set the input focus to the default window every time
the key-focus changes to NULL (see shell-global.c ->
sync_stage_window_focus()). Now when closing the alt-tab switcher and
activating a window while there's an always-on-top window on the
workspace, meta_workspace_focus_default_window() will focus that
always-on-top window right after closing the alt-tab switcher, making it
impossible to focus another window using alt-tab.

To fix this, make meta_workspace_focus_default_window() check if there's
an existing focus_window first, if there is, use that, and if there
isn't, resort to just focusing the topmost one.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5162
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2328>
2022-03-30 11:41:52 +00:00
Bartłomiej Piotrowski
7a7fb863a2 tests/virtme-run: Expose two CPUs
We're multi threaded, so make things more like reality by exposing more
CPUs using the '-smp 2' qemu option.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2152>
2022-03-28 16:17:21 +00:00
Bartłomiej Piotrowski
7435bfd0e5 tests/virtme-run: Disable pdcm
There are issues when running a nested KVM with Fedora 35 when pdcm is
enabled. Work around this for now by disabling it.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2022075
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2152>
2022-03-28 16:17:21 +00:00
Bartłomiej Piotrowski
4ce233b89e tests/virtme-run: Create fake stdin
When running in CI, the stdin may be /dev/null, which causes issues
for qemu. Avoid this issue by creating our own fake stdin.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2152>
2022-03-28 16:17:21 +00:00
Jonas Ådahl
31bc1c80ab tests/kvm: Forward the test environment variables to the VM
This will help with finding the right libdefault.so and correctly setup
the GLib test framework.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2152>
2022-03-28 16:17:21 +00:00
Jonas Ådahl
189068d465 tests/build: Set up test environment using a dict()
This will allow us to reuse the keys and values more easily, as later
commits will rely on being able to iterate over the keys and values to
construct explict env strings for passing into special test cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2152>
2022-03-28 16:17:21 +00:00
Robert Mader
f9857cb8bd wayland/surface: Disable WL_SURFACE_ERROR_INVALID_SIZE check again
The check was introduces in ab17c98c94
but turned out to trigger client crashes in common cases.
Turn it into a warning for now until clients are fixed.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2335>
2022-03-24 15:15:08 +00:00
Jonas Dreßler
0280b0aaa5 events: Use the event target actor to determine window for event
We use get_window_for_event() to check whether an event happened on top
of a window or on top of shell UI to decide whether to bypass delivering
the event to Clutter. In case of crossing events though, we can't just
use the device actor to determine whether to forward the event to
Clutter or not: We do want to forward CLUTTER_LEAVE events which
happened on top of shell UI. In that case the device actor is already a
window actor (the pointer already is on top of a window), but the shell
still needs to get the LEAVE crossing event.

Since the event source actor got removed from the detail of
ClutterEvent, the context we're looking for (which actor did the pointer
leave) is now the target actor that the event gets emitted to. Since the
last commit, we also made event filters aware of this context by passing
the target actor to them, so use this context now to determine whether
we're on top of a window or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2321>
2022-03-21 23:08:40 +00:00
Jonas Dreßler
2aad56b949 clutter: Pass target actor of events to event filter functions
We'll need the additional context of which actor the event will be
emitted to in mutters event filter (see next commit), so pass that
target actor to the event filters that are installed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2321>
2022-03-21 23:08:40 +00:00
Ivan Molodetskikh
690b8806dd backends/native: Change uint32_t modifiers to uint64_t
They were erroneously cast to uint32_t. In particular this prevented the
invalid modifier from working as it is equal to a 64-bit -1.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2322>
2022-03-06 16:56:27 +03:00
Robert Mader
7f93004809 compositor/native: Check that the surface can be scanned out untransformed
Before scanning out the surface of a native client we have
to check the following attributes that influence the
relationship between buffer and the defined result on screen:
 - buffer scale
 - buffer transform
 - viewport

In the future we can loose these checks again in cases where the
display hardware supports the required operations (scaling, cropping
and rotating).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2276>
2022-03-05 14:14:37 +00:00
Robert Mader
6330acfaa2 compositor: Some header cleanups
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2276>
2022-03-05 14:14:37 +00:00
Sebastian Keller
251bb45ec0 window/wayland: Always include a size when sending a configuration
Prior to 67033b0a mutter was accidentally including sizes for
configurations that were just focus state changes. This was not leading
to any known problems on the client side, but it was causing issues in
mutter itself when detecting whether a resize originated from the client
or the server.

Not including sizes in focus change configurations anymore however
revealed a bug in gtk. It was storing the window size when in a fixed
size mode (tiled/maximized/fullscreen), but not on any other server side
resizes. It was then restoring this stored size whenever there was a new
configuration without a size while in floating mode, i.e. the focus
change configurations generated by mutter after 67033b0a.

This change now addresses the issue 67033b0a was fixing in a way that
restores the previous behavior of always including the size whenever
sending a configuration.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2091
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2238>
2022-03-05 13:18:58 +00:00
Jonas Ådahl
46f81afb3b kms/impl-device/atomic: Fix function type signature
The property enum type was wrong.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
590e32dc62 wayland/tablet-pad: Fix fallthrough warning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
339c315ed9 input-settings/native: Fix switch fallthrough warning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
43870a5f55 input-settins/x11: Fix switch fallthrough warning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
79319a3a91 barrier/native: Fix warning about implicit enum conversion
Also add static asserts to make sure the values match so casting can be
done.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2319>
2022-03-04 23:12:24 +00:00
Jonas Ådahl
1914f533b8 tests/screen-cast: Add input injection tests to screen cast client
This tests that cursor metadata are handled properly, and that the
display server handles input events correctly, including ones that are
sent too early.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
1e50ca0057 remote-desktop/virtual: Drop absolute events if not active
If the remote desktop service emits absolute input events (e.g. absolute
pointer events) before the stream has started streaming, we don't have a
virtual monitor, as the size has not been negotiated yet. When this
happens, just drop the event. Remote desktop services should probably
make sure not to send events before the streaming has started, but them
doing so anyway shouldn't trigger a crash, which would be the case
otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
d649445bb7 tests/screen-cast: Also make it a remote desktop session
This will allow emitting input events / remote control too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
88cfd31f18 tests/screen-cast: Test virtual stream resizing
This test resizes the stream by updating the PipeWire stream properties.
This triggers a format negotiation, that results in the buffers being
reallocated with the new size. The test makes sure we eventually
receive this new size.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
c49037469a tests/screen-cast-client: Set an explicit size
Don't set a range, take control of the size. This is fine, since we're
only recording virtual monitors, which get their size from the PipeWire
negotiation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
4de740c7a3 screen-cast/virtual-src: Don't recreate the virtual monitor on resizes
Keep the virtual monitor around if it's being resized. This reduces the
number of unnecessary object rebuilding that happen during monitor
rebuilding.

This changes finalize() vfunc into a dispose() vfunc in the abstract
stream source object implementation, as it needs the abstract stream
source object to close the stream early, so that various signal
listeners get disconnected early.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1904
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
34d0e68aef virtual-monitor: Add way to change virtual monitor mode
This can be used to change the size of the virtual monitor without
recreating it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
a97b6560d7 virtual-monitor: Never reuse mode IDs
We'll change mode's on-demand so using IDs identical to the virtual
monitor ID would mean IDs didn't change when changing mode, and that is
rather unintuitive. IDs don't mean much anyhow, just make them grow
within the realm of a 63 bit unsigned integer, as the 64th bit means its
a virtual mode ID. Making sure the ID is in the virtual mode namespace
is handled by meta_crtc_mode_virtual_new().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
ee8de0dc83 backend/native: Remove unused ID namespace macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
46a4a080b7 virtual-monitor: Split out mode info into separate struct
Will help when changing virtual monitor modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2270>
2022-03-04 18:13:45 +00:00
Jonas Ådahl
a09b99261f wayland/dma-buf: Handle lack of gbm_device gracefully
In some configurations (e.g. NVIDIA driver 470) Xwayland may use DMA
buffer for passing buffers around. When this is done, we might attempt
to scanout these buffers when they are fullscreen, and to do so we
import them using gbm.

However, for the mentioned configuration, there is no gbm device
available for importing. This was not handled, and resulted in a crash;
avoid this crash by checking whether we have a gbm device and fail
gracefully if we don't.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2098
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2318>
2022-03-04 17:27:29 +00:00
Jonas Ådahl
370de58868 wayland/surface: Add support for wl_surface.offset
This aims to replace the x,y arguments in wl_surface.attach(); meaning
it can be used more sanely together with EGL, and at all when using
Vulkan.

The most common use case for the offset is setting the hotspot of DND
surfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1905>
2022-03-04 17:38:30 +01:00
Jonas Ådahl
fadffe3fad wayland/xdg-shell: Add toplevel bounds support
This implements the new 'bounds' event that is part of the xdg_toplevel
interface in the xdg-shell protocol. It aims to let clients create
"good" default window sizes that depends on e.g. the resolution of the
monitor the window will be mapped on, whether there are panels taking up
space, and things like that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
28a5946a28 tests/wayland-unit-tests: Remove unnecessary message check
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
cb424b68e6 tests/wayland-unit-tests: Make some function names less generic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
546b94545e window: Make a better guess at initial monitor
We'd guess the initial monitor before it was actually calculated by
looking at the initial geometry. For Wayland windows, this geometry was
always 0x0+0+0, thus the selected monitor was always the primary one.

This is problematic if we want to provide initial more likely
configurations to Wayland clients. While we're not doing that yet, it'll
be added later, and this is in preparation for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
17e239246a window: Add function to calculate current bounds
This will later be used to tell Wayland clients about a size they
shouldn't exceed.

If the window doesn't have a main monitor, this function does nothing
and returns FALSE.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Jonas Ådahl
213f0d8dd3 window/wayland: Pass x,y,width,height as rectangle
Will make the number of variables a bit more managable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
2022-03-04 14:48:25 +00:00
Carlos Garnacho
e736b04deb clutter: Remove "source" event union fields
These are no longer used, drop the last places that modify those
in event structs and remove them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
5dd818cf1a tests: Move away from clutter_event_get_source()
The target actor as seen by the stage is equivalent, so use that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
9b6253bf3f wayland: Move away from clutter_event_get_source()
Instead ask the stage about the target actor, which is equivalent
and ensured to be up-to-date.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Carlos Garnacho
52002d042e core: Move away from clutter_event_get_source()
Instead ask the stage for the target actor for the given device/sequence.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2311>
2022-03-04 10:58:28 +00:00
Robert Mader
8f91d831ee wayland/dma-buf: Fix typos in struct name
Fixes 7acecb1c72

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2297>
2022-03-04 09:16:28 +00:00
Robert Mader
5b9abecc1b wayland/dma-buf: Add missing wl_array_release()
So we don't leak the array.

Fixes 7acecb1c72

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2297>
2022-03-04 09:16:28 +00:00
Ivan Molodetskikh
bcf6ee5e55 Name unnamed sources
These names show up in GLib traces in sysprof, so let's make sure they
exist.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1928>
2022-03-04 10:10:05 +03:00
Bilal Elmoussaoui
7717383deb meson: Allow to build without gnome-desktop
gnome-desktop is used to retrieve the monitor vendor name which in some
use cases is not needed  as it brings a bunch of gnome-desktop unwanted
dependencies.
The change makes mutter fallback to an "Undefined" vendor name if it is
built without gnome-desktop

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2317>
2022-03-03 15:07:38 +00:00
Alfonso Sánchez-Beato
8ccbb32f71 egl: Fix number of configs returned in meta_egl_choose_all_configs
Return in meta_egl_choose_all_configs() the actual number of
configurations returned by eglChooseConfig(), which are not
necessarily the same number as those from eglGetConfigs().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2303>
2022-03-03 08:18:56 +00:00
Jonas Dreßler
672696f823 dnd: Notify about events during compositor grab from event filter
Since the introduction of ClutterGrabs, MetaDnd now no longer gets
notified about input events on the stage during grabs (for example while
the alt-tab popup is shown) and thus can't move the grab feedback actor
anymore.

To fix this, forward events to MetaDnD directly from
meta_display_handle_event() when a ClutterGrab is in effect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2308>
2022-03-02 15:12:23 +00:00
Jonas Dreßler
8a11069dca events: Only get MetaWaylandCompositor once
We get the MetaWaylandCompositor a bunch of times, but we can do with
getting it only once and then also replace the is_wayland_compositor()
checks with a if (wayland_compositor).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2308>
2022-03-02 15:12:23 +00:00
Carlos Garnacho
32332fd53d wayland: Handle xdg_activation_v1_activate on non XDG activation tokens
The XDG activation support was missing interoperability with other
startup sequences, notably those coming from other means than XDG
activation.

In order to play nice with X11 startup sequence IDs, we not just
have to check for the startup ID being in the general pool, but
we also need to fallback into X11-style timestamp comparison so the
window ends up properly focused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2314>
2022-02-28 17:34:27 +01:00
Olivier Fourdan
fe41e69eea wayland/xdnd: Use multiple DnD X11 peers
When a drag and drop occurs from an X11 client to a Wayland native
client, mutter uses an internal X11 window as a peer for the DnD  drop
site.

That internal X11 window is moved and resized to match the Wayland
native windows as the drag destination moves.

When moving from one Wayland native window to another Wayland native
window, the same X11 window is used, and as a result no DND enter/leave
events is emitted.

In that case, the drop may occur on the wrong Wayland native window,
because no new XdndEnter/XdndLeave event were emitted.

To avoid that issue, use a pair of X11 windows instead of just one and
alternate between the two when repicking a new drop surface, so that
moving from a Wayland surface to another will always generate the
expected enter/leave events that we rely on.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2136
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2305>
2022-02-25 11:35:35 +01:00
Dor Askayo
2a5506170a core: Initialize g_autofree with NULL
This prevents build warnings about use of potentially uninitialized
variables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2301>
2022-02-23 20:48:10 +00:00
Bilal Elmoussaoui
26790f7f39 wayland/keyboard: Remove unnused define
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2306>
2022-02-22 11:05:36 +01:00
Carlos Garnacho
1ad98879b7 core: Mark both directions in rings/strips as (un)handled altogether
If going on a direction has a keycombo associated and the other does
not, it does not make sense to let the wayland bits handle pad
ring/strip events that only go in one direction.

Ensure that's the case, and also while figuring out the ring/strip
direction based on the initial events.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1886
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>
2022-02-14 15:24:27 +00:00
Carlos Garnacho
952caf6b71 core: Refactor strip/ring direction guessing in action handling
Make it all happen in meta_pad_action_mapper_handle_action(), since
we'll need better handling here than just "return FALSE".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>
2022-02-14 15:24:27 +00:00
Carlos Garnacho
101cae03f3 core: Handle mixture of keycombo/no action in pad rings/strips
When generating the action label, we expect both directions of these
features to have consistent settings (either both get a keycombo, or
they don't) or these just return NULL altogether.

Since one of the directions has an action associated, this is
misleading, so be more lenient at the time of generating the action
label.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2001>
2022-02-14 15:24:27 +00:00
Carlos Garnacho
7bf10de538 wayland: Warn and fix accounting on missed CLUTTER_TOUCH_END events
If we happen to handle a CLUTTER_TOUCH_BEGIN without a corresponding
CLUTTER_TOUCH_END at MetaWaylandTouch, we would still attempt to
reuse the older MetaWaylandTouchInfo, resulting in an assert triggered
as there is a stale touch reference on the previous surface.

Warn in place and create a new touch info struct to still fix the
broken surface accounting, instead of finding out the hard
way after the surface is destroyed. The assert is preserved to ensure
the accounting does not sneakily break anymore/further.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/584
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2251>
2022-02-14 13:54:33 +00:00
Daniel van Vugt
b7f7b82b89 onscreen/native: Warn instead of crashing if the frame_info queue is empty
Some Ubuntu systems with mutter 40 and 41 report `maybe_update_frame_info`
crashes with SIGSEGV when `frame_info == NULL`.

The same was reported by @rmader as happening "after wakeup" in testing
(https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441#note_1301588)
although the Ubuntu reports show it's not related to that MR.

Fixes: https://launchpad.net/bugs/1960585
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2282>
2022-02-14 10:51:18 +00:00
Jonas Ådahl
ca5488c3d6 monitor-manager: Don't introspect "monitor-privacy-screen-changed"
It passes a MetaLogicalMonitor, which isn't introspected right now, so
skip it completely. The entry point to the UI is handled via
MetaDisplay, so it isn't needed.

This fixes the following warning:

<unknown>:: Warning: Meta: (Signal)monitor-privacy-screen-changed: argument object: Unresolved type: 'MetaLogicalMonitor'

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2287>
2022-02-14 10:01:54 +00:00
Jonas Ådahl
2a624dbd1e monitor-manager/native: Emit privacy-screen-changed signal later
Make sure the monitor and output state is up to date when we emit the
privacy-monitor-changed signal, otherwise the signal emission code will
try to look up out of date state.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2119
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2280>
2022-02-14 09:29:48 +00:00
Florian Müllner
7ff52b6128 wayland/gtk: Only perform allowed titlebar gestures
The window functions "work" regardless of whether the client allows
the behavior or not. That is, it's up to the caller to not call
maximize and friends when the action isn't allowed.

Add appropriate checks, which should make the titlebar_gesture()
behavior identical to titlebar actions for server-side decorations.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2281>
2022-02-10 20:00:15 +01:00
Konstantin Kharlamov
338eea7a37 backends/native/meta-seat: Sync keyboard LEDs when changing layout
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/633
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2279>
2022-02-10 08:11:56 +00:00
Jonas Ådahl
5588f2a21c tests: Decrease boiler plate needed for adding more tests
Structure tests in a list of dictionaries, instead of requiring each
test to have its own executable(...) and test(...) statement. The
intention of this is to make it easier to add more test cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Jonas Ådahl
afca974405 tests: Move monitor test utils into libmutter-test.so
It already was built into it without any symbols exported, but also
duplicated in test cases that used it. Make it so that the built in
functions are exported, with prefixes, and make all tests use the
exported functions. While at it, make things go via MetaContext or
MetaBackend depending on how early in initialization things are run.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Jonas Ådahl
3fc0d8b81d tests/build: Remove duplicated meta-gpu-test.c file inclusion
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Jonas Ådahl
15b8f89c02 tests: Move ref test framework to libmutter-test.so
Will make it available to most tests without having to explicitly
include.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Jonas Ådahl
bd18af1a0d tests/build: Sort sources list
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Jonas Ådahl
195766cb69 tests: Add helper for creating virtual test monitors
This uses virtual monitors in the headless backend, in contrast to the
ones used by the monitor configuration tests which use the nseted
backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Jonas Ådahl
b7f23c1baf tests/utils: Add helper to find a window given a title
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Jonas Ådahl
b522e3cecd tests/wayland: Move test client helper into a utils file
This will make it easier to run Wayland test cases from other test
executables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>
2022-02-09 09:04:09 +00:00
Carlos Garnacho
d90adfe303 backends: Keep cursor hidden on tablet input on Wayland
Tablets have their own cursor, in order to avoid confusions just
hide the regular pointer like we do on touchscreens, so there's
the illusion that there is a single cursor.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/75
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
a870e6b38d backends/x11: Update MetaBackend on ClutterEvent processing
This should fix wonky handling of last used device and pointer
visibility on X11. At least does on --nested under presence of
touchscreen/tablet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
13330f34f3 backends: Add private call to update MetaBackend from a device
We update some details like the last used device and pointer visibility
from events, but this is done inconsistently on X11 since the
ClutterEvents are created and pushed from an additional place.

Make these updates happen on a private call, that will be called from
these places in X11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
f5c0bcbf9c backends: Split handling of pointer visibility on events
This was done as part of the "last updated device" changes, separate
that as we want different checks and policies.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
f852e5ab2b backends: Make meta_backend_update_last_device() private
This is now handled entirely in the backend, no need to export this
function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
d72bacb3cd backends/x11: Drop handling of XI_DeviceChange
Even though it's great that XI2 has an event to notify about device
changes, this is something we can let the MetaBackend code handle
consistently for all backends, since looking for the source device
works everywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
4e85e0e1b3 core: Drop handling of updates to the last used device
This is now done in the backend for the Wayland case, so we can
drop this update here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
9708d04f7e backends: Check for updates in the last used device after dispatching events
Instead of relying in the device being updated from different parts of our
machinery for different backends, hook this up to our own event dispatching.
This will allow dropping all other places where this is done.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
ecafc489c1 backends: Move function definitions
These will be made private and called from different places. At the
moment there is no functional change here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
3ab59175c8 backends/native: Fix cursor renderer assignment for tablet devices
We create a cursor renderer per device for those at
meta_seat_native_handle_event_post() with PROXIMITY_IN events, but
the MetaWaylandTabletTool handles the event before that, and goes
with a NULL cursor renderer.

Make MetaBackend::get_cursor_renderer() on the native backend create
those cursor renderers on demand, and only handle PROXIMITY_OUT in
handle_event_post() to dispose those. This makes MetaWaylandTabletTool
happily get a cursor renderer again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
a88c9b9ff2 wayland: Use default cursor on tablet tools
Now that we "replace" the pointer cursor on tablet input, have it
use the default cursor so it blends in better.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:47 +00:00
Carlos Garnacho
f2ff9dcc01 backends: Unify cursor visibility checks
We are adding more to this logic, so make this check be its own
function that checks devices individually.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
2022-02-08 14:34:46 +00:00
Jonas Ådahl
52ce81657d backend/native: Only disable dmabuf screen cast when not hw accelerated
We now only enable DMA buffer based PipeWire screen casting if a
format/modifier has been negotiated. This practically means a consumer
is aware about what is needed, and we should not try to predict that it
uses the DMA buffer the right way (i.e. not mmap:ing directly).

However, in case we're not hardware accelerated, we never want to
attempt to use DMA buffer screen sharing, as we want to avoid
compositing into a DMA buffer on such hardware as doing so can be very
slow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2086>
2022-02-07 19:16:45 +00:00
Jonas Ådahl
169dd2fb7a window: Move some display level window processing to MetaDisplay
meta_window_(un)queue() was implemented with global arrays in window.c
that managed MetaLater handle IDs and lists of window queues. In order
to rely less on scattered static variables and making it clearer that
we're dealing with per display window management and not something
specific to a single window, move the window resize/calc-showing queue
management to MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
ac5d728abd window: Fix coding style in meta_window_unqueue()
As with meta_window_queue(), it had some comments duplicating code, so
those were removed too to increase readability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
aeae90d5d9 window: Move icon management to X11 implementation
It's still used by e.g. GNOME Shell to produce fallback icons for X11
applications that doesn't come with a .desktop file. Geometry stays in
the generic class because it's used for minimize animations and is
configured by the panel (e.g. the one in gnome-shell-extensions).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
35ac3a096d compositor: Destroy actors when unmanaging
When disposing, actors being destroyed might want to access the disposed
compositor; avoid that by destroying them earlier.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
dd14592314 laters: Expose MetaLaters publicly
Will allow not having to use the context-less meta_later_add().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
73c010d8b0 window: Remove musings from meta_window_queue()
The comments in this function tells a story of C programmer self
reflecting about data types and Perl. While that can be nice, the rest
consisted mostly of repeating what the code line below did, with the end
result being that the function didn't fit on screen, resulting in worse
readability overall.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Jonas Ådahl
b5d873a8ac window: Clean up coding style of meta_window_queue()
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
2022-02-07 17:52:05 +00:00
Carlos Garnacho
09538422c6 backends: Update idle time after opening the lid
When handling lid state, we used to update the idle time right after
opening the lid. This behavior changed in commit 14b6c8780d due
to a typo/thinko, "if (lid_is_closed)" used to be an early return
condition before updating idle time, now it only updates in that
case.

Restore the original behavior, since this idle time update is key
in having gsd-power light up the display again, this presumably
fixes situations that required extra "light up" hints after suspend.
What it does surely fix is "ninja test" in g-s-d against recent
mutter, since the behavioral change induced a test timeout there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2272>
2022-02-07 16:52:39 +00:00
Sebastian Wick
abadb29132 xwayland: Relax the ownership requirements of /tmp/.X11-unix
The `ensure_x11_unix_perms` function tries to detect systems on which
/tmp/.X11-unix is owned by neither root nor ourselves because in that
case the owner can take over the socket we create (symlink races are
fixed in linux 800179c9b8a1e796e441674776d11cd4c05d61d7). This should
not be possible in the first place and systems should come with some way
to ensure that's the case (systemd-tmpfiles, polyinstantiationm …). That
check however only works if we see the root user namespace which might
not be the case when running in e.g. toolbx.

This change relaxes the requirements such that in the root user
namespace we detect and abort if a vulnerable system is detected but
unconditionally run in toolbx.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2261>
2022-02-07 16:01:26 +00:00
Olivier Fourdan
6427b27602 mutter: Raise the NOFILE limit if a Wayland compositor
When being run as a Wayland compositor, raise the NOFILE limit to
mitigate the risk of running out of file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:47 +01:00
Olivier Fourdan
8305c7bd06 wayland/client: Restore the NOFILE limit
Make sure the restore the original NOFILE limit prior to run the
trusted Wayland client so it does not inherit from the raised value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:47 +01:00
Olivier Fourdan
acded0648c core: Restore the NOFILE limit
When restarting or when running a dialog, the original NOFILE limit
should be restored.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:47 +01:00
Olivier Fourdan
8b9341131a context: Add a new API to raise and restore NOFILE limits
Wayland, especially when using SHM buffers, can use a lot of file
descriptors and can possibly reach the NOFILE soft limit.

Add a new API to MetaContext to raise and restore the NOFILE limit so
that the Wayland compositor can use as many file descriptors as the hard
limit allows.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1283
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>
2022-02-07 16:11:42 +01:00
Jonas Dreßler
38f3bf6ee2 screen-cast/src: Add debug logging when creating buffers
Add some debug logging that allows checking whether we're using DMA
buffers for screencasting or system memory buffers. This can be useful
for debugging screencasting performance and CPU usage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2256>
2022-02-07 13:37:56 +00:00
columbarius
b34ca56cae screen-cast-stream: Check for a modifier in the format negotiation via pipewire
Announce SPA_PARAM_BUFFERS_dataType accordingly if the modifier key
exists in the returned SPA_PARAM_Format.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
columbarius
42047d18b6 screen-cast-stream: Announce support for implicit modifiers
With the ability to query the renderer for DMA-BUF support we can
announce support for implicit modifiers. This allows PipeWire to check
for matching modifiers while negotiation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
columbarius
72aae9d6ac screen-cast-stream: Add push_format_object function
This function is used to build EnumFormat spa_pods for format
negotiation and contains support for modifiers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
Jonas Ådahl
49ac60e346 cogl/renderer: Add 'is_dma_buf_supported()' vfunc
Returns TRUE if the active renderer backend can allocate DMA buffers.
This is the case hardware accelerated GBM backends, but FALSE for
surfaceless (i.e. no render node) and EGLDevice (legacy NVIDIA paths).
While software based gbm devices can allocate DMA buffers, we don't want
to allocate them for offscreen rendering, as we really only use these
for inter process transfers, and as buffers allocated for scanout
doesn't use the relevant API, making it return FALSE for these solves
that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1939>
2022-02-07 10:56:57 +00:00
Carlos Garnacho
d838460fe9 core: Do not eat both wayland and clutter events with wayland popups
There may be situations where we may stack a ClutterGrab on top of a
wayland popup's. Since ClutterGrab should win over client grabs, we
mostly correctly figure out that it should start doing
bypass_wayland=TRUE and bypass_clutter=FALSE while the ClutterGrab
holds, however the late checks for the MetaDisplay event route can
still toggle bypass_clutter on, resulting in neither handling events.

This check for wayland popups in the display event route should just
enforce wayland handling if wayland is meant to be receiving events,
so ensure these don't mix together.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5020
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2271>
2022-02-04 18:24:19 +01:00
Jonas Ådahl
0205398d96 constraints: Try place popup on the same monitor as the anchor rect
When we'd place a popup, if the initially calculated position would be
on another monitor than the anchor rect on the parent window, the
later constrained position would end up on another monitor than the
parent window. This could for example happen if a popup menu opening
towards the right was opened very close to the screen edge of a right
most monitor in a two side by side monitor setup.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1783
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1768
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2252>
2022-01-31 13:14:22 +00:00
Carlos Garnacho
e8ed9ece1c core: Drop META_GRAB_OP_COMPOSITOR
There is no longer meta_plugin_begin_modal(), so this grab operation
is no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
2022-01-29 02:11:37 +01:00
Carlos Garnacho
b6de66e353 compositor: Remove meta_plugin_begin/end_modal
Amazingly, this is no longer used. This way to let Clutter grab input
is no longer necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
2022-01-29 02:11:37 +01:00
Carlos Garnacho
b8853b07a5 tests: Rewrite interactive Clutter grabs tests
So it uses ClutterGrab, instead of an API that is soon to disappear.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2100>
2022-01-29 02:11:37 +01:00
Carlos Garnacho
a840c039a0 core: Handle redirection changes in and out of ClutterGrab grabs
Wayland event processing and WM operations are themselves outside the
ClutterGrab loop so far. Until this is sorted out, these pieces of
event handling have got to learn to stay aside while there is a
ClutterGrab going on.

So, synchronize foci and other state when grabs come in or out, and
make it sure that Wayland event processing does not happen while
grabs happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
3a79b7b066 clutter: Add docs and introspection annotations to grabs
Since we want these accessed from bindings this must be a boxed
type. This has the side effect of making ClutterGrab a refcounted
object, since we want to avoid JS from pointing to freed memory
and maybe causing crashes if misusing the object after dismiss.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Carlos Garnacho
6144244201 clutter: Drop clutter_stage_[gs]et_motion_events_enabled()
This is (luckily!) unused, and it's inconvenient to have a toggle to
break the input model we are striving towards. Drop this function
and stick to the default behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
Olivier Fourdan
b8870a11b8 xwayland: Warn when autoclose-xwayland is not usable
The experimental feature "autoclose-xwayland" requires a couple of
prerequisites:

1. Be able to (re)start Xwayland on demand, i.e. with systemd
2. Xwayland must support the terminate delay

Add a warning message if "autoclose-xwayland" was requested but any of
those prerequisites is not met.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2258>
2022-01-28 15:46:56 +00:00
Olivier Fourdan
6ce80ccc54 xwayland: Remove stop xserver timeout
Since commit 226afa24a - "Use Xwayland auto-terminate feature", the
callback function shutdown_xwayland_cb() does not check for the
autoclose-xwayland experimental feature anymore.

As a result, when running nested or outside of systemd,
gnome-shell/mutter would quit after 10 seconds unless some X11 window
was mapped.

But now that we rely on Xwayland's own terminate feature, there really is
no need to use any xserver timeout function anymore.

We do not need to keep track of X11 windows being created or unmapped, as
again, Xwayland does all that for us at the client level.

Remove all this code that we do not need anymore.

fixes: 226afa24a - Use Xwayland auto-terminate feature

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2258>
2022-01-28 15:46:56 +00:00
Daniel van Vugt
c970bb3e6c cogl: Merge FEATURE_ID_GET_GPU_TIME into FEATURE_ID_TIMESTAMP_QUERY
Because both code paths require the existence of `GL_TIMESTAMP[_EXT]`
which is only guaranteed if `ARB_timer_query` (included in GL core 3.3)
is implemented.

We know when that is true because `context->glGenQueries` and
`context->glQueryCounter` are non-NULL. So that is the minimum
requirement for any use of `GL_TIMESTAMP`, even when it is used in
`glGetInteger64v`.

Until now, Raspberry Pi (OpenGL 2.1) would find a working implementation
of `glGetInteger64v` but failed to check whether the driver understands
`GL_TIMESTAMP` (it doesn't).

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2107
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2253>
2022-01-27 22:58:59 +00:00
Olivier Fourdan
226afa24aa xwayland: Use Xwayland auto-terminate feature
When using Xwayland-on-demand (default), if the (experimental) autoclose
features is enabled, we can rely on Xwayland's auto-terminate feature
instead of explicitly killing the Xwayland process.

With it, gone is the mechanism that was added to check the X11 clients
connected and their executable to check whether we can (safely) kill
Xwayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1794>
2022-01-26 14:42:22 +01:00
Olivier Fourdan
42855b69e7 xwayland: Mark our X11 connection terminatable
The connection to the Xserver for the X11 window manager part of mutter
even on Wayland may prevent the Xserver from shutting down.

Currently, what mutter does is to check the X11 clients still connected
to Xwayland using the XRes extension, with a list of X11 clients that
can be safely ignored (typically the GNOME XSettings daemon, the IBus
daemon, pulseaudio and even mutter window manager itself).

When there is just those known clients remaining, mutter would kill
Xwayland automatically.

But that's racy, because between the time mutter checks with Xwayland
the remaining clients and the time it actually kills the process, a new
X11 client might have come along and won't be able to connect to
Xwayland that mutter is just about to kill.

Because of that, the feature “autoclose-xwayland” is marked as an
experimental feature in mutter and not enabled by default.

Thankfully, the Xserver has all it takes to manage that already, and
is even capable of terminating itself once all X11 clients are gone (the
-terminate option on the command line).

With XFixes version 6, the X11 clients can declare themselves
"terminatable", so that the Xserver could simply ignore those X11
clients when checking the remaining clients and terminate itself
automatically.

Use that mechanism to declare mutter's own connection to the Xserver as
"terminatable" when Xwayland is started on demand so that it won't hold
Xwayland alive for the sole purpose of mutter itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1794>
2022-01-26 14:42:22 +01:00
Jonas Ådahl
b49421d8e8 monitor-config-store: Allow changing D-Bus configuration policy
Adding a <dbus/> element containing a boolean (yes/no) determines
whether org.gnome.Mutter.DisplayConfig ApplyMonitorsConfig will be
callable. The state is also introspectable via the
ApplyMonitorsConfigAllowed property on the same interface.

For example

    <monitors version="2">
      <policy>
        <dbus>no</dbus>
      </policy>
    </monitors>

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
3d4a6875e6 monitor-config-store: Add test for monitor configuration policy
The test aims to verify that setting the following policy

    <policy>
      <stores>
        <store>system</store>
      </stores>
    </policy>

only applies monitor configurations from the system level.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
d8a66a3892 tests: Split out monitor configuration tests to its own test case
This makes it easier to run without having to run all the other tests,
and it will allow us to be more particular with its setup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
67425bf653 tests: Move orientation helper to monitor test utils
It was used by both the orientation tests, and the monitor configuration
tests. Lets move the helper to common ground.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
20686f3354 tests/monitor-unit-tests: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
85a3ca3d17 tests: Add more monitor config policy parsing tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
c611b64c53 monitor-config-store: Add way to define config store loading policy
This adds a way to define a way, at the system level, to define a policy
of how monitor configuration files are loaded.

The intended use case is to e.g. either prefer system level monitor
configurations before user levels, or only allow system level
configurations.

Examples:

Prefer system over user level configurations:

    <monitors version="2">
      <policy>
        <stores>
          <store>system</store>
          <store>user</store>
        </stores>
      </policy>
      <configuration>
        ...
      </configuration>
    </monitors>

Only allow system level configurations:

    <monitors version="2">
      <policy>
        <stores>
          <store>system</store>
        </stores>
      </policy>
      <configuration>
        ...
      </configuration>
    </monitors>

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
6c4380ed41 monitor-config-store: Fix incorrect string comparison with empty string
strncmp() always return 0 if the passed length is 0. What this means is
that whatever the first string check happens to be, if the parsed XML
cdata was empty (e.g. if we got <element></element>), the first
condition would evaluate to true, which is rather unexpected.

Fix this by making sure the string length is correct first. Also move it
into a helper so we don't need to repeat the same strlen() check every
time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
b74e99b10b monitor-config-store: Make parsing a bit more forgiving
Allow unknown XML elements inside <monitors>. This makes extending in
the future easier.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
2022-01-25 16:25:48 +00:00
Jonas Ådahl
2d7a8c3ce9 kms: Don't enter power saving via updates
The way device backends implement power saving differ, and power saving
needs to contain nothing incompatible in the same update. Make it
impossible to e.g. mode set, page flip, etc while entering power save by
not using MetaKmsUpdate's at all for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
3472ff50ce tests/kms/device: Add power saving test
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
2e774e8e14 tests/kms: Check predicted state is correctly predicted
When we're predicting state, i.e. when having posted an update while
avoiding reading KMS state, copy the predicted state, update the actual
state, and check that the predicted state matches the newly updated one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
2478000c73 kms: Properly predict power saving effect on tracked state
Entering power saving effectively disables CRTCs, and thus the CRTC id a
connector is associated with. Make sure that the tracked state reflects
this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
8ea49fe9d9 kms/connector: Add missing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
0fab55dbc0 tests/kms/device: Add mode setting test
Checks that the relevant device state is correct after mode setting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
feadaacfdd kms/connector: Add getter for preferred mode
This replaces a helper used in tests. The intention is to use it from
other tests, and seemed like a good fit to place it under the KMS
connector object itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
6a9e2e9e2d tests/kms-utils: Add helpers for common buffer sizes
This makes it more convenient to allocate and configure buffers covering
the whole primary plane given a mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
c35e8f5a51 kms: Concentrate update processing in MetaKmsDevice
It was a bit scattered, with it being split between MetaKms and
MetaKmsImpl, dealing with MetaKmsDevice and MetaKmsImplDevice
differentation. Replace this by, for now, single entry point on
MetaKmsDevice: meta_kms_device_process_update_sync() that does the right
thing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
43a1ba3432 tests: Add KMS device tests
As other KMS tests, depends on being DRM master and vkms being loaded.

Currently consists of a sanity check that checks for the expected set of
connectors, CRTCs, planes, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
23a530cb09 monitor-manager/native: Get CRTC gamma from cache if available
Right now gamma is set only via the D-Bus API (from gsd-color), but the
actual gamma isn't right after SetCrtcGamma(), meaning if one would call
GetCrtcGamma() right after setting it, one would get the old result.
Avoid this by getting the "current" CRTC gamma from the cache we manage.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
cd517216ae kms/impl-device: Clear fd source on prepare-shutdown
This ensures we won't receive any untimely page flip callbacks during
later phases of shutting down.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
4276e9ddd3 tests/kms-update: Add mode setting sanity tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
65073c145c tests/kms: Add basic plane assignment update tests
Test that adding a couple of plane assignments were correctly added to
the update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
758e5e23fa kms/mode: Add width/height getters
This avoids some situations where one would otherwise need to fetch the
drm mode to check the dimensions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
990267026a boxes: Add rectangle init macro
META_RECTANGLE_INIT() works like e.g. GRAPHENE_RECT_INIT() and similar
macros.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
de06d5d9e7 kms/update: Add init helper macros for fixed 16 rects
META_FIXED_16_INIT(), taking MetaFixed16's, and META_FIXED_16_INIT_INT()
taking integers, converting them to MetaFixed16.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
acd51a7e69 tests: Add some basic MetaKmsUpdate unit tests
Mostly rudimentary sanity testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
bf398a5f84 kms/update: Add getter for cursor plane assignment
To be used in tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
501b6f52d3 monitor-manager/native: Fix include macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Jonas Ådahl
daa945175b virtme-run: Forward some more environment variables
XDG_DATA_DIRS and LD_LIBRARY_PATH is needed to make sure non-system link
directories are respected, e.g. when using jhbuild.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2159>
2022-01-25 15:47:03 +00:00
Florian Müllner
5b720a157c compositor/plugin-manager: Split start() from new()
In order to support dynamic imports, gjs added an implicit mainloop
that can drive the main context independently from other mainloops
like the one from GApplication or MetaContext.

That means that sources can now get dispatched to the main context
from the moment the plugin is started, resulting in a crash as the
association between compositor and plugin manager doesn't exist until
meta_plugin_manager_new() returns.

Make sure this doesn't happen by only starting the plugin after
meta_plugin_manager_new() has returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2242>
2022-01-25 15:15:13 +01:00
Marco Trevisan (Treviño)
8cf3485ab0 monitor-manager: Notify privacy screen changes on hotkey press
When privacy screen is changed and this happens on explicit user request
(that is not a setting change) we should notify about this via an OSD.

To perform this, we keep track of the reason that lead to a privacy
screen change, and when we record it we try to notify the user about.

When the hardware has not an explicit hotkey signal but we record a
change we must still fallback to this case.

Fixes: #2105
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
47d7bc7a13 backends/kms: Implement privacy screen handling and setting
Privacy screen events on connector are handled as notification events
that won't cause any monitors reconfiguration but will emit monitors
changed on DBus, so that the new value can be fetched.

We monitor the hardware state so that we can also handle the case of
devices with hw-switchers only.

In case a software state is available it means we can also support
changing the state, and if so expose the state as unlocked.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
4b0a10c562 backends/kms/update: Add ability to remove result listeners
We may need to remove a result listener once we've added it, and before
that it ha been processed, so add support for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
fd1f6094c9 monitor-manager: Expose the privacy screen state on DBus current state
Expose each monitor state as two booleans, not to expose the whole flags

Related-to: GNOME/gnome-control-center#909
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
f96a167aea monitor-manager: Apply privacy monitor settings on changes
When both a setting change and a monitor change happens we need to
ensure that the monitor settings are applied.
This is currently only related to privacy settings, but will in future
also handle other monitor parameters such as brightness.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
55469fda78 settings: Read desktop privacy settings and monitor privacy-screen option
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Marco Trevisan (Treviño)
f231672084 monitor: Add support to privacy screen
Some monitors support hardware features to enable the privacy screen
mode that allows users to toggle (via software or hardware button) a
state in which the display may be harder to see to people not sitting
in front of it.

Expose then this capability to the monitor level so that we can get its
state and set it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1952>
2022-01-25 07:31:19 +00:00
Sebastian Wick
8ebdae8092 launcher: Use $XDG_SESSION_ID if available
In some cases mutter is started in the user scope from a TTY (for
example using toolbox). Using sd_pid_get_session fails because it's not
in the session scope so it falls back to the primary session
(sd_uid_get_display). We want to start mutter on the TTY we started
mutter on however. Instead of relying on the scope to figure out the
correct session we first look at $XDG_SESSION_ID which is set by
systemd_pam.so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2254>
2022-01-24 18:09:44 +01:00
Robert Mader
dea9f8bbfe wayland/surface: Make ensure_cached_state() static
There is no reason for it to be public or have a return value.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Robert Mader
e3f0efa065 wayland/surface: Ensure to apply cached state
It is possible that we never create a cached state for a surface
even if it is synced. That is the case if `commit()` is never called.
We still need to call `apply_state()` in this case in order to run
e.g. `role_post_apply_state()` or `parent_state_applied` on subsurfaces.

So just ensure to initialize the cached state instead of bailing out.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Robert Mader
03434e566a wayland/subsurface: Ensure cached state recursivly gets applied on set_desync()
Subsurfaces can be effectively synced indirectly via their ancestors.
Right now such indirectly synced surfaces don't apply their cached
state when their ancestor effectively becomes desync as by the time
we call `parent_state_applied()` on them, they are considered as
desync.

Thus sligthly reoder things so when the ancestors becomes desync
and applies its state, those surfaces still count as synced and
will thus apply their cached state as well.

While on it, add a check to prevent `set_desync()` to have side
effects when the target surface is not currently synced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2232>
2022-01-19 17:13:17 +00:00
Michel Dänzer
5127f7df56 native/cogl-utils: Add 10 bpc format support
Avoids assertion failure in meta_drm_buffer_gbm_fill_timings with direct
scanout of a 10 bpc EGL client surface (which works now with dma-buf
feedback).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2230>
2022-01-17 10:39:13 +00:00
Daniel van Vugt
6673fbcf68 onscreen/native: Remove a goto in DisplayLink fallback
At first glance the `goto` looks like a loop, or potentially an infinite
loop. It's not a loop because the mode has changed at that point to
`META_SHARED_FRAMEBUFFER_COPY_MODE_PRIMARY`. But we can make it more
obvious and avoid the need for a goto.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2240>
2022-01-17 10:03:17 +00:00
Jonas Ådahl
35fa75a085 clutter/backend/x11: Remove stray whitespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
e4e0eaac9d clutter/backend/x11: Stop keeping track of the screen and root window
They are now only ever accessed via the actual X11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
cf00ee9724 stage/x11: Get root window from the X11 backend
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
c41d2a17da xkb-a11y/x11: Get X11 display from X11 backend
Instead of from ClutterX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
4622bd7ca8 xkb-a11y/x11: Cleanup include macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
7851e69bbf virtual-input-device/x11: Get X11 display and screen from X11 backend
Instead of from ClutterX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
d796c40156 seat/x11: Get root window from X11 backend
Instead of going via ClutterX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
b1fb8cbf57 backend/x11: Add API to get the X11 screen
Will be used to replace a similar ClutterX11 API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
440359e85f virtual-input-device/x11: Cleanup include macros
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
39e1d5a214 stage/x11: Fetch the X11 display pointer from the X11 backend
This eliminates going through the clutter backend singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
5eae0c84ed stage-impl: Change the backend pointer to MetaBackend
A pointer to the real backend is more useful, so lets use that. This
affects various places that now need to fetch e.g. the clutter backend
via the real backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
c0fb52cfe6 stage-impl: Move properties from the stage window here
The stage window is an interface, that added properties, that were only
then actually managed by MetaStageImpl. Shuffle things slightly, and let
the MetaStageImpl object deal with these things itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:51 +01:00
Jonas Ådahl
ed112fe0c6 keymap/x11: Store a MetaBackend pointer instead of ClutterBackend
What the keymap eventually is after, are things handled by the actual
backend (MetaBackendX11), so let it keep a pointer to that. This
eliminates some usages of globals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:48:50 +01:00
Jonas Ådahl
eae1e532dd seat/x11: Make clutter backend variable naming more consistent
Name ClutterBackend pointers clutter_backend. That'll make things less
confusing when mixed with MetaBackend pointers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
fc3b80fc60 input-device/x11: Get X11 state from the X11 backend
Go directly to the X11 backend to get the root window and X11 display
connection. This eliminates some uses of clutter globals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
05b655e60f seat/x11: Add API to get backend
Will be used instead of going via globals by places that already has a
seat to fetch things from.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
dfbe97a8e5 backend/x11: Add API to get the root window
Will later be used from here instead of via the clutter backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
6f80c1e7b5 seat/x11: Keep a pointer to the backend
This adds a pointer to the backend and replaces places that fetched
backend resources via globals (mostly via clutter).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2014>
2022-01-17 09:45:36 +01:00
Jonas Ådahl
585befbf7d tests: Add test for constraining pointer on hotplug
It tests that if we go from (x is the pointer cursor)

    +--------+
    |        |
    |     X  |
    +--------+

to
             +----------------+
             |                |
             |                |
    +--------+                |
    |        |                |
    |     X  |                |
    +--------+----------------+

i.e. making sure that X ends up somewhere within the logical monitor
region.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Jonas Ådahl
d84f7971e4 tests/utils: Add meta_wait_for_paint() helper
This function queues a full stage redraw, then waits for every view to
receive the "presented" signal before returning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Jonas Ådahl
57d1d82ead test/utils: Add helper to set custom monitors config
Make the existing implementation a wrapper to avoid changing monitor
config tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Jonas Ådahl
1f758dd78c test/utils: Make (WAYLAND_)DISPLAY passing to client optional
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Jonas Ådahl
1886785b3d test/utils: Make meta_test_client_do*() not crash on NULL error
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Jonas Ådahl
68fd9bf534 test/utils: Add vararg variant of meta_test_client_do()
To be used by wrapper that puts the error in a g_error().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Carlos Garnacho
5e3f89e342 backends: Do not try to move pointer onscreen in common code
This is now handled inside the input thread in the native backend,
and X11 has always done something similar to this. This common code
is no longer necessary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Carlos Garnacho
70e44c281c backends/native: Ensure pointer is onscreen in input thread
It's slightly racy to have the main thread update the views and warp
the pointer, since the input thread may not be aware yet of the new
viewport layout.

Make the input thread clamp the pointer so it remains onscreen
instead, when the new viewports are obtained.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/64
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2237>
2022-01-16 18:38:20 +00:00
Björn Daase
75e220a1c1 boxes-tests: Make pointer declaration match code style
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2236>
2022-01-14 20:04:20 +01:00
Björn Daase
cbc6965b80 boxes: Make pointer declaration match code style
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2236>
2022-01-14 20:02:26 +01:00
Björn Daase
5f78e932a8 boxes: Fix grammar in warning
Spotted while debugging https://gitlab.gnome.org/GNOME/mutter/-/issues/64

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2236>
2022-01-14 19:12:02 +01:00
Björn Daase
ee96ba44f9 boxes: Remove double whitespace
Spotted while debugging https://gitlab.gnome.org/GNOME/mutter/-/issues/64

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2236>
2022-01-14 19:10:20 +01:00
Jonas Ådahl
812954b22c tests: Add ways to run privileged tests without KVM
These will be skipped by default, but can be run from a TTY for easier
debugging by doing:

    dbus-run-session -- meson test -C build --suite mutter/native/tty --setup plain

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
06eb27d503 tests: Run KMS tests inside a QEMU virtual machine
This commit makes it possible to run test executables in a test
environment constructed of a virtual machine running the Linux kernel
with the virtual KMS driver enabled, and a mocked system environment
using meta-dbus-runner.py/python-dbusmock.

The qemu machine is configured to use 256M of memory, as the default
128M was not enough for the tests to pass.

Using qemu is also only made possible on x86_64; more changes are needed
for it to be runnable on aarch64, so add a warning if it was enabled on
any other architecture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
b5284e5ccc tests/dbus-runner: Add methods needed for taking control of a session
This is needed if one wants to run the test suite parts that need KMS or
evdev access in a virtual machine.

However, only initiate these methods if the meta-dbus-runner.py program
was launched with --kvm, as it's only suitable for using while running
as root in a virtual machine.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
1cc786ffd3 launcher: Pass fallback session/seat ID when in test mode
When we test, we might not have a systemd session to rely on, and this
may cause some API we depend on to get various session related data to
not work properly. Avoid this issue by passing fallback values for these
when we're running in test mode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
8372af9cd7 tests/mock/logind: Add mock seat and session
Will be needed for KMS testing in KVM.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
9538143fac dbus-runner: Add some high level logging
Will log about starting services and running test case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
8b628f0ae4 launcher: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
c8c9d49f79 Add rudimentary mode setting test
Add a test that uses vkms to test that mode setting works, and that
rendering works. It renders 10 frames in a row after mode setting, then
exits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
51368227f2 context/test: Add flag to test runner helper
This will later be used to allow skipping tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
124a1582e1 native: Replace 'headless' property with 'mode' property
There will be another mode added later, 'test'; prepare for this by
changing the existing "mode" boolean ('headless') to a mode, which is
either 'default' or 'headless'. Checking the is_headless variable is
changed to using the function is_headless(), except for one place, being
VT switching, which in preparation is only allowed on the 'default'
mode. Other places where it makes sense, the conditions are changed to
switch statements.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
a2382f3251 wayland/dma-buf: Don't warn if there was no render node
When running in KVM, the EGL driver supports querying the render node
path, but it returns NULL. Handle that better by falling back to
querying the device main device file, instead of falling back on v3 of
the protocol and logging a warning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Jonas Ådahl
719a6c0006 egl: Don't set an error when there is none
Some API will return NULL or the equivalent; sometimes it's an error,
and sometimes it's not, and the way to check that is by looking at the
return value of eglGetError(). When we check this, don't set the GError
if it returned EGL_SUCCESS, as that indicates that the return value is
expected behavior, and not an error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00
Carlos Garnacho
75f263ddb8 tests: Add tests for crossing events generated during ClutterGrab
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Carlos Garnacho
e9addb0ad7 clutter: Add ClutterSeat private API to grab devices
This will be necessary to string along ClutterGrab with backend
behavior, and mostly for the X11 backend so implement this pair
of vfuncs there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
2022-01-11 16:13:39 +00:00
Jonas Ådahl
bb6ae40a0f onscreen/native: Always free the next framebuffer on dispose
There was a sanity check that complained if there was still a "next
framebuffer" when disposing an onscreen. This is correct to complain
about under normal operation, as we always wait until receiving the page
flip callback before cleaning up the onscreen and their state.

However, when there are many hotplugs occurring, we might end up with
race conditions when the above sanity check is not valid: when we have
more than one monitor active, paint 1 one of them, but receive a hotplug
event before we paint the other(s), we will discard the already painted
onscreen before really issuing a page flip.

In this situation, we will have the "next framebuffer", but having that
is not a bug, it's a race condition, thus to not leak in this situation,
make sure to clean up the next framebuffer here too.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2081
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2225>
2022-01-09 23:03:02 +00:00
Jonas Ådahl
8e91c6295d renderer/native: Clear old KMS updates on views rebuild
If there are any pending updates, for example if we painted one of
multiple monitors but without having posted the update due to waiting
for another monitor to be painted, but before we paint all of them and
post the update, another hotplug event happens, we'd have stale pending
KMS update. When that update eventually would be processed, we'd try to
apply out-of-date updates which may contain freed memory.

Fix this by discarding any update when we're rebuilding the views. We
can be sure not to need any of the old updates since we're rebuilding
the whole content anyway.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1928
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2216>
2022-01-09 22:34:16 +00:00
Robert Mader
af08847126 Revert "backends: Don't include damage history in swap region"
This reverts commit a82dd68605.

It causes severe issues in multi monitor setups - lets back
out for now and reland a fixed version later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2220>
2022-01-08 16:01:24 +01:00
Erico Nunes
a82dd68605 backends: Don't include damage history in swap region
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 reduce the amount of rectangles that get passed to
the backend.

Also rework some of the regions that were using fb_clip_region and
missing the last scaling to support fractional scaling.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2089>
2022-01-07 21:53:09 +00:00
Robert Mader
ab17c98c94 wayland/surface: Implement WL_SURFACE_ERROR_INVALID_SIZE check
From the spec:
> This means that at commit time the supplied buffer size must be
> an integer multiple of the buffer_scale. If that's not the case,
> an invalid_size error is sent.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2188>
2022-01-07 20:46:42 +00:00
Georges Basile Stavracas Neto
77d5c8c928 screen-cast/monitor-stream: Immediately record scanout frames
When the before-paint function is executed, it's only purpose
is to check if there's any scanout queue, and immediately
record it if any.

However, since [1], we regressed in this specific case with the
introduction of an idle callback in the before-paint function.
The regression only happens when the PipeWire stream is using
DMA-BUF buffers, and it would operate as follows:

 1. In before-paint, when there's a scanout available, we queue
    an idle callback to capture the monitor. The idle callback
    (almost always) executes after the scanout is pulled from
    the stage view

 2. meta_screen_cast_stream_src_maybe_record_frame() is called
    by the idle callback. In the DMA-BUF case, it then runs
    meta_screen_cast_monitor_stream_src_record_to_framebuffer()

 3. In meta_screen_cast_monitor_stream_src_record_to_framebuffer(),
    because the stage view doesn't have a scanout anymore, it
    ends up calling cogl_blit_framebuffer() with the stage view
    framebuffer. This is the regression bug.

This regression presents itself in the form of the screencast
stream showing the desktop when there's an unredirected fullscreen
application window running.

Revert before-paint - and only that - back to immediately capturing
any available scanout. Only record these frames when the target
buffer is a DMA-BUF handle. Nothing is captured on before-paint if
the stream is not using DMA-BUF, since the regular paint routine
will handle these frames regularly post-paint.

[1] https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2186>
2022-01-07 19:59:36 +00:00
Georges Basile Stavracas Neto
8fe45d7750 screen-cast/stream: Add DMABUF-only record flag
Next commits will reintroduce a certain behavior of stage
capturing that can only happen with DMA-BUF buffers. To
control this, add a new flag tp MetaScreenCastRecordFlags
for this behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2186>
2022-01-07 19:59:36 +00:00
Jonas Ådahl
926c34cc89 wayland/dma-buf: Fix typo
A = was placed where a ; should have been placed. Caught by coverity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2215>
2022-01-07 19:31:23 +00:00
Robert Mader
df3f81e709 compositor/native: Consider Wayland subsurfaces for scanout
If a Wayland subsurface is the topmost actor, consider in for
scanout as well. This will extend our scanout capabilities to apps
like Firefox

While on it, correct a unnessary type check to a NULL check.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2211>
2022-01-07 18:54:27 +00:00
Robert Mader
8abe876d15 window-actor: Add API to get the topmost surface actor
On Wayland a window actor may have more than one surface actor,
most importantly when subsurfaces are used.
Add a new function to request the one which is at the top -
it will be used in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2211>
2022-01-07 18:54:27 +00:00
Jonas Ådahl
5523242eb9 wayland/dma-buf: Define fallback EGL_DRM_RENDER_NODE_FILE_EXT
If the EGL header is not new enough, it will not contain that relatively
new macro definition, so to avoid breaking compilation, define it
ourselves for now. Should be possible to remove after some time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2214>
2022-01-07 18:25:41 +00:00
Jonas Ådahl
13f35ab064 window: Initialize saved_rect_fullscreen too
We save the window rect before going fullscreen to a dedicated variable,
so we can go back to the correct dimension. We also have a dedicated
variable for returning from other window states, e.g. maximized, and
this one we initialized when creating the MetaWindow. This meant that we
could always rely on this being up to date on X11 windows that were
mapped maximized or fullscreen.

What the commit that introduced the saved rect dedicated for going
unfullscreen missed was to initialize the new saved rectangle too when
creating the MetaWindow. This resulted in windows mapped as fullscreen
often ending up misbehaving when unfullscreening, as mutter would tell
them to unfullscreen to 0x0.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1786
Fixes: a51ad8f932
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2210>
2022-01-07 16:18:51 +00:00
Sebastian Keller
986d3043ab x11: Avoid memory waste and work when creating selection input stream
Since every input stream now uses its own window, the X property used to
transfer the data no longer has to be unique, so we can stop generating
those unique names. This avoids creating a new atom for every transfer
since those are never freed, neither on the shell nor on the server
side. Also don't unnecessarily duplicate other strings that are
(almost) never used and get them from the atom in the rare case when
they are needed.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1812>
2022-01-07 02:21:28 +01:00
Sebastian Keller
dbd6e74d3c x11: Let selection input streams create their own window
When there are two (or more) concurrent XConvertSelection requests with
the same target, selection and window and the data is large enough for
SelectionNotify events to overlap. This can result in the affected streams
being considered completed without any data being transferred.

While regular mutter/shell code does not make use of concurrent
XConvertSelection requests with the same targets, some extensions might.
Such as for example a clipboard manager that like the built-in clipboard
manager tries to read the selection on owner-changed.

One potential solution would be to make sure the event is for the correct
property, but not all clients seem to support concurrent requests for the
same targets but different properties on the same window.

This commit instead changes the streams to use their own window which
seems to be more widely supported.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1812>
2022-01-07 02:21:28 +01:00
Sebastian Keller
d25175b91c x11: Always delete selection input stream property when flushing
This is a preparation for each input stream creating its own window. It
moves deleting the property from meta_x11_selection_input_stream_xevent
where it can run after the stream has been finalized to a spot where
the stream still exists. Use an error trap in case the property was not
set by the client, such as when the conversion failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1812>
2022-01-07 02:10:05 +01:00
Mark
888e69d3a4 plugins/default: Fix broken switch_workspace()
Swap which windows are switched with which in the workspace switching
animation of the default plugin since this was backwards (resulting in
failures), but animate only those which are on either the current
workspace or the one to switch to. Have the animation span the entire
screen as intended.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2038
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2076>
2022-01-06 16:49:25 +00:00
Fernando Monteiro
12de68abf3 wayland: Drop deprecated text input
This has been replaced for text-input-v3.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2185>
2022-01-05 22:30:21 +00:00
Fernando Monteiro
a8bf9d8c68 wayland: Drop wl-shell protocol
This protocol is deprecated since a long time, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2183>
2022-01-05 21:43:29 +00:00
Jonas Ådahl
8a2fcf3be0 wayland: Use new KMS update test API to try acquiring scanout
This significantly increases the chance of a fullscreen surface buffer
being scanned out instead of being painted via composition. This is
assuming the client supports the DMA buffer feedback Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
a14923e993 kms: Add update test API
This API can be used to construct a MetaKmsUpdate with plane assignments
that in isolation will be tested against the current KMS state. How it
is tested depends on the KMS implementation; in the simple / legacy KMS
backend, the tests are identical to the current scanout requirements
(dimension, stride, format, modifiers, all must match), and with atomic
KMS, it uses the TEST_ONLY on a real constructed atomic mode setting
commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
2022-01-05 20:00:36 +00:00
Jonas Ådahl
64e6bedb6b wayland/dma-buf: Add support for scanout surface feedback
Whenever a surface is promoted as a scanout candidate by
MetaCompositorNative, it'll get a CRTC set as the candidate CRTC.

When a client asks for DMA buffer surface feedback, use this property to
determine whether we should send a scanout feedback tranche.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
4c54b36126 wayland/dma-buf: Move should_send_modifiers() to the top
It's very much an auxiliary method; lets move it to where it belongs,
according to HACKING.md.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
43161c6660 compositor/native: Track what Wayland surface is a scanout candidate
For the current candidate, set the candidate CRTC on that surface. This
will later be used to send DMA buffer feedback for direct scanout purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
9a47766a96 wayland/dma-buf: Add tranche priorities
Unused for now, but will be added to prioritize scanout tranches higher
than render only ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
9c942a43d6 wayland/dma-buf: Make manager object a GObject
Will make certain operations easier, i.e. setting up a GQuark.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
90076cf268 wayland/surface: Remove unnecessary NULL check
This check has caused repeated confusion, as there are no current code
paths where this can ever end up in the true-branch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
2a16a750c5 wayland/dma-buf: Always advertise non-modifier fallback
This is done to explicitly tell clients that the compositor supports
implicit modifier paths (i.e. using modifier unaware API).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
7acecb1c72 wayland/dma-buf: Add basic support for DMA buffer feedback
This includes sending the default tranche, but so far only sends the
same for every surface feedback requested. Scanout tranche will be added
later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
1978e93f28 wayland/dma-buf: Prepare format/modifier map up front
As the format table is setup up front, it doesn't change when this
experimental feature setting change. Make the settings documentation
reflect that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
51308a9d78 wayland/dma-buf: Add manager struct
It'll be used to store state related to DMA buffer Wayland support.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Jonas Ådahl
7ce481bf69 egl: Add eglQueryDisplayAttribEXT() helper
To be used to fetch the EGLDevice used for an EGL display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1959>
2022-01-05 16:36:48 +00:00
Daniel van Vugt
44c09dcefe clutter: Remove unused time_us parameter from ClutterFrameListenerIface
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2161>
2022-01-05 15:57:45 +00:00
Daniel van Vugt
f5498950d3 tests/clutter/frame-clock-timeline: Loosen duration testing
The final tick of a timeline is >= its duration, but when using ticks that
are slightly in the future ("next presentation time") this means the final
tick will execute and complete the timeline up to one frame interval before
the timestamp of that final tick.

For the single clock test we now just check if the overall duration is
within one frame of the expected timeline duration.

The dual clock (switching) test needs a threshold of two frames because
starting each new clock creates a phase shift (error) of up to one frame.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2161>
2022-01-05 15:57:45 +00:00
Robert Mader
9ee03fe93b wayland: Fix some code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Robert Mader
6d1bd87b32 egl: Fix code style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Robert Mader
f51cccbc29 wayland/surface: Fix code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 20:12:41 +01:00
Jonas Ådahl
32affbf05a wayland/dma-buf: Fix building without native backend
The usefullnes of Wayland without the native backend is questionable,
but since it's theoretically possible, make it at least compile again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:24:36 +01:00
Jonas Ådahl
ae086a31dd device-pool: Remove duplicate include macro
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:24:36 +01:00
Jonas Ådahl
06c215c747 wayland/surface: Remove unnecessary resource user data changing
We're in the destructor, it's pointless to unset the userdata as we'll
never ever see a request being invoked with it ever again, since the
resource itself will be destroyed or marked as destroyed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2202>
2022-01-03 19:19:33 +01:00
Robert Mader
58f82d0624 texture-tower: Fix code style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2199>
2022-01-03 14:38:09 +01:00
Robert Mader
cd781758eb surface-actor-x11: Fix code style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2199>
2022-01-03 14:12:01 +01:00
Robert Mader
f99d3c01a4 shaped-texture: Fix code style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2199>
2022-01-03 14:11:54 +01:00
Sebastian Keller
450ab0fdb9 window-group: Disable culling when rendering to non-stage-view buffer
When rendering to a buffer that is not the stage view buffer, we can not
know where the buffer will be displayed on the screen. As a result we
also can not know what translation would need to be applied to culling.

This was causing glitches when the gnome-shell magnifier was applying
offscreen effects. ClutterOffscreenEffect causes MetaWindowGroup to be
rendered to an offscreen buffer at an offset, because it draws to a
slightly larger texture with an accordingly translated origin. This
translation then later is canceled out again when the offscreen buffer
is drawn. To meta_actor_painting_untransformed() however which only sees
the translation used when drawing to the buffer this looked like the
window group was being rendered at the offset. This then lead to
redraw_clip getting translated accordingly, resulting in wrong
coordinates used for culling.

Similarly this was leading to issues when taking area screenshots while
at 1x zoom.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1678
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4876
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2080>
2022-01-03 11:20:50 +00:00
Robert Mader
36481b8d21 gen_default_modes: Add more refresh rates to fallback modes
Refresh rates >60Hz become ever more common. In order to allow users
to keep hight refresh rates when not running at a natively advertized
resolution, add common refresh rates to our fallback modes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2189>
2022-01-03 10:48:29 +00:00
Robert Mader
fb9564b87b output/kms: Filter out duplicate fallback modes
Right now we often add a duplicate fallback mode that's almost
identical to the native mode. This adds unnecessary clutter to
UIs, thus filter out such modes.

In order to keep the code small, use `MetaCrtcModeInfo` directly
instead of recalculating the values. And to keep consistency, do
the same in the loop above.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2189>
2022-01-03 10:48:29 +00:00
Robert Mader
60d7cd82ba crtc-mode-xrandr: Take RR_DoubleScan and RR_Interlace flags into account
Otherwise we often advertise wrongly calculated modes.
Original patch from Jonas Ådahl and the xrandr project.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2190>
2022-01-02 21:10:31 +00:00
Sebastian Keller
97dd5d8877 backends/x11: Fix memory leak in meta_x11_handle_event()
The event was leaked after it had been processed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2192>
2022-01-02 12:36:30 +00:00
Sebastian Keller
3941597485 window-actor/wayland: Fix child actor list leak on dispose
The list returned by clutter_actor_get_children() is caller owned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2193>
2022-01-02 05:06:47 +01:00
Ievgen Popovych
b596de2680 wayland/window-configuration: Fix missing horizontal maximized check
Signed-off-by: Ievgen Popovych <jmennius@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2187>
2021-12-28 20:21:52 +02:00
Jonas Ådahl
fc1de74442 cursor: Hold reference to cursor tracker
This is so that it can unregister from it on tear down. The tracker owns
references to cursors too, but this cycle is already broken as the
backend calls 'g_object_run_dispose()' when tearing the cursor tracker
down.

Fixes a crash on shutdown.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2181>
2021-12-22 19:37:16 +01:00
Jonas Ådahl
287908e05a renderer/native: Don't clear GPU data with pending page flips
An incorrect assumption that after mode set there would be no pending
page flips was made. This meant that if there was a mode set, followed
by a page flip, if that page flip was for a CRTC on a now unused GPU,
we'd crash due to the renderer GPU data having already been freed. This
commit avoids that by keeping it alive as long as the page flips are
still in the air. It fixes crashes with backtraces such as

  0) meta_render_device_get_egl_display (render_device=0x0)
     at ../src/backends/native/meta-render-device.c:320
  1) secondary_gpu_state_free (secondary_gpu_state=0x1c8cc30)
     at ../src/backends/native/meta-onscreen-native.c:560
  2) meta_onscreen_native_dispose (object=0x1cb65e0)
     at ../src/backends/native/meta-onscreen-native.c:2168
  3) g_object_unref (_object=<optimized out>)
     at ../gobject/gobject.c:3540
  4) g_object_unref (_object=0x1cb65e0)
     at ../gobject/gobject.c:3470
  5) clutter_stage_view_finalize (object=0x1cbb450)
     at ../clutter/clutter/clutter-stage-view.c:1412
  6) g_object_unref (_object=<optimized out>)
     at ../gobject/gobject.c:3578
  7) g_object_unref (_object=0x1cbb450)
     at ../gobject/gobject.c:3470
  8) meta_kms_page_flip_closure_free (closure=0x1d47e60)
     at ../src/backends/native/meta-kms-page-flip.c:76
  9) g_list_foreach (list=<optimized out>, func=0x7fb3ada67111 <meta_kms_page_flip_closure_free>, user_data=0x0)
     at ../glib/glist.c:1090
 10) g_list_free_full (list=0x1cb4d20 = {...}, free_func=<optimized out>)
     at ../glib/glist.c:244
 11) meta_kms_page_flip_data_unref (page_flip_data=0x1c65510)
     at ../src/backends/native/meta-kms-page-flip.c:109
 12) meta_kms_callback_data_free (callback_data=0x227ebf0)
     at ../src/backends/native/meta-kms.c:372
 13) flush_callbacks (kms=0x18e2630)
     at ../src/backends/native/meta-kms.c:391
 14) callback_idle (user_data=0x18e2630)
     at ../src/backends/native/meta-kms.c

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
4159c76a5b cursor-renderer/native: Clear GPU state before closing device
This ensures we don't have any left over cursor GPU buffers (via
gbm_bo's) after destroying the corresponding gbm_device (owned by
MetaRenderDevice).

Fixes crashes with backtraces such as

  1) meta_drm_buffer_gbm_finalize at ../src/backends/native/meta-drm-buffer-gbm.c:450
  4) invalidate_cursor_gpu_state at ../src/backends/native/meta-cursor-renderer-native.c:1167
  9) update_cursor_sprite_texture at ../src/wayland/meta-wayland-cursor-surface.c:70
 10) meta_wayland_surface_role_apply_state at ../src/wayland/meta-wayland-surface.c:1869
 11) meta_wayland_surface_apply_state at ../src/wayland/meta-wayland-surface.c:832
 12) meta_wayland_surface_commit at ../src/wayland/meta-wayland-surface.c:993
 13) wl_surface_commit at ../src/wayland/meta-wayland-surface.c:1158
 14) ffi_call_unix64 at ../src/x86/unix64.S:76
 15) ffi_call at ../src/x86/ffi64.c:525

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
ada524265f backend: Return NULL cursor renderer if there is no seat
During tear down, if anything teared down after the seat tries to get
the cursor renderer, we'd crash trying to get it as the seat would
already be gone. Avoid this by returning NULL when there is no seat.

It's assumed that any path that will happen during tear down that relies
on getting the cursor renderer will gracefully handle it not being
present, e.g. by relying on the cursor rendering cleaning up itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
c87779f62e cursor-tracker: Add missing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Jonas Ådahl
25ed64b61d cursor-sprite: Register all cursor sprites with the cursor tracker
This will later be used to invalidate GPU state when closing device
nodes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2147>
2021-12-22 16:22:08 +00:00
Robert Mader
c498ae337f wayland/surface: Do not uncoditionally process surface damage
Most clients nowadays switched to buffer damage, most notably Mesa
and Xwayland. Thus lets avoid the extra cost of allocating three
`cairo_region_t`s and doing some calculations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
c166811695 wayland/surface: Use correct default viewport for surface damage
If no viewport is set, the neutral viewport is the surface size
without viewport destination size applied - i.e. transform and
scale applied to the buffer size. Change it accordingly, giving
us the same values we'd return in `get_width` in this case.

As result, this only changes cases where a viewport destination
size but no viewport source rectangle is set.

The change fixes exactly such cases, e.g. the Gstreamer Wayland
sink. Can be tested with: `gst-play-1.0 --videosink=waylandsink`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Robert Mader
f4717d0ac5 wayland/surface: Switch order for calculating surface damage
Process surface damage in the right order, simplifying the
calculations.

No functional change intended.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2168>
2021-12-22 12:14:29 +00:00
Olivier Fourdan
56939abd2f cursor-renderer/native: Add a means to disable HW cursors
When dealing with a faulty hardware or bugs in the driver, it might be
interesting to force the use of software cursors for debugging purposes.

Add a debug environment variable MUTTER_DEBUG_DISABLE_HW_CURSORS to
disable hardware cursors and force using software cursors.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2046
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2150>
2021-12-20 10:41:28 +00:00
Marco Trevisan (Treviño)
65df817096 monitor-unit-tests: Check orientation changes with transformed panels
Ensure that orientation changes still work as expected when using a
panel that has some native transformation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2090>
2021-12-20 10:08:13 +00:00
Marco Trevisan (Treviño)
54b36d77ab monitor-unit-tests: Take panel orientation transform in account
When checking panel orientation on logical monitors we should take
panel orientation transform to check it's properly applied, so ensure
that we're checking the right one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2090>
2021-12-20 10:08:13 +00:00
Hans de Goede
cc9bb7c516 monitor-manager: Fix orientation changes on devices with 90° mounted panels
Commit 2289f56112 ("monitor-manager: Don't apply unneeded orientation
changes") added an early return to handle_orientation_change () in case
the transform is unchanged.

But this did not take the correction of the transform for devices
with 90° mounted panels into account causing a desired orientation
change to get skipped if the new orientation matches the corrected
logical orientation from the previous transform setting.

Fix this by calling meta_monitor_crtc_to_logical_transform () on the
transform before comparing it, matching the
meta_monitor_crtc_to_logical_transform () call in
create_for_builtin_display_rotation ().

Related: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2090>
2021-12-20 10:08:13 +00:00
Robert Mader
6204769fdb surface-actor: Fix unobscurred_fraction calculation
This calculation wrongly applied a `x2 - x1` pattern.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2169>
2021-12-19 23:46:11 +01:00
Jonas Ådahl
0df12ebee6 xwayland: Don't remove /tmp/.X11-unix/X0 when running tests
When Xwayland was not initalized, we'd still clean things up. What this
accidentally meant was that the uninitialized display number 0 was
cleanud up, which very likely was main display of the host session.

What this meant in practice was that /tmp/.X11-unix/X0 was often
removed, causing every Flatpak X11 application to fail to start until
Xwayland was restarted nad the X0 socket file was restored.

Fix this in two ways: firstly only shutdown Xwayland if we ever started
it, i.e. if the X11 display policy was not 'disabled'. This should fix
the issue most of the times. Secondly only clean up the socket if it was
ever initialized. This should fix things if the socket creation failed,
as if it did, the name would be set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2162>
2021-12-19 16:52:45 +00:00
Jonas Ådahl
75d8fedcf5 tests/wayland/xdg-apply-limits: Uncomment assert
The test driver is needed for the test, so assert it was found.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
6613c24f1a tests/wayland/xdg-apply-limits: Add missing whitespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
618cc5050b tests/wayland-unit-tests: Fix some style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
3602762a18 tests/wayland-unit-tests: Add test case for remapping popup with subsurface
This test reproduces the crash in
https://gitlab.gnome.org/GNOME/mutter/-/issues/1828. It does not
reproduce with 'window-actor/wayland: Remove subsurface actors on
dispose' (dd416dd3e2). applied. This test case differs slightly
from the one that came with the dd416dd3e2 as in that it uses
withdrawn popup surfaces instead of explicitly client managed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
8a43123765 xdg-shell/popup: Reset 'dismissed-by-client' state when remapping
A popup surface can be remapped multiple times using the same
wl_surface, if a new xdg_popup object is created. To properly handle
this, we need to reset the 'dismissed_by_client' boolean to false, as
otherwise we won't allow new buffer commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
41e426af10 tests/wayland-unit-tests: Clean up toplevel_apply_limits() signal handler
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
ed4e532690 tests/wayland-test-driver: Add sync event
Will be used to signal test cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
a1d5c96e86 unit-tests: Print error when configuring context
More helpful than an assert.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
d8521ffc56 tests/wayland-test-driver: Add surface argument to sync_point request
Will allow more "specific" sync points; will be used in the future by
new tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
ed677f49ff context/test: Let g_test_init() consume argc/argv first
This allows passing e.g. -p /path/to/test to test executables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
d111c47c88 tests/wayland-unit-tests: Change to use headless backend
Change to use the headless backend with a virtual monitor, instead of
the nested backend. This means tests can create and use virtual input
devices, which isn't possible with the nested backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
7992b46566 tests/invalid-xdg-shell-actions: Avoid flakyness
The roundtrip in the handle-configure function could in theory (and in
practice in the future) happen to receive another configure event. If we
send yet another invalid geometry the second time, we log one time too
many in the server, which fails the test. Avoid this by ignoring the
second configure event; it's enough to pass through the error handling
path once.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
2021-12-19 15:48:51 +00:00
Jonas Ådahl
4469042e2a workspace: Downgrade abort() to a warning when getting index
Instead of crashing on invalid input, just log a warning and return -1.
This will hopefully result in less abort():y behavior with missbehaving
Javascript code.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4203
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2134>
2021-12-19 15:16:12 +00:00
Florian Müllner
525cb7e10e display: Add meta_display_list_all_windows()
We now have a use case in gnome-shell for getting a list of all
windows (including OR ones), but the existing API is private.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2163>
2021-12-16 16:35:15 +00:00
Florian Müllner
3643e0ba1e events: Bypass windows with modal transients
The expected behavior for modal dialogs is that the user
cannot interact with the parent window. However toolkits
like GTK and Qt can only implement that behavior for windows
within the same process.

Address this by enforcing that behavior in the compositor to
get "foreign" windows and other toolkits behave consistently.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>
2021-12-14 18:23:23 +01:00
Florian Müllner
ccf6bbc673 window: Add has_modals() function
We'll soon use that to enforce modal behavior for foreign transient
windows. It'll only be used inside mutter (for the time being), so
keep it private for now.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>
2021-12-14 18:23:23 +01:00