1
0
Fork 0
Commit graph

12176 commits

Author SHA1 Message Date
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
Carlos Garnacho
80ed79a0d3 wayland: Add default event interface handling seat events
This is implemented at the MetaWaylandSeat level, and it governs
focus and event delivery for all devices, falling through each
of the MetaWaylandPointer/MetaWaylandKeyboard/etc components.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 12:36:26 +01:00
Carlos Garnacho
a2c11f0e87 wayland: Introduce MetaWaylandInput/MetaWaylandEventInterface
MetaWaylandInput is an object that will become in charge of handling
input events on their way to the Wayland socket. It keeps a stack
of event handlers, and propagates events and changes across them in
order to have them emit Wayland events, or change focus.

Each of these event handlers has a MetaWaylandEventInterface, this
is a vtable meant to replace MetaWaylandPointerGrabInterface and
MetaWaylandKeyboardGrabInterface in an unified manner, with the
following methods:

- get_focus_surface: to return the focus surface for a device/sequence.
  Since several handlers will want to delegate logic on previous
  handlers, it is optional to chain up with
  meta_wayland_event_handler_chain_up_get_focus_surface().
- focus: To trigger a focus change for a device/sequence, since
  event handlers are daisy chained by default, it is mandatory to
  chain up with meta_wayland_event_handler_chain_up_focus(), either
  with the given surface, or passing NULL to let later handlers
  unset their state.
- press/motion/release: Unified handlers for pointer/touch/stylus
  input, they chain up like event handlers do.
- key: Key event handler, propagates like event handlers do.
- other: Fallthrough for other events (pad, scroll, ...), propagates
  like event handlers do.

Since there is a variety of expected behaviors, and the possibility
of stacking for some of the existing Wayland "grabs", this provides
the mechanism for that to happen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
77ec0d1e41 wayland: Add API to change a tool focus surface
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
9c2514b75c wayland: Add MetaWaylandPointer method to focus surface
This method ATM hooks up with MetaWaylandPointer's grabbing
mechanism, triggering a focus on the existing grab interface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
a98f1b2764 wayland: Add getter for the implicitly grabbed surface of a touch sequence
This will be used to implement the default MetaWaylandEventInterface at
MetaWaylandSeat.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
20f7a60e11 wayland: Add getter for the current surface of a tablet device
That would be the surface under the tool that is being currently used
on the device. This will be used by MetaWaylandSeat to implement the
default MetaWaylandEventInterface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
fe71588a2d wayland: Add getter for MetaWaylandPointer current surface
This is the surface currently under the pointer, and will be used
by MetaWaylandSeat to implement the default MetaWaylandEventInterface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
09101e36f8 wayland: Handle pointer focus inhibition at the Clutter level
The MetaWaylandPointer used to put this together through
MetaCursorTracker cursor visibility, and ClutterSeat-level
inhibition API, applying the pointer focus changes due to
visibility logically to Wayland clients.

In order to make this work over all Clutter widgetry
instead of just Wayland clients, make the ClutterSeat-level
inhibition API control this feature at the ClutterStage picking
level, and leave/enter the seat pointer as appropriate.

By default, the seat pointer has (un)focus inhibited. The
MetaCursorTracker has been made another player in unfocus
inhibition, simply asking for the pointer to get its focus
while the cursor is visible.

This in practice means that picking code may return a NULL
actor, some asserts and preconditions had to be changed to
handle this, plus some test code slightly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
7a2411ce50 wayland: Refactor grab checks for tablets
Do not jump at MetaWaylandSeat across the MetaWaylandTabletSeat to
poke at the tablet tools, and chain up the checks through a
MetaWaylandTabletSeat method instead.

