Commit Graph

106 Commits

Author SHA1 Message Date
JiDe Zhang 73db481037 wlr_output: update cursor when scale changed
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3699
2023-08-03 02:13:00 +00:00
JiDe Zhang 61903ed66b wlr_output_cursor: assert renderer isn't NULL
When a wlr_output add to wlr_output_layout, wlr_cursor will create
wlr_buffer of xcursor for the wlr_output, this behavior depends
wlr_renderer of wlr_output, using assert to ensure renderer is
initialized before wlr_output_layout_add and wlr_cursor_set_buffer/
wlr_cursor_set_xcursor.
2023-08-03 02:13:00 +00:00
Simon Ser 000081db19 cursor, output: apply viewport to cursor
Instead of passing the scale, pass the source and destination
boxes.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3676
2023-07-17 14:55:22 +00:00
Simon Ser 7a9f8d8d6b Use struct initializers instead of memset()
This is a bit more type-safe.
2023-07-07 17:31:11 +02:00
Simon Ser f8d70fbece cursor: remove usage of wlr_output_cursor_set_image()
Stop using wlr_output_cursor_set_image() because it's getting
dropped. Instead, use wlr_output_cursor_set_buffer().

This mirrors what wlr_output_cursor_set_image() is doing
under-the-hood.
2023-07-03 09:45:34 +02:00
Simon Ser 0fc532f8de cursor: remove wlr_cursor_set_image()
Superseded by wlr_cursor_set_buffer().
2023-07-02 22:42:37 +00:00
Simon Ser 71c87ff4b8 cursor: add wlr_cursor_set_buffer()
A saner replacement for wlr_cursor_set_image():

- Takes a wlr_buffer instead of numerous parameters and a hardcoded
  format.
- The scale is not used to filter outputs.
- A ref to the buffer is kept to apply it to new outputs.
2023-07-02 22:42:37 +00:00
Simon Ser bb91787b5f cursor: stop using set_image() in wlr_cursor_unset_image()
set_image() will go away.
2023-07-02 22:42:37 +00:00
Simon Ser 53b07b5b72 cursor: set image for new outputs
When an output is added to wlr_cursor, update its cursor image.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2119
2023-06-30 17:24:44 +00:00
Simon Ser d5581e42d4 cursor: add cursor_update_outputs()
Sets the cursor image for each output depending on the wlr_cursor
state.
2023-06-30 17:24:44 +00:00
Simon Ser d1d6cd9008 cursor: keep track of XCursor manager and name
Will be useful to apply the current cursor to new outputs.
2023-06-30 17:24:44 +00:00
Simon Ser 69c44de22f cursor: track surface globally, instead of per-output
Most of the surface-related state does not need to be per-output.
Move it to wlr_cursor_state.
2023-06-30 17:24:44 +00:00
Simon Ser c46fabe45c cursor: use wlr_cursor_unset_image() in wlr_cursor_set_surface() 2023-06-30 17:24:44 +00:00
Simon Ser f0b8a68654 cursor: store wlr_cursor inline in wlr_cursor_state
Removes one allocation, makes this a bit more consistent with the
rest of wlroots.
2023-06-30 17:24:44 +00:00
Simon Ser d59749aa44 cursor: add support for animated XCursor 2023-06-22 14:55:32 +02:00
Simon Ser 220402b717 cursor: add wlr_cursor_unset_image()
It's pretty awkward to call wlr_cursor_set_image() with 6 zeroes.
Hide that awkwardness in wlroots.
2023-06-15 18:40:33 +02:00
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