1
0
Fork 0
Commit graph

222 commits

Author SHA1 Message Date
Florian Müllner
fabad0be9c wayland: Remove unnecessary COMPOSITOR_GRAB checks
Since the new ClutterGrab API replaced the old plugin-modal hook,
the event-route is never set to COMPOSITOR_GRAB.

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

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

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
2022-01-29 00:37:14 +00:00
José Expósito
cea5c47671 wayland/pointer: Return on scroll without client
Return early from handle_scroll_event if no client is focused to avoid
redundant calculations.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
José Expósito
d703ba56c3 wayland/pointer: Call wl_resource_get_version once
Call wl_resource_get_version once for each pointer resource.

Refactor, no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1966>
2021-12-14 15:44:48 +00:00
Georges Basile Stavracas Neto
87a66830dc cogl: Drop cogl-wayland-server.h
This header only defines one function that doesn't exist anymore,
and nothing else. It can be safely dropped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2145>
2021-12-07 18:34:00 -03:00
Carlos Garnacho
5e93708d86 wayland: Mark sprite as invalid after cursor changes
This will be used to hint the backend that the cursor surface
might need uploading again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
2021-12-07 20:04:08 +00:00
Carlos Garnacho
c07c50d189 wayland: Make the pointer leave non-alive surfaces
Listen to changes in MetaWindow::is-alive, so that the pointer
can logically leave the surface as soon as that happens. This
helps prevent flooding the client socket while it is stalled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2122>
2021-12-07 17:15:21 +00:00
JoseExposito
8d34b50918 wayland/pointer-gestures: Implement hold gesture
Update the pointer gestures protocol to version 3 and implement the new
hold gesture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1830>
2021-12-02 20:48:24 +00:00
Olivier Fourdan
20bb8bf502 wayland: Avoid a race in wl_seat capabilities
The way wl_seat capabilities work, by notifying clients of capabilities
changes, and clients consequently requesting the relevant interface
objects (pointer, keyboard, touch) is inherently racy.

On quick VT changes for example, capabilities on the seat will be added
and removed, and by the time the client receives the capability change
notification and requests the relevant keyboard, pointer or touch,
another VT switch might have occurred and the wl_pointer, wl_keyboard or
wl_touch already destroyed, leading to a protocol error which kills the
client.

To avoid this, create the objects when requested regardless of the
capabilities.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1797
Related: https://bugzilla.gnome.org/show_bug.cgi?id=790932
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/77>
2021-09-16 06:52:20 +00:00
Jonas Ådahl
9827687ca1 wayland/seat: Unset resource user data when disabling
We make objects inert when disabling the seat, but we requests may still
have effect. This is especially bad if disabling is followed by
destroying, but also means e.g. set_cursor() not doing an early out
after the pointer capability was disabled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Robert Mader
6eeeffdc68 src: Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:52:27 +01:00
Carlos Garnacho
65e7b9ae3a wayland: Repick (again) on pointer motion
Unfortunately there's situations where we can't fully rely on only
crossing events here. One such situation is pointer visibility changes
due to touch interaction, or e.g. after closing the lid.

In these situations the pointer position stays the same, picks the
same actor, yet we want to see the right surface as the pointer focus
again in the wayland side.

This used to happen on the first motion event after the pointer
visibility change before commit ad3f2b0b86, use motion events again
for picking so we don't break these usecases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1657>
2020-12-28 19:11:26 +01:00
Carlos Garnacho
d39d4d124e wayland: Do not account touch crossing events for pointer
These events may be emitted for touchpoints (in which case they contain
an event sequence). Ignore those as they are not relevant for pointer
picking, and shouldn't influence its focus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1657>
2020-12-28 19:11:26 +01:00
Carlos Garnacho
ad3f2b0b86 wayland: Only repick pointer on crossing events
These are the only situations where it makes sense to determine a new
focus surface.

Suggested-by: Jonas Dreßler <verdre@v0yd.nl>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
ce6b91bb64 wayland: Drop meta_wayland_compositor_repick()
This is now unused, thus the whole call chain from this function
to meta_wayland_pointer_repick() can be removed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Carlos Garnacho
717e5d969a wayland: Avoid repick_for_event() call
We can also tell the stage to emit crossing events, which will be
handled in place (i.e. not queued), and yield the same result.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:45 +01:00
Carlos Garnacho
1f17a7ffef wayland: Do not query seat for pointer coordinates
In the wayland code we are in synchronization with the events that
the ClutterStage is managing at the moment. Asking the ClutterSeat for
the pointer position gets ahead of the current events, and may result
in imprecise coordinates sent in wl_pointer.enter.

