1
0
Fork 0
Commit graph

12176 commits

Author SHA1 Message Date
Pascal Nowack
e70fa342a9 monitor-manager: Fix minor code style issue
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3307>
2023-11-30 12:13:26 +01:00
Jonas Ådahl
822ea67358 tests/utils: Add helper for waiting for monitor reconfigurations
This is useful after having removed a virtual monitor, which
will soon reconfigure in an idle callback.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3307>
2023-11-30 12:13:26 +01:00
Jonas Ådahl
5dc0824ea9 tests/utils: Raise error if monitors changed while waiting for paint
If it does, the views we are waiting for won't get painted.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3307>
2023-11-30 12:13:26 +01:00
Jonas Ådahl
c3c144f991 color-manager: Don't try to manage virtual monitors
There is no way to set any gamma luts, or do anything other color
management related. Eventually we'll probably want to, but that requires
bringing color management plumbing to PipeWire.

Doing this is also needed when running a headless session, as when
headless, polkit doesn't let us create colord devices without explicit
user permission, meaning we'll spam the session with useless dialogs
each time a session is started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3423>
2023-11-27 14:21:37 +00:00
Carlos Garnacho
8de30c3b6e core: Disconnect notify::is-grabbed signal when closing display
Given destruction order, the display goes away before the stage, so
this lingering signal connection may trigger unintended crashes.

Fixes: 05eeb684d1 ("window: Postpone focusing until grab ended if uninteractable")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3422>
2023-11-24 13:54:05 +01:00
Daniel van Vugt
8103ebc21a backends/native: Count MetaRenderDeviceEglStream instances externally
`count_mode_setting_devices` was incorrect in both name and in function.
What it was actually doing was counting GPUs that had been registered with
the backend so far (during the `init_gpus` loop). What it was intended to
do was to count the number of `MetaRenderDeviceEglStream` instances, which
is the thing we're limited to only one of. So `count_mode_setting_devices`
would return zero whenever the first GPU initialized happened to be a
`MetaRenderDeviceEglStream`, which would in turn prevent
`MetaRenderDeviceEglStream` from successfully initializing. Seems it only
ever worked in the case of a hybrid system where the first GPU initialized
was GBM-based.

Now we count `MetaRenderDeviceEglStream` instances (zero or one) externally.
This allows initialization to succeed when it happens to be the first (or
only) GPU. And so `MUTTER_DEBUG_FORCE_EGL_STREAM=1` now works.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2905>
2023-11-24 15:07:16 +08:00
Daniel van Vugt
6cb68d39f5 native/render-device-egl-stream: Remove unused variable
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2905>
2023-11-24 15:07:16 +08:00
Michel Dänzer
69e0ce36b1 renderer/native: Try 10 bpc formats for EGL surfaces
For scanout on a secondary GPU, for the time being try only formats
which are guaranteed to be renderable with GLES3, which notably excludes
10 bpc formats without alpha channel.

v2:
* Use separate format array for 10 bpc formats without alpha.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3139>
2023-11-23 20:11:31 +00:00
Michel Dänzer
e1f795ff79 onscreen/native: Add and use choose_onscreen_egl_config helper
If the EGL_KHR_no_config_context extension is supported, use it to
choose a format per onscreen which is compatible with the scanout CRTC
and the GL rendering API used.

Suggested by Jonas Ådahl.

v2:
* Drop code which checked for GLES3 renderability. Makes no sense for
  various reasons, in particular that EGLconfigs are about EGLSurfaces,
  whereas secondary GPU contexts use an FBO for blitting.