While at it, use g_autoptr to manage the tool list, and fix a leak.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
Carlos Garnacho
a37fd34bbb wayland: Make MetaWaylandSeat in charge of its own tablet seat
The relation between seats and tablet seats is always 1:1, Make
the MetaWaylandSeat hold its own MetaWaylandTabletSeat, and
manipulate it directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
2024-02-13 01:01:48 +01:00
columbarius
692a4cec09 screen-cast-stream-src: Cleanup includes and defines
Removes unused includes and fix indentation of macros to make CI happy
:).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2557>
2024-02-12 21:46:14 +01:00
columbarius
9d328001d1 screen-cast-stream-src: Renegotiate when DMABUF allocation fails
After negotiation of DMABUF transport mutter will silently allocate SHM
buffers if the allocation in the add_buffer callback fails. It's cleaner
to renegotiate the supported formats without announcing DMABUF
capabilities in this case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2557>
2024-02-12 21:45:27 +01:00
columbarius
1462eb69a8 screen-cast-stream-src: Move FormatParam building code into function
To fixate the format or renegotiate after a DMABUF allocation failed we
need to rebuild the EnumFormat params.

The function meta_screen_cast_query_modifiers will return false if no
modifiers are supported, thouse we can drop the check and remove the
macro guard.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2557>
2024-02-12 21:45:27 +01:00
columbarius
265a17e01c screen-cast: Implement query_modifiers
This function contains a stub, which returns support for implicit
modifiers, if modifiers are supported preserving the current
capabilities. The stub has to be replaced with a query to the cogl
renderer to support explicit modifiers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2557>
2024-02-12 21:45:27 +01:00
Robert Mader
f26939255e compositor-view/native: Remove leftover check
This check was originally added because `window` was actually used.
While technically correct, there's no reason to keep it around.

Fixes: 4736f873f2 ("compositor/native: Add support for direct scanout per view")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
bd6196f4ca wayland: Implement direct scanout for cropped and scaled surfaces
Until now we only supported direct scanout to the primary plane if the
buffer size perfectly matched the display size.
Since display controllers usually support scaling and cropping buffers
highly efficiently, try to let them do the job. This is usually helpful
if wp_viewporter is used by the client or Mutter uses fractional
scaling.

This has several advantages:
 - Games (e.g. SDL2 based ones) can almost always hit direct scanout
   paths in fullscreen mode. Notably when fractional scaling is used or
   the game renders in a non-native resolution (or both).
 - Video players using YUV buffer formats and wp_viewporter can easily
   hit direct scanout paths, making displaying video very power
   efficient as the 3D engine is not used at all.

Note that this still only uses the primary plane, no overlay or underlay
planes, making this change comparatively low risk.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
ed50cbbfe4 window-actor/wayland: Update scanout candidate check
In a following commit we will start supporting scaled and croped
surfaces, thus, in preparation, update the logic to three common cases:
1. only one surface, fullscreen (most apps)
2. a content surface and a black background surface which the client
   does not want to unmap, fullscreen
3. top-level subsurface covers the whole window and is opaque (Firefox)

The remaining currently supported cases should be fairly uncommen and
and harder to compute.

Note that we already check that the window cover the stage view in
MetaCompositorView.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
50f8f1e8b3 wayland/single-pixel: Add API to check if buffer is opaque black
Which is the typical background color we also use for fullscreen
padding. This will allow us to apply optimizations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
adc776d0d7 crtc/kms: Pass on src and dst rects to primary plane assignments
This allows us to pass on the related data from CoglScanouts.

If dst_rect does not match the mode, we assume that not covered areas
are opaque black - usually black bars around a centered surface.

While such driver behaviour does not appear to be documented (well) yet,
it seems to be followed by all known existing drivers and is used in a
similar way in ChromeOS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
26ce5cd6be kms/update: Add meta_fixed_16_from_double helper
It will be used in the next commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
d5fe58f355 kms/update: Use bitshifts for fixed_16 helpers
For easier understanding.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
912cd80f10 cogl/scanout: Add API for source/destination rectangles
These will get passed on to KMS later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Robert Mader
52c4b85161 cogl: Turn CoglScanout into an object
We need an object to hold additional scanout related information, such
as scaling and positioning data. Turn CoglScanout into such an object,
moving the interface into CoglScanoutBuffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3177>
2024-02-10 17:41:12 +00:00
Bilal Elmoussaoui
f72dbc8046 barrier: Drop deprecated display property
It was deprecated 23 months ago in 0debb24e12

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3573>
2024-02-09 18:03:09 +01:00
Bilal Elmoussaoui
fa59796afd meta: Drop deprecated methods
Both functions were deprecated 20months ago, so should be safe
to remove now

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3573>
2024-02-09 18:03:09 +01:00
Bilal Elmoussaoui
cc1957a4ba clutter/flow-layout: Use Orientation enum
Instead of having a custom FlowOrientation one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3573>
2024-02-09 18:03:09 +01:00
Bilal Elmoussaoui
9bf55cd054 cleanup: Drop unused MetaVirtualModifier
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3573>
2024-02-09 18:03:09 +01:00
Bilal Elmoussaoui
cd245bce0c core/stack: Check client type before getting group
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/3283

