Commit graph

153 commits

Author SHA1 Message Date
Derek Foreman
6adef7fa06 trace: Don't try to show details when there's no focus client
This can turn into a NULL pointer dereference, and the values
aren't meaningful in this state anyway.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-05-21 16:10:04 -05:00
Marius Vlad
a276db50f8 input: Add support for tracking input events on egress side
This includes an additional _double variant for _Generics and a bool
one.

Similarly, _WESTON_TRACE_ANNOTATE_FUNC_FLOW gets a _Generics macro variant
to handle the case were we have a integer flow ID, rather than an a
pointer.

Finally we always have a flow ID set when weston_input_event gets
initalized.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-21 21:58:17 +03:00
Marius Vlad
5d07696101 input: Add TL_POINTs for kernel timestamps at input initialization
This basically starts tracking input event. From here on we can start
flow tracking the event until it exits and is being delivered to the
client.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-21 21:47:05 +03:00
Marius Vlad
a1ac3c2e8d timeline: Add support for weston_input_event
And with it include a dedicated track in Perfetto to display the event
timestamp on that a weston_seat. This includes support for timeline and
for timeline Perfetto.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-21 21:47:02 +03:00
Marius Vlad
c6ae939221 input: Introduce weston_touch_event
Similar to "input: Introduce weston_key_event struct" this struct is for
touch events. With this we add the initialization helpers, pass the
weston_touch_event as a const and remove the timespec argument.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-19 00:21:52 +03:00
Marius Vlad
98f8a08896 input: Re-work weston_pointer_axis_event
Move to a const struct weston_pointer_axis_event, add the base_event
struct that contains the timespec and use the initialization functions.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-19 00:21:52 +03:00
Marius Vlad
539bb34df4 input: Introduce weston_pointer_button_event
Similar to "input: Introduce weston_key_event struct", this adds a way
to store all required information with a common struct event to be able
to pass it down and to allow also pass additonal information like
Perfetto's flow IDs.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-19 00:21:52 +03:00
Marius Vlad
ce2f53a2f9 input: Remove notify_motion_absolute
We're now able to use the mask to pass the proper type so need for
a specialized version.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-19 00:21:52 +03:00
Marius Vlad
f9c1a4bf5d input: Re-work weston_pointer_motion_event
This adapts weston_pointer_motion_event struct to align in with
weston_key_event and includes the following changes:

- include base struct
- remove the const struct timespec from calls and use the base struct
- pass by a const pointer motion event in all the callers
- add init helper

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-19 00:21:52 +03:00
Marius Vlad
754d00e400 input: Drop time field from weston_pointer_motion_event
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-19 00:21:52 +03:00
Marius Vlad
47a3823672 input: Use weston_pointer_move_to on output re-configuration
Replace weston_pointer_move with weston_pointer_move_to and drop
uneeded weston_pointer_motion_event, as weston_pointer_move_to
would clamp the pointer inside the output's area.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-19 00:21:18 +03:00
Marius Vlad
99527e6b92 input: Introduce weston_key_event struct
Rather than passing a time stamp, key, key state and key event state
use a weston_key_event struct to pass by all that using it.

This would allow in further patches to attach additional information
like a flow id used by Perfetto debug annotations for input events.

This patch has no functional change as it is now.

All the callees will just will extract the required information out of
struct weston_key_event.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2026-05-13 21:38:55 +03:00
Derek Foreman
2598073d99 input: Remove a bunch of explicit transform updates
All of these precede calls to weston_coord functions that now
do the transform update implicitly.

Some of them precede it immediately, and others through
functions like weston_pointer_set_focus and weston_pointer_send_motion
which use weston_coord_global_to_surface.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2026-04-02 15:29:55 +03:00
Pekka Paalanen
83424f4025 libweston: use new label for pointer cursors
Part of migration away from get_label().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2026-03-04 07:28:49 +00:00
Leandro Ribeiro
65e82a47d8 libweston: do not forget to emit touch->focus_signal
This signal is never emitted when touch focus changes. In this patch we
start emitting it, allowing listeners to react to touch focus changes.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2026-02-20 22:13:01 +00:00
Wang Ruitang
c23ea4ba8d libweston: check focus surface before enabling pointer constraint
Check if surface matches before enabling pointer constraint. If not
match, no constraint enabled. Otherwise, assertion would failed in
confined_pointer_grab_pointer_motion() and weston would crash.

This fixes crashes reported in GitLab issues #185 and #670.

Closes: https://gitlab.freedesktop.org/wayland/weston/-/issues/185
Closes: https://gitlab.freedesktop.org/wayland/weston/-/issues/670
Signed-off-by: Ruitang Wang <Ruitang.Wang@amd.com>
2026-02-05 13:28:52 +08:00
Pekka Paalanen
c23d028300 libweston: fix false-positive uninitialized variables sx, sy
GCC 14.2 with debugoptimized build complained:

../../git/weston/libweston/input.c: In function ‘weston_pointer_set_focus’:
../../git/weston/libweston/input.c:1988:29: error: ‘sx’ may be used uninitialized [-Werror=maybe-uninitialized]
 1988 |                 pointer->sx = sx;
      |                 ~~~~~~~~~~~~^~~~