* Use error parameter directly for meta_renderer_native_choose_gbm_format
  call (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3139>
2023-11-23 20:11:31 +00:00
Michel Dänzer
4c42eab358 renderer/native: Refactor meta_renderer_native_choose_gbm_format helper
Preparation for the following commits, no functional change intended.

v2:
* Pass through MetaEgl pointer
v3:
* Make it return gboolean (Robert Mader)
v4:
* Add debug logging and corresponding purpose parameter
v5:
* Fix excessive function parameter indentation (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3139>
2023-11-23 20:11:31 +00:00
Sebastian Wick
3897bf68f7 tests/wayland-unit-tests: Order unit test categories alphabetically
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3394>
2023-11-22 13:56:48 +00:00
Sebastian Wick
c0952f02e7 tests/wayland-unit-tests: Use the same naming convention for all tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3394>
2023-11-22 13:56:48 +00:00
Sebastian Wick
e1812dbf86 tests/wayland: Order test clients and add missing dependencies
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3394>
2023-11-22 13:56:48 +00:00
Sebastian Wick
97c1d19017 wayland-buffer: Use MetaFormatInfo to find supported formats
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3280>
2023-11-22 12:11:38 +00:00
Sebastian Wick
dbdc821ca7 multi-texture-format: Expose immutable fields directly
Split the struct into mutable and immutable parts. Access the mutable
parts via getters and the immutable parts via a single struct. This
avoids copying around the immutable parts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3280>
2023-11-22 12:11:38 +00:00
Sebastian Wick
6f1edfc776 common/drm-formats: Rename to MetaFormatInfo and simplify API
Every format kind has it's own function to search for a MetaFormatInfo
from which contains all the information.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3280>
2023-11-22 12:11:38 +00:00
Ivan Molodetskikh
2d1fc65b3a Adjust COGL_TRACE names to improve automatic processing
In profilers with a timeline or flame graph views it is a very common
scenario that a span name must be displayed in an area too short to fit
it. In this case, profilers may implement automatic shortening to show
the most important part of the span name in the available area. This
makes it easier to tell what's going on without having to zoom all the
way in.

The current trace span names in Mutter don't really follow any system
and cannot really be shortened automatically.

The Tracy profiler shortens with C++ in mind. Consider an example C++
name:

SomeNamespace::SomeClass::some_method(args)

The method name is the most important part, and the arguments with the
class name will be cut if necessary in the order of importance.

This logic makes sence for other languages too, like Rust. I can see it
being implemented in other profilers like Sysprof, since it's generally
useful.

Hence, this commit adjusts our trace names to look like C++ and arrange
the parts of the name in the respective order of importance.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3402>
2023-11-22 11:46:07 +00:00
Georges Basile Stavracas Neto
f96d6b0afe screen-cast/monitor-src: Bring back blitting
Now that the monitor screencast records to DMA-BUF buffers immediately
(since bc2f1145d8), and we know which phase of the paint rountines we
are (since last commit), we have the opportunity to bring back the
blitting technique.

Bring back blitting. This time, instead of simply failing if the blit
fails, add a fallback path that does a stage paint if something goes
wrong. Unlike the previous implementation of blitting, this one only
blits the current view - it does not blit all views that intersect
with the screencasted monitor.

Embedded cursors should still be fine because hardware cursor is
inhibited while embedded cursor screencasts are running.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3406>
2023-11-22 07:55:04 +00:00
Georges Basile Stavracas Neto
91bdb2b692 screen-cast/src: Track paint phase
Track where we are in terms of the paint cycle. Do this through an
enumeration that is passed through the paint vfuncs of screencast
sources.

Right now, this information is not used by any one of the sources,
but next patch will use it to prevent blitting when detached from
the paint cycle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3406>
2023-11-22 07:55:04 +00:00
Robert Mader
9ddb0371c6 cursor-renderer/native: Disable HW cursor when inhibited by backend
We need to disable the hardware cursor in some situations, notably when
doing a screencast with clients that require an embedded cursor.

While a API to do so is in place already, until now we didn't actually
make use of it. Do so.

Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7007

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3412>
2023-11-20 22:51:57 +01:00
Jonas Ådahl
8d3696f39a monitor-manager/x11: Ignore errors when creating tiled monitors
The error is most likely a race where the tiled outputs disappeared
before we had the chance to turn them into a whole monitor. Ignoring the
error should be harmless, as we should be receive another RANDR event
where we'd eventually fix things up.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7120
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3335>
2023-11-18 10:33:23 +00:00
Carlos Garnacho
571acf57d1 backends/native: Make tablet devices "floating"
With the existing ClutterInputMode terminology (inherited from XI2),
hardware devices may be "physical" (i.e. attached to a logical device),
or "floating" (i.e. detached from all logical devices).

In the native backend, tablet devices are closer to "floating" than
"physical", since they do not emit events relative to the ClutterSeat
pointer logical device, nor drive the MetaCursorTracker sprite. This
is in contrast to X11 where all tablet devices drive the Virtual
Core Pointer by default, along with every other pointing device.

Change this mode in the Wayland backend to be more coherent. The
existing checks on the ClutterInputMode along Mutter seem appropriate
for handling these as floating devices, since they mainly care about
logical vs non-logical.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3393>
2023-11-17 20:49:18 +00:00
Mike Gorse
c1feb2dc40 screen-cast/window-stream: Mark as configured
This is needed for the pointer to be exposed to an existing libei session.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3403>
2023-11-17 19:43:48 +00:00
Sebastian Wick
63c6fe11fb window-actor/wayland: Keep track of when the geometry needs to be synced
The window actor can be mapped every frame, e.g. when it is dragged in
the overview. This commit keeps track when the geometry changed and we
didn't managed to sync the geometry yet and need to sync it at a later
time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
9e036bfd23 window-actor/wayland: Map the window before trying to sync geometry
We need to chain up to the parent class to make sure the
WindowActorWayland is actually mapped which is required for the
sync_geometry_internal function to succeed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
2dbfc1c23d window-actor/wayland: Move map method to a more appropriate place
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
ee7f13fd84 window-actor/wayland: Return success status from syncing geometry
We do this by  moving it to a helper function. We will use this to keep
track of when syncing the geometry is actually needed in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
90d27e7b2e window-actor: Adjust sync_geometry
At the end of the sync_actor_geometry function the window buffer_rect
and the WindowActor position and size are the same and consistent.

Call the virtual method at the end and let the implementations look at
either the buffer_rect or the actor position/size itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3404>
2023-11-17 16:08:36 +00:00
Sebastian Wick
976bcef3d5 window-actor/wayland: Sync geometry only when window is mapped
In some cases the window is not mapped when the geometry changes.
Without the mapped window the surfaces are not mapped either and don't
have a sensible allocation.

This patch makes sure we abort syncing the geometry if the window is not
mapped and also make sure we sync geometry when the actor eventually
does get mapped.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3152
Fixes: 8f4ab53bd ("window-actor/wayland: Ensure to use allocation for black background check")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3401>
2023-11-15 17:03:45 +01:00
Ivan Molodetskikh
47814fab71 Remove COGL_TRACE_BEGIN in favor of BEGIN_SCOPED
Scoped traces are less error prone, and they can still be ended
prematurely if needed (this commit makes that work). The only case this
doesn't support is starting a trace inside a scope but ending outside,
but this is pretty unusual, plus we have anchored traces for a limited
variation of that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3396>
2023-11-15 13:57:43 +00:00
Bilal Elmoussaoui
371d28a766 cleanup: Stop allowing deprecated Cogl API usage
Allow only specific files to use those deprecated APIs making
it easier to find where deprecated APIs are still in use
and avoid introducing new usages without being noticed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3400>
2023-11-15 13:13:00 +01:00
Bilal Elmoussaoui
da2771e293 tests/cleanup: Stop allowing deprecated GLib API usage
We only use one deprecated API, so allow only that file to contain
deprecated APIs

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3400>
2023-11-15 13:12:13 +01:00
Bilal Elmoussaoui
7de0707dfa clutter/cleanup: Stop disabling deprecated API usage warnings
As we have stopped using the deprecated APIs all over clutter, so let us
enforce that newly introduced code doesn't use code that gets depreccated
in the future

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3400>
2023-11-15 13:12:13 +01:00
Bilal Elmoussaoui
f5dac3a5d9 build: One config file to rule them all
Group all the three config files from clutter/cogl/meta into one
and also remove unnused configurations and replace duplicated ones

This also fixes Cogl usage of HAS_X11/HAS_XLIB to match the expected
build options

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3368>
2023-11-15 12:00:19 +00:00
Michel Dänzer
ca5bf847ee wayland/surface: Rename output/protocol_state to applied/committed_state
This is more consistent with Wayland protocol spec language.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3395>
2023-11-15 10:55:21 +00:00
Ivan Molodetskikh
31c5525382 wayland/dma-buf: Name readiness source
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3398>
2023-11-15 10:24:41 +00:00
Ivan Molodetskikh
a1b2725238 thread: Name callback source
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3398>
2023-11-15 10:24:41 +00:00
Ivan Molodetskikh
6c2383d625 thread: Name wrapper source
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3398>
2023-11-15 10:24:41 +00:00
Ivan Molodetskikh
a6e23dc9e2 thread/impl: Correct task source name
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3398>
2023-11-15 10:24:41 +00:00
Ivan Molodetskikh
be81296fb2 eis: Name event source
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3398>
2023-11-15 10:24:41 +00:00
Bilal Elmoussaoui
306ff81004 clutter: Drop ClutterUnits
As nothing uses it now that ClutterScript was dropped

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3354>
2023-11-14 16:13:19 +01:00
Bilal Elmoussaoui
8a3181f741 clutter: Make json-glib a debug only dependency
Currently, json-glib is used for two things:
- For loading scripts, nothing seems to use that in real life other
than some tests
- For debugging paint nodes

For now, the PR drops the first use case and only require json-glib
if it is a debug build

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3354>
2023-11-14 16:13:18 +01:00
Zander Brown
c42fa34b01 clutter/actor: Rename ::actor-{added,removed} to ::child-{added,removed}
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3384>
2023-11-14 09:59:52 +00:00
Zander Brown
7113ecd86c clutter/actor: Take responsibility for ::actor-{added,removed}
These signals have de facto been ClutterActor signals for some time now,
simply move them in from ClutterActor

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3384>
2023-11-14 09:57:39 +00:00
Zander Brown
e1cdeb0319 clutter/layout-manager: Consume Actors not Containers
We don't actually need the host to be a container, so simply work on
actors saving us a few casts.

This'll simplify dropping ClutterContainer entirely later, and
StViewport/ShellWindowPreviewLayout will also need to be updated for the
new signatures

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3384>
2023-11-14 09:57:39 +00:00
Carlos Garnacho
9399c984cc backends/native: Avoid redundant changes to sticky keys state mask
Sticky keys configuration changes reset the pressed modifier state mask,
even though the XKB state might already match with the expected new
state. In those cases we can avoid the XKB state mask update completely.

This also fixes a crash at initialization with sticky keys toggled on,
since configuring the device a11y settings will trigger a XKB state
mask merely reassuring the initial state with no modifiers pressed,
while the connection between the ClutterSeat and the impl object has
not been set up yet. This crash was introduced by commit 00bb4190b
("backends/native: Drop device_native->seat_impl field").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3392>
2023-11-13 16:47:21 +00:00
Sebastian Wick
ad7ce7c7ca tests/stacking: Add pointer rest and auto raise tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
ac33792db4 tests/stacking: Add a test for sloppy focus
Tests that
* the window under the cursor has focus
* focus_default_window won't move the focus away from a previously
  focused window even if the cursor is somewhere else

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
de2daf65b4 wayland-pointer: Call meta_window_handle_enter when focusing desktop
When the desktop is focused instead of a window we want to tell the core
about this to handle focus-mode mouse. This is handled by looking for
CLUTTER_LEAVE events where the newly focused window is NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
49d1af2023 display: Deal with destroying windows in pointer rest callback
Take a reference to the window to make sure the MetaFocusData->window
pointer is not pointing to a freed object.

Also make sure that the window that we want to focus is not currently
unmanaging.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
44fcf33156 display: Handle entering NULL windows (desktop)
On X meta_window_handle_enter was called when the desktop window was
entered. On wayland the "desktop" is no window anymore. We still want to
inform the core that the desktop is focused, so it can unfocus windows
if focus-mode is mouse.

This commit prepares the core for handling a NULL windows to mean the
desktop.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
5a33b0075a core: Move window enter/leave to display
The following commits will make it possible to pass a NULL window to
display_handle_window_enter/leave to represent the cursor entering the
desktop. This means it can't be a method of the window class anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
c73e178a2d workspace: Refactor focus_default_window
The existing nested if-else statements are hard to follow. Handle cases
and return as early as possible.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
8a1388c930 workspace: Focus on existing focused window if possible
If we have an existing focused window that may have focus, default focus
will leave the focus there. An unmanaging window for example must not
have focus and default focus will continue to select another window in
this case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Sebastian Wick
87907674f5 tests/test-client: Use draw_surface for subsurface corner case tests
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3388>
2023-11-12 12:49:22 +01:00
Carlos Garnacho
91d70ad7a2 core: Query pad devices on MetaPadActionMapper initialization
This object might miss pad devices being made available too early
during seat construction at Mutter initialization, and not initialize
its own backing data properly for these.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3143
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3370>
2023-11-10 21:05:44 +00:00
Carlos Garnacho
2dec4dd088 core: Manage MetaPadActionMapper devices through events
Use the CLUTTER_DEVICE_ADDED/REMOVED set of events instead of the
ClutterSeat signals to track device availability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3370>
2023-11-10 21:05:44 +00:00
Florian Müllner
b611569b26 clutter/bin-layout: Remove custom alignment properties
The layout manager takes the generic ClutterActor expand/align
properties into account. Everyone should already use those instead
of the custom layout/child properties, so removing them should have
little fallout, while making for a nice cleanup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3382>
2023-11-10 00:24:26 +01:00
Zander Brown
84c3a3fbef clutter/script-parser: Drop support for child properties
Which means ClutterContainer is no longer special cased, removing one of
it's final users.

In practice ClutterScript is unused anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3377>
2023-11-09 18:11:00 +00:00
Zander Brown
7ae7beaa94 tests: Stop using ClutterContainer
clutter_container_{add,remove}_{,actor} have been deprecated for a
decade, using them rather than ClutterActor's API in tests is a tad
silly

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3377>
2023-11-09 18:11:00 +00:00
Bilal Elmoussaoui
81c75b3157 clutter/swipe-action: Remove deprecated swept signal/vfunc
Also update the test to use swipe signal instead. Nothing seems to
use the signal from GNOME Shell side though

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3379>
2023-11-09 16:42:24 +00:00
Michel Dänzer
8ec26dfd27 test/wayland: Add subsurface-corner-cases unit test
It tests various sub-surface corner cases. It would fail without the
previous fixes.

v2:
* Fix draw_descendant parameter formatting
* Make toplevel window fullscreen (Robert Mader)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
35d92e0fac wayland/subsurface: Drop unapplied subsurface state on unmap
To prevent it from getting spuriously applied if a wl_subsurface is
later created again for the same wl_surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
cdfc8cf967 wayland/subsurface: Reset position to (0, 0) in permanent unmap helper
To make sure a new wl_subsurface created for the same wl_surface won't
inherit the position from the wl_subsurface being destroyed.

v2:
* Move into permanently_unmap_subsurface

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
9dc5d98607 wayland/subsurface: Use unmap helper in destructor & parent_destroyed
Instead of duplicating the code in both.

v2:
* Rename helper to make it clear(er) that it permanently unmaps the
  sub-surface
* Move transaction allocation & commit into the helper

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
9f4eee33a2 wayland/subsurface: Remove redundant g_node_unlink call
If the sub-surface has no parent, the node was already unlinked by
get_subsurface_placement_op.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
a2863fc1ea wayland/subsurface: Hook up sub-surface placement ops in callers
wl_subsurface_place_above/below need to hook it up to the parent
surface's pending state, so that it gets picked up next time the parent
is committed.

v2:
* Adapt to wl_subsurface_destructor not resetting sub-surface position

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
6718e267fb wayland/transaction: Call add_placement_surfaces from commit
This is simpler, and makes sure it's called only once for each surface
in the transaction as committed.

v2:
* Use array for surface states with placement ops (Jonas Ådahl)
v3:
* Use GPtrArray instead of GArray (Robert Mader)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
66408f907f wayland/subsurface: Fix actor hiding in sync_actor_subsurface_state
Unmapped sub-surfaces need to be hidden instead of just ignored.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
6fd77ce515 wayland/transaction: Call sync_actor_state for unmapped sub-surfaces
This is necessary to make sure the unmapped sub-surface is no longer
visible.

v2:
* Use META_IS_WAYLAND_SUBSURFACE (Jonas Ådahl)
* Use same sequence of assignments in both cases

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Michel Dänzer
0bd40968ab wayland/transaction: Handle NULL from->state in entry_merge_into
This never happened so far, but it will with following commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3364>
2023-11-08 09:47:57 +00:00
Sebastian Keller
0807579cdd window: Add IS_ALIVE to get_property
This was causing looking glass to wrongly claim that is_alive = false
for all windows.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3367>
2023-11-08 09:02:32 +00:00
Sebastian Keller
d978ab1890 delete: Don't wrongly set window as not alive when pings are disabled
meta_display_ping_window() does nothing when check-alive-timeout is set
to 0, but meta_window_check_alive_on_event() was relying on it to reset
the events_during_ping. Without this events_during_ping was just
counting up until the threshold was reached and the window was marked as
not alive, preventing further pointer events from being sent to the
window.

Fix this by not doing anything in meta_window_check_alive_on_event() if
check-alive-timeout is 0, similar to meta_display_ping_window().

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3142
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3367>
2023-11-08 09:02:32 +00:00
Carlos Garnacho
8cae7ff0f6 core: Ignore locked modifiers in keycombo machinery
Locked modifiers should probably not have an effect on keybindings
while toggled. this is most relevant for modifiers that can be
either/both pressed or locked (e.g. Caps Lock key), if used in
keybindings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3369>
2023-11-08 08:07:41 +00:00
Carlos Garnacho
38228da550 clutter: Add ClutterModifierSet argument to key event constructor
This struct contains the pressed/latched/locked set of modifiers applying
to the event, and may be filled in by backends generating those events.
Other places where we forward modified key events, state may be normally
obtained from the original event.

Since this constructor is used in a variety of places, this commit
updates them all in one go.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3369>
2023-11-08 08:07:41 +00:00
Sebastian Keller
145cac3a37 surface-actor: Fix leak when setting non-empty clip region
When 655b4a9c75 ported this to MtkRegion, it removed the unref of the
copied region after setting it in the shaped texture.

Fixes: 655b4a9c7 ("Port to MtkRegion")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3140
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3365>
2023-11-06 20:30:37 +01:00
Corentin Noël
a772c709aa wayland/surface: Make MetaWaylandSurface public
Only expose the method to get the associated MetaWindow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3340>
2023-11-04 01:12:11 +00:00
Sebastian Wick
5dbb6c31e9 cogl: Rename COGL_PIXEL_FORMAT_G_16 with COGL_PIXEL_FORMAT_R_16
Mechanical rename. The format already describes the first two (rg/xy)
components.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3276>
2023-11-04 00:11:52 +00:00
Sebastian Wick
764d5dd67b cogl: Rename COGL_PIXEL_FORMAT_G_8 with COGL_PIXEL_FORMAT_R_8
Mechanical rename. The format already describes the first (r/x)
component.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3276>
2023-11-04 00:11:52 +00:00
Sebastian Wick
4e088cac0e core/window: Propagate focus appearance to all ancestors
The loop in meta_window_propagate_focus_appearance breaks if any
ancestor has attached_focus_window == focus_window but further ancestors
might still have a different attached_focus_window.

Continue the loop until the root ancestor instead.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2913
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3356>
2023-11-03 14:20:39 +00:00
Sebastian Wick
6f6f16c2b1 tests/wayland-test-client-utils: Sync event serial in same dispatch
If multiple sync events are send in the same dispatch, a further call to
wait_for_sync_event will get stuck. Fix this by keeping track of the
latest sync event serial in the display and always compare against that.

This also means sync event sequences must start at 0 and increase by 1.
The wayland-x11 interop test is the only one where that wasn't already
the case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3358>
2023-11-03 12:02:29 +00:00
Bilal Elmoussaoui
c79332a5f8 build: Remove no longer existing config options
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3349>
2023-11-03 11:36:07 +00:00
Bilal Elmoussaoui
57cfd1ab75 cleanup: Remove unneeded ifdef
As it is just a comment

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3349>
2023-11-03 11:36:07 +00:00
Bilal Elmoussaoui
7a6a821ed0 cogl: Drop unnused experimental API config
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3349>
2023-11-03 11:36:07 +00:00
Bilal Elmoussaoui
c683d971a1 compositor: Move region_to_cairo_path helper where it is used
The helper is X11 specific and only used once in that file. Moving
it there would help us in the future to build without cairo if x11 is disabled

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
9f58fb121f wayland: Rename peek_cairo_region to peek_region
So that grep 'cairo_' won't show these false positives and it is no longer
a cairo_region anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
655b4a9c75 Port to MtkRegion
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
7c98910488 mtk: Add a Region type
Currently, we use cairo_region_t despite it being a thing wrapper around pixman_region_32
In order to push for a cairo-less and wayland only build in the future, replace
cairo_region_t with a thin wrapper that is almost a copy of the upstream cairo implementation

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
058afb67f4 actor/frames: Check if frame bounds existing before copying them
Avoids a failure once we port to MtkRegion as we ensure that the region is not NULL

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Bilal Elmoussaoui
f84733f791 meta/stage: Check if the swap region is not empty before transforming it
As cairo_region_create_rectangles would return NULL if n_rects=0 but the upcoming
commits which port to MtkRegion disallows that

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Sebastian Wick
c645b6c6fa tests/wayland-unit-tests: Make toplevel_apply_limits easier to follow
Use the wait_for_sync_point method instead of the convoluted callback
and state handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3348>
2023-11-03 10:34:27 +00:00
Sebastian Wick
8c3c29d0c0 tests/wayland-test-utils: Keep track of process exit
Whenever a MetaWaylandTestClient exists without success the calling test
will fail. This fixes a bunch of cases where the test would get stuck
waiting for some event from the client when it already died and won't be
able to send the event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3348>
2023-11-03 10:34:27 +00:00
Sebastian Wick
10a840c92d kms/impl-device: Handle NULL gamma updates
We should not ever get one right now, but if we do, a NULL update means
we bypass the gamma LUT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3309>
2023-11-01 13:16:15 +00:00
Sebastian Wick
e21f839776 tests/dbus-runner: Detect nested invocations to skip mocking
The test and dist CI jobs run wrap the meson calls in dbus-runner to
avoid setting up dbus servers and mocking services for every test but
the dbus-runner invocation from meson test didn't actually skip all the
setup.

This nested mocking also doesn't work because the system bus is assumed
to be the host system bus and not a mocked one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2618>
2023-11-01 10:55:04 +00:00
Jonas Ådahl
e848f86514 tests/dbus-runner: Forward logind methods when not in KVM
This means one can run meta-dbus-runner.py effectively mocking
everything relevant except logind itself, meaning one can run from a TTY
and get permission to mode set etc, while still mocking things like
gsd-color, colord, etc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2618>
2023-11-01 10:55:04 +00:00
Jonas Ådahl
a174819b32 tests/dbus-runner: Move logind helper into a separate file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2618>
2023-11-01 10:55:04 +00:00
Bilal Elmoussaoui
2c4968fb41 cogl: Port Primitive away from CoglObject
- The associated CoglAttribute's are now stored in GPtrArray as suggested
by carlosg in
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193?commit_id=19b619073b3c7d311c64e0a997558f943b38c94a#note_1849281
- cogl_primitive_set_attributes was dropped for "simplicity"
especially that nothing uses it.
- As this is the last remaining CoglObject subclass, the commit also drops
all the CoglObject related macros/types

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
b044e26e62 cogl: Drop no longer used user data helpers
This also drops the test-object conform test as it doesn't do anything
interesting and the gobject qdata functionnality is already well tested
across the platform

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
9b9e12edb2 cogl: Port Node/Pipeline/PipelineLayer away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
739c59fefc cogl: Port Buffer* away from CoglObject
Make CoglBuffer an abstract class and inherit the various Cogl*Buffer types from it.
As none of the subclasses is overriding the vtable functions, they were not turned into
vfuncs but plain function pointers in CoglBuffer.
We still use _cogl_buffer_initialize until we port the various params into actual construct-only
properties, similar to the previous commit for CoglTexture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
863163cc6e cogl: Port Texture* away from CoglObject
- Make Texture a parent GObject class and move the vtable funcs as vfuncs
instead of an interface as we would like to have dispose free the TextureLoader.
- Make the various texture sub-types inherit from it.
- Make all the sub-types constructors return a CoglTexture instead of their respective
specific type. As most of the times, the used functions accept a CoglTexture,
like all the GTK widgets constructors returning GtkWidget.
- Fix up the basics of gi-docgen for all these types.
- Remove CoglPrimitiveTexture as it is useless: It is just a texture underhood.
- Remove CoglMetaTexture: for the exact same reason as above.
- Switch various memory management functions to use g_ variant instead of the cogl_ one

Note we would still want to get rid of the _cogl_texture_init which is something
for the next commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
4792db371a cogl/cleanup: Stop using CoglHandle
We use a GParamSpecPointer for CoglPipeline until that
gets ported from CoglObject

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
bbdc0b42fc cogl: Port Program away from CoglObject
This also switches from using CoglHandle to CoglProgram where
appropriate
which allowed dropping a duplicated function that had the wrong
signature...

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
3aaae11d6b cogl: Port Shader away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
c1e6948e42 cogl: Port Bitmap away from CoglObject
We still need to use set_qdata_full as CoglBitmapPixbuf would free
the data itself by unrefing the pixbuf

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
d71fe5c55e cogl: Port OnscreenTemplate away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
df8ae83040 cogl: Port Indices away from CoglObject
Also renames Indices.get_type to Indices.get_indices_type to avoid
a conflict with the generated Object.get_type function

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
f0923aab44 cogl: Port Attribute away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
312d5c367e cogl: Port Snippet away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
748c1fb9f4 cogl: Port FrameInfo away from CoglObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
2023-10-29 21:16:24 +00:00
Bilal Elmoussaoui
f2c55d6479 cleanup: Remove header only functions
The functions are defined only in the header file and don't have
an actual implementation

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3352>
2023-10-28 12:37:31 +02:00
Michel Dänzer
f128bb4db1 Remove unused _clutter_stage_window_get_wrapper
Unused since 89daa8d4fa ("wayland: drop wayland backend").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3178>
2023-10-26 09:49:29 +00:00
Sebastian Wick
cfb3a20215 core/window: Don't mark comment as documentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3347>
2023-10-25 20:45:10 +00:00
Bilal Elmoussaoui
98bd2aa2c2 clutter: Move cairo pixel format to cogl
As Cogl already defines a pixel format enum, it makes sense to move such
endian dependant pixel format there

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3086>
2023-10-25 20:03:08 +00:00
Bilal Elmoussaoui
c0fdf0a470 clutter: Drop set_source_color helper
The helper doesn't do anything that makes it worth
to be exposed as public API. End-users, such as GNOME Shell could have
an in-tree helper if they end up using it that much.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3086>
2023-10-25 20:03:08 +00:00
Sebastian Wick
9a6ddd2dff window: Add a target workspace for raise_and_make_recent
The shell might raise and make windows recent for another workspace when
an app gets activated on another workspace. Making the windows only
recent on the current workspace thus results in inconsistent focus when
another window of the same app is closed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3315>
2023-10-25 13:44:27 +02:00
Florian Müllner
13d9edc687 wayland/client: Add make_desktop() method
There are existing extensions that implement desktop icons as
a combination of a GTK program and a small extension to make
the wayland window behave as if it was of type DESKTOP on X11.

That's quite painful, as it requires reimplementing WM behavior
that is already implemented in mutter itself (stacking, stickiness,
skip-taskbar, ...), as well as modifying gnome-shell to consider
the window in addition to "real" DESKTOP windows (workspace-switch
animations, ctrl-alt-tab, ...).

In addition to that, other extensions may also have special handling
of DESKTOP windows, and their code cannot easily be monkey-patched
to handle "alternative" desktop icons.

This whole game of whack-a-mole can easily be avoided by allowing
desktop-icons extensions to mark their desktop windows as DESKTOP,
so do just that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3305>
2023-10-24 19:25:24 +00:00
Florian Müllner
6a22b52579 window: Consider stickiness changes on feature recalc
Some properties like the window type can affect the stickiness.
Make sure workspaces are updated in that case to pick up the
change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3305>
2023-10-24 19:25:24 +00:00
Florian Müllner
b9008ee83d window: Handle layer of DESKTOP windows
Assigning the corresponding stack layer of DESKTOP windows is
currently X11 specific, because there is no way for wayland
clients to set the DESKTOP window type.

This is about to change, so move the code to the generic layer
handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3305>
2023-10-24 19:25:24 +00:00
Alexandros Frantzis
3a5ecca348 wayland: Send keyboard modifiers after the enter event
Change the order of events to adhere to the Wayland specification for
wl_keyboard.enter, which mandates:

> The compositor must send the wl_keyboard.modifiers event after
> this event.

Mutter currently sends the modifiers event before the enter event,
which may break applications that require information about the focused
surface in order to properly handle the modifiers.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2231
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3341>
2023-10-24 11:18:30 +03:00
Bilal Elmoussaoui
12c85002e9 clutter: Depend on gdk-pixbuf only for tests
As clutter doesn't use any of it APIs by itself

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3097>
2023-10-23 16:32:35 +00:00
Bilal Elmoussaoui
8ae7ec08b4 mutter: Explicitly depend on gdk-pixbuf
As it is used by MetaBackgroundImageCache

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3097>
2023-10-23 16:32:35 +00:00
Bilal Elmoussaoui
138767fa7c cogl: Drop unnused functions
These functions ends-up calling gdk-pixbuf for loading textures/bitmaps
from a file and they don't seem to be used anywhere.

These changes are only useful with the following up commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3097>
2023-10-23 16:32:35 +00:00
Peter Hutterer
7a44b112c1 input-capture: Add more barrier tests, mostly for invalid barriers
Remove the warning to info since we now expect it to happen and add a
set of barrier edge cases that we expect to fail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3319>
2023-10-23 06:57:45 +00:00
Peter Hutterer
85885c6539 input-capture: Check barriers don't extend into nonexisting monitors
Create a fake monitor region right of the right-most monitor and if a
horizontal barrier extends into that region, fail the barrier. Barriers
are aligned on the top/left edge of the pixel so the most natural
barrier of (e.g. 0-1024) is also wrong - it's one pixel into the next
monitor.

Check this for nonexisting screens on the right too to avoid clients
suddenly failing when multiple monitors are present.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3319>
2023-10-23 06:57:45 +00:00
Peter Hutterer
b7078ddab7 input-capture: Fix off-by-one for barrier validation
Assuming two 1920x1080 screens next to each other: a horizontal barrier
starting at 1920 going east is always outside the left screen.

Assuming two 1920x1080 screens on top of each other: a vertical barrier
starting at 1080 going south is always outside the top screen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3319>
2023-10-23 06:57:45 +00:00
Olivier Fourdan
909cc6c240 renderer/native: Send modifiers even without AddFb2
When running headless, only the invalid modifiers are advertised.

That breaks with the NVIDIA proprietary driver which then rejects the
buffers created with the invalid modifier, and that kills Xwayland,
meaning that running Xwayland on top of a mutter based compositor
headless is not possible.

The reason the modifiers are not sent is because AddFb2 is not supported
when running headless.

Other compositors (weston, wlroots) would still send the modifiers even
without AddFb2, and Xwayland works fine on those compositors when
running headless.

Remove the requirement for AddFb2 to send the modifiers, so that
Xwayland can work fine on top of mutter headless with the NVIDIA
proprietary driver.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3060
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3320>
2023-10-18 13:19:28 +00:00
Olivier Fourdan
f1eaf26845 wayland/dma-buf: Advertise INVALID modifier without AddFb2
If DRM_CAP_ADDFB2_MODIFIERS isn't supported, scanout tranches should
advertise only DRM_FORMAT_MOD_INVALID if supported by EGL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3320>
2023-10-18 13:19:28 +00:00
Olivier Fourdan
8de5bdc89c renderer/native: Add a new has_addfb2 property
We want to be able to tell from MetaWaylandDmabuf to fine tweak when and
which modifiers should be sent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3320>
2023-10-18 13:19:28 +00:00
Robert Mader
b5a59ec109 tests/clutter/event-delivery: Avoid race with stage update
`clutter_actor_destroy()` queues a stage update. Under certain
circumstances - i.e. when run in a very slow container - this can race
with the stage update triggered by the following
`clutter_virtual_input_device_notify_button()`, occasionally resulting in
`wait_stage_updated()` to return before the
`on_event_return_propagate()` callbacks ran, making the test fail.

This notably became more common since

8f27ebf87e (clutter/frame-clock: Start next update ASAP after idle period)

landed.

Thus wait for a stage update to happen after `clutter_actor_destroy()`,
preventing the race.

Fixes: f6da583d06 (tests/clutter/event-delivery: Add tests for implicit grabbing)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3332>
2023-10-18 08:01:42 +02:00
Michel Dänzer
effc985401 tests/clutter/frame-clock*: Use clutter_frame_get_target_presentation_time
Instead of g_get_monotonic_time. This makes sure last_presentation_time_us
advances by refresh_interval_us.

Doesn't affect test results at this point, but it will with the next
commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3174>
2023-10-17 19:09:10 +02:00
Robert Mader
8d3d8b86e5 screen-cast/stream-src: Assert that dmabuf handle lookup succeeds
To prevent issues like the one fixed in the previous commit.

Also remove a redundant variable assignment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3326>
2023-10-13 16:41:04 +00:00
Robert Mader
5809ef62f5 screen-cast/stream-src: Calculate stride after adding handle to hash table
`calculate_stride()` looks up the dmabuf handle from the hash table so
we need to add it first.

Fixes 9b663f44e6

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3326>
2023-10-13 16:41:04 +00:00
Jonas Ådahl
ed6c335140 backends: Use helper to translate from/to clutter/evdev button codes
This fixes an issue in the MetaEisClient implementation which didn't
offset correctly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3325>
2023-10-13 16:24:43 +00:00
Jonas Ådahl
26b4583164 backend: Introduce helpers for turning from/to clutter/evdev buttons
We have multiple implementations of these types of transformations, and
one is broken. Instead of just fixing it, add this helper so that it can
use it instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3325>
2023-10-13 16:24:43 +00:00
Ray Strode
5d3e31a499 kms/impl-device: Inhibit real-time scheduling when mode setting
Certain kernel drivers can take an unreasonably long time to
complete mode setting operations. That excessive CPU time is charged
to the process's rlimits which can lead to the process getting killed
if the thread is a real-time thread.

This commit inhibits real-time scheduling around mode setting
commits, since those commits are the ones currently presenting as
excessively slow.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3037
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3324>
2023-10-11 10:25:55 -04:00
Ray Strode
b1db87ae30 thread: Allow turning off rt scheduling for running thread
At the moment if a thread is made real-time there's no going back,
it stays real-time for the duration of its life.

That's suboptimal because real-time threads are expected by RTKit to
have an rlimit on their CPU time and certain GPU drivers in the kernel
can exceed that CPU time during certain operations like DPMS off.

This commit adds two new ref counted functions:

    meta_thread_{un,}inhibit_realtime_in_impl

that allow turning a thread real-time or normally scheduled. At the same
time, this commit stores the RTKit proxy as private data on the thread
so that it can be reused by the above apis.

A subsequent commit will use the new APIs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3324>
2023-10-11 10:25:55 -04:00
Ray Strode
d285a9c21c tests/dbusmock-templates/rtkit: Add MakeThreadHighPriority
mutter will soon need to call an additional method in RTKit,
MakeThreadHighPriority.

In preparation for that, this commit stubs it out in the
dbusmock template.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3324>
2023-10-11 10:23:02 -04:00
Ray Strode
f46e428a5c thread: For consistency, s/real_time/realtime/
Most of the code writes "real-time" as "realtime" not "real_time".

The only exception is one function `request_real_time_scheduling`.

This commit changes that function for consistency.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3324>
2023-10-11 10:23:02 -04:00
Jonas Ådahl
b1b95c8681 tests/kms/render: Add test for setting empty config
This should disable CRTCs and unassign outputs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3318>
2023-10-11 01:57:19 +00:00
Jonas Ådahl
f9bbe22499 monitor-manager/native: Update assignments on empty-config too
Not doing so means we'll have whatever old assignments were there, which
can cause problems when e.g. newly generated output/crtc objects
automatically find old assignments.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2242612
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3318>
2023-10-11 01:57:19 +00:00
Jonas Ådahl
23876efad3 renderer/native: Clear old pending mode sets when unsetting all modes
If we queued a mode set, but didn't end up compositing all frames, we'll
have pending mode sets in a hash table waiting to be applied. If we
before all monitors again try to reconfigure things we should drop the
old pending mode sets and start fresh.

We already do this when we're doing so when generating views, but when
just unsetting modes, we didn't, so fix that.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2242612
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3318>
2023-10-11 01:57:19 +00:00
Jonas Ådahl
a4e1afc648 renderer/native: Fold mode unsetting into renamed unset_modes()
We had a function called "reset_modes()" on MetaRendererNative, but what
it expected to do was to unset all modes on all CRTCs. Despite this, it
had code to unset modes on unconfigured CRTCs, probably because it was
used for multiple things in the past.

Make this a bit easier to follow by renaming the function
"unset_modes()" and fold the function doing the unsetting into the
function itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3318>
2023-10-11 01:57:19 +00:00
Sebastian Wick
3d318e18b5 kms/impl-device/atomic: Fix blob size
Fixes: ed0682003 ("kms/impl-device/atomic: Fix stack overflow")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3323>
2023-10-11 00:54:23 +02:00
Sebastian Wick
ed06820035 kms/impl-device/atomic: Fix stack overflow
Intel has started to advertise big gamma LUT sizes on some hardware
because the hardware supports segmented LUTs. This means they have a lot
more precision at certain segments then others. The uAPI can't expose
this functionality meaningfully so they chose to expose a huge number of
TAPs to sample from to their segmented LUT.

This increase in uAPI LUT size resulted in stack overflows because we
allocated the LUT on the stack. This commit moves it to the heap
instead.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3064
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3322>
2023-10-10 14:20:27 +00:00
Robert Mader
9b663f44e6 screen-cast/strieam-src: Fix stride and max buffer size calculation
1. Centralize stride calculation in one function.
2. For dmabufs query the stride instead of assuming a certain value.
3. For system memory buffers use the pixel format to calculate the
   stride.
4. Stop negotiating `SPA_PARAM_BUFFERS_size` and
   `SPA_PARAM_BUFFERS_stride`.

2. fixes an actual bug where we reported wrong max buffer sizes,
resulting in crashes in Gstreamer when doing area screencasts on AMD
GPUs.

The reasoning for 4. is that the values were possibly wrong for
dmabufs as the negotiation happens before we create any buffers.
Further more neither Mutter nor the common consumers required it.
The later either ignore the values (OBS), always accept (gstpipewiresrc)
them or calculate the exact same possibly wrong values (libwebrtc).

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6747
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3311>
2023-10-09 23:11:16 +02:00
Robert Mader
b258e1f7ee screen-cast/stream-src: Various code cleanups
No functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3311>
2023-10-09 23:11:16 +02:00
Olivier Fourdan
dda13526c3 wayland: Add conditional Xwayland EI portal support
With EI support wired to XTEST, and oeffis being enabled in Xwayland
means that XTEST will always go through the XDG portal.

While this the intended behavior for the general use case of Xwayland
running rootless on a desktop compositor, that breaks when Xwayland is
running on a nested compositor, because the portal is for the entire
session and not limited to the nested Wayland compositor.

Enable XDG portal support in Xwayland only when we managed to connect
to the GNOME session manager, which means we are running in a full
desktop session, and not in any form of nested mode.

This is determined by simply using the status returned by set_gnome_env()
which will fail if not connected to a GNOME Session manager.

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1586
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1170
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3047
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3303>
2023-10-09 07:36:52 +00:00
Olivier Fourdan
8abbbc7ea9 wayland: Have set_gnome_env() return a status
The function set_gnome_env() is used to pass environment variables
though DBus using the "org.gnome.SessionManager".

If that fails, it means we are not running in a full environment, which
might be useful to determine whether Xwayland should enable the portal
support.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3303>
2023-10-09 07:36:52 +00:00
Olivier Fourdan
fe9017c15a xwayland: Enable optional XDG EI portal support
Xwayland has now a new command line option "-enable-ei-portal" [1] for
the Wayland compositor (who spawn Xwayland) to explicitly enable support
for XDG EI portal in Xwayland.

Add that command line option when spawning Xwayland according to what
was requested from the MetaXWaylandManager .

[1] https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1170

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3303>
2023-10-09 07:36:52 +00:00
Olivier Fourdan
e8fa92cf0e xwayland: Add EI portal support to the Xwayland manager
This adds a new API to instruct the MetaXWaylandManager to enable input
emulation XDG portal support when Xwayland is started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3303>
2023-10-09 07:36:52 +00:00
Michel Dänzer
83b762e0e4 kms/impl-device: Reverse update merge order in process_mode_set_update
This makes sure the new update takes effect over the pending update for
any common properties. It matches the other users of
meta_kms_update_merge_from.

Fixes: 27ed069766 ("kms/impl-device: Add deadline based KMS commit scheduling")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3316>
2023-10-08 19:35:36 +00:00
Rohan Hendrik Jotz-Lean
74b9d46d7c input-settings: Apply pointing stick settings
Apply the pointing stick (TrackPoint) configuration -- speed,
acceleration profile, and scrolling method -- from the gsettings desktop
schema.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3089>
2023-10-06 15:06:02 +00:00
Jonas Ådahl
1802065953 monitor-config-store: Discard config with fractional scale when unusable
When a configuration has a fractional scale, but we're using a physical
monitor layout, we can't use the scale, but if we do, we end up with
wierd issues down the line. Just discard the config if we run into this.

Eventually we probably want to store the layout mode in the
configuration so we can handle more seamless switching between physical
and logical layout mode, but first do this.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3057
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3299>
2023-10-06 13:48:53 +00:00
Robert Mader
8f4ab53bd6 window-actor/wayland: Ensure to use allocation for black background check
The surface actors may not have a valid allocation when running the
test. The preferred height, which `clutter_actor_get_size()` returns
in that case, can be wrong in certain cases, making us not add the black
background when it's actually needed.

Query the allocation instead, even at the expense of additional
relayouts.

While on it, sneak it some small cleanups.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3024
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3310>
2023-10-05 04:48:54 +02:00
Robert Mader
eafe331cf7 compositor-view/native: Skip direct scanout when using software cursors
If a cursor is visible over the scanned out actor and we can't use
hardware planes we need to go through the paint machinery.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3302>
2023-10-03 15:41:05 +00:00
Robert Mader
d71c0a94a1 stage-view: Add API to query cursor overlay inhibition
It will be used in a later commit to check if the stage-view maybe have
a software cursor on it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3302>
2023-10-03 15:41:05 +00:00
Carlos Garnacho
6fe1b3145f backends/native: Translate keycodes with xkb_key_state_get_one_sym()
There's two aspects from its documentation
(https://xkbcommon.org/doc/current/group__state.html#gae56031a8c1d48e7802da32f5f39f5738)
affecting us here:

1. "This function is similar to xkb_state_key_get_syms(), but intended for
    users which cannot or do not want to handle the case where multiple
    keysyms are returned (in which case this function is preferred)."

   We are indeed in that field, and have been for a long time.

2. "This function performs Capitalization Keysym Transformations."

   This is unlike the xkb_key_get_syms() function that we use, and
   convenient here for parity with X11 since it behaves exactly that
   way.

Fixes cases where the keysym for some keys is not properly capitalized
when caps lock is toggled, due to the output of capslock+key being
different from shift+key. An example of this is 'é' in french(azerty)
layout (bound to the '2' key). Even though shift+2 outputs '2',
capslock+é should output 'É'.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3058
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3306>
2023-09-29 13:51:36 +02:00
Carlos Garnacho
b567256873 x11: Add another mechanism to ignore crossing events
This is similar, but reserved for the crossing events induced by the
input shape changes on our overlay window. The mechanism in the previous
commit does again protect against this, so this mechanism may go away.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3267>
2023-09-28 15:39:44 +00:00
Carlos Garnacho
8b0da940cf x11: Simplify handling of focus-follows-mouse
Focus follows mouse is meant to avoid focusing windows that happened
to pop up under the pointer, e.g. due to mapping, workspace changes,
etc... On X11, this has been done since ancient times through a
moderately complex synchronization mechanism, so mutter would know
to ignore crossing events caused on those situations.

This mechanism is much prior to XInput 2 though, where we may know
this in a more straightforward way: If the sourceid of the crossing
event is a logical pointer (i.e. equals deviceid), the crossing event
was triggered logically, and not through user input.

Perform this simpler check, and drop the existing mechanism to
ignore logically induced crossing events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3267>
2023-09-28 15:39:44 +00:00
Daniel van Vugt
f23876e99e wayland/surface: Account for geometry scale in scanout check
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3025
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3290>
2023-09-28 16:37:44 +08:00
Corentin Noël
3829888463 wayland/surface: Drop undeclared function definition from header
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3298>
2023-09-27 16:53:36 +02:00
Corentin Noël
9886dcc001 wayland/surface: Expose the MetaWindow of the MetaWaylandSurface as a property
This allows Mutter users to have access to the window without having to expose
the whole MetaWaylandSurface class.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3298>
2023-09-27 16:52:07 +02:00
Jonas Dreßler
c4b9431bb2 screen-cast/stream: Pass redraw clip to stage watches instead of paint context
The virtual stream source with CURSOR_MODE_EMBEDDED uses
META_STAGE_WATCH_AFTER_PAINT as the callback for recording its frame. In
this stage of the paint though, there is no ClutterPaintContext anymore
(there only is a paint context during the paint, not afterwards).
The callback (actors_painted()) tries to get the redraw clip from the paint
context, and we end up with a NULL pointer crash.

We actually do still have a redraw clip at this point, so because everyone
uses the paint context to get the redraw clip anyway, just pass the redraw
clip to the stage watches directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3283>
2023-09-26 18:07:10 +00:00
Daniel van Vugt
7cf9997757 kms/crtc: Increase default deadline evasion to 800 microseconds
This seems to be enough to fix:
 * Constant stuttering on Apple Magic Trackpad 2 (90Hz)
 * Constant stuttering on Microsoft IntelliMouse Explorer 3.0 (125Hz)
 * Wake-from-idle frame skips on Microsoft Classic IntelliMouse (1000Hz)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2974
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3212>
2023-09-25 09:48:07 +00:00
Carlos Garnacho
39f599018c core: Do not repick pointer while syncing wayland foci
This is a remnant of unreliable pointer state after some of the
event grabbing conditions (originally introduced for window dragging
at commit 1b29113150). Since the introduction of ClutterGrab
and implicit grabs generating crossing events when the conditions
change, this is not necessary.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2977
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3287>
2023-09-21 12:28:06 +00:00
Sebastian Keller
8a5067c917 events: Don't un-bypass Clutter event handling in presence of grabs
After an event has been handled such that it bypasses both Clutter and
Wayland, e.g. when handling a keybinding, bypass_clutter would get
unset in the presence of a wayland grab. This means that the event is
handled both as a keybinding and by Clutter.

In the case of switcher popups in gnome-shell in the presence of a gtk4
autohide popover this meant that instead of selecting the next element,
it would select the one after that. If there are only two elements, as
is common with input sources, this would mean going back to the current
one, preventing switching them with a single press of the keybinding.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6738
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3054>
2023-09-21 10:00:52 +00:00
Pascal Nowack
483601844b backends/eis-client: Do not add device before adding EIS regions
When a device is added, libei does not allow adding additional regions
for that particular device, as it is already advertised to the EI
client.
As a result, mutter currently effectively only adds the first region to
a device, but not the others.
This makes input in multi monitor sessions only possible on one monitor,
as the EI client cannot look up the other regions, since they were not
advertised to it.

Fix this situation by not adding and resuming the device, when a shared
device is used.
Instead, for shared devices, always add all regions first, and then
after that, add and resume the device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3273>
2023-09-16 22:13:05 +02:00
Pascal Nowack
4c5db8e3bd backends/eis-client: Fix type of index
libei uses as index size_t. To avoid a potential endless loop due to
overflow, fix that type accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3273>
2023-09-16 22:13:05 +02:00
Pascal Nowack
83454e944b screen-cast-stream: Also release mapping id when clearing stream
Use the previously added API to release acquired mapping ids, when the
corresponding stream is destroyed.
Otherwise, the remote desktop session would maintain a whole bunch of
unused mapping ids, as their corresponding streams are already
destroyed, but maybe not the session.
Such situation would be a remote multimonitor session, where the amount
of used virtual monitors changes multiple times during the session.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3273>
2023-09-16 22:13:05 +02:00
Pascal Nowack
3461e1e18c backends/remote-desktop-session: Add API to release mapping ids
The remote desktop session currently provides a mechanism to acquire
mapping ids.
However, when they are not used anymore, they currently cannot be
removed and thus just linger around.

So, add an API to release these acquired ids.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3273>
2023-09-16 22:13:05 +02:00
Carlos Garnacho
e056ce0ea3 backends/native: Pass ClutterSeat into virtual input device constructor
Avoid passing the MetaSeatImpl, since it may be potentially null at
MetaSeatNative construction time. An example of this triggering issues
are mousekeys, since those work on an emulated pointer device created
indirectly after a keyboard device is added (and the right settings are
enabled) at a time that the MetaSeatImpl is still being created, so the
MetaSeatNative cannot yet have a reference to it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2869
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3278>
2023-09-16 10:29:21 +00:00
Carlos Garnacho
00bb4190b3 backends/native: Drop device_native->seat_impl field
Work our way to the MetaSeatImpl internally in MetaInputDeviceNative,
instead of keeping a pointer right to it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3278>
2023-09-16 10:29:21 +00:00
Carlos Garnacho
4ce97fba6c backends/native: Avoid meta_input_device_native_get_seat_impl()
These objects already have a pointer to the ClutterSeat that has a
pointer to the MetaSeatImpl in its native implementation. This data
may be considered pretty much immutable (a pointer to the seat is
held, and the native implementation will shut down the implementation
thread within ClutterSeat finalization.

Avoids some awkward code, since the MetaInputDeviceNative needs to
be aware of the Clutter object implementation and the implementation
object.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3278>
2023-09-16 10:29:21 +00:00
Daniel van Vugt
48c9b638f3 kms/impl-device: Inhibit deadline timer on vc4 (Raspberry Pi)
vc4's implementation of `drmModeAtomicCommit` seems to require a few
milliseconds advanced notice or else it will miss the frame deadline.
That's too high for our deadline evasion threshold which is measured
in microseconds. Let's stop trying to use deadline timers on vc4 to
avoid this conflict without having to disable atomic KMS.

Suggested-by: Jonas Ådahl <jadahl@gmail.com>
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2953
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3279>
2023-09-15 13:30:52 +08:00
Daniel van Vugt
eab5e94862 kms/impl-device: Rename deadline_timer_failed to deadline_timer_inhibited
Because in the next commit we'll reuse the flag for conditional
inhibition on platforms where the deadline timer doesn't fail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3279>
2023-09-15 13:25:20 +08:00
Sebastian Keller
bac157b037 tests/wayland-unit: Fix typo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3032>
2023-09-14 10:41:11 +00:00
Jonas Ådahl
ec35d74f1f wayland/idle-inhibit: Handle actor going away
There were some fixes to how to handle actor going away and being
recreated, but it didn't go all the way. This is the last step that
should have been.

Fixes: a3c62bf8aa ("wayland/idle-inhibit: Add state tracking to fix races")
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2238785
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/3014

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3277>
2023-09-13 23:06:28 +00:00
Robert Mader
a9c24ff653 multi-texture-format: Add P010 YCbCr format
It's the 10 bit equivalent to NV12 and uses the same layout as P016, i.e.
16 bit components with the lowest 6 bits set to 0 (padding), allowing us
to use 16 bit "subformats".

Thus adding support is quite trivial as we can reuse the NV12 shader.
The format is widely supported in decoding and display hardware (on Intel
since Kaby Lake), as well as modern codecs (AV1, VP9, HEVC) and has
visible quality advantages over NV12.

Note that the additional colors are lost if composited to a 8 bit RGB
framebuffer. Switching between direct scanout and compositing can thus
cause quality differences. This is no new phenomena, however, as the
same is the case already for e.g. GL clients using 10 bit formats -
including video players.

Also note that P012 and P016 could trivially added as well - it's not
done here as they are uncommen and thus hard to test.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
2023-09-13 14:11:27 +02:00
Robert Mader
66799c1aa0 multi-texture-format: Generalize shader names
These shaders can be used for similar formats with other component
sizes since the values are represented as floats. So whether the source
value was stored in 8bit, 10bit or 16bit doesn't matter - the driver
will covert it for us.

Thus use a Weston-inspired, more general naming scheme.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
2023-09-13 14:11:27 +02:00
Robert Mader
6be2add1b0 multi-texture-format: Initialize format info list with enums
To make the relations more obvious.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
2023-09-13 14:11:27 +02:00
Robert Mader
15320b5a66 cogl/pixel-format: Add G16 and RG1616 pixel formats
They are needed as "subformats" for higher bit YCbCr formats, such as
P010, and we don't plan to use or expose them otherwise. Thus don't
implement any conversion or packing features.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3244>
2023-09-13 14:11:27 +02:00
Jonas Ådahl
4ff54997b6 cursor-renderer/native: Create all view objects before realizing
Realizing a cursor will assume view related state objects are valid so
they can mark them as dirty. This assumption broke when there were a
scale changed that happened with multiple CRTCs, as we'd create view
object by view object as we realized the texture. Realizing the texture
would trigger a signal that had the handler assuming the validity of all
view objects, but if we only had gotten to the first, the second view
would not be there yet, thus we'd be doing a NULL pointer dereference.

Creating the view objects first, then handling the updating avoids this
problem by making the already done assumption valid on hotplugs.

The test case added tests exactly this series of events, and uses a
virtual monitor as a cheap trick to make the KMS CRTC based view the
first one, and an arbitrary view the second that previously had its view
object initialized too late.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3012
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3262>
2023-09-13 10:38:06 +00:00
Jonas Ådahl
c7efb68ff1 wayland/pointer: Update cursor surface when current surface changes
The cursor surface is decided by the "current" surface; if that alone
changed (e.g. current surface was destroyed), we didn't update the
cursor, meaning it either got stuck, or got hidden if the client exited
completely.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3262>
2023-09-13 10:38:06 +00:00
Jonas Ådahl
838d8881d9 tests/kms/cursor-hotplug: Remove extra trailing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3262>
2023-09-13 10:38:06 +00:00
Jonas Ådahl
a4aaee06f6 tests/kms/hotplug: Add missing newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3262>
2023-09-13 10:38:06 +00:00
Jonas Ådahl
2e295e269c tests/kms-cursor-hotplug: Clean up virtual monitor at end of test
Otherwise it'll leak into the next test, when we add one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3262>
2023-09-13 10:38:06 +00:00
Sebastian Wick
e3b659cfe8 monitor-manager: Add logging to enabling and disabling HDR mode
It's hard to tell why turning on HDR mode failed without these log
messages. It could be missing support in the sink (EDID/DisplayID) or
missing support in the driver/display hardware (connector properties) or
just a failure turning it on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3251>
2023-09-13 08:19:23 +00:00
Sebastian Wick
c96341dcd5 output: Validate EDID information as UTF-8 only if it exists
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3021
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3268>
2023-09-12 20:48:18 +02:00
Sebastian Wick
4514d29c90 edid: Copy the Manufacturer Code char array to a NULL-term string
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3268>
2023-09-12 20:06:22 +02:00
Sebastian Wick
de4cf18bd0 edid: Move libdisplay-info and fallback code around
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3116>
2023-09-12 17:52:34 +02:00
Sebastian Wick
d382d55eae edid: Fix up libdisplay-info support
* The code did not compile before.
* Change the MetaEdidInfo struct to be more friendly to libdisplay-info
* Change to nit based luminance from encoded values

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2896
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3116>
2023-09-12 17:52:34 +02:00
Jonas Ådahl
4749c073eb monitor-manager/xrandr: Trap DPMS changes
Apparently DPMSForceLevel() can fail to force a valid level sometimes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2857
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6883
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3160>
2023-09-12 14:41:26 +00:00
Carlos Garnacho
4075847278 backends/native: Use correct constructor for CLUTTER_TOUCH_CANCEL events
We were using the generic constructor for BEGIN/UPDATE/END events, that
have more data than CLUTTER_TOUCH_CANCEL. Since that function checks for
the event type, we were awkwardly forwarding a NULL event here.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/3016
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3261>
2023-09-12 13:38:16 +00:00
Jonas Ådahl
b6c7303ee9 window: Mark the suspend-state property with (skip)
The enum used is private, and lets for now declare it private API.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3018
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3263>
2023-09-12 10:46:58 +00:00
Daniel van Vugt
c7815f33a2 backends/x11: Trap errors from XIAllowTouchEvents
And report them as debug messages instead of crashing. We don't want them
to be visible usually because failures are expected in the autodeny
code path.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2808,
        https://launchpad.net/bugs/2029413

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3253>
2023-09-07 15:04:55 +08:00
Carlos Garnacho
80e15775a5 compositor: Fix surface accounting at MetaWindowActor
When the actor gets a new "main" surface assigned, it adds the
new surface to the stack of surface actors, but forgets to remove
the old one.

This stale pointer in the array may cause invalid reads and crashes
after the assigned surface is disposed, e.g. when destroying the
MetaWindowActor tries to disconnect signals from all accounted
surface actors.

Fixes: 9a2c8b2592 ("window: Add suspend state")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3252>
2023-09-06 18:13:00 +02:00
Joan Torres
33eef7211a launcher: Fix unrefing seat_proxy
When using meta-laucher headlessly, there isn't a seat_proxy.
In that context, doing directly g_object_unref gives an error.
This commit fixes it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3249>
2023-09-06 13:02:30 +00:00
Florian Müllner
bc74d166dd window: Really fix portrait orientation check for tiling
Commit 3bfcb6d1 fixed the check for tiling via keybindings, but
ignored a subtle edge case when tiling with the pointer: The
monitor used for tiling is the monitor with the pointer, which
is not necessarily the one that contains the largest part of the
window.

That is, the correct monitor to check against depends on the
context where the function is called. We can either figure
it out automatically via the current window drag, or make it
a parameter.

The latter is clearer, because the callers already decide which
monitor to use for tiling anyway.

Fixes: 3bfcb6d1b9 ("window: Fix portrait orientation check for tiling")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3248>
2023-09-06 12:36:57 +00:00
Carlos Garnacho
a6bda759f9 wayland: Do not trigger focus sync when destroying data offers
These objects are tied to the keyboard focus lifetime, but do not drive
it in any way. There is likewise no need to synchronize Wayland focus
when those are destroyed, that will be triggered through crossing events,
surface destroy notifications, etc...

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2993
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3246>
2023-09-06 10:55:55 +00:00
Daniel van Vugt
7c8f1b4cc0 compositor/multi-texture-format: Cache snippets
These snippets are retrieved anew every time a window is resized. But
callers never modify them, they're effectively read-only so cache them
at the place of creation.

This is required to convince the pipeline hash that each reuse of the
same snippet really is the same snippet and so the pipeline is unchanged.
`CoglPipelineSnippetList` only does shallow comparisons and there's no
need right now to reimplement it as a deep comparison.

This eliminates the log message:

> Over 50 separate %s have been generated which is very unusual,
> so something is probably wrong!

which isn't actually a leak but more a warning about wasting time.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6958
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3224>
2023-09-06 10:26:48 +00:00
Carlos Garnacho
6427b5b1f6 backends/x11: Prevent uneven error traps init/deinit on GInitable failure
GInitable initialization is failable, currently, it may fail before error
traps are initialized, but error traps would be invariably deinitialized on
finalize() of the failed object. This results in an assert hit, on top of the
original failure to initialize the backend.

The libX11 error handlers are a pure client-side construct, and not a server
request, they just need XInitThreads() called to set up the library-side locks
protecting access to the global variable. This is done beforehand already at
meta_backend_x11_init(), so initialize the error traps around that time too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3242>
2023-09-06 10:03:21 +00:00
Carlos Garnacho
cc874f5d33 x11: Avoid poking MetaCompositor during MetaDisplay destruction
Commit 9c3b130f67 changed slightly destruction order to handle use-after-free
situations, but missed a small new one introduced by the order change: The
MetaX11Display may schedule callbacks through MetaLaters, which depend on the
MetaCompositor, which is now freed before the MetaX11Display.

Since there is no winning move here, make the MetaX11Display aware of this
by avoiding to remove the callback if the MetaCompositor is already gone.
The MetaLaters infrastructure is already fully freed at this point (incl. the
data it contained), so this shouldn't be a leak.

Fixes: 9c3b130f67 ("display: Fix destruction order")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3247>
2023-09-06 09:28:09 +00:00
Uzair Ahmad
3bfcb6d1b9 window: Fix portrait orientation check for tiling
Use work area from the monitor that the window is currently on to
determine if tiling should be allowed.

Window tiling is disabled for monitors with portrait orientation, but
the work area we use to detect portrait orientation is taken from the
monitor that currently has the mouse pointer.

This works fine for edge tiling using the mouse, but this is broken when
using keybindings for window tiling because your mouse pointer could be
on a different monitor that has horizontal orientation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3199>
2023-09-05 20:13:48 +00:00
Bilal Elmoussaoui
81a12a7db4 cleanup: Replace cairo_matrix_t with graphene_matrix_t
Reduce cairo usage where graphene can do a much better job

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3243>
2023-09-05 18:25:49 +00:00
Jeremy Cline
379996a63e onscreen/native: Check frame_info for null in finish frame callback
While adjusting the monitor layout of my docked laptop, mutter got a
segfault while attempting to dereference the frame_info struct. This
happened on gnome-shell 44.4-1.fc38.

cogl_onscreen_peek_head_frame_info() just forwards the call to
g_queue_peek_head() which returns NULL in the event that the queue is
empty. If finish_frame_result_feedback() is expected to always be called
with a non-empty queue there's still a bug somewhere, but regardless
this API can legitimately return NULL so it should be checked for prior
to dereferencing.

Fixes: 61801a713a ("onscreen/native: Avoid freezing the frame clock on failed cursor commits")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3229>
2023-09-05 16:26:49 +00:00
Jonas Ådahl
fddcf8ca91 renderer/native: Don't drop disable-only mode set updates
If we are making an update that only disables CRTCs, we would not
actually post it, but just drop it then post nothing, as it wasn't ever
added to the mode set update hash table. This resulted in hotplugs where
we loose the all the connectors we had, where we want to disable all
CRTCs and enable nothing, to fail to disable said CRTCs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3073>
2023-09-05 12:41:41 +00:00
Jonas Ådahl
15a3c47df5 eis: Rebuild absolute pointers when any viewport changes
This fixes remote desktop client side resize via changing virtual
monitor stream sizes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3241>
2023-09-04 12:14:42 +02:00
Jonas Ådahl
1a1a16324b remote-desktop/session: Only add configured streams as viewports
This means they will have a valid size/position. This makes absolute
pointer events work on virtual monitor streams again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3241>
2023-09-04 12:14:42 +02:00
Jonas Ådahl
264d29b435 screen-cast/session: Use add_stream() helper everywhere
It was introduced, but using it everywhere appropriate was forgotten.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3241>
2023-09-04 12:14:42 +02:00
Jonas Ådahl
242737c4dc screen-cast/stream: Add 'is-configured' property
When this is TRUE, it has a size, position etc. Only virtual streams do
this asynchronously, as they go via monitor configuration after being
created.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3241>
2023-09-04 12:14:42 +02:00
Jonas Ådahl
731c3e0ba3 screen-cast/stream: Keep track of object properties
This will make it possible to emit notify events without going via
strings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3241>
2023-09-04 12:14:42 +02:00
Barnabás Pőcze
9c3b130f67 display: Fix destruction order
MetaCompositorX11 might need the MetaDisplay's x11_display
during shutdown (meta_sync_ring_destroy -> meta_sync_free),
and `meta_display_shutdown_x11()` needs the MetaStack as
it calls `meta_stack_{freeze,thaw}()`. So fix the order
of destruction so that dependencies are destroyed
after dependants.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2852
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3202>
2023-09-03 23:31:37 +02:00
Barnabás Pőcze
d6b3679bd3 core: Subscribe to stack changes in the stack-tracker
This removes the implicit dependency on `display->stack_tracker`
existing and being valid in `on_stack_changed()` because
now it is the stack-tracker's responsibility to subscribe
to the "changed" signal of the stack and handle the changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3202>
2023-09-03 23:31:37 +02:00
Carlos Garnacho
af10ead918 x11: Find nearest input affecting _NET_WM_MOVERESIZE X11 requests on Wayland
The _NET_WM protocol, written before the birth of XInput 2.x, does have
no notion of different input devices whatsoever. Anyways, in a X11 session
it is safe to assume this refers about the Virtual Core Pointer since
every input device by default drives it (incl. touchscreens through the
"pointer emulating sequence", and styli).

This assumption falls apart in a Wayland session with non-pointer input,
since we do actually distinguish between all the distinct pointer devices
and touchpoints, and do not let them emulate mouse input.

We do need to specify a device/sequence there to drive the window
move/resize operation. The _NET_WM_MOVERESIZE message just gives us the
x/y root coordinates the resize was started from, so work from there
into guessing what is the most likely device/sequence that did trigger
the request on the client side.

Conversely, on Wayland we do not need to check for possible race
conditions in the pressed button states since we have larger guarantees
about not missing these events if we checked for the button modifier
mask beforehand, so make that race condition check specific to the
X11 sessions.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2836
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3059>
2023-09-03 20:59:16 +00:00
Jonas Ådahl
7c2453cd8c screen-cast/stream-src: Fix min/max framerate typo
The min was set to the max, and the max was set to the min, making
virtual monitors refresh rate very very slow.

Fixes: 215b91a2e6 ("screen-cast/src: Consider preferred format for stream")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3239>
2023-09-03 22:19:23 +02:00
Jonas Dreßler
e303551745 backend: Ignore events without source_device for pointer visibility
There can be events which don't not have source devices set on them, because
they are not backed by real hardware and rather generated by us, for example
IM events coming from the shell's OSK.

So don't assume all events have a source device in
update_pointer_visibility_from_event() and rather ignore those without one,
as we are only interested in events coming from "real hardware" here.

This fixes an issue where the mouse pointer would appear on devices without
any input from actual mice/touchpads on OSK key presses.

Fixes: 6aa42d6dad
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3236>
2023-09-03 19:38:07 +00:00
Jonas Dreßler
e5b50d14cf wayland: Get device directly from clutter in get_grab_info() for touch case
When we call get_grab_info() to get the sequence, device and coordinates for
a touch window drag, as the device we use the device from the
MetaWaylandPointer, assuming that it's set to the core pointer.

In the case where there is no pointer device present on the seat (so no
mouse nor touchpad), the wayland pointer remains disabled though, and
pointer->device is NULL.

This means touch window dragging on hardware without pointer devices
present is broken (because MetaWindowDrag assumes that there's a valid
device passed in meta_window_drag_begin()). Fix it by taking the core
pointer directly from ClutterSeat instead of going the extra detour through
MetaWaylandPointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3238>
2023-09-03 09:12:29 +00:00
Georges Basile Stavracas Neto
94a39087bc eis-client: Always set has_position variable
If meta_eis_viewport_get_position() returned FALSE, the variable
'has_position' would be initialized. This variable represents
exactly the return value of meta_eis_viewport_get_position(),
so just assign it to the variable directly.

Spotted by Coverity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3237>
2023-09-02 19:05:13 +00:00
Pascal Nowack
38cdaaf1f8 backends/eis-client: Use scroll source 'wheel' instead of 'unknown'
CLUTTER_SCROLL_SOURCE_UNKNOWN only generates continuous scroll events
and no discrete scroll events.
As a result, scrolling only works in applications, that support high
resolution scroll wheels, like GTK4 applications.
GTK3 applications, on the other hand, don't support high resolution
scroll wheel events, and such scrolling does not work in these
applications.

Fix this issue by using the scroll source CLUTTER_SCROLL_SOURCE_WHEEL.
Since commit 92a90774a4 ([0]),
CLUTTER_SCROLL_SOURCE_WHEEL generates discrete events to ensure that
scrolling in legacy applications still works.

[0]: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2664

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3235>
2023-09-02 11:58:35 +00:00
Jonas Ådahl
b20d7a5cc4 renderer/native: Don't queue mode set on hotplug power-save on
We need to trigger a mode set when power-save changes to 'on' if it's
purely about power saving, but when they arrive as part of a hotplug
event, we'll handle all that later, in the monitors-changed handling,
that contains the new configuration.

This avoids a crash that happens due to the mode set being queued on now
disabled connectors.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2985
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3233>
2023-09-02 11:07:39 +00:00
Jonas Ådahl
efbb8df611 tests/kms/hotplug: Clean up signal handlers in switch-config test
They remained connected, and poked at subsequent tests stack, causing
unexplainable crashes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3233>
2023-09-02 11:07:38 +00:00
Jonas Ådahl
96d4ae5ac8 monitor-manager: Add 'reason' argument to 'power-save-changed' signal
We can change power save mode for two reasons: gsd-power told us to, or
we saw a hotplug event. Sometimes it's useful to be able to make the
distinction to why a power save mode changed, so add a reason to the
signal.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3233>
2023-09-02 11:07:38 +00:00
Daniel van Vugt
444e241ab4 kms/impl-device: Don't skip set_needs_flush during a page flip
If the deadline timer is disabled (like on nvidia-drm or when
`MUTTER_DEBUG_KMS_THREAD_TYPE=user`), then we need to call
`meta_kms_device_set_needs_flush` on every cursor movement. But some were
getting skipped if they coincided with page flips, which resulted in some
cursor movements failing to schedule the frame clock. This resulted in
unnecessary levels of frame skips when using lower frequency input devices
which are less likely to provide another event within the same frame period.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3002
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3210>
2023-09-02 10:30:58 +00:00
Carlos Garnacho
7224bb8a8d backends: Drop X11 ClutterBackend error traps
Replace these with Mtk error traps altogether, and avoid stacking
one API over the other here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Carlos Garnacho
99bcd20f0a backends/x11: Add pair of error trap init/deinit calls
Add a pair of calls to ensure the error trap infrastructure
survives for the MetaBackend. This will help on later commits that
largely operate on the MetaBackendX11 Display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Carlos Garnacho
ef366c5fcb mtk: Make error traps multi-display
Keep a per-display list of error traps, so we don't mix them
together, and possibly deem unintended error traps outdated.

This means init/deinit calls are now stackable, and need to
happen evenly. In order to honor this, move the MetaX11Display
error trap destrution to finalize.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Carlos Garnacho
6f46edd93b x11: Replace Mutter X11 errors with Mtk ones
Use Mtk X11 errors in favor of our own implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Jonas Ådahl
88fef1d021 wayland/idle-inhibit: Handle immediate inhibitor destruction
If the inhibitor object was destroyed immediately, the proxy
construction completing would try to update the inhibitation state, but
this didn't work since it was already freed. Fix this by adding an
'initializing' state that keeps track of this.

Fixes: a3c62bf8aa ("wayland/idle-inhibit: Add state tracking to fix races")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2998
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3234>
2023-09-01 23:17:06 +00:00
Jonas Ådahl
10d8c5fa82 tests/dbus-runner: Add mocked screensaver service
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3234>
2023-09-01 23:17:06 +00:00
Jonas Ådahl
4a600e1031 test/wayland: Don't double-free GThreads
g_thread_join() frees the thread object, so don't use g_autoptr
(Gthread) when they will all be joined.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3234>
2023-09-01 23:17:06 +00:00
Joan Torres
adf12504c0 backends/native: Set headless mode when no seat_id
This forces not using the seat_proxy. But still allows the use of
session_proxy.

On tests, headless mode is explicitly set and it might not be available a
systemd session. To avoid test failing on this situation skip using
meta_launcher wich uses session_proxy and seat_proxy.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3093>
2023-09-01 17:05:16 +00:00
Jonas Ådahl
f0bb540797 remote-desktop/session: Add regions for all monitors if input-only
If we're a input-only remote desktop session, create libei regions on an
absolute pointer device corresponding to all logical monitors. This
allows absolute pointer motions without screen casting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:45:33 +02:00
Jonas Ådahl
b23225cea8 eis: Don't treat EIS errors as fatal
g_error() is fatal, but EIS errors are not necessarily that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:44:01 +02:00
Jonas Ådahl
69fad154b9 eis: Use either standalone or shared devices for absolute input
Sometimes it makes no sense to have a shared pointer device, for example
when they have no set region occupying the global stage coordinate
space. This applies to for example window screen cast based pointer
device regions - they are always local to the window, and have no
position.

We do need shared absolute devices in some cases though, primarily
multi-head remote desktop, where it must be possible to keep a button
reliably pressed when crossing monitors that have their own
corresponding regions.

To handle this, outsource all this policy to the one who drives the
emulated input devices. Remote desktop sessions where the screen casts
correspond to specific monitors (physical or virtual), we need to make
sure they map to the stage coordinate space, while for window screencast
or area screencasts, we create standalone absolute pointer devices with
a single region each.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:44:01 +02:00
Jonas Ådahl
d4559a9ca4 screen-cast: Implement MetaEisViewport in all stream types
This will be used to describe a eis_region in a eis_device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 15:44:01 +02:00
Jonas Ådahl
7faac2aef4 remote-desktop/session: Add API to acquire new mapping ID
They are guaranteed to be unique per session, and never reused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
b3ba8aedcb eis: Tear down in dispose
This means clients can disconnect signals without warnings being logged.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
27b790d8c1 screen-cast: Pass remote desktop session on construction
We already have the remote desktop session ID, and we'll soon need the
actual remote desktop session in the screen cast session, so pass it on
construction.

The old screen cast type is set implicitly instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
f5e063ab57 eis: Fix header include style
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
271fb86b15 eis: Add "viewport" interface
A MetaEisViewport represents an absolute region backend by e.g. a
pointer device. There are two kinds: a standalone viewport, which
corresponds to a viewport that has no neighbours, and a non-standalone,
which represents a region of a global coordinate space.

The reason for having non-standalone viewports is to allow to mirror the
logical monitor layout of a desktop, while the standalone are meant to
represent things that are not part of the logical monitor layout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
12c7c1bffb eis/client: Add user_data to add-device helper
This will allow passing extra context to the configure function.
Currently all NULL, but preparing for the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
63acc732ad eis: Add some spacing in API declarations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
2eda81aadf remote-desktop/session: Limit device type access when using libei
The portal could limit access to certain device types, but this was not
forwarded to the EIS context. Add a way to do this, and make use of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
72cc627546 eis/client: Fix minor coding style issues
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
e2a9e6c36b eis/client: Fix indentation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
0160f3c0a0 remote-desktop/session: Take over EIS context
This means there will be an EIS context per session, which will enable
per session devices and region.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
ce61c8dc61 eis: Don't expose global socket
How EIS will be used depends on its context, meaning we'll have multiple
EIS contexts that expose different things. To prepare for this remove
the global socket since that won't work with multiple contexts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Jonas Ådahl
7e8bc5850e eis: Remove meta_ prefix from variables
This is more or less never used elsewhere, so don't start here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3228>
2023-09-01 10:43:26 +00:00
Bilal Elmoussaoui
da380f2732 boxes: Drop the MetaRectangle typedef
As gjs actually doesn't support typedef/aliases and there is now
a workaround from gnome-shell instead as part of
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2930

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3231>
2023-09-01 09:42:48 +00:00
Daniel van Vugt
98738535dc thread: Remove unused variable when HAVE_PROFILER is not defined
This fixes a compiler warning:
```
meta-thread.c:297:16: warning: unused variable ‘context’ [-Wunused-variable]
  297 |   MetaContext *context = meta_backend_get_context (priv->backend);
      |                ^~~~~~~
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3223>
2023-08-31 22:18:11 +00:00
Daniel van Vugt
fdbd38121b x11/events: Don't define an unused function when tracing is disabled
This fixes a compiler warning:
```
src/x11/events.c:523:1: warning: ‘get_event_name’ defined but not used [-Wunused-function]
  523 | get_event_name (MetaX11Display *x11_display,
      | ^~~~~~~~~~~~~~
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3223>
2023-08-31 22:18:11 +00:00
Carlos Garnacho
aed9f7eb9d backends: Make base MetaCursorRenderer implementation want an overlay
This used to be the behavior, until commit 5d35138df0 changed the meaning
of the return value of MetaCursorRendererClass::update_cursor(). This
made the user of pure-overlay cursors (singular, MetaWaylandTabletTool)
miss their overlays.

Change the return value, so that it matches the desired behavior of
a backend-less overlay-only cursor renderer.

Fixes: 5d35138df0 ("cursor-renderer: Make 'handled_by_backend' state 'needs_overlay'")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3218>
2023-08-31 21:46:35 +00:00
Carlos Garnacho
d24be90941 backends/native: Fix accounting of cursor overlay inhibition
We react on changes to has_hw_cursor, but always try to inhibit if
there is no cursor sprite. While this looks like a reasonable optimization
with the typical situation of one cursor renderer, it may fall into
inhibiting twice without knowing to unwind, e.g.:

1. has_hw_cursor: TRUE, cursor_sprite: !=NULL -> inhibit
2. has_hw_cursor: FALSE, cursor_sprite: NULL -> inhibit
3. has_hw_cursor: TRUE, cursor_sprite: !=NULL -> uninhibit, but once

And this may also result in the CLUTTER_PAINT_FLAG_NO_CURSORS flag
staying on for Tablet cursors, that (so far) always use overlay paths.
This results in invisible tablet cursors after using the mouse at
least once.

Fixes: e52641c4b6 ("cursor-renderer/native: Replace HW cursor with KMS cursor manager")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3218>
2023-08-31 21:46:35 +00:00
Carlos Garnacho
630f13db78 x11: Handle ConfigureRequest events in frames
Under strange timings, the GTK frames client may implicitly queue
relayouts that end up disagreeing with the latest frame size as
given by Mutter, this results in GTK calling XResizeWindow, and
Mutter plain out ignoring the resulting XConfigureRequestEvent
received.

This however makes GTK think there's pending resize operations,
so at the next resize it will freeze the window, until enough
resizes happened to thaw it again. This is seen as temporary
loss of frame-sync ness (e.g. frozen frame, and other weird
behavior).

In order to make GTK happy and balanced, reply to this
XConfigureRequest, even if just to ignore it in a more polite
way (we simply re-apply the size Mutter thinks the frame should
have, not GTK), this results in the right amount of
ConfigureNotify received on the frames client side, and the
surface to be thawed more timely, while enforcing the size as
managed by Mutter.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2837
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3189>
2023-08-31 20:53:04 +00:00
Daniel van Vugt
025e5d5327 Remove unused *.pc.in
It seems *.pc are instead now entirely generated from meson.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3226>
2023-08-31 09:47:50 +00:00
Bilal Elmoussaoui
788caf76aa boxes: Add an alias for MetaRectangle
This is meant for compatibility purposes with the shell extensions
avoiding to break a bunch of them in the last minute and we would
drop it in the GNOME 46 release.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
640cbf339f tests: Move Mtk specific tests from boxes
More of the boxes tests would be moved once we have a new region type

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
1abef24154 mtk: Move Rectangle.from_graphene_rect from Meta
And drop the clutter helper

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
a93471eb90 mtk: Move Rectangle.to_graphene_rect from Meta
Also drops the clutter equivalent

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
3d693e8309 mutter: Completely replace MetaRectangle with MtkRectangle
There are still various helpers that might be worth to move to mtk as
well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
aec8e50df8 mtk: Move Rectangle.[contains|could_fit]_rect from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
eafe07de31 mtk: Move Rectangle.overlap_* from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
db77759938 mtk: Move Rectangle.area from Meta
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
af7c7befd8 mtk: Move Rectangle constructors from Meta
Also rename the rect constructor from mtk_rect to mtk_rectangle_new so
it is detected as a proper constructor instead of a random function by
g-ir-scanner

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
565acaed9c mtk: Move Rectangle.intersect from Meta
Also replaces it usage everywhere & remove the Clutter helper. Note the
tests were not moved yet to mtk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
6f66dd9944 mtk: Move Rectangle.union from Meta
Similar to Rectangle.equal. The clutter helper was not used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
9b2cba4e86 mtk: Move Rectangle.equal from Meta
Moves equal the equal function and removes the clutter equivalent. The
tests were not moved until all the remaining helper functions are moved.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
918ae0f4d4 mutter: Replace cairo_rectangle_int_t with MtkRectangle
Note: the various helpers in boxes.c were not ported yet, see the next
commit. This was intentionally done to simplify the porting process

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
765a918a62 build: Add a Meta Toolkit private library
Currently, Meta/Cogl/Clutter makes use of cairo_rectangle_int_t despite
the existance of MetaRectangle.

In order to make MetaRectangle usable in Cogl/Clutter as well, Mtk would
provide such base types that are shared across the various private
libraries

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Sandro Bonazzola
ff4d87727b Update license access method
Dropped obsolete Free Software Foundation address pointing
to the FSF website instead as suggested by
https://www.gnu.org/licenses/gpl-howto.html
keeping intact the important part of the historical notice
as requested by the license.

Resolving rpmlint reported issue E: incorrect-fsf-address.

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3155>
2023-08-30 08:48:23 +02:00
Bilal Elmoussaoui
b004d1c577 cleanup: Drop empty vfuncs overrides
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3209>
2023-08-29 23:38:32 +00:00
Carlos Garnacho
7d8d7c89d4 backends: Check that buffer age is available when checking damage history
This used to be the case before the refactor at commit 43cee4b6b6,
use_clipped_redraw would be unset before the larger check if has_buffer_age
was set, but clutter_damage_history_is_age_valid() was FALSE. This got
replaced by a check just on the latter, which will also be FALSE if
has_buffer_age is not present.

We have other means to achieve clipped redraws, so this slight change
culled all of them.

Fixes: 43cee4b6b6 ("stage-impl: Do clipped redraws when drawing offscreen")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2771
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3221>
2023-08-29 11:27:35 +02:00
Jonas Ådahl
a3c62bf8aa wayland/idle-inhibit: Add state tracking to fix races
This changes how state is tracked by introducing an explicit state. We
need this since we use asynchronous calls to the out of process
component that handles actual inhibitation, including idleness.

This means if inhibitations changes rapidly, we might end up with an
incorrect state if we e.g. try to uninhibit while we're currently trying
to inhibit.

This is done by adding a state variable that accounts for the pending
state, as well as the active state, with a function that looks at the
current conditions to derive what state we should be in, and what state
we are in, to decide what the next action should be.

For example, if we're trying to inhibit, but now wants to uninhibit,
we'll wait for the inhibit call to complete, recheck what we want, which
would result in an async uninhibit call being made.

Fixes: 388b534062 ("wayland: Implement idle inhibit protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 19:16:04 +02:00
Jonas Ådahl
34b60757c2 wayland/surface: Add signal for when the actor changes
This can happen on a xdg-toplevel that is remapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 16:25:08 +02:00
Jonas Ådahl
170ba63dbf wayland/idle-inhibit: Change to use GObject signals
Fixes: 388b534062 ("wayland: Implement idle inhibit protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 16:25:03 +02:00
Jonas Ådahl
45abae7ebb wayland/idle-inhibit: Remove confusing comment
Something about the surface being destroyed and visibility checked,
which isn't what is going on.

Fixes: 388b534062 ("wayland: Implement idle inhibit protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
2023-08-28 16:24:59 +02:00
Charbel Assaad
388b534062 wayland: Implement idle inhibit protocol
This is based on the original work done by:
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/111

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/20
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3145>
2023-08-26 20:19:22 +02:00
Sebastian Keller
8db400660a backends/x11: Drop warning about libinput property item count
libinput 1.3 introduced a custom acceleration profile extending the
related properties from 2 to 3 items, which now triggering this warning.
This does not have a functional impact since GNOME currently does not
make use of the new profile. Also increasing the libinput version
dependency which would be needed to change the expected item count is
not possible in a stable release either. So just drop this warning to
be compatible with newer versions of libinput.

See: https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput/-/merge_requests/39#note_1656566
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2987
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3215>
2023-08-26 12:15:47 +02:00
Jonas Ådahl
e683264051 tests: Add metatests for cloned windows and suspend state
Tests https://gitlab.gnome.org/GNOME/mutter/-/issues/2984.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
87b7b073d3 window-actor: Don't update suspend state if no window
If the window is gone, don't try to update it. This might happen on
unmap animations with active clones.

Fixes: 9a2c8b2592 ("window: Add suspend state")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2984
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
cb6290832e tests/test-runner: Add utilities for testing cloned windows
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
9df38c2126 tests/test-runner: Fix include order
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
baa0f62ced tests/shell: Restore minimized actor state in idle callback
This fixes the following
1. Minimize window; minimize animation starts
2. Do something that immediately destroys the animated actor (e.g. terminate)
3. This triggered the timeline of the animation to emit a "stopped"
   signal while all transitions of the actor were destroyed

Previously we'd implicitly animate the scale again (set_scale(..)) which
created a new transition The hash table iterator didn't like this and
abort():ed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 21:15:07 +02:00
Jonas Ådahl
1e25cb746a window: Don't update suspend state after unmanaging
The actor will try to update the suspend state when it goes away, which
can in the case of unmap animations be after the window was unmanaged.
In this case, don't try to update any suspend state.

Fixes: 9a2c8b2592 ("window: Add suspend state")
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2984
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 15:48:19 +02:00
Jonas Ådahl
b743cc3528 tests/test-runner: Add 'sleep suspend_timeout' command
It's a tweak to the 'sleep' command to allow well known sleep lengths.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3213>
2023-08-25 15:47:05 +02:00
Jonas Ådahl
5071a6df87 wayland/xdg-shell: Set the suspended state to suspended windows
This will allow clients to e.g. enter power saving mode when they are
e.g. on another workspace, minimized or fully obstructed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:58 +00:00
Jonas Ådahl
3af02e1b57 wayland/xdg-shell: Implement support for xdg_toplevel.wm_capabilities
Nothing dynamic yet, we don't have API for this, but we need it to
implement the next version. Sending "all" should be equivalent to v4
anyhow, so this is harmless.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:58 +00:00
Jonas Ådahl
9a2c8b2592 window: Add suspend state
The 'suspend state' is meant to track whether a window is likely to be
visible any time soon. The hueristics for this are as follows:

 * If a window is hidden, it will enter the 'hidden' state.
 * If a window is visible, and unobscured, it will enter the 'active'
   state.
 * If a window is visible, but obscured by another window, it will enter
   the 'hidden' state.
 * If there is a mapped clone of a window, it will enter the 'active'
   state.
 * If the window has been in the 'hidden' state for 3 seconds, it will
   enter the 'suspended' state.

This will eventually be communicated to Wayland clients so that they can
change their behaviour to e.g. save power.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:58 +00:00
Jonas Ådahl
2d7a062913 window-actor: Be more consistent declaring the property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3019>
2023-08-24 19:57:57 +00:00
Niels De Graef
069fe8e915 src: Chain up to finalize()
We forgot to chain up to the parent class' `finalize()` vfunc in both
`MetaEis` and `MetaEisClient`. Plugs 2 (probably tiny) memory leaks.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3203>
2023-08-22 21:57:07 +02:00
Daniel van Vugt
c4d7265656 kms/cursor-manager: Transform cursor movement from view space to CRTC
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2955,
        https://gitlab.gnome.org/GNOME/mutter/-/issues/2957

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3180>
2023-08-22 15:16:27 +00:00
Daniel van Vugt
ca27dbabd9 backends/native: Pass cursor transform from renderer to cursor manager
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3180>
2023-08-22 15:16:27 +00:00
Daniel van Vugt
5a05b1a901 monitor-transform: Invert the behaviour of transform_point
Previously it transformed a physical CRTC coordinate to a logical desktop
coordinate. But current and future users of the function all require
conversion from logical coordinates to physical coordinates. We would have
had to always invert the transform parameter which is a waste of time when
we can instead just invert the function behaviour.

We also simplify the parameters to show both the point coordinate and the
area dimensions are potentially transformed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3180>
2023-08-22 15:16:27 +00:00
Sebastian Keller
133931e3a3 core: Don't unmap XWayland windows without buffers on visibility update
18be74ed was changing meta_window_should_be_showing_on_workspace() to
only show XWayland windows when they have buffers to prevent starting
transitions with a seemingly black window.

This however did not just delay the transition, but when called in
meta_window_update_visibility() could result in the X11 window getting
unmapped again if the call happens before there is a buffer. Then,
depending on the client, the window would either remain hidden or if the
client tries to map the window again, this would repeat the process,
triggering the closing transition every time.

This commit instead just hides the XWayland window from the compositor
but keeps the corresponding X11 window mapped while it does not have a
buffer yet.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2611
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2965
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2820
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2867
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3194>
2023-08-21 18:32:41 +00:00
Carlos Garnacho
5d72be4016 backends/native: Regain time precision in a11y generated events
Get times in microseconds, instead of converting from milliseconds.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3190>
2023-08-21 15:11:15 +00:00
Georges Basile Stavracas Neto
d4c923edf9 screen-cast/window-src: Report alpha-enabled pixel format
This allows windows screencasts with proper shadows, instead of
a black border around the window!

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2099
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:42:04 -03:00
Georges Basile Stavracas Neto
215b91a2e6 screen-cast/src: Consider preferred format for stream
When creating a new stream, check if the preferred format is
different from the default (COGL_PIXEL_FORMAT_BGRX_8888). If
it is, then also include it in the list of potential formats
for the stream.

COGL_PIXEL_FORMAT_BGRX_8888 is still passed around as it's
both the default, and the fallback for when things go wrong.

When creating buffers, use the negotiated SPA format instead
of a hardcoded value. We leave it to PipeWire to figure out
what's the best format, since clients may not support the
preferred format of the stream.

Due to how chaotic things got, this commit also cleans up
the create_pipewire_stream() to use an auxiliary array of
SPA formats, which is then iterated on in order to generate
the format pods.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:42:04 -03:00
Georges Basile Stavracas Neto
b6bf6572a1 screen-cast/src: Add get_preferred_format vfunc
This allows subclasses to hint which pixel format they would
prefer to be used. It may or may not be respected, depending
on the available hardware capabilities.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
e24be82c12 backends/screen-cast: Pass pixel format to DMA-BUF constructor
Following the previous commit, do the same function parameter
treatment to meta_screen_cast_create_dma_buf_handle().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
b391ded7bf renderer/native: Try to convert and use Cogl format
Convert the CoglPixelFormat format to a DRM format, and try
and use it to create a GBM buffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
b814aff600 common/drm-formats: Add function to map Cogl → DRM
It's basically the reverse mapping. It does not deal with
multiplanar formats.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
fdc3f3fec3 cogl/renderer: Pass pixel format to DMA-BUF constructor
In future commits, we will want to create DMA-BUFs with pixel
formats other than COGL_PIXEL_FORMAT_BGRX_8888. In preparation
for that, let's start passing a new pixel format parameter to
this function, and the corresponding winsys vfunc.

All callers of this function pass COGL_PIXEL_FORMAT_BGRX_8888
for now. Next commits will change that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Georges Basile Stavracas Neto
14ed29e7b2 renderer/native: Trivial variable rename
Rename 'format' to 'drm_format' to not clash with following
commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
2023-08-19 23:00:28 -03:00
Sebastian Keller
73bc074917 core: Destroy the correct opaque region when destroying a frame
Freeing the window opaque region rather than the frame one when was
leaking the frame opaque region and wrongly setting the window opaque
region to NULL.

Fixes: 82b2b7688 ("core: Add infrastructure to keep window frames' opaque regions")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-17 00:00:55 +02:00
Sebastian Keller
f57c239a26 kms/cursor-manager: Free struct in meta_kms_cursor_manager_impl_free()
The free function was not actually freeing anything, which was causing a
small leak.

Fixes: 6d873036e ("Add KMS cursor manager")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-17 00:00:39 +02:00
Sebastian Keller
5fdb6a847f kms/update: Free struct in meta_kms_crtc_color_updates_free()
The free function was only freeing the structs its members were pointing
to, but not the struct itself, causing a small leak.

Fixes: 0180ffdaa ("backends/native: Introduce MetaKmsCrtcColorUpdate")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-16 21:24:28 +02:00
Sebastian Keller
193a21c601 surface-actor-wayland: Fix leak in apply_transform()
Using g_object_get() to get the allocation creates a copy that needs to
be freed by the caller.

Fixes: e94b52777 ("surface-actor/wayland: Implement stable size and position rounding")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-16 21:24:28 +02:00
Sebastian Keller
03ba3a825e context: Fix a small leak in meta_context_main_get_x11_display_policy()
The caller of sd_pid_get_user_unit() is supposed to free the unit name
string.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3188>
2023-08-16 21:24:28 +02:00
Carlos Garnacho
90a00dae99 compositor: Handle grab state through ClutterStage::is-grabbed handler
This is something the compositor could now track by itself, instead of
being pushed through events. It also makes more sense to do this directly
when the grabbing conditions change, as opposed to the next event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
0b9f5ae75b tests: Add test case for restoring focus after overview
This is a test case for
https://gitlab.gnome.org/GNOME/mutter/-/issues/2690.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
05eeb684d1 window: Postpone focusing until grab ended if uninteractable
When GNOME Shell is in the overview, we don't want windows to steal
focus left and right, but once we leave the overview, we do want
whatever was mapped with "take_focus" to get focus. Do that, but after
the last grab was dismissed.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2690
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
587c31b611 tests/test-runner: Add toggle_overview command
This will emit the `overlay-key` key which will be handled by the test
shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
8268ec2ee8 tests/test-shell: Emulate overview grabs
This mimics what gnome-shell does when the overview is shown. This means
having a grab active, and setting the keyboard focus to the stage
itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
524c9aa458 tests: Introduce and use a custom test shell
Except for the tests that launches `mutter`, use a custom shell
implementation. It's roughly a copy of default.c with some cleanups on
top. A custom shell allows for a bit more freedom when doing testy
things.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
2023-08-16 15:34:46 +00:00
Jonas Ådahl
92051d59a6 constraint: Use WxH format for size in debug logs
Whether W,H or +W,H means "size" or "position" is rather unclear; fix
that by formating size as WxH instead of +W,H.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3124>
2023-08-12 21:11:15 +00:00
Bilal Elmoussaoui
cd27cb5c85 cleanup: Fix various typos
Using the typos cli app

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3169>
2023-08-12 20:13:37 +00:00
Michel Dänzer
04f18ae726 backend/x11: Free barriers in meta_backend_x11_dispose
Should fix a memory leak.

Fixes: 0debb24e12 ("barriers: Make barriers fully part of the
backend").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
b081e51a21 Remove unused meta_x11_display_increment_event_serial
Unused since dfcefd3315 ("Remove meta_core_increment_event_serial").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
1a5fb51396 Remove unused meta_window_x11_has_active_sync_alarms
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
75a7870259 Remove unused meta_wayland_tablet_pad_group_lookup_resource
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
76c5eb0060 Remove unused meta_wayland_pointer_constraint_get_seat
Unused since 8a8d47725c ("backends: Delegate pointer confinements to
an impl object").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
09feed5d21 Remove unused meta_wayland_data_device_is_dnd_surface
Unused since 6ec7fa2cbd ("wayland: Use surface role when special
casing surface commits").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
16e8bb34de Remove unused meta_stack_get_bottom
Unused since 1b3a58c951 ("...").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
830f8fcf06 Remove unused meta_seat_x11_lookup_device_id
Unused since d72bacb3cd ("backends/x11: Drop handling of
XI_DeviceChange").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
58326c85a4 Remove unused meta_seat_impl_get_devices_in_impl
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
43716457d1 Remove unused meta_renderer_x11_nested_ensure_legacy_view
Unused since fc8a4afc45 ("Remove meta_is_stage_views_enabled()").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
3b847f28ad Remove unused meta_region_scale_double
Unused since 8b3c1f4b87 ("cullable: Generalize actor coordinates space
translation for regions").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
65add94bfd Remove unused meta_rectangle_edge_to_string
Unused since 52bc675fcb ("introspection: remove --allow-unprefixed")
(if ever used at all).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
15df7c62a3 Remove unused meta_power_save_to_dpms_state
Unused since 5f6aee3419 ("kms/update: Make power saving an update wide
change").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
c3afdefd15 Remove unused meta_output_is_laptop
Unused since cbb2a286f2 ("monitor-manager: Don't use wacky physical
dimensions in display name").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
d3ec28848b Remove unused meta_monitor_get_crtc_mode_for_output
Unused since e52641c4b6 ("cursor-renderer/native: Replace HW cursor
with KMS cursor manager").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
7f9b71cd42 Remove unused meta_kms_update_drop_plane_assignment
Unused since 02b1cfe08f ("onscreen/native: Handle unexpected scanout
failures async").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
f4b8704ae9 Remove unused meta_keymap_x11_get_key_group
Unused since 09b956997c ("backends/x11: Drop platform-specific event
data").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
fbe904471c Remove unused meta_get_renderer_native_parent_vtable
Unused since fe72876b20 ("cogl/onscreen: Make swap_buffer/region
CoglOnscreen class vfuncs").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
a9b42c5c10 Remove unused meta_frame_native_set_kms_update
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
a828eab13c Remove unused meta_crtc_kms_is_gamma_invalid
Unused since 24bdafa220 ("onscreen/native: Track GAMMA_LUT
invalidations here").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
3bf3b14e3f Remove unused meta_crtc_kms_get/set_cursor_renderer_private
Unused since e52641c4b6 ("cursor-renderer/native: Replace HW cursor
with KMS cursor manager").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
bdad097af1 Remove unused *_menu_for_rect functions
Unused since 84785951fd ("x11: Remove MetaX11WindowControl").

v2:
* Leave struct _MetaPluginClass::show_window_menu_for_rect, still used
  by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
63a7313a1b compositor: Fold meta_compositor_do_manage into meta_compositor_manage
meta_compositor_manage hasn't been public API since 4b3cab2cca
("compositor: Don't make internal API public").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
bf53623128 Remove unused meta_clutter_x11_get_root_window declaration
The corresponding definition was removed in e4e0eaac9d
("clutter/backend/x11: Stop keeping track of the screen and root window").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
b0c6864b28 Remove unused meta_stack_get/set_positions
Unused since 9e51d98f4a ("Remove tabpopup and friends").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Bilal Elmoussaoui
f2f9e63568 build/gi: Set header & pkgconfig names
So that the docs generated by gi-docgen contains them

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3087>
2023-08-12 19:34:20 +00:00
msizanoen
6b79a0bae1 cullable: Split unobscured and redraw clip region culling
This splits culling into two different phases to move unobscured region
culling to pre-paint to fix #2680. This is needed as direct scanout
skips the paint phase altogether, but the pre-paint phase always runs as
it's used for selecting the direct scanout surface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3127>
2023-08-12 10:27:45 +00:00
Carlos Garnacho
1d6d8d45d0 clutter: Update ClutterActorClass event vmethods to use ClutterEvent
With the ClutterEvent subtype structs sealed, this remains the only useful
struct type that is now usable on the Javascript side. Make all
ClutterActorClass event vmethods use ClutterEvent, and update all users
to this change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3163>
2023-08-09 11:53:18 +00:00
Carlos Garnacho
f168866369 backends/native: Fix handling order of key event
First create the event with the current xkb modifier mask, then
update the xkb_state and the modifier mask. This is how it happened
before commit 2e8d839708, and how it should stay.

Fixes: 2e8d839708 ("backends/native: Port to new event constructors")

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2951
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3162>
2023-08-09 11:36:42 +00:00
Carlos Garnacho
dc527ed510 backends/native: Close the input thread in all situations on dispose
In test situations we sometimes do not create a libinput context, so
our check on dispose to see if we need closing the input thread is off
if META_SEAT_NATIVE_FLAG_NO_LIBINPUT was provided.

Check the input thread existing instead, since that is the thing we
want to undo here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
ba4795a5f9 tests: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
60aa098e94 backends/x11: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
dbbfd03436 backends/native: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
8f3e503c04 backends: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
64490c3489 wayland: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
71fb87a9f2 compositor: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:13 +02:00
Carlos Garnacho
17191d5a6c core: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:11:11 +02:00
Carlos Garnacho
9dd2edac18 clutter: Add private call to describe an event
Move the string construction bits in the event logging happening in
MetaSeatImpl to a clutter_event_describe() call, so that it has more
freedom in fiddling with ClutterEvent internals, and may be potentially
reused in other places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
97213041e8 clutter: Add getters/arguments for missed ClutterEvent fields
Add methods, and change the API of some rarely used methods, in order
to make all event info currently held/necessary accessible through
ClutterEvent getters, instead of direct field access.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
562c5532c4 backends/native: Rewrite event for sticky keys
Avoid modifying the event in place, and use a full copy with changed
modifiers, for sticky keys purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
2c86bff0cc backends/x11: Drop clutter_event_set_state_full() helpers
Since the full decomposed modifier state is unused, and only the
effective modifier mask matters to users, the new constructors take
just this effective modifier mask. This	means this helper went
unused in the port to the new constructors, so can be now dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
a837b105d0 backends/native: Drop clutter_event_set_state_full() helpers
Since the full decomposed modifier state is unused, and only the
effective modifier mask matters to users, the new constructors take
just this effective modifier mask. This means this helper went
unused in the port to the new constructors, so can be now dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
2e8d839708 backends/native: Port to new event constructors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
1f9e787b83 backends/x11: Use new constructor for emulated pointer events
Use the new constructor to generate a synthesized motion event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
75e8bab1c1 backends/x11: Use new event constructors
Use the new event constructors to create input events, instead
of creating them through clutter_event_new (CLUTTER_NOTHING) and
struct field fiddling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
85b13ebd18 core: Pass ClutterStage explicitly to MetaGestureTracker
Pass a ClutterStage argument explicitly, instead of fetching it
from the event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
77510ca72d wayland: Avoid getting the ClutterStage through ClutterEvents
Fetch the ClutterStage through other means, as that field will go
away from events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
af9d406610 tests: Avoid getting the stage through ClutterEvents
Obtain the stage through other means, as this information will
eventually move away from events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
6fd7f95ed3 tests: Port faked events to new constructors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:02:54 +02:00
Carlos Garnacho
c5fc9481c5 backends/x11: Drop return value from main XEvent handler
This return value is unchecked, and may be removed. While at it
rename the function to meta_backend_x11_handle_event().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:00:35 +02:00
Carlos Garnacho
ca3256ee97 backends/x11: Rename function to reset X11 cached current monitor info
This is done from the backend X11 connection, but needs directing at times
from the frontend X11 connection. Commit 5a8509f895 added a XEvent
argument presumably for possible future expansions that did never come.

Since this function is nothing about events, drop the XEvent argument and
make the name a little bit more ad-hoc (according to what it does, at
least).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:00:11 +02:00
Carlos Garnacho
d5938958c0 clutter: Drop ClutterBackend translate_event vmethod
Despite the attempt to make this a generic interface, this was
pretty much used only by the X11 backend, and now it ported away
from it.

This now stands unused and may be removed, in favor of backends
each creating and injecting events as they please.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
b3d6ae34ee backends/x11: Handle MetaSeatX11 event translation in main event handler
This is about the only reason now to go through the ClutterBackend
translate_event vmethod. We can do that directly, and stop requiring the
generic vmethod that is actually just used for X11 events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
990a50539e backends/x11: Handle stage events from the main XEvent handler
This does not do any event translation, so does not need to be
handled through the translate_event() ClutterBackend vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
830a5c0caa backends/x11: Drop unused event time accounting in MetaClutterBackendX11
This has been unused for some time, by the looks of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
a5519fe544 backends/x11: Drop MetaClutterBackendX11 event filters
These are now unused, and may be removed. Event handling in
the backend Display should happen directly from the XEvent
handler from now on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:43 +02:00
Carlos Garnacho
def478edc8 backends/x11: Handle a11y changing XKB events together with other XKB events
There's no need for an XEvent filter, since this is already code close enough
to MetaBackendX11 XEvent handling and always required anyways. Make the a11y
configuration checks happen directly from MetaBackendX11 event handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:59:41 +02:00
Carlos Garnacho
0dfb5d1c31 backends/x11: Call cogl xlib event handler directly when handling XEvents
We are pretty much guaranteed that the first event will be handled after
the cogl renderer has been set up. We can avoid the loop through
ClutterBackend vmethods and X11 event filters, and call this directly
from the code that is already close to the MetaClutterBackendX11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
a08eea7f10 backends: Do not use clutter_event_[set|is]_pointer_emulated()
Add a new ClutterEventFlag to propagate this information, affecting
a few selected events on each backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
9e96b523ea wayland: Change MetaWaylandDragDest::motion vmethod signature
Stop taking a ClutterEvent and pass the essentials here (x/y/evtime),
we don't have a ClutterEvent handy in all places that we call this
API, and it feels awkward to create one just for calling this vmethod.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
2e3d55c948 clutter: Change clutter_do_event() name/signature
It is a bit backwards that events contain information about
the stage they are being handled by. It makes more sense to
specify in the ClutterEvent handling entrypoint the stage
that will handle the event.

As a first step, add this ClutterStage argument, even though
the information is still carried through the event in order to
keep satisfying calls to the getter function.

This entrypoint has been also renamed to clutter_stage_handle_event(),
so that its ownership/namespace is clearer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Carlos Garnacho
72c433ef02 compositor: Stop forwarding MapNotify events back through the backend
Nowadays, all our MapNotify event handling happens already prior to
the MetaCompositorX11 handling of XEvents. It does not make sense to
channel these events again through the backend, at best all it could
lead to is double handling of the same events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 03:58:42 +02:00
Bilal Elmoussaoui
a955f0e47c cleanup: Make include macro usages consistent
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
ead9a3024c cleanup: Switch to pragma once
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Olivier Fourdan
d291d4a733 settings: Set xwayland_allow_byte_swapped_clients at startup
The value for the key "xwayland-allow-byte-swapped-clients" was being
updated on change, but never actually set at startup.

As a result, Xwayland was spawned with byteswap clients disabled, even
if the key was set to TRUE.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2938
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3156>
2023-08-07 22:08:37 +00:00
Olivier Fourdan
b9b26cba03 settings: Use appropriate type for xwayland-allow-byte-swapped-clients
The key "xwayland-allow-byte-swapped-clients" is of type boolean, it's
not a flag.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3156>
2023-08-07 22:08:37 +00:00
Olivier Fourdan
e35eafebba settings: Remove stray new line
Cosmetic only, no functional change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3156>
2023-08-07 22:08:37 +00:00
Jonas Ådahl
8a20d20fe9 kms/cursor-manager: Set hotspot
This is important when running via virtual machines.

Fixes: 6d873036e0 ("Add KMS cursor manager")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2916
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3147>
2023-08-07 21:27:53 +00:00
Jonas Ådahl
6ea816184d cursor-renderer/native: Scale hotspot correctly
This got lost during the switch to the KMS cursor manager.

Fixes: e52641c4b6 ("cursor-renderer/native: Replace HW cursor with KMS cursor manager")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3147>
2023-08-07 21:27:53 +00:00
Jonas Ådahl
730efb17d7 cursor-renderer/native: Change comma to semi colon
It was a typo.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3147>
2023-08-07 21:27:53 +00:00
Bilal Elmoussaoui
68b4cc661d clutter: Remove deprecated & unnused enums
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Bilal Elmoussaoui
185058456f clutter: Remove deprecated BoxLayout pack-start property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Bilal Elmoussaoui
8d038789f6 clutter: Remove deprecated macros usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3103>
2023-08-07 19:30:34 +00:00
Carlos Garnacho
cd39ba8baf core: Get per-direction pad feature labels for rings/strips
Let the caller specify the directions, so that the pad OSD UI may
assign distinct labels to each direction, instead of showing an
unified one on both directions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
3e3660ae5f core: Drop META_PAD_DIRECTION_NONE
Avoid this strange value, and stick with the ones suitable
for rings/strips.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
3e6f7a9463 core: Drop META_PAD_FEATURE_BUTTON value
This is now handled externally through separate API calls.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
2da9b67673 core: Separate pad button labels in high-level MetaDisplay API
These "features" are somewhat less featured, it's becoming too ugly
to handle all of them with a single API call. The clear outlier are
buttons, so move them to a separate function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:01 +00:00
Carlos Garnacho
b6a6e9f187 core: Separate MetaPadActionMapper pad button labeling
This will be handled separately in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Carlos Garnacho
85ac3a2d1a wayland: Separate pad button labeling from other pad features
This will be fully split in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Carlos Garnacho
233e612ef8 core: Rename MetaPadActionType to MetaPadFeatureType
We want to separate pad buttons from strips and rings for
purposes of labeling. Start by renaming the enum "features"
to use a less englobing word.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3005>
2023-08-07 18:25:00 +00:00
Jonas Ådahl
112cca75e2 kms/impl-device: Remove deadline timer arming from queue_update()
queue_update() in a previous iteration was called in two situations:

 * A page flip was already pending, meaning if we would commit an
   update, it'd fail with EBUSY.
 * A update was marked as "always-defer" meaning it should only be
   processed from the deadline callback (would there be one). These were
   used for cursor-only updates.

In the latter, we had to arm the deadline timer when queuing a new
update, if it wasn't armed already, while in the former, we would
currently idle, waiting for the page flip callback. At that callback
would the deadline timer be re-armed again.

Since we're only handling the former now, we'll never need to arm the
timer again, so remove code doing so. The code removed were never
actually executed anymore, after the "always-defer" flag on updates was
removed.

Fixes: 27ed069766 ("kms/impl-device: Add deadline based KMS commit scheduling")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2940
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3150>
2023-08-07 15:59:18 +00:00
Daniel van Vugt
bafea13e95 kms/impl-device: Handle empty updates properly
This fixes freezes on cursor movement when:

1. meta_onscreen_native_finish_frame would create an empty update.
2. maybe_update_cursor_plane would leave it empty (!cursor_invalidated).
3. do_process would fail to recognise a non-null empty update as an error.
4. meta_kms_impl_device_handle_update would fail to send feedback on errors
   from do_process, because do_process is meant to do it.
5. Page flip listeners would wait forever for feedback that never comes.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2923,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2924,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2926,
       https://gitlab.gnome.org/GNOME/mutter/-/issues/2933

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3138>
2023-08-07 16:51:43 +08:00
Daniel van Vugt
b516b009fa kms/impl-device: Treat handling update as flushing
Primary plane updates were forgetting to do this in OnscreenNative, but
rather than do it for each post there we should simply do it for each
post.

This fixes cursor stutter in the fallback path (not using deadline timers)
where needs_flush_crtcs would remain populated but CRTC_NEEDS_FLUSH would
never be emitted, because handle_flush hadn't been called for the last
post.

This is safe as the current use of scheduled flushing is only for cursor
updates, and since cursor updates happen on the same thread as processing,
and due to the fact that we always use the most up to date cursor position
when flushing, we never risk leaving an old cursor state unflushed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3138>
2023-08-07 16:50:36 +08:00