Fixes: 43351b483 ("window: Move group to WindowX11")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3572>
2024-02-08 22:05:39 +01:00
Bilal Elmoussaoui
5d4cfb607c core/stack-tracker: Guard X11 usages
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3555>
2024-02-08 16:55:06 +01:00
Bilal Elmoussaoui
e1e6534eb2 group: Move various functions to MetaWindowX11
Except meta_window_x11_get_group, which is still used by GNOME Shell
and we can't make it a private API for now.

Will need further investigation and could be done as a future
step

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3555>
2024-02-08 16:55:06 +01:00
Bilal Elmoussaoui
f0c22cb3bc core: Guard MetaGroup usage
For now, we just guard part of the group header as it is
consumed by gnome-shell. Ideally, we would drop that use case and make
the whole header private.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3555>
2024-02-08 16:54:50 +01:00
Bilal Elmoussaoui
43351b483f window: Move group to WindowX11
Which means meta_window_get_group now requires a x11 client type,
so ensure we don't call it on a wayland client

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3555>
2024-02-08 16:24:58 +01:00
Bilal Elmoussaoui
e17d20191e display: Refactor IN_TAB_CHAIN macro
The macro used to call into a bunch of other macros so let us turn it
into a single function.
This would simplify things for the next commit that puts the MetaGroup
usage behind a X11 ifdef

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3555>
2024-02-08 16:24:58 +01:00
Bilal Elmoussaoui
467120d5aa cleanup: Remove unused callbacks
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3570>
2024-02-08 13:32:51 +00:00
Daniel van Vugt
1c58c8cb92 onscreen/native: Notify frame complete on failure to lock front buffer
If such a failure is followed by a successful frame then the Cogl frame
queue would have size 2, leading to an assertion failure in
`meta_onscreen_native_notify_frame_complete`:

```
g_assert (!cogl_onscreen_peek_head_frame_info (onscreen));
```

Notifying on the failure however keeps the Cogl frame queue limited to
a size of 1 and we recover gracefully with only a missed frame and a
warning message.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3278
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3565>
2024-02-08 12:44:55 +00:00
Carlos Garnacho
0eb9c43908 wayland: Trigger seat focus change on popup changes
Popups were missing the "input focus" unification in the pointer
seat, triggering MetaWaylandKeyboard focus changes underneath. On
one hand this missed moving all associated focus with it, on the
other hand this made keyboard and global input focus get out of
sync, and bring funky behavior like keyboard focus loss after
dismissing popups.

Fixes: 7b232d9f65 ("wayland: Keep track of the "input focus" on MetaWaylandSeat")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3256
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3568>
2024-02-08 11:32:31 +00:00
Carlos Garnacho
bf89ada2c1 backends: Disambiguate output mapped to tablet with connector name
In some circumstances, we may end up with outputs with the same
vendor/product/serial, in which case we have a hard time finding the
right one to map tablets to, since configuration only has these 3
pieces of data.

Add the handling of a 4th argument containing the output name
based on the connector (e.g. HDMI-1), so that it can be used to
disambiguate the output if necessary.

This only kicks in if there actually are multiple outputs with the
same EDID data. A goal of the configuration as it was stored was to
remain useful if the user changed how the device is physically
connected to the computer, this remains true for the vast majority
of users having a single thing of each.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3556>
2024-02-06 10:03:48 +00:00
Peter Hutterer
ff38cf366d backends/x11: Store eraser and stylus tools separately
Our hashtable stores tools by the serial but our stylus tool and eraser
tool share the same serial - they only differ by the tool type.

