1
0
Fork 0
Commit graph

12354 commits

Author SHA1 Message Date
Carlos Garnacho
39d8e44f5e wayland: Always send wl_pointer.axis after .axis_value120/discrete
The wl_pointer.axis_discrete axis (applicable to wl_seat <= v8) is
meant to be sent together with wl_pointer.axis events in the same
frame. And the wl_pointer.axis_value120 event replaces it in
wl_seat >= v9, but has the same relation with the other information
available in a frame.

This emission should not be conditional to anything, so drop the
various checks leading to maybe sending wl_pointer.axis or not.

This fixes emission of wl_pointer.axis in conjunction with discrete
events, for some combinations of versions and (non)value120 mice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
2024-03-05 21:47:43 +00:00
Carlos Garnacho
ddc76d878e wayland: Fix handling of non-v120 discrete events on wl_seat >= v8
Unveiled by commit e0c4b2b241 ("backends/native: Mark the emulated smooth
scroll event as such"). The sudden "lack" of smooth scroll events (Used by
Clutter to forward v120 events) made it evident we silently ignore Clutter
discrete events, as we don't send wl_pointer.axis_value120 for these.

Fix this by assigning a value120 value to discrete scroll events. This
makes wl_pointer.axis_value120 events actually sent on non-v120 mice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
2024-03-05 21:47:43 +00:00
Carlos Garnacho
7aebc9e63d clutter: Pass scroll source to discrete events
This piece of information was lost, always returning
"unknown". We can do better on the native backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3642>
2024-03-05 21:47:43 +00:00
Jonas Dreßler
58290cca57 window: Stop event propagation for drag and window-menu triggering events
meta_window_handle_ungrabbed_event() triggers the show of the window menu in
gnome-shell via meta_window_show_menu() on hold of Meta + right mouse button
click.

Since meta_display_handle_event() was refactored lately and now forwards a
lot more events to Clutter (including the one triggering the window menu),
gnome-shell now sees this event after the menu has opened, figures that the
source-actor is outside of the menu, and immediately closes the menu again.

This is the correct behavior from the PopupMenuManager on the gnome-shell
side, it is the responsibility of the event handler that opens the menu (aka
meta_window_handle_ungrabbed_event()) to return CLUTTER_EVENT_STOP and stop
event propagation.

So fix this issue by adding a return value to
meta_window_handle_ungrabbed_event() and stopping event propagation in case
the event opened the window menu.

While at it, also return CLUTTER_EVENT_STOP for events triggering window
drags, so we can drop the extra check for that in
meta_display_handle_event().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3623>
2024-03-04 09:59:59 +00:00
Peter Hutterer
6a31664a42 input-capture: Ignore emulated scroll events
For each libinput scroll event we generate two clutter events
(continuous and discrete), one of them marked as emulated. libei
explicitly specifies that emulation of scrolling must be done in the
client (if desired) so drop the emulated one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3637>
2024-03-04 08:46:38 +00:00
Peter Hutterer
e0c4b2b241 backends/native: Mark the emulated smooth scroll event as such
This path is hit for discrete (wheel) scroll events from libinput but
the emulated smooth scroll event isn't marked as such.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3637>
2024-03-04 08:46:38 +00:00
Sebastian Keller
c09fb9c5a1 compositor/drag: Use "default" cursor for moving windows
This is consistent with the DnD related cursor changes that also use the
"default" cursor for moving. The "move" cursor is kept for moving and
resizing windows using the keyboard since we currently have no other way
indicate this state.

See: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7425#note_2023057
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3634>
2024-03-02 23:42:55 +00:00
Barnabás Pőcze
fb890ead96 display: Force window user time update to happen
`meta_window_set_user_time()` will not update the window's
user time if it timestamp in the argument is before the
currently saved timestamp. However, when trying to work around
problematic timestamps, this is exactly what needs to be done.

So force the update to happen by setting the "is user time set?"
flag to false.

Fixes: 8f3da9f68a ("Use meta_window_set_user_time for setting user time consistently")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3027>
2024-03-02 23:19:22 +00:00
Robert Mader
e8b43d3b1b surface-actor: Add NULL check for stage
In some cases Wayland surface actors are not decendents of the stage,
notably subsurfaces without a parent surface. The code changes in the
mentioned commits dropped the previously existing check for that - readd
it.

Fixes: 627ab24721 (surface-actor: Add meta_surface_actor_schedule_update())
Fixes: 7eb99ddef7 (wayland/surface: Schedule updates in the context of the surface actor)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3323
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3633>
2024-03-02 22:37:22 +00:00
Jonas Dreßler
e9866eee0f compositor: Set priv->current_drag before calling meta_window_drag_begin()
priv->current_drag is the property that
meta_compositor_get_current_window_drag() and therefore also
meta_display_is_grabbed() bases its check on. We use
meta_display_is_grabbed() to select which cursor to use (window cursor
vs root cursor) when updating the cursor in MetaCursorTracker.

Since meta_window_drag_begin() sets a new cursor, and therefore triggers the
cursor tracker to update the current visible cursor, we should set
priv->current_drag before the call to meta_window_drag_begin(). This makes
sure the cursor tracker sees that there's a window drag and changes the
cursor right away when the window drag begins (instead of doing so on
subsequent pointer events).