To be in consistence with the motion events that might be already
queued, we should ask the stage for the last known coordinates.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:29:41 +01:00
Carlos Garnacho
0021fe173b wayland: Don't use CLUTTER_LEAVE source actor for repick
This is the actor receiving the event, therefore precisely not the
actor the pointer is on. We should avoid this event's source here,
use the related actor (i.e. the one being entered) instead.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1584
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:29:12 +01:00
Jonas Dreßler
ae6d83fb47 clutter: Switch to storing device->actor associations in ClutterStage
As planned and prepared with the last commits, let ClutterStage take
care of tracking input devices and their respective actors. This means
we now can remove the old infrastructure for this from
ClutterInputDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
2020-12-18 16:17:00 +01:00
Carlos Garnacho
b88790554b clutter: Move relative motion information to ClutterEvent
Instead of using native backend platform data specifically, store
this info in ClutterMotionEvent. This includes time in usec since
it's just used for motion events, in the future it could make sense
to make these general to all events again, but it could make sense
to make ClutterEvent structs private before.

In order to express that a motion event has relative motion info,
the CLUTTER_EVENT_FLAG_RELATIVE_MOTION event flag has been added
for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
9f5c453fc7 clutter: Move evdev evcode data to Clutter button/key events
We have this as platform-dependent data in the native backend, and
a bunch of fallback code done in place in the evcode users. Stop
making this platform-dependent data, and move it to the relevant
ClutterEvents.

The fallback code for the X11 backend case is about the same, but
now it is done directly by the X11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
c6849a66e8 clutter: Drop clutter_input_device_get_coords() method
This is not device state anymore. It uses ClutterSeat API underneath,
so let callers do that instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
0d83fcc870 wayland: Look up cursor renderer for device on MetaWaylandPointer
Make it explicitly look up the pointer device, instead of implicitly
relying on it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
a76a47fbde clutter: Pass timestamp to clutter_input_device_set_actor()
This function emits crossing events, so needs a (most times truthful)
timestamp. Make it explicit instead of fetching it from the device.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:19 +00:00
Carlos Garnacho
6a6894a397 clutter: Specify stage on clutter_input_device_update() function
This is the function performing the picking, tell it explicitly the
stage it should happen on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
2020-10-23 18:48:18 +00:00
Jonas Dreßler
7539de2320 clutter/input-device: Make clutter_input_device_get_actor() public
Make the clutter_input_device_get_actor() API public and remove
clutter_input_device_get_pointer_actor() in favour of the new function.

This allows also getting the "pointer" actor for a given touch sequence,
not only for real pointer input devices like mice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Dreßler
ad8ba69423 wayland/pointer: Use g_signal_connect_swapped for one signal
Remove the rather useless callback function that's currently used for
handling the "visibility-changed" signal and instead connect to the
signal using `g_signal_connect_swapped()`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1077
2020-02-24 09:52:06 +00:00
Jonas Dreßler
bf24b816c2 wayland/pointer: Add support for the new ClutterSeat inhibit-unfocus API
The last commit added a new API to ClutterSeat to inhibit setting the
focus-surface of the MetaWaylandPointer to NULL, let's do that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1077
2020-02-24 09:52:06 +00:00
Jonas Ådahl
c0c74484bc wayland: Don't access MetaWaylandSurface::window directly
It'll be moved to the role owning it, accessed via a helper function
implemented by the role. Currently it still just fetches the field in
MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Daniel van Vugt
06dae3a8cc wayland-pointer: Bail unconditionally if without native backend
Using `-Dnative_backend=false` caused build failure due to a missing
(implicit) definition of `META_IS_BACKEND_X11`. But if we define it
properly then that just leaves some of the function's locals uninitialized
and it will never work anyway. Just return unconditionally if there's no
native backend to initialize the variables.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1025
2020-02-05 18:09:34 +08:00
Carlos Garnacho
f1d4d687f3 backends: Drop get_relative_motion_deltas() vfunc
Just go ATM through backend checks, and looking up directly the
native event data, pretty much like the rest of the places do that...
Eventually would be nice to have this information in ClutterEvent,
but let's not have it clutter the MetaBackend class.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:37 +01:00
Carlos Garnacho
6dfd2ffcef wayland: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Olivier Fourdan
a382698acc wayland: Update input device before repick
When a Wayland window is mapped or unmapped, the Wayland compositor is
expected to send the coorespoindign `wl_pointer` enter/leave events to
the affected clients.

To do so, mutter calls `meta_wayland_compositor_repick()` which
eventually calls `meta_wayland_pointer_repick()` and
`repick_for_event()`.

If pointer input device has not been updated yet, the old clutter actor
is picked and no enter/leave event is emitted.

Make sure we update the pointer input device prior to do the repick to
get the actual `ClutterActor` under the pointer.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1016
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Jonas Ådahl
fcfe90aa9f wayland: Replace manual GNode subsurface iteration with macro
Similar to wl_list_foreach(), add
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE() that iterates over all the
subsurfaces of a surface, without the caller needing to care about
implementation details, such as leaf nodes vs non-leaf nodes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:21 +00:00
Robert Mader
92375c75f8 cleanup: Use g_clear_signal_handler() where possible
This is inspired by 98892391d7 where the usage of
`g_signal_handler_disconnect()` without resetting the corresponding
handler id later resulted in a bug. Using `g_clear_signal_handler()`
makes sure we avoid similar bugs and is almost always the better
alternative. We use it for new code, let's clean up the old code to
also use it.