This results in only one tool being created and this tool re-used for
the other type tool. Fun side-effects of this are that the stylus ends
up using the eraser pressure curve (or vice versa).

Hack around this by bit-flipping the serial for the eraser to
make it distinct - this is the only place we need to wrorry .

Closes #1884

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3542>
2024-02-05 12:33:43 +00:00
Olivier Fourdan
b8914da0c8 input-capture: Fix barrier validation without a monitor at (0.0)
For barrier validation, check_barrier() would start from the
(presumably) left-most monitor and walk the neighbor monitors to the
right.

This is assuming that there is always a monitor at (0.0), which is not
necessarily the case. If the first monitor on the left is not aligned at
the top, there is no logical monitor at (0.0) causing a NULL pointer
derefence.

Instead of starting from the monitor at (0,0), start from the primary
logical monitor, as there is necessarily one.

Fixes: 85885c6 - Check barriers don't extend into nonexisting monitors
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3562>
2024-02-05 10:45:26 +01:00
Robert Mader
a422ae022b wayland/buffer: Move scanout lifetime handling
There doesn't seem to be a good reason to keep this code in
`MetaWaylandSurface`. Moving it to `MetaWaylandBuffer` cleans things
up and will allow us to tread buffers differently depending on their
type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3559>
2024-02-02 17:52:30 +01:00
Robert Mader
03a98343d2 wayland/dma-buf: Take MetaWaylandBuffer in try_acquire_scanout
And do some minor variable order cleanup while on it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3559>
2024-02-02 17:40:37 +01:00
Peter Hutterer
e928128743 core: Handle Alt in the MetaPadActionMapper
In the parser we set MOD1 if we encounter <Alt>, so let's send the
respective key event here.