Fixes: 525ed1166c ("wayland/pointer: Unset current surface during window drags")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3630>
2024-03-02 20:24:26 +00:00
Michel Dänzer
0690addcfc wayland/tablet-tool: Check for non-NULL surface resource
A MetaWaylandSurface object can outlive the corresponding wl_surface
object since https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880 .

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3320
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3632>
2024-03-02 19:46:15 +01:00
Dor Askayo
8df0beae08 monitor-manger: Expose the minimum refresh rate of monitors
This exposes the minimum refresh rate of monitors through D-Bus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
a53c02bba5 monitor: Add meta_monitor_get_min_refresh_rate()
This function gets the minimum refresh rate of the monitor's main
output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
cb40a1c510 output: Add meta_output_info_get_min_refresh_rate()
This function gets the minimum refresh rate of an output if it was
found in EDID.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
a96d524503 edid: Decode the minimum vertical rate from the display range limits
This is used as the minimum refresh rate in the variable refresh rate
range.

This value is expected to be found in the DisplayPort and eDP EDID of
every monitor that supports variable refresh rate.

It is also found in the HDMI EDID of some monitors that support
variable (FreeSync), but most likely not all of them. The rest require
parsing the AMD vendor extension which libdisplay-info doesn't
support.

No fallback is implemented for cases where libdisplay-info support is
disabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3576>
2024-03-02 12:35:36 +00:00
Dor Askayo
4919a53f84 compositor/native: Enable frame synchronization for surface actors
Find a surface actor that meets the criteria to drive the refresh
rate for the view. If a new surface actor is found, add a
reference to it and request frame synchronization to be enabled
for the relevant MetaRendererViewNative.

Whenever the surface actor schedules a repaint or an update, and
in case frame synchronization is enabled for the
MetaRendererViewNative, schedule the update to occur "now". This
effectively makes the surface actor's frame rate drive the refresh
rate of the monitor.

If the actor is frozen or destroyed, it is no longer expected to
schedule repaints or updates and should stop driving the refresh
rate.

When there is no surface actor to drive the refresh rate, request
frame synchronization to be disabled for the MetaRendererViewNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
7eb99ddef7 wayland/surface: Schedule updates in the context of the surface actor
This makes all stage updates that result from applying the pending
state of a Wayland surface emit an "update-scheduled" signal in the
context of the relevant surface actor.

A common case where an "update-scheduled" signal is needed is
when applying "empty" client commits. In this case a
"repaint-scheduled" signal would not be emitted since the commit
doesn't trigger a repaint. However, it is still important to add
handling for such updates with variable refresh rate when the
releavnt actor is also driving the refresh rate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
627ab24721 surface-actor: Add meta_surface_actor_schedule_update()
This function allows scheduling a stage update in the context of a
surface actor and emit the "update-scheduled" signal. This signal is
similar to "repaint-scheduled", but can be used to be notified of
updates that do not necessarily result in a repaint.

With variable refresh rate, any update potentially affecting the
frame pacing of a surface actor needs to be handled differently
depending on whether that surface actor drives the refresh rate or
not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
1318cd3faf window: Allow checking if a window covers a rect
This is just a small function to improve the readability of the code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
4e5ac0186c surface-actor: Allow checking if a surface actor covers a rect
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
f5e5032eac surface-actor: Add "is-frozen" property
This can be used to receive notification of when a surface actor
becomes frozen or thawed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
fee3329997 onscreen/native: Allow requesting frame synchronization
Frame synchronization is enabled for a view as long as it's
applicable to be enabled. It is considered applicable if it's both
requested for the onscreen and if the onscreen uses a CRTC which is
configured with a variable refresh rate mode.

When frame synchronization is enabled, it enables both the the variable
scheduling mode of ClutterFrameClock and the variable refresh rate
property for the CRTC.

Changes in the frame synchronization mode are applied asynchronously,
before the next frame is drawn.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
732f5afe13 monitor-manager: Add support for refresh rate modes
The refresh rate mode is exposed in the DisplayConfig D-Bus interface
and is made persistent through monitors.xml.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
1721dad5ec monitor: Include the refresh rate mode in the mode spec
Variable refresh rate modes are preferred over their fixed refresh
rate counterparts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
be36c18787 output/kms: Initialize variable refresh rate output modes
Add variable refresh rate output modes for connectors that are VRR
capable when VRR is not disabled for the GPU.

Variable refresh rate output modes are sorted before their fixed
refresh rate counterparts. They are also marked as the preferred mode
for the output between the two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
455ac43e0a kms: Initialize variable refresh rate CRTC modes
When VRR is not disabled for a GPU, create two variants of every
display mode: one with fixed refresh rate and another with variable
refresh rate.

The variable refresh rate modes are not used yet. They will be used
in a following commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
9fcc938075 gpu/kms: Allow checking if VRR should be disabled
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
b2ceb055d6 backends/native: Add support to disable VRR using udev
This can be used to disable VRR in specific drivers and hardware
combinations where it is found to be problematic.

No default rules are added for now to encourage testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
e72baac97d settings: Add experimental feature for variable refresh rate
Require the "variable-refresh-rate" keyword under the
"experimental-features" gsetting to enable the feature for now.

It would no longer be required once the experience with variable
refresh rate is good enough for general use and handles all common
use cases well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
a74fbecbd6 kms/crtc: Calculate CRTC deadline for VRR
Use a sufficiently low refresh rate to calculate the CRTC deadline
when variable refresh rate is enabled. This is done to avoid cursor
updates from driving the monitor refresh rate.

It's not great solution and is sometimes not enough, but it avoids
stutter in the main content as a result of cursor movement in most
cases.

The unfortunate downside of this approach is that cursor movement
would usually only update with the main content and would not be
smooth when the main content updates are not frequent enough.

A better solution may use an approach similar to LFC (Low Framerate
Compensation) to insert cursor-only updates between updates of the
main content, but achieving adequate results with an approach of this
nature requires more research and experimentation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
2a3fc9b830 kms/impl-device: Allow the expected presentation time to be unknown
It is not trivial to accurately estimate the expected presentation
time with variable refresh rate, and not doing so only affects debug
prints.