../../git/weston/libweston/input.c:1913:20: note: ‘sx’ was declared here
 1913 |         wl_fixed_t sx, sy;
      |                    ^~
../../git/weston/libweston/input.c:1989:29: error: ‘sy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1989 |                 pointer->sy = sy;
      |                 ~~~~~~~~~~~~^~~~
../../git/weston/libweston/input.c:1913:24: note: ‘sy’ was declared here
 1913 |         wl_fixed_t sx, sy;
      |                        ^~

Initialize with an arbitrary value to avoid the warning. This value
should never make it outside of this function.

The debug build did not complain.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-12-16 15:19:02 +00:00
Derek Foreman
0680683539 input: Don't refocus clients when pointer moves against boundary
If we don't clamp the input before updating the pointer surface coords,
we'll trigger the "surface jumped beneath us" logic later when the clamp
really happens. That leads to spurious pointer leave/enter events.

Add clamping to weston_pointer_send_motion() to fix this.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-16 09:22:05 +00:00
Derek Foreman
613558e69e input: refactor weston_pointer_move_to
Pull the clamping out and expose an internal pre-clamped function, which
will be used elsewhere in a later commit.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-16 09:22:05 +00:00
Derek Foreman
d830ce962a input: move some pointer functions
These will be used earlier in the file soon, move them now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-12-16 09:22:05 +00:00
vorlunez
025f5a7c45 input: fix setting hint_is_pending
when the hint_is_pending is true, it should assign the hint_pending to the hint and set the hint_is_pending to false, but the hint_is_pending set to true again after setting to false.

remove the redundant line to fix this.

Signed-off-by:  Vorlune Zhang <Vorlune.Zhang@gmail.com>
2025-12-16 15:16:15 +08:00
Derek Foreman
76dc730d3d compositor: Move region_init_infinite to a header
We've got it in two places, let's share the code.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-05 10:01:42 -05:00
Taehyeon Jeong
0add10986d input: improve keyboard keys array traversal in notify_key()
The loop in notify_key() that traverses the keyboard keys array has been
improved by adding a break statement after removing a key and simplifying
the loop structure. This eliminates unnecessary iterations and removes
ambiguity in the code flow, making it both more efficient and clearer.

Signed-off-by: Taehyeon Jeong wxogus25@gmail.com
2025-06-20 20:17:37 +00:00
Marius Vlad
1a2c25116b libweston: Rename LED_* to WESTON_LED*
This is required to avoid a namespace collision for LED_COMPOSE key
code and was introduced with c112760368, "input: Add support for
LED_COMPOSE and LED_KANA".

If not already done this requires a libweston major version bump.

Fixes: #997
Fixes: c112760368, "input: Add support for LED_COMPOSE and LED_KANA
USB HID LEDs"

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-03-07 14:30:20 +00:00
Martin Rys
c112760368 input: Add support for LED_COMPOSE and LED_KANA USB HID LEDs
Also bump up the xkbcommon dependency to a newer, 10 year old version,
to be able to remove very old ifdefs.

Signed-off-by: Martin Rys <martin@rys.rs>
2025-02-12 17:04:06 +02:00
Marius Vlad
207fed2710 Revert "shared/helpers.h: Migrate helpers.h to libweston"
This is problematic as we don't have namespacing for these and some of
the macros can interfere with other defines.

This reverts commit 8634c7e349.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-01-17 10:18:26 +02:00
kang-sooyeon
c77a5d386a libweston/input.c: Fix weston crash with the mouse event
Fix weston crash when user click the mouse continuosly while
the video is playing.
Call weston_view_update_transform before calling
weston_coord_global_to_surface to update view->transform.dirty to 0.

Fixes #985

Tested-by: Sooyeon Kang sooyeon8979@gmail.com
Signed-off-by: Sooyeon Kang sooyeon8979@gmail.com
2025-01-17 07:54:59 +00:00
Marius Vlad
8634c7e349 shared/helpers.h: Migrate helpers.h to libweston
As weston_windowed_output_get_api needs ARRAY_LENGTH() move helpers to a
libweston/ so other users can re-use that instead of re-defining these
all over. Easier for other front-ends to make use of them.

With this change windowed-output-api.h also includes the helpers header.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-11-25 11:26:35 +00:00
David Edmundson
fe64eee3ae libweston: Send seat name before announcing devices
Clients need to know the seat name at the time they create mouse and
keyboard objects. This brings Weston in line with other compositors.

The documentation upstream currently is not super clear. It states name
is explicitly sent on bind, capabilities don't mention being sent on
bind in any way.