Closes: gnome-control-center#2593
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3522>
2024-02-01 10:22:22 +00:00
Bilal Elmoussaoui
3774554028 core/window: Guard some x11 calls
Also drops an unused x11 header

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
2024-01-31 12:25:39 +00:00
Bilal Elmoussaoui
e68a8a0a17 core/launch-context: Guard X11 calls
Also make use of display where possible to avoid a warning
about an unused display variable if one tries to build without x11

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
2024-01-31 12:25:39 +00:00
Bilal Elmoussaoui
d8812c0d2f compositor/drag: Guard X11 call
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
2024-01-31 12:25:39 +00:00
Bilal Elmoussaoui
67e21e0881 compositor/actor: Guard X11 actor usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
2024-01-31 12:25:39 +00:00
Bilal Elmoussaoui
b6f38b21b7 backends/barrier: Guard X11 usage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
2024-01-31 12:25:39 +00:00
Bilal Elmoussaoui
8922ada681 core/context: Guard X11 calls
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
2024-01-31 12:25:39 +00:00
Bilal Elmoussaoui
c388abe1e3 core/context: Make notify_ready vfunc optional
As it is used only in a X11 build for session management
See next commit

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3540>
2024-01-31 12:25:39 +00:00
Sebastian Wick
947f20b1a7 renderer-native: Ensure all planes support EGL config format
For secondary GPU rendering contexts we currently might choose an EGL
config with a format which is not supported on all primary planes. The
renderer is created when a GPU is detected and lighting up outputs and
thus assigning CRTC and primary planes can happen at any point after
that. This means we have to make sure that all possible plane
assignments will work with the rendering context when we create it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3235
Fixes: cc7bca073 ("crtc/kms: Dynamically assign primary and cursor planes")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3512>
2024-01-31 00:58:29 +00:00
Sebastian Wick
fbf68bf88c crtc-kms: Get rid of meta_crtc_kms_supports_format
Instead get the assigned primary plane and use
meta_kms_plane_is_format_supported.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3512>
2024-01-31 00:58:29 +00:00
Sebastian Wick
60fd80b616 crtc-kms: Get rid of meta_crtc_kms_get_modifiers
Instead get the assigned primary plane and use
meta_kms_plane_get_modifiers_for_format.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3512>
2024-01-31 00:58:29 +00:00
Sebastian Wick
2fda8ae6d9 crtc-kms: Get rid of meta_crtc_kms_copy_drm_format_list
Instead get the assigned primary plane and use
meta_kms_plane_copy_drm_format_list.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3512>
2024-01-31 00:58:29 +00:00
Sebastian Wick
ee60e33d95 crtc-kms: Get rid of unusedmeta_crtc_kms_set_is_underscanning
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3512>
2024-01-31 00:58:29 +00:00
Sebastian Wick
84070b4a3f crtc-kms: Get rid of unused is_transform_handled
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3512>
2024-01-31 00:58:29 +00:00
Sebastian Wick
d6dc403fa8 backends/native: Move KmsUpdate plane assignment to OnscreenNative
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3512>
2024-01-31 00:58:29 +00:00
Sebastian Wick
23b30267b5 monitor-unit-tests: Add basic tests for RGB range
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
926f7ea26d backends: Get the RGB range from a monitor config to the output
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
3f866d22c9 monitor-config-store: Store and parse rgbrange monitor property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
5ca2e06b2c monitor-config-store: Explicitly initialize MonitorConfig
To the defaults. This will become useful in the next commit where we
want a default value that's not 0.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
7b1e89b046 monitor: Add a getter for the RGB range
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
d945626318 onscreen/native: Set the RGB range when mode setting
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
aa7cd84f7c output: Introduce the RGB range property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
665c21e65b output: Explicitly initialize output properties
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
c4399bd94d kms/connector: Add support for the Broadcast RGB property
It can be used to force a specific RGB range. Some monitors don't follow
the specification and expect a signal different from what we send. This
property allows to force a mode which hopefully then works correctly for
the sink.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
d45104c14a backends/native: Build up connector updates in onscreen-native
instead of building them in OutputKms. The KMS objects are really not
the place for this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Sebastian Wick
af4de2a681 output/native: Remove unused function declarations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
2024-01-30 16:24:52 +00:00
Carlos Garnacho
3528b54378 backends/native: Fix clutter button number assignment to pointer evcodes
Commit 947c636275 meant to swap BTN_STYLUS* buttons, not BTN_MIDDLE/RIGHT
as used by pointing devices. This was also missed during review.

Fixes: 947c636275 ("backends/native: Swap BTN_STYLUS and BTN_STYLUS2")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3550>
2024-01-27 14:11:42 +01:00
Peter Hutterer
a26d08d3bc core: Detect pad ring wraparound values
A ring will naturally go from 355 degrees to 5 degrees (or vice versa),
giving us the illusion of a direction change. Avoid this by assuming
that any change larger than 180 degrees is actually the equivalent
smaller change in the other direction.

Closes #1885

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3545>
2024-01-27 10:44:51 +00:00
Peter Hutterer
947c636275 backends/native: Swap BTN_STYLUS and BTN_STYLUS2
BTN_STYLUS is the lower one and traditionally (read: in X) maps to
middle button (2), BTN_STYLUS2 is the upper one and traditionally maps
to right button (3).

This is also what GTK does and our desktop actions too map MIDDLE to
BTN_STYLUS and RIGHT to BTN_STYLUS2.

See also gtk!6168

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3541>
2024-01-27 10:32:40 +00:00
Peter Hutterer
d92c89ca23 backends/native: Use the define for BTN_STYLUS3
We #define it if at the top of the file if it's not available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3541>
2024-01-27 10:32:40 +00:00
Carlos Garnacho
381048cf90 wayland: Restore IM state flushing before handling key events
The code that maybe flushed IM state before processing a key event
became ineffective at commit 7716b62fa2, since the handle_event()
method on MetaWaylandTextInput won't handle key events, only IM
events and touch/button press events causing IM state to be
committed. Basically, the events that directly change the IM state.

Move this ineffective code to the the filter_event() method handling
the key presses in order to let the IM maybe filter them, and handle
them so that any key event that is let through (both key events
previously injected by the IM, and key events that the IM chooses to
ignore) will ensure that the pending IM state is flushed before the
key event is handled and emitted to the client.