No change in behavior for now because the expected presentation time
is always calculated. A following commit will introduce a case where
it is not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
4ad282cf26 kms: Allow setting the "VRR_ENABLED" property on a CRTC
Add functions to update and monitor the value of the "VRR_ENABLED"
KMS property.

This requires the addition of functions to process CRTC property
updates in both the atomic and the simple KMS backends. The
implementation is similar to the implemention of processing
connector updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Dor Askayo
b7128b1d12 connector/kms: Detect variable refresh rate capability
The "vrr_capable" property indicates whether variable refresh rate is
supported for a connector.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
2024-03-02 12:08:21 +00:00
Jonas Dreßler
525ed1166c wayland/pointer: Unset current surface during window drags
Commit d48129f5ee broke the displaying of our own drag cursor during window
drags, as now the window cursor is always used, even during stage grabs
(window grabs are just a kind of stage grab).

To fix it, while not regressing on the intention of the other commit, unset
the MetaWaylandPointer surface in case a window drag is active (instead of
all kinds of grabs) by checking via meta_display_is_grab().

Fixes: d48129f5ee ("wayland: Fix pointer cursor during Wayland grabs")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3316
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3624>
2024-03-01 16:41:46 +01:00
Carlos Garnacho
8519a31e8f wayland: Make MetaWaylandTabletTool struct private
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
f17300a22e wayland: Refactor tablet tool grab checks
Move the bulk of the implementation inside MetaWaylandTabletTool
files, so MetaWaylandTablet does not need to access at tool struct
fields.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
314ab7c3cb wayland: Remove some unnecessary header includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
bff8269a3e wayland: Make MetaWaylandPointer struct definition private
Move it outside the header and into private code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
f53adae278 wayland: Avoid MetaWaylandPointer struct peeking in touchpad gestures
Use getters for the MetaWaylandPointerClient and MetaWaylandSurface for
the logical focus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
bf4d46097b wayland: Add getter for the pointer focus client
Similarly to MetaWaylandKeyboard, there's some subsystems
that want access to this, e.g. touchpad gestures.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
03b504fc38 wayland: Refactor pointer grab checks
Move the bulk of the implementation inside MetaWaylandPointer
files, like it happens in other places (e.g. MetaWaylandTabletSeat).
This avoids MetaWaylandPointer struct peeking from outside.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
84d48254d7 wayland: Make MetaWaylandKeyboard struct private
Move it out of the header and into the C code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
fb7cd18ebf wayland: Fetch seat input focus as focus for new pad devices
Use the MetaWaylandSeat focus, and avoid peeking at MetaWaylandKeyboard
internals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
017eff6663 wayland: Avoid MetaWaylandKeyboard struct access
Use the MetaWaylandSeat focus, instead of peeking at MetaWaylandKeyboard
internals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Carlos Garnacho
81df305645 wayland: Add MetaWaylandSeat input focus getter
This will be useful for MetaWaylandCompositor to get the
current input focus for keyboard and other related devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
2024-03-01 14:37:58 +00:00
Sebastian Keller
9e77d45704 Revert "frames: Always initialize _MUTTER_FRAME_EXTENTS to zero"
The _MUTTER_FRAME_EXTENTS need to have the correct size before the
window is shown, otherwise the client window size will effectively have
the headarbar height subtracted when initially syncing the frame/client
geometries.

This reverts commit f10b3eac62.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3628>
2024-03-01 10:54:32 +01:00
Carlos Garnacho
c12991936e wayland: Let the tablet tool handle the handle_event() return value
This was being ignored, and the events propagated always. This may lead
to confusion with Clutter about who handled what, since shockingly the
events may be delivered to clients.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3317
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3625>
2024-02-28 22:46:03 +00:00
Carlos Garnacho
4c4c0b847d wayland: Do not claim tablet tool events as consumed without focus
If the tablet tool has no focus, it should let events go through.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3625>
2024-02-28 22:46:03 +00:00
Sebastian Wick
8234f5bc7e egl: Return success status from meta_egl_query_device_string
QueryDeviceString can successfully return NULL. The convention however
is that when NULL is returned, the error will be set.

This commit makes the returned string an output parameter which allows
us to return the success status and have the error set accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3614>
2024-02-27 13:13:53 +00:00
Sebastian Wick
46619573e0 egl: Make sure GError gets set when we return FALSE
The convention is that when a function returns FALSE or NULL, the error
will be set. In this file we call set_egl_error but it might not set an
error. Code of the form

if (egl_do_thing (..., &error))
 use_error (error);

will crash in those cases.

This commit makes sure we always set the error even if EGL doesn't give
us an error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3614>
2024-02-27 13:13:53 +00:00
Doğukan Korkmaztürk
a816470996 screen-cast-stream: Remove stale comments and an unused variable
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3592>
2024-02-27 12:38:01 +00:00
Marco Trevisan (Treviño)
839158ffd5 build/meta: Add explicit dependency on Gio-2.0 gir
We depend on Gio for many introspection features (GSettings, GFile...)
without this we'd end up not having many symbols being exposed.

And errors such as
  Warning: Meta: meta_display_add_keybinding: argument settings:
    Unresolved type: 'GSettings*'

