Commit Graph

90 Commits

Author SHA1 Message Date
Simon Ser da04b066ea cursor: add wlr_cursor_set_xcursor()
This keeps track of the last set XCursor. If it hasn't changed,
skip the texture upload.

In the future, support for animated XCursors can be added.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3436
2023-06-15 18:28:43 +02:00
Simon Ser 6e8fb5509f cursor: only reset the cursor when the surface changes
If the set_cursor request is used with the same surface, don't call
cursor_output_cursor_reset_image(). That function sends
wl_surface.leave and can cause an infinite feedback loop with some
clients (submitting a LoDPI cursor when the surface leaves an HiDPI
output).

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3669
2023-06-12 12:42:31 +00:00
Kirill Primak 31d958f70a cursor: fix applying hotspot offset
"On surface.attach requests to the pointer surface, hotspot_x and
hotspot_y are _decremented_ by the x and y parameters passed to the
request."
2023-06-07 10:35:49 +03:00
Simon Ser 09c87cec3f cursor: fix wl_pointer.set_cursor hotspot updates
A client might update the cursor with the same wl_surface as
before, but with a different hotspot. Don't ignore such updates.

Fixes: 9c9e3f6263 ("cursor: ignore wlr_cursor_set_surface() with same surface")
2023-06-02 22:33:40 +00:00
Simon Ser 6668c822b3 cursor: unset wlr_output_cursor.texture on surface destroy
When the surface is destroyed, its current wlr_texture is about to
get destroyed as well. Reset wlr_output_cursor.texture to prevent
use-after-free.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3652
2023-06-02 16:27:54 +00:00
Simon Ser 9c9e3f6263 cursor: ignore wlr_cursor_set_surface() with same surface
Avoids damaging the output and rendering the cursor again if it
hasn't changed.
2023-06-02 16:27:54 +00:00
Alexander Orzechowski 18139f4d87 wlr_cursor: Don't multiply hotspot by scale^2
We are already multiplying in output_cursor_set_texture
2023-05-08 09:17:22 +00:00
Alexander Orzechowski 47a250ae12 wlr_cursor: Consider surface state when setting new cursor surface
Found by inspection
2023-05-06 20:55:11 +00:00
Simon Ser 78afce5e2d cursor: add surface handling
Only rely on wlr_output_cursor_set_texture(), because
wlr_output_cursor_set_surface() will get dropped.
2023-05-06 17:48:56 +00:00
John Lindgren 68c8cef38e cursor: Don't warp to (0,0) when last output is disconnected
There doesn't appear to be any good reason to warp the cursor to
the top-left corner when all outputs are disconnected; it's no more
valid than any other (x,y) point in that case.

The real-world case here is a user with a single external monitor
turning it off (which apparently counts as disconnected depending
on the connection type/hardware).  For that user, it's desirable to
have the cursor remain in its original location when the monitor
is turned back on.
2022-09-21 14:25:09 -04:00
John Lindgren 5417a182e5 cursor: Add a more general check for infinite/NaN cursor position
It should be considered a bug if a compositor sets a non-finite
cursor position, so fail loudly (in debug builds) if that happens.

The existing check in wlr_cursor_warp_closest() is now redundant,
and would silently hide such bugs, so remove it.
2022-09-21 14:25:09 -04:00
Kirill Primak 4462f5dcb3 cursor: avoid uninitialized wlr_box fields 2022-08-30 19:26:20 +03:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Kenny Levinsen 03dc7e2df5 wlr_{keyboard,pointer,touch}: Update event docs
Events used by our input devices were recently renamed from wlr_event_* to
wlr_*_event, but the documentation and a single point of use was not updated
accordingly.