This brings back lost guarantees of orderly event emission when IMs
alternate key events and IM actions.

Fixes: 7716b62fa2 ("clutter: Separate ClutterInputFocus event processing and filtering")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3090
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3536>
2024-01-27 10:18:40 +00:00
Bilal Elmoussaoui
92ef543a44 window: Clarify rectangle type
It is no longer a cairo rectangle

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3530>
2024-01-27 10:03:15 +00:00
Bilal Elmoussaoui
700ef19e8b tests: Remove unnused cairo import
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3530>
2024-01-27 10:03:15 +00:00
Sebastian Keller
f99c6badb9 backends: Update cursor names to match updated metaphors
adwaita-icon-theme updated its cursor metaphors and changed all DnD
cursors to use arrows instead of hands, except for the grab related
ones. Mutter was using "grabbing" as default DnD cursor, which now
does not match the other DnD cursors ("copy" and "no-drop") anymore.
Change this to the "default" cursor.

Additionally, because the "no-drop" cursor now puts a stronger emphasis
on the crossed out symbol also prefer "default" for
META_CURSOR_DND_IN_DRAG and only use "no-drop" for things that
explicitly don't accept a drop.

Related: https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/merge_requests/63
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3532>
2024-01-26 23:44:02 +00:00
Sebastian Wick
af0ca0cdc2 kms/cursor-manager: Create CrtcStateImpls for all active CRTCs
even if they don't have a cursor plane. This way we can just use the
object. Updating the cursor plane then just looks at the cursor_plane
field to skips updates when there is none.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3254
Fixes: cc7bca073 ("crtc/kms: Dynamically assign primary and cursor planes")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3539>
2024-01-26 23:07:39 +00:00
Dor Askayo
0eaf4b4f4c Revert "frame/native: Remember whether the frame carried a kms update"
This reverts commit 020d128d15.

This API is no longer used and can be removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3549>
2024-01-26 22:23:05 +00:00
Dor Askayo
b8deb4caa0 wayland: Emit frame callbacks when the frame is pending presentation
When Wayland clients send commits without a buffer attached ("empty"
commits), they may lead to stage updates that do not result in any
frame being submitted for presentation ("empty" updates).

Due to how frame scheduling is handled, there can be many such
"empty" updates in a single refresh cycle. If frame callbacks were
emitted after each of these "empty" updates, and if the client
sending "empty" commits was using frame callbacks to throttle the
same logic that results in these "empty" commits being sent, it would
result in a feedback loop between Mutter and the client where the
client would send "empty" commits and Mutter would reply almost
immediately with a frame callback causing the client to send "empty"
commits continuously.

As such, when an "empty" update is detected, frame callbacks are
scheduled to be emitted only once in every refresh cycle, avoiding the
feedback loop.

When a "non-empty" update is detected, frame callbacks are instead
emitted immediately to allow clients to draw their next frame as soon
as possible. It is safe to emit frame callbacks in this case because
the frame for the current refresh cycle is already "finalized" and
that any commit sent by the client at that point would only be handled
in a future refresh cycle.

To implement this, the previous logic had used
meta_frame_native_had_kms_update() to detect "non-empty" updates,
assuming that those would always result in a KMS presentation with the
native backend.

However, this approach misses the fact that virtual monitors do not
use KMS, and as such do not result in KMS presentation even for
"non-empty" updates. As a result, frame callbacks would not be emitted
immediately, resulting in unintended throttling of client rendering.

Instead, assume that it is safe to emit frame callbacks immediately
whenever an update results in the frame clock waiting to be notified
of presentation, since this is also when commits sent by clients are
scheduled to be handled in a future refresh cycle.

This issue was mostly hidden because frame callbacks would be sent
immediately when the target presentation time for the frame had
changed compared to the previous frame. However, this behavior was
removed in 26d8b9c69 ("wayland: Remove unnecessary dispatch of frame
callback source"), exposing the issue.

Fixes: a7a7933e0 ("wayland: Emit frame events in GSource after "empty" updates")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3263
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3549>
2024-01-26 22:22:52 +00:00