As per previous commit we now have this dependency implicitly, but still
it's better to make it clearer in case Clutter would drop it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3620>
2024-02-27 10:35:06 +01:00
Carlos Garnacho
e5483a963e wayland: Pass button/touch press begin coordinates as window drag hint
This will make windows stick to the pointer from the right point
where dragging started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:22 +01:00
Carlos Garnacho
1b3759d51c x11: Pass NET_WM_MOVERESIZE coordinates as window drag hint
This will make windows stick to the pointer from the right point
where dragging started.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:22 +01:00
Carlos Garnacho
4b1e24fcc4 core: Pass position hint to meta_window_begin_grab_op()
Add an argument to pass the position hint to this public API
call, so that callers can specify such hint. Everyone passes
NULL at the moment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:22 +01:00
Carlos Garnacho
51e084ee8d compositor: Forward window drag position hint across internals
Allow passing an argument to meta_compositor_drag_window() to pass
the hint. Unused so far.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:19:20 +01:00
Carlos Garnacho
e4542a6495 compositor: Add MetaWindowDrag API to add a hint on the grab coordinates
This is added as a hint so that the caller can optionally use it, e.g.
in the case that a window drag is driven by the mouse. This will be used
to more accurately follow the drag position, other than starting at the
current pointer position.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3546>
2024-02-27 00:18:23 +01:00
Carlos Garnacho
4fa2706b9b wayland: Look up pointer logical focus when enabling constraints
Pointer constraints obey to logical pointer focus changes, and looking
up the current surface in order to maybe enable them is getting ahead
of itself, since the pointer focus might differ from the current surface
due to other factors (e.g. grabs).

Change the code checking whether constraints should be enabled to again
check the pointer logical focus, this will be influenced by the
MetaWaylandEventInterface mechanism, and correctly reflect the logical
state accounting for those factors.

Fixes: 125ba92169 ("wayland: Port pointer constraints to using MetaWaylandEventInterface")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3303
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3618>
2024-02-26 22:15:19 +00:00
Carlos Garnacho
1d5676bc9a wayland: Handle event interface changes during focus synchronization
Currently, we don't handle too well the removal of a MetaWaylandEventInterface
during meta_wayland_event_interface_invalidate_all_focus(), since the
MetaWaylandEventInterface may be freed at an intermediate point in that function
while handling the focus change for all input devices.

Turn this invalidate_all_focus() function into a MetaWaylandInput method, and
always ensure to use the currently effective MetaWaylandEventInterface when
resetting the focus for each device.

This fixes the situation through handling reentrancy naturally, a focus
sync (say, triggered by a grab) would reset a device focus (say, pointer), which
would remove an event interface (say, a pointer constraint), which would
invalidate_all_focus() again underneath using the new effective
MetaWaylandEventInterface. When that is done, the initial invalidate_all_focus()
call would re-apply the same focus to the same currently effective
MetaWaylandEventInterface, resulting in a no-op for the remainder of the function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3618>
2024-02-26 22:15:19 +00:00
Carlos Garnacho
7fc49f742b wayland: Add getter for the MetaWaylandPointer logical focus
Even though the logical focus is typically business that only the
MetaWaylandEventInterface mechanism minds about, there are some pointer
subsystems that want to look this up, as opposed to the current surface.

Add a getter to make this easier, without struct peeking.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3618>
2024-02-26 22:15:19 +00:00
Sebastian Wick
b102b6eca7 kms/connector: Remove getters for state tracked by KmsConnectorState
This also removes some g_return_if_fail's because the test suite expects
to be able to create arbitrary KmsUpdates even if they don't make sense
for the real state. We just get lucky that the test suite isn't
constructing updates with color space and hdr changes, yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
420c8cb37f kms/connector: Simplify privacy screen tracking
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
3e14edb00c kms/connector: Track max_bpc in KmsConnectorState
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
e9e613a6c3 kms/connector: Track underscan in KmsConnectorState
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
0dc43c04ee onscreen/native: Move rgb range support to OutputInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
706bee2a58 onscreen/native: Use max bpc support from OutputInfo
The max bpc support is already tracked in the OutputInfo, so let's use
that instead of querying the KMS Connector directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
8acf250583 output: Move privacy screen support to OutputInfo
Same as previous commit for privacy screen support.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
a3a4de6c6b output: Move color space and hdr tf support to OutputInfo
Currently querying support for some output features is done partially
through the OutputInfo and partially via KMS CRTC and Connector objects.
Let's be consistent and use OutputInfo always which works with all
backends and backend types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
fb7b9b0955 onscreen/native: Disable the CRTC LUT when we have no LUT to set
The KmsImplDevice supports bypassing the hardware LUT when we pass in
NULL or an empty LUT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
eb8a12c24b tests/kms/update: Use proper gamma LUT size
We're currently pretending the gamma LUT has another size. This becomes
a problem when we try to reset the LUT to passthrough, create an
identity LUT for it and it has a size that the kernel doesn't accept.

We do track the size and have utility for creating the LUTs, so let's
just use them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
b083ad67df kms/impl-device/simple: Handle NULL gamma LUTs for passthrough
The kernel doesn't let us set gamma to passthrough with the legacy API
so we have to trick a bit and create an identity LUT, and also when we
read the KMS state, detect when an identity LUT is active.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Wick
a55e2e5af2 crtc: Add identity gamma LUT helpers
One to create a identity LUT of a certain size, one to check if a LUT
represents identity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
2024-02-26 18:18:53 +00:00
Sebastian Keller
6876b51875 frames: Drop unused border property from frame content
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3608>
2024-02-26 17:03:56 +00:00
Sebastian Keller
f10b3eac62 frames: Always initialize _MUTTER_FRAME_EXTENTS to zero
The frame size_allocate() will set it correctly once show() is called by
the window tracker.

This is less code and also help reduces the chance of a brief visual
glitch in fullscreen games during startup. If the window is initially
still decorated the gray area would still show up until the next redraw,
which due to loading times can take a while.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3608>
2024-02-26 17:03:56 +00:00
Sebastian Keller
bcdd282e9c frames: Update _MUTTER_FRAME_EXTENTS from frame size_allocate
Relying on the content size_allocate() to determine the content position
can fail in situations where the position of the content has changed,
but not its size.