Signed-off-by: David Edmundson <davidedmundson@kde.org>
2024-09-26 13:28:30 +00:00
Loïc Molinari
8c2d47f86d input: Fix release/debugoptimized build warning with gcc
Fix ‘old_sx’ and ‘old_sy’ used uninitialized.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2024-07-03 10:54:34 +00:00
vanfanel
90664b0f3b libweston: enable pointer constraints for fullscreen surfaces.
Signed-off-by: vanfanel <redwindwanderer@gmail.com>
2024-03-04 12:45:07 +01:00
Daniel Stone
7f62fe817a input: Use surface/view helpers to map
Use the helpers to map a weston_surface and weston_view, rather than
manually manipulating the internals.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-12-06 12:16:27 +00:00
Daniel Stone
1f9e0ce9ad input: Use helpers to map surfaces/views
When working on tablet tools, use the weston_surface and weston_view
helpers to manipulate their cursors, instead of manually setting various
members.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-12-06 12:16:27 +00:00
Derek Foreman
e622be7423 input: avoid crash by using surface directly
A constraint always has a surface, but may not have a view - use the
surface pointer directly without trying to get it through the view.

Fixes #823

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-13 07:46:44 -05:00
Derek Foreman
720421c193 libweston: Add and use weston_coord_surface_add/sub helpers
We already have these for global coordinates, now we have them for
surface coordinates too. In addition to removing some unsightly
unadorned coordinate usage, this also adds appropriate coordinate space
id checks at runtime.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00:00
Derek Foreman
18cce195d3 libweston: Make a common helper for clamping a coord to an output
This is a tricky bit of code and we use it in two places. Let's make a
single implementation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-10-03 18:19:17 +00:00
Derek Foreman
9f7f8faff6 input: Use weston_coord in the cursor confinement code
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman
5fa3ef26c9 libweston: Use weston_coord for touch interfaces
Most of these don't use the parameter that changes at all, but some get
a nice simplification.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman
8eed64c7df libweston: Add weston_view_set_position_with_offset
There are many times when we want to set a global position with a surface
offset added.

It's a fairly nasty operation, and most places in the code currently do
it naively, ignoring the painful existence of freeform window rotations
and other complex transforms that could be in play (but probably aren't)

Add a helper for this and convert existing usage.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Derek Foreman
b87dcbdf34 input: Fix pointer hotspot coordinate space
Oops, this was always wrong but nothing actually checked it. Checks are
coming, so it needs to be fixed.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-18 20:35:37 +00:00
Daniel Stone
bd97abf18f input: Remove unnecessary repaint schedules
There's no need to call weston_view_schedule_repaint() once we've
updated view properties.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-07-24 12:35:47 +03:00
Derek Foreman
0bf2d82e0c libweston: Use weston_coord in struct weston_touch
Convert the grab coordinate to a weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:58:17 -05:00
Derek Foreman
e8208d21d7 libweston: Use weston_coord in struct weston_output
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:22 -05:00
Derek Foreman
244dc963b9 libweston: use weston_coord for weston_view_set_position
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:19 -05:00
Sergio Gómez
a7f63c1220 libweston/input: Use WESTON_ACTIVATE_FLAG_FULLSCREEN in activation logic
The addition in a former commit of the flags field in the activation data will
let us pass the reason for activation to the constraint logic. We use that
reason here to unconditionally enable constraints in the recently 'fullscreened'
surface.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-05-25 12:07:03 +03:00
Sergio Gómez
ed012ee505 libweston: Store view instead of surface, and add flags, to activation data
Since we want to pass the view to the surface activation listener inside the
constraints code, and the surface is reachable from the view anyway.

The flags field will let us pass the reason for activation to the constraints
code, which will then handle especially the fullscreen case.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-05-25 12:07:03 +03:00
Sergio Gómez
d11732c0fd libweston/input: Move activation signal logic out of keyboard focus function
Currently, and for legacy reasons, weston_seat_set_keyboard_focus() contains
logic related to surface activation. Since this function is always called from
weston_view_activate_input(), move that code there where it seems more
appropriate.

This will help us in subsequent commits by avoiding to have to change the
signature of weston_seat_set_keyboard_focus(), which would make that function
even more awkward than it currently is.

Signed-off-by: Sergio Gómez <sergio.g.delreal@gmail.com>
2023-05-25 12:07:03 +03:00
Michael Olbrich
9eab270de5 tablet: Add binding to activate surfaces using the tablet tool
Based on patches from:
Peter Hutterer <peter.hutterer@who-t.net>
Lyude Paul <thatslyude@gmail.com>
Bastian Farkas <bfarkas@de.adit-jv.com>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Lyude Paul
6a06669b58 clients: Add support for tablet cursor motion to window frames in libtoytoolkit
When it comes to a window frame, a tablet tool and cursor act almost
identical; they click things, drag things, etc. The tool type and extra
axes don't serve any use in the context of a window frame, so tablet
pointers share the frame_pointer structures used for the mouse pointer.

Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Lyude Paul <thatslyude@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com>
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00
Michael Olbrich
818c1c275c libweston: handle tablet cursors in the compositor
The tablet is given a separate cursor. Most tablet interaction is an absolute
interaction and shouldn't need a cursor at all, but usually the cursor is used
to indicate the type of virtual tool currently assigned.

Based on patches from
Peter Hutterer <peter.hutterer@who-t.net>
Lyude Paul <thatslyude@gmail.com>
Bastian Farkas <bfarkas@de.adit-jv.com>
Maniraj Devadoss <Maniraj.Devadoss@in.bosch.com>

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-31 12:10:26 +00:00