Regressed by: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3484
2022-06-28 09:50:30 +00:00
Isaac Freund 91943a68a6 wlr_input_device: remove anon union field
This union is unnecessary since the recent input device refactor and can
now be replaced by wlr_*_from_input_device() functions.
2022-06-21 18:42:07 +00:00
Simon Zeni aaf787ee56 types/wlr_touch: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni e732c5c895 types/wlr_tablet_tool: uniformize events name 2022-03-17 18:16:14 +00:00
Simon Zeni bd6c000d14 types/wlr_pointer: uniformize events name 2022-03-17 18:16:14 +00:00
Isaac Freund 252b2348bd
wlr_cursor: constify map to region box arguments 2022-02-05 16:32:38 +01:00
Kirill Primak 3cfe29b598 cursor: ensure mapping box is always initialized
Commit 498f30aad1 changed the logic of
get_mapping() in types/wlr_cursor.c to use updated version of
wlr_output_layout_get_box(). However, the case where c_device isn't NULL
but doesn't have output or geometry mappings wasn't handled properly,
resulting in leaving the output value uninitialized. This commit fixes
`c_device != NULL` branch by returning from the function only when a
mapping is found.

Fixes https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3369
2022-01-31 21:00:20 +03:00
Kirill Primak ba6ba4b07a cursor: store mapped_box as value 2022-01-31 10:32:47 +00:00
Kirill Primak 498f30aad1 output-layout: make wlr_output_layout_get_box() take a box as parameter
Closes https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/812
2022-01-31 10:32:47 +00:00
Jonathan Wong 0fb479ca61 Added whitespace between "output" and "(not" 2021-11-28 16:56:09 +00:00
José Expósito 4c3e307ec8 cursor: emit hold gesture events
Recevie the hold gesture events from the libinput or Wayland backends,
abstracted as pointer signals, and re-emit them from the cursor
interface.
2021-09-27 15:30:31 +02:00
Simon Ser 22fd411bc3 cursor: add touch frame event 2021-07-08 09:12:17 +02:00
Simon Zeni e192d87731 move wlr_box from /types to /util 2021-07-06 21:43:17 +02:00
Isaac Freund e06c9e43af Remove unneeded includes from wlr_input_device.h
This uncovered many places where we were using things without directly
including them.
2020-11-11 15:40:47 +01:00
Tudor Brindus ad28f57533 input/tablet: fix up updated axes after rotation
In the case that only one axis received an event, rotating the input can
cause the change to actually happen on the other axis, as far as clients
are concerned.

This commit updates the axes flags to be consistent post-rotation.

Fixes swaywm/sway#4776.
2020-04-27 18:34:09 +02:00
Manuel Stoeckl f22a5d1704 Fix output rotation direction
The Wayland protocol specifies output transform rotations to be
counterclockwise and applied to the surface. Previously, wlroots
copied Weston and incorrectly made rotations act clockwise on
surfaces. This commit fixes that.

This change will break compositors which expect transform rotations
to be clockwise, and the rare applications that make use of surface
transforms.
2020-02-17 21:43:05 +01:00
Ilia Bozhinov 480a31ea4e wlr_box: properly calculate closest point for non-positive area boxes
If box->width/height is <= 0, the box doesn't contain any points, and so
there is no closest point. wlr_box_closest_point should return NAN in this
case.

In addition, we need to handle empty boxes in a few other
output-layout-related places, because outputs can have size 0x0 when
they are created or destroyed.
2019-10-11 23:43:13 +03:00
Simon Ser ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
Greg V 9fe8e37961 Implement the pointer-gestures-unstable-v1 protocol
This protocol relays touchpad gesture events produced by libinput to
supporting clients (e.g. Evince, Eye of GNOME).
2019-01-28 22:06:36 +01:00
emersion 5de26ad8ed
pointer: add a frame event
Frame events group logically connected pointer events. It makes sense to make
the backend responsible for sending frame events, since once the events are
split (ie. once the frame events are stripped) it's not easy to figure out
which events belongs to which frame again.

This is also how Weston handles frame events.