This happens for example when the window initially is sized fullscreen
height + headerbar height while not considered fullscreen yet. Then when
the window is resized to just the fullscreen height and marked as
fullscreen, the content size has not changed and size_allocate() is not
called on the content. Thus the previous position which assumes the
presence of a headerbar still applies. As a result the window is shifted
down, revealing a headerbar sized area showing the gtk window background
color.

This issue can be avoided by using the frame's size_allocate(), which
gets called in response to all relevant events, such as any headerbar
size changes, headerbar visibility changes, window resizes and
fullscreen status changes.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2937
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3608>
2024-02-26 17:03:56 +00:00
Leonhard
d603cc351f wayland/client: Add make_desktop() method
Allows to mark a wayland client window as a DOCK window. The reason for
this is that in Gala (elementary OS's window manager) we would like to
continue using GTK apps as panel and dock on wayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3612>
2024-02-26 11:19:03 +00:00
Leonhard
7bf8945da4 window: Handle layer of DOCK windows
Assigning the corresponding stack layer of DOCK windows is currently X11
specific, because there is no way for wayland clients to set the DOCK
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/3612>
2024-02-26 11:19:03 +00:00
Florian Müllner
5bd820d746 tests/wayland-test-clients: Update cursor names
adaita-icon-theme cleaned up its cursor set, and now only provides
names defined by GTK/CSS. Update the cursor-hotplug test to not
use legacy cursor that will fail with a recent cursor theme.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3613>
2024-02-25 21:46:36 +00:00
Sebastian Keller
fa67588788 frames: Use g_clear_pointer
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3611>
2024-02-24 21:30:00 +00:00
Sebastian Keller
9a5aa846e4 frames: Rename update_extents to clarify it is not public
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3611>
2024-02-24 21:30:00 +00:00
Sebastian Keller
f47b816037 frames: Move overrides and class functions after helpers
This is in preparation of calling helper functions from class overrides
in a later commit and also brings things more in line with the mutter
coding style.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3611>
2024-02-24 21:30:00 +00:00
Sebastian Keller
9bac742ba5 frames: Drop unused class member
Everything just uses gtk_window_get_child() to get the content.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3611>
2024-02-24 21:30:00 +00:00
Bilal Elmoussaoui
60e10511ae cogl: Remove Color.init_from_4ub
Slowly switching to using floats only in CoglColor
Helps https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3594>
2024-02-22 12:34:58 +00:00
Bilal Elmoussaoui
cf0803ab71 cogl: Remove Color.get_*_byte
Helps with https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3594>
2024-02-22 12:34:58 +00:00
Bilal Elmoussaoui
40dde833af cogl: Remove Color.get_*_float
They are exactly the same as the get_* variants

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3594>
2024-02-22 12:34:57 +00:00
Bilal Elmoussaoui
11691b107c cleanup: Avoid using None on non-x11 only code paths
Just replace it with it actual value

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3606>
2024-02-21 18:29:03 +01:00
Bilal Elmoussaoui
68d5b5ea50 keybindings: Use ClutterModifierType
As it is compatible with the X11 KeyMask avoiding x11 usage

Helps https://gitlab.gnome.org/GNOME/mutter/-/issues/2272

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3606>
2024-02-21 18:28:54 +01:00
Bilal Elmoussaoui
2834780cbe window: Move set_frame_xwindow to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3603>
2024-02-21 16:01:00 +01:00
Bilal Elmoussaoui
3cc44b1f04 cleanup: Guard x11 headers includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3603>
2024-02-21 16:01:00 +01:00
Bilal Elmoussaoui
b5cf16fa74 cleanup: Remove not used X11 includes
Also add ones where they are actually used

Helps https://gitlab.gnome.org/GNOME/mutter/-/issues/2272

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3603>
2024-02-21 15:25:44 +01:00
Jonas Dreßler
a14200a75c wayland/surface: Notify highest scale monitor after updating window monitor
meta_window_update_monitor() can emit "::highest-scale-monitor-changed",
and we connected to that signal right before. Let's avoid calling
meta_wayland_surface_notify_highest_scale_monitor() twice and move the
g_signal_connect() for that signal and the initial call to
meta_wayland_surface_notify_highest_scale_monitor() to happen after
meta_window_update_monitor().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3598>
2024-02-21 12:19:02 +00:00
Jonas Dreßler
0fc39b2a87 Revert "wayland/surface: Add fallback for get_highest_output_scale"
Turns out there is a better solution: Almost always, MetaWindow already has
an idea on which monitor it will be, even if it isn't positioned yet. Since
the last commit we're now using that monitor for setting the
highest-output-scale of the window, so this fallback is no longer necessary.

While we could keep this fallback around and also return a valid scale in
case the surface is not even mapped yet, this means we report fractional
scale twice for new surfaces: Once from
wp_fractional_scale_manager::get_fractional_scale() (here we'll enter the
fallback), and a second time (this time with correct scale) right after
creating the MetaWindow.

Note that wp_fractional_scale_v1 doesn't specify that a preferred_scale
event must be sent immediately after
wp_fractional_scale_manager::get_fractional_scale(), so we can safely remove
the fallback.

This reverts commit 8cfbdb4313.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3598>
2024-02-21 12:19:02 +00:00
Jonas Dreßler
bf4aff823f window: Fall back to main window monitor for highest scale monitor
MetaWindow always tries to have a main monitor: If the frame rect is empty
and the window has not been positioned, in meta_window_constructed() we fall
back to asking the backend for the current monitor, and in
meta_window_wayland_update_main_monitor() we fall back to
meta_window_find_monitor_from_id(), which then falls back to the primary
monitor.

In general this means that window->monitor is always set as long as there is
a monitor around.

For getting the highest-scale-monitor the window is on, we currently rely
completely on the frame rect. If the frame rect is empty, we set the
highest-scale-monitor to NULL. Since we usually know though which monitor
the window is, or will be on, and window->monitor is even set to that, we
can just fall back to window->monitor for the highest-scale-monitor.

This makes sure ::highest-scale-monitor-changed is emitted right after the
window is created, and it's set to the correct monitor that the window will
be on. This in turn means that we can send a correct wp_fractional_scale
fraction_scale event to clients right away.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3598>
2024-02-21 12:19:02 +00:00
Agustín Dall'Alba
9dff6a5013 backends/native: Remove DO_NOT_AUTO_START flag from rtkit dbus proxy
With this flag, the KMS Thread isn't made realtime at boot when the shell
starts before the rtkit daemon

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3327>
2024-02-21 11:48:49 +00:00
Bilal Elmoussaoui
917526ee9d plugin-manager: Drop MetaPluginClass.xevent_filter
This was added for registering profiling hooks for glx.swapComplete on
x11 code paths.

Nowadays we have sysprof

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3599>
2024-02-20 15:21:21 +00:00
Bilal Elmoussaoui
c72e129eb2 cursor-renderer: Move x11 specific bits to CursorRendererX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3599>
2024-02-20 15:21:21 +00:00
Bilal Elmoussaoui
899b4aad37 x11/display: Don't go through meta_create_x_cursor
As the cursor would always be default in this case and we would
want to move that function to the x11 cursor renderer.See next commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3599>
2024-02-20 15:21:21 +00:00
Bilal Elmoussaoui
ea74414b2e cursor-renderer: Make translate_meta_cursor public
Would be used in the upcoming commits

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3599>
2024-02-20 15:21:21 +00:00
Daniel van Vugt
f606a4424a compositor/x11: Sync again at the end of before_paint
The existing comment tells us this is necessary:

> there may be drawing between the last damage event and the
> XDamageSubtract() that needs to be flushed as well.

But the commit message for 551101c65c also tells us that
synchronization is necessary before-update. Assuming both are correct
then it needs to be done in both places.

I did try optimizing out the second sync to only do it if damage
arrived during the update, but that doesn't seem to be the issue.
The damage event is arriving before the update starts and it's some
secondary changes within the damage region running late that need
flushing. So this means the client is reporting damage more frequently
than the frame rate and we're ignoring the secondary damage reports
for efficiency (XDamageReportBoundingBox), which is still a good thing.

Fixes: 551101c65c ("compositor-x11: Move synchronization to before-update")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2880
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3590>
2024-02-20 18:22:00 +08:00
Bilal Elmoussaoui
cf9f7f427e window: Add a copy of XSizeHints
The type ended being used even in wayland code paths
so add a copy of it for now.

Helps https://gitlab.gnome.org/GNOME/mutter/-/issues/2272

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3597>
2024-02-19 20:19:41 +01:00
Bilal Elmoussaoui
97635753d9 clutter/tests: Remove unused color check helpers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3595>
2024-02-17 14:30:19 +01:00
Bilal Elmoussaoui
85dbdc8fa6 cleanup: Remove unused defines
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3595>
2024-02-17 14:16:20 +01:00
Corentin Noël
e7de5c36f3 build: Remove the config.h inclusion from all public headers
Do not include it at header side as it is not part of the installed headers.

Only keep it in cogl-gl-headers.h as it is a private header.

Add it to all the source files that depend on it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3593>
2024-02-17 11:58:55 +00:00
Daniel van Vugt
5b49e0853c core/events: Restore IS_GESTURE_EVENT check for X11
It got lost during feec896d85 resulting in a PROPAGATE that should
be STOP.

For Wayland, gesture events are already handled (663f9d44).

Fixes: feec896d85 ("core: Simplify meta_display_handle_event()")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3293
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3589>
2024-02-17 08:26:05 +00:00
Doğukan Korkmaztürk
dc2b2e379b screen-cast-stream: Add explicit modifier support
This change adds modifier-aware screencasting support to Mutter.
Implicit modifier support is kept for backward compatibility and the
code fallbacks to implicit modifiers in case any new functionality added
for explicit modifier support fails.

The advertised modifiers are retrieved by a call to
eglQueryDmaBufModifiersEXT() function. The "external only" modifiers are
excluded as Mutter uses the buffers created with the explicit modifiers
as renderbuffers. Support for implicit modifiers is checked with a test
allocation since there are drivers that do not support them.

This change also removes various implicit modifier support checks that
disable DMA-BUF screen casting support globally as they are no longer
needed. DMA-BUF support for screencasting is determined by the available
formats and modifiers case-by-case now.

It also effectively enables DMA-BUF screencasting on NVIDIA hardware as
well since GBM buffer objects with linear modifiers are no longer used
by default to create a renderbuffer object for screencasting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3537>
2024-02-16 09:15:34 -05:00
Doğukan Korkmaztürk
34d00d769e render-device: Update DMA-BUF allocation API to allow modifiers
meta_render_device_gbm_allocate_dma_buf() function is updated to take a
list of modifiers. If no modifiers are specified, the modifier is
selected by the allocator, and implicit modifiers are used to import the
created DMA-BUF.

Co-authored-by: Jonas Ådahl <jadahl@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3537>
2024-02-16 08:22:04 -05:00
Bilal Elmoussaoui
ab1322781d tests/cogl: Remove unused legacy_mode
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3553>
2024-02-16 12:13:23 +01:00
Bilal Elmoussaoui
2c613df4eb cogl: Drop Pipeline.set_color_*
Those setters variants makes it very hard to do across project changes
to the
color type. As part of
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544
I would like to switch from using integers to floats inside CoglColor
which this PR would simplify

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3553>
2024-02-16 12:13:23 +01:00
Bilal Elmoussaoui
b00fcbf948 clutter: Remove unused Color APIs
Nothing uses them in GNOME Shell, so let us simplify the API
a little bit

Helps https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3588>
2024-02-16 10:24:24 +00:00
Bilal Elmoussaoui
72c2d8913e clutter: Drop static colors
There is literally zero reasons nowadays to still provide the tango color
palette as part of the Clutter API. End users of Mutter can define the
colors on their side if they want to.

The change simplifies https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3588>
2024-02-16 10:24:24 +00:00
Bilal Elmoussaoui
41cc85c857 window: Move shape_region to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
Bilal Elmoussaoui
5e8e7df5bd window: Move input_region to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
Bilal Elmoussaoui
606197de46 window: Move opaque_region to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
Bilal Elmoussaoui
bf5f597141 window: Remove unused fields
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
Bilal Elmoussaoui
09fc3e966a window: Move wm_client_machine to WindowX11
Also removes the public getter as nothing uses it and it no longer
make sense to expose X11-ism as API

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
Bilal Elmoussaoui
692414c078 window: Move sm_client_id to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
Bilal Elmoussaoui
72326d8ca5 window: Move grab_on_frame to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
Bilal Elmoussaoui
de2a24b313 window: Move keys_grabbed to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
2024-02-15 13:40:07 +00:00
msizanoen
b6802e1f00 wayland-surface: Fix get_absolute_coordinates() for active transition cases
Currently, we blindly apply the transformation matrices of all parent
actors when calculating the absolute coordinates. This means if this
function is called while the window actor containing the surface is in
the middle of a transition (e.g. window open animation), it may return
incorrect values. As this function is used for calculating pointer
confinement bounds for a specific surface, this will result in incorrect
bounds value being used if pointer constraints are applied by the
application at the same time the window is created and the mouse is
inside the surface's bounds when it's created.

Fix this by only applying transformation matrices up to the window actor
of the surface and then calculating the absolute coordinates by adding
the position of the window actor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3585>
2024-02-15 13:20:33 +00:00
Sebastian Wick
8677e36c4c edid: Change HDR Static Metadata luminances to be float
They are float in libdisplay-info and our own EDID parsing also returns
a float but when then converted both to an integer. Especially the min
luminance can be <1.

We also don't need a variable for indicating presence of a CTA Static
Metadata block. The values are all zero if it is absent.

Found by Dor Askayo.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3574>
2024-02-14 21:46:26 +00:00
Bilal Elmoussaoui
32082f26ce keybindings: Simplify initializing builtin keybindings
Reduces code duplication

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3583>
2024-02-14 19:10:21 +00:00
Bilal Elmoussaoui
ec3d658968 keybindings: Drop unneeded function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3583>
2024-02-14 19:10:21 +00:00
Bilal Elmoussaoui
bd1ca76168 keybindings: Move grab/freeze functions per backend
By making those functions virtual functions of MetaBackend
and have the BackendNative implementation no op

Helps https://gitlab.gnome.org/GNOME/mutter/-/issues/2272

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3583>
2024-02-14 19:10:21 +00:00
Bilal Elmoussaoui
e31c47877a frame: Inline get_mask where it is used
The function was used only once so just move it content where it is
called. It allows us to drop more cairo paths from the API surface even
if it is not part of a public api

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3581>
2024-02-14 11:20:30 +00:00
Robert Mader
8cfbdb4313 wayland/surface: Add fallback for get_highest_output_scale
If we don't have a monitor for a surface - e.g. because the surface is
not mapped yet - return the highest scale of all outputs. This makes us
send a preferred scale before a client draws its first frame. The highest
scale is always correct in single monitor cases and arguably a good
option otherwise as scaling down usually looks better than scaling up.

Note that this is currently only used by the fractional scale protocol,
but will also be used for the core `send_preferred_scale()` once we
implement it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3217>
2024-02-13 12:42:13 +00:00
Robert Mader
6034100160 wayland/surface: Move a function
So it's closer to where it's used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3217>
2024-02-13 12:42:13 +00:00
Carlos Garnacho
feec896d85 core: Simplify meta_display_handle_event()
With all early "goto out" paths bypassing wayland, we can pretty
much avoid the goto and use early returns in this function. This
will hopefully improve readability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:27 +01:00
Carlos Garnacho
663f9d4495 wayland: Return boolean value handling pointer events
We've so far returned FALSE (i.e. PROPAGATE) here, somehow
oblivious of the fact that the core event handler would stop
all non-gesture events directed to windows.

Incorporate this knowledge there, in order to be able to
streamline this piece of event handling in core/ code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:27 +01:00
Carlos Garnacho
c496b17b3d core: Move display->current_time out of meta_display_handle_event()
While this updates the display current time a bit earlier, it allows
for early returns in the big bad function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
93a9e7f3f4 core: Move code ignoring events on windows with modals to Wayland
This is Wayland specific code, handle it directly in MetaWaylandPointer.
This also fixes issues with the crossing event itself managing to reach
the window occluded by modals.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
f46205417f compositor: Drop grab_begin/end vfuncs
These do no longer anything on any implementation, and may be
removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
3c5bbedb7c compositor: Move code to sync pointer position to backends/x11
Since the backend also knows when did we start/stop being grabbed,
we can shuffle this backend-y code to the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
afed7fde03 wayland: Update DnD surface scale according to correct device
Pass the device/sequence to the DnD surface role, so it can to
coordinate tracking for scale updates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
e7f436bc39 compositor: Refactor MetaDnD wayland event handling
Hook MetaDnD event delivery in the case of Wayland DnD ops
directly in the Wayland code, instead of indirectly in core/
code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
d48129f5ee wayland: Fix pointer cursor during Wayland grabs
With Wayland popups and drag-and-drop using grabs, we
should let window cursors prevail when there is one
in effect.

Also, resort always to the actor as known by the
stage. This fixes the cursor lookup right after crossing
events induced by grabs, e.g. right clicking on the
gtk4-demo textview without motion would keep the I-beam
cursor, now results on the right actor/cursor for the
menu being picked.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
2bcf6607d3 compositor: Do not sync input focus
The wayland bits do already take care of logically unsetting
their focus in the presence of extraneous grabs, there is no
need to trigger this from the compositor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
2a584a8f01 wayland: Make use of Wayland event grabbing mechanism
Enable grabbing input for popups, and drag-and-drop. Since the very
switch to using ClutterGrab underneath Wayland grabs will challenge
assumptions in existing code, these had to change in one go. A notable
one is that meta_display_windows_are_interactable() is not 100% true
anymore for xdg_popups, at least not the same.

Another change happening in lockstep is MetaDnD no longer having
to funnel events to Wayland, since the grab triggered by Wayland DnD
is now a cause of "compositor grabs", and will naturally receive events
as long as it hold. while "modal".

A number of ad-hoc checks for grabbing state has also been dropped
from src/wayland/ internals, since again Wayland grabs are a reason
for Clutter grabs, plus the mechanism itself will already take care
of focus loss and restoration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
67773ab88d wayland: Add argument to grab when attaching MetaWaylandEventInterface
Add the mechanism to integrate MetaWaylandEventInterface with grabs,
callers may now specify whether a grab is required, in which case
one is created, shared by all the event interface stack.

ClutterStage grab state is also tracked, so the MetaWaylandEventInterface
in charge will focus or unfocus depending on whether input should be
handled (if ungrabbed, or grabbed by the MetaWaylandInput itself), or
not (if grabbed by something else).

At the moment nothing uses this mechanism yet, later commits will add
the first users.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
b154fddd0f clutter: Make ClutterGrab a GObject
We'll want to add notifications on it, make it a GObject
to allow that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
02bb9651e1 wayland: Unify pointer constraints event interfaces
Now that the backend handles 0-size regions naturally and MetaWaylandPointer
avoids sending wl_pointer.motion on unchanged coordinates, we can use the
default motion handler for the locked pointer constraint.

And since that is the only difference with the pointer constraint event
interface, we can unify them both into a single MetaWaylandEventInterface
handling focus for them both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
0e56ebb51a wayland: Avoid sending wl_pointer.motion on unchanged coordinates
This might happen for a variety of reasons, like monitor edges or
pointer constraints. Handle this naturally in MetaWaylandPointer for
all these cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
07d24fe502 backends/native: Allow infinitely small pointer constraint regions
The small catch is that MtkRegion (and pixman regions) "optimize away"
0-size rectangles, so a 0-sized region will always be seen as having
a 0,0 origin. We don't want that, so transfer the origin separately from
the region.

While at it, make the Wayland pointer lock use one such 0-size region,
to avoid the 1x1px wiggle room that it currently has (accounting for subpixel
motion).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
c931ed0d81 wayland: Allow XDnD with other devices than the pointer
While every kind of input is seen as coming from the Virtual
Core Pointer in the X11 case, we can largely abstract away from
that fact, and lock XDnD pointer input to the most plausible
source (e.g. a device with a pressed button), instead of only
working with pointer input.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
b09374735b wayland: Cleanup MetaWaylandPointer header
Drop some functions that are no longer used outside of MetaWaylandPointer,
after interactions between components were reduced.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
ec435ea540 wayland: Drop pointer grab interface
This is now unused, with everything ported to MetaWaylandEventInterface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
bcfb7a4a33 wayland: Drop keyboard grab interface
This is now unused and may be dropped. All usage has been
replaced by MetaWaylandEventInterface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
5fa112c298 wayland: Port drag and drop to MetaWaylandEventInterface
This collection of event handlers is the most special of them all, as
they want to unset any pointer/touch/stylus/keyboard/pad/etc focus,
and handle events from a selected device/sequence combination through
the MetaWaylandDragDest interfaces.

The same interfaces also replace the MetaWaylandKeyboardGrabInterface
in effect that handled DnD action changes.

On the XDnD special grab side, we mainly need to let the current
client (i.e. the drag source) keep receiving input events, as they
drive the DnD operation from the X11 realm.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
5ade2060a7 wayland: Port popup grabs to MetaWaylandEventInterface
This is again a grab interface that mostly wants to meddle with focus,
logically setting a NULL surface if the surface client does not match
the popup client.

Since popups are meant to naturally work with any input device, the
code has been refactored to not involve the MetaWaylandPointer directly
in MetaWaylandPopup creation or getting the top popup surface (memory
management was shuffled), or compressing multiple grabbing xdg_popups
together (the existing grab maintains a single MetaWaylandEventHandler
for all).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
125ba92169 wayland: Port pointer constraints to using MetaWaylandEventInterface
Besides the pointer locking/constraining mechanism, these grab interfaces
were more of a focus tracking mechanism, revoking the constraints when
the conditions didn't meet.

This can be handled pretty similarly to keyboard grabs with the new
interface, with the added bonus that we can chain up to let the
parent/default handler handle the events themselves, without poking at
MetaWaylandPointer API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
9da40aa9fd wayland: Port xwayland key grabs to MetaWaylandEventInterface
This event interface simply enforces key focus to the grab window,
but stands out of the way for every other kind of input.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00