A further benefit is that it can get called even if the passed id is
0, allowing us to remove a lot of now unnessecary checks, and the fact
that `g_clear_signal_handler()` checks for the right type size, forcing us
to clean up all places where we used `guint` instead of `gulong`.

No functional changes intended here and all changes should be trivial,
thus bundled in one big commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/940
2019-11-21 15:02:27 +00:00
Georges Basile Stavracas Neto
160cc9182d Replace ClutterPoint by graphene_point_t
Remove the tests for ClutterPoint since it's
corresponding code moved to private ClutterStage
methods.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Carlos Garnacho
7735a919d1 wayland: Check pointer visibility on post-grab focus changes
Just like sync_focus_surface() does, we shouldn't set a focus surface while
the pointer is hidden, so the illusion that there is none remains.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:37:13 +02:00
Carlos Garnacho
9f617ae43d wayland: Warn if a surface is being set while the pointer is invisible
This is an unexpected condition, better not to fall in it without further
indications.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:30:09 +02:00
Robert Mader
77229f99b8 wayland: Implement subsurface.place_below() for parents
Flatten the subsurface actor tree, making all surface actors children
of the window actor.
Save the subsurface state in a GNode tree in MetaWaylandSurface, where
each surface holds two nodes, one branch, which can be the tree root
or be attached to a parent surfaces branch, and a leaf, which is
used to save the position relative to child branch nodes.

Each time a surface is added or reordered in the tree, unparent all
surface actors from the window actor, traverse all leaves of the
tree and readd the corresponding surface actors back to the window
actor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/664
2019-08-27 11:31:00 +03:00
Carlos Garnacho
8b03d9ecc3 clutter: Move evdev input to src/backends/native
The end goal is to have all clutter backend code in src/backends. Input
is the larger chunk of it, which is now part of our specific
MutterClutterBackendNative, this extends to device manager, input devices,
tools and keymap.

This was supposed to be nice and incremental, but there's no sane way
to cut this through. As a result of the refactor, a number of private
Clutter functions are now exported for external backends to be possible.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
2019-08-24 08:59:08 +00:00
Jonas Dreßler
4bc7425332 wayland/pointer: Remove duplicate include
https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Jonas Dreßler
a2a8f0cdaa wayland/pointer: Set focus to NULL when the cursor is hidden
This is important when using a touchscreen or stylus instead of a mouse
or touchpad. If the cursor only gets hidden and the focus stays the
same, the window will still send hover events to the UI element under
the cursor causing unexpected distractions while interacting with the
touchscreen.

Fix this by emitting a visibility-changed signal from the cursor tracker
which then triggers a focus surface sync and always set the focus
surface to NULL when it's synced while the cursor is hidden.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Niels De Graef
1c6ea5d1db Use a consistent style for enum braces
https://gitlab.gnome.org/GNOME/mutter/merge_requests/361
2019-02-28 09:31:01 +01:00
Jonas Ådahl
2f4a68c8c3 Clean up include macros mess
The order and way include macros were structured was chaotic, with no
real common thread between files. Try to tidy up the mess with some
common scheme, to make things look less messy.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
50ff9d4c71 wayland: Rename cursor role types
Rename the two cursor role types according to the convention used by the
other roles. This means that MetaWaylandSurfaceRoleCursor was renamed to
MetaWaylandCursorSurface, and MetaWaylandSurfaceRoleTabletCursor was
renamed to MetaWaylandTabletCursorSurface. The corresponding filenames
were renamed accordingly too.

https://gitlab.gnome.org/GNOME/mutter/issues/77
2018-06-15 19:09:49 +00:00
Carlos Garnacho
5db48faca4 wayland: Update button state on motion/button events
More specifically, avoid crossing events, since clutter does not set
modifier/button state on those. Fixes implicit grabs being broken when
the pointer moves past the surface boundaries.

https://bugzilla.gnome.org/show_bug.cgi?id=785347
2017-07-24 17:57:31 +02:00
mitchmindtree
8457e2bad6 wayland/pointer: Check for subsurfaces when grabbing
Previously, the function only returned `TRUE` if the given surface was
equal to the given pointer's focused surface. This changes the behaviour
to also return `TRUE` if any of the given surface's subsurfaces are
equal to the pointer's focused surface.

https://bugzilla.gnome.org/show_bug.cgi?id=781811.
2017-06-07 09:47:29 +08:00
Jonas Ådahl
b4120a75e0 wayland/pointer: Track lifetime of current surface
Clear the pointer->current when the surface is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=783113
2017-06-01 12:46:32 +08:00
Jonas Ådahl
b19e4592df wayland/pointer: Use glib signals tracking focus surface
Use the "destroy" MetaWaylandSurface signal instead of the wl_resource
destroy signal for tracking the lifetime of the surface with pointer
focus.

As unsetting the focus may have side effects due to handlers of the
"focus-surface-changed" signal, connect the signal after the default
handler to make sure other clean up facilities have the chance deal with
the surface destruction before we try to unset the focus.

https://bugzilla.gnome.org/show_bug.cgi?id=783113
2017-06-01 12:46:32 +08:00