Fixes https://github.com/swaywm/wlroots/issues/1468
2019-01-26 11:04:05 +01:00
emersion dfdbc1f870
output-layout, cursor: fix duplicate cursors
wlr_cursor: make sure the output doesn't have a cursor before
creating a new one

wlr_output_layout: don't emit the "add" event when the output is
already in the layout
2018-10-19 14:50:35 +02:00
Las fa2e6e7d9d Implement pointer-constraints protocol in wlroots and rootston 2018-09-18 10:14:33 +02:00
Aidan Epstein e334b46b39
Fix uninitialized value in wlr_cursor. 2018-08-31 23:36:38 +00:00
random human 8589ae19de Fix bugs listed by clang's static analyzer
A few pedantic changes and unused variables (1-4), and genuine bugs (5,
6).

The reports with the corresponding files and lines numbers are as
follows.

1. backend/libinput/tablet_pad.c@31,44,57
"Allocator sizeof operand mismatch"
"Result of 'calloc' is converted to a pointer of type 'unsigned int',
which is incompatible with sizeof operand type 'int'"

2. types/tablet_v2/wlr_tablet_v2_pad.c@371
"Allocator sizeof operand mismatch"
"Result of 'calloc' is converted to a pointer of type 'uint32_t', which
is incompatible with sizeof operand type 'int'"

3. types/wlr_cursor.c@335
"Dead initialization"
"Value stored to 'dx'/'dy' during its initialization is never read"

4. rootston/xdg_shell.c@510
"Dead initialization"
"Value stored to 'desktop' during its initialization is never read"

5. types/tablet_v2/wlr_tablet_v2_pad.c@475
"Dereference of null pointer"
"Access to field 'strips' results in a dereference of a null pointer
(loaded from field 'current_client')"

The boolean logic was incorrect (c.f. the check in the following
function).

6. examples/idle.c@163,174,182
"Uninitialized argument value"
"1st function call argument is an uninitialized value"

If close_timeout != 0, but simulate_activity_timeout >= close_timeout,
the program would segfault at pthread_cancel(t1).
2018-08-31 19:41:18 +02:00
Markus Ongyerth d9e978e1b3 rename wlr_tablet_tool to wlr_tablet
The previous naming was based on the input-device capability names from
libinput.
With code that uses the libinput_tablet_tool and mapping into tablet-v2,
this is confusing, so the name is changed to follow the names used in
the protocol.
2018-07-14 09:49:58 +02:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
Genki Sky d1cf9acbd5 cleanup: Use void for zero-parameter functions
Signed-off-by: Genki Sky <sky@genki.is>
2018-05-30 20:19:16 -04:00
Ivan Chebykin cec7cd2b39
Fix gcc maybe-uninitialized in wlr_cursor apply_output_transform 2018-05-04 18:41:51 +03:00
Guido Günther 4efae8c177 wlr_cursor: transform absolute coordinates
Honor output rotation when processing absolute coordinates. This fixes
touch events on rotated outputs.

Fixes #928
2018-05-03 11:09:14 +02:00
emersion 6e7c0b57f6
cursor: use NAN for unspecified axes, refactor absolute warping code 2018-04-28 09:24:38 +01:00
emersion 625a7a48dc
Don't use the wlr_ prefix for static functions 2018-04-25 23:51:00 +01:00
emersion bc0bfde5ee
cursor: allow to call wlr_cursor_wrap_absolute with zero 2018-04-24 19:46:29 +01:00
Drew DeVault 324b9d910d Remove width_mm from wlr_touch events 2018-03-28 11:04:40 -04:00
Drew DeVault a35a5786b0 Remove width_mm from wlr_pointer events 2018-03-28 10:46:50 -04:00
Drew DeVault 1d9be89e2d
Revert "ELF Visibility" 2018-02-19 18:01:27 -05:00
Scott Anderson 86269052eb Explicitly export EFL symbols 2018-02-19 14:26:40 +13:00
emersion c2e1474010
Reformat all #include directives 2018-02-12 21:29:23 +01:00