1
1
Fork 0
mirror of https://github.com/swaywm/sway synced 2024-06-10 22:56:40 +02:00
Commit Graph

305 Commits

Author SHA1 Message Date
Florian Franzen cab2189aa6 sway: add bindgesture command
Co-authored-by: Michael Weiser <michael.weiser@gmx.de>
2022-05-30 12:20:43 +02:00
Simon Zeni 440d0bc22d sway/input: follow up wlroots input device events renaming 2022-03-17 21:52:59 +03:00
Simon Zeni 0345148ea6 sway/input/cursor: take device mm size from wlr_tablet 2022-03-17 21:52:59 +03:00
Tudor Brindus 8ca2847b42 input/cursor: pass through pointer hold gestures
This just follows swaywm/wlroots#3047, so `wl_pointer_gestures_v1`
clients can be notified of these events.
2022-01-22 23:43:46 +01:00
Tudor Brindus 7d1ccafae5 input/cursor: treat swipe begin as idle activity too
Accidentally overlooked in fd53f80.
2022-01-17 23:17:36 +01:00
Tudor Brindus fd53f80156 input/cursor: count pointer gestures as idle activity
Fixes https://github.com/swaywm/sway/issues/6765.
2022-01-17 23:05:19 +01:00
Rasmus Moorats aaf68cf423 fix cursor input for layer-shell surfaces
previously, fullscreen global containers would grab cursor input
even if a shell-layer surface was on top of it

related issue: https://github.com/swaywm/sway/issues/6501
2021-10-26 15:13:37 +03:00
siikamiika f4db502d44 use node_is_view 2021-10-10 09:35:15 +02:00
Simon Ser 2e03a61262 Fix wl_pointer.frame not sent on touch emulation
When emulating touch, the simulating_pointer_from_touch field is
set to true. It's switched back to false when a touch_up event is
received. However we need to ensure we always send a wl_pointer.frame
event following a group of other wl_pointer events.

Since a touch_frame event is always guaranteed to come after a group
of touch events, unset simulating_pointer_from_touch in the touch_frame
handler instead of the touch_up handler. Add a new field to know whether
the touch_frame handler should stop emulation.
2021-07-26 16:58:11 +02:00
Simon Ser 7114030159 Add support for touch frame events
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3001
2021-07-08 09:18:20 +02:00
Simon Ser 4832fc937f Update wlr_box includes
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3011
2021-07-07 11:29:14 +02:00
Kenny Levinsen 80315217f7 input: Move get_current_time_msec in from util
get_current_time_msec is only used in cursor.c, so we can move it in and
make it static. This is primarily intended to avoid a symbol collision
with wlroots, which we unfortunately do not have a good solution for
yet.
2021-06-23 09:55:36 +02:00
Kenny Levinsen a047b5ee4a container: Move pending state to state struct
Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.

Instead, use the state struct for both current and pending.
2021-02-16 22:05:00 -05:00
Kenny Levinsen b5b628cb41 input: Only commit transactions when necessary
There is no need to check for transactions at the end of every user
input, as the vast majority of input will not issue transactions. This
implementation can also hide where changes are made without an
appropriate transaction commit, as a future unrelated input would issue
the commit instead.

Instead, commit transactions in places where changes are made or are
likely to be made.
2021-02-14 13:19:08 -05:00
Tudor Brindus cc2c0d5966 input/cursor: unhide cursor on synthetic input
Fixes #5847.
2020-12-06 09:38:49 +01:00
Simon Ser a56098a24e
Add missing includes for wlr_input_device.h
References: https://github.com/swaywm/wlroots/pull/2470
2020-11-11 15:40:50 +01:00
Tudor Brindus 60d95414d4 commands/focus: force container warp when fulfilling `focus mode_toggle`
This commit switches focusing behavior to force a warp when executing
`focus mode_toggle`.

Fixes #5772.
2020-11-01 03:43:00 -05:00
Tudor Brindus 8c12e71a66 input: remove motion deltas from seatop callbacks
Straightforward cleanup, they haven't been used for a while.
2020-10-31 23:15:32 +01:00
Tamir Zahavi-Brunner 96578aa91e hide_cursor: Add an option to hide when typing
Add an option for the `hide_cursor` command to hide the cursor when
typing, i.e. whenever a key is pressed.
2020-10-30 09:59:54 +01:00
Tudor Brindus ed247c031c input/tablet: add tool_mode option to set tablet tools as relative input
Closes #4139.
2020-10-12 15:01:37 +02:00
Tudor Brindus 136add4e12 input/cursor: default tablet lens tool to relative motion
It is recommended that mouse and lens cursor tool default to relative
mode and all pen-like tools to absolute mode.

Refs
https://wayland.freedesktop.org/libinput/doc/1.11.3/tablet-support.html#tablet-relative-motion.
2020-10-12 15:01:37 +02:00
Rouven Czerwinski 41999d7c9f cursor: update hide timer during config apply
We can't arm the timer during cursor creation since the config may not
be ready yet. Instead arm the timer while applying the input
configuration, by this time the configuration has been parsed and we can
arm the hide timer.

Fixes #5686
2020-09-16 07:53:57 +02:00
Rouven Czerwinski 299a159add cursor: arm cursor hide timer immediately
According to the wayland docs, wayland timers are disarmed on creation.
This leads to the cursor not being hidden if there is no activity after
creation, since the timer is armed on activity, but not at creation.
Arm the timer after creation to ensure the cursor is hidden even if
there is no cursor activity after creation.

Fixes #5684
2020-09-15 09:55:30 +02:00
Tudor Brindus 2efecc14ef input/pointer: update cursor activity after updating button counts
Otherwise, Sway will not re-hide a cursor after the last button has been
released.

Needed alongside afa890e to fix #5679.
2020-09-14 22:28:21 -04:00
Rouven Czerwinski afa890e8e9 input/cursor: reset event source after unhide
Reset the event source after unhiding the cursor, to ensure that the
timeout starts after showing the cursor. Also remove the open coded
variant in seat_consider_warp_to_focus().

Fixes #5679
2020-09-14 18:14:08 -04:00
Tudor Brindus 6b9a9b6246 input/cursor: don't send wl_pointer.motion event on pointer unlock warp
On warping to a cursor hint, update the pointer position we track as
well, so that on the next pointer rebase we don't send an unexpected
synthetic motion event to clients.

Fixes #5405.
2020-07-15 19:40:09 +02:00
Simon Ser 5432f00adf config/output: don't change output state before commit
Previously, we called output_disable prior to wlr_output_commit. This
mutates Sway's output state before the output commit actually succeeds.
This results in Sway's state getting out-of-sync with wlroots'.

An alternative fix [1] was to revert the changes made by output_disable
in case of failure. This is a little complicated. Instead, this patch
makes it so Sway's internal state is never changed before a successful
wlr_output commit.

We had two output flags: enabled and configured. However enabled was set
prior to the output becoming enabled, and was used to prevent the output
event handlers (specifically, the mode handler) from calling
apply_output_config again (infinite loop).

Rename enabled to enabling and use it exclusively for this purpose.
Rename configure to enabled, because that's what it really means.

[1]: https://github.com/swaywm/sway/pull/5521

Closes: https://github.com/swaywm/sway/issues/5483
2020-07-10 18:18:27 -04:00
Tudor Brindus d328c2439c input/pointer: don't trigger pointer bindings for emulated input
Prior to this commit, a tablet device could trigger mouse button down
bindings if the pen was pressed on a surface that didn't bind tablet
handlers -- but it wouldn't if the surface did bind tablet handlers.

We should expose consistent behavior to users so that they don't have to
care about emulated vs. non-emulated input, so stop triggering bindings
for any non-pointer devices.
2020-06-18 22:35:01 +02:00
Tudor Brindus 82c439c4f1 input/cursor: send idle events based off device type, not input type
Previously, a tablet or touch device could report activity as a pointer
device if it went through pointer emulation. This commit refactors idle
sources to be consistently reported based on the type of the device that
generated an input event, and now how that input event is being
processed.
2020-06-18 22:35:01 +02:00
Tudor Brindus d7900c6e5e common/util: fix `get_current_time_msec` returning microseconds
This commit makes `get_current_time_msec` correctly return milliseconds
as opposed to microseconds. It also considers the value of `tv_sec`, so
we don't lose occasionally go back in time by one second. Finally, the
function is moved into `util.c` so that it can be reused elsewhere
without having to consider these pitfalls.
2020-06-06 13:38:41 +02:00
Thomas Hebb 84ec8f92a6 Use new wlroots API for clearing keyboard/pointer focus during grabs
We are not allowed to do what we did in #5222 and pass a `NULL` surface
wlr_seat_pointer_notify_enter(), and it's causing crashes when an
xdg-shell popup is active (see #5294 and swaywm/wlroots#2161).

Instead, solve #5220 using the new wlroots API introduced in
swaywm/wlroots#2217.
2020-06-05 17:24:23 +02:00
Tudor Brindus f7e050c58f input/cursor: refactor tablet tool tip events into seatops
This commit moves tool tip event generation into seatops. In doing so,
some corner cases where we'd erroneously (but likely harmlessly)
generate both tablet and pointer events simultaneously are eliminated.
2020-06-04 10:20:32 +02:00
Tudor Brindus 6da1631090 input/cursor: rename `simulated_tool_tip_down` to be more accurate
This is a tiny cleanup commit that renames `simulated_tool_tip_down` to
`simulating_pointer_from_tool_tip`, making it match
`simulating_pointer_from_touch`.

This is a better name since it makes it clear that it's the *pointer*
that's being simulated, not the tool tip.
2020-05-29 08:44:56 +02:00
Tudor Brindus 6ea45395c7 input/pointer: send pointer enter event on confine warp
The spec has this to say about sending events on confine creation:

  Whenever the confinement is activated, it is guaranteed that the
surface the pointer is confined to will already have received pointer
focus and that the pointer will be within the region passed to the
request creating this object.

...and on region update:

  If warped, a wl_pointer.motion event will be emitted, but no
wp_relative_pointer.relative_motion event.

Prior to this patch, sway did neither, and updated the hardware cursor
position without notifying the underlying surface until the next motion
event. This led to inconsistent results, especially in applications that
draw their own software cursor.
2020-05-28 09:44:00 +02:00
Tudor Brindus d71fed95da input/cursor: keep reference to cursor in constraint
set_region accepts a NULL *data, so we can't use it to reference the
constraint and find the cursor through its seat.

Fixes #5386.
2020-05-26 16:24:52 +02:00
Tudor Brindus 34e0cad9ac input/cursor: fix heap-buffer overflow in constraint set_region
Fixes #5383, caused by an oversight in 6f0a0bd.
2020-05-25 21:30:53 +02:00
Tudor Brindus 5d13f647f9 input/tablet: add seatop_down entry for tablet input
Currently, when tablet input exits a window during an implicit grab, it
passes focus to another window.

For instance, this is problematic when trying to drag a scrollbar, and
exiting the window &mdash; the scrollbar motion stops. Additionally,
without `focus_follows_mouse no`, the tablet passes focus to whatever
surface it goes over regardless of if there is an active implicit.

If the tablet is over a surface that does not bind tablet handlers, sway
will fall back to pointer emulation, and all of this works fine. It
probably should have consistent behavior between emulated and
not-emulated input, though.

This commit adds a condition for entering seatop_down when a tablet's
tool tip goes down, and exiting when it goes up. Since events won't be
routed through seatop_default, this prevents windows losing focus during
implicit grabs.

Closes #5302.
2020-05-25 10:01:00 +02:00
Tudor Brindus 6f0a0bd385 input/pointer: only warp cursor when the confine region has changed
Refs #5268.
2020-05-21 10:45:08 +02:00
David96 2473cac32c Implement pointer simulation if client hasn't bound to touch 2020-05-13 14:29:15 -04:00
Tudor Brindus 2262ae60f4 input/cursor: don't apply pointer constraint to emulated tablet input
Closes #5268.
2020-05-13 08:58:23 +02:00
Tudor Brindus 726d187d3c input/tablet: simplify parameter plumbing for tablet references
This is a small cleanup commit for removing `sway_tablet` parameters
from functions that already accept `sway_tablet_tool`, since the tablet
reference can be accessed through `tool->tablet`.
2020-05-10 16:49:35 +02:00
David96 e5fed6b246 Don't unhide cursor on touch events
Touch events hide the cursor so unhiding it again only causes it to
flicker.
2020-05-05 17:39:26 +02:00
Tudor Brindus 52bd6aecf2 input/cursor: remove erroneous cast for tablet tool button
The type expected by wlroots is uint32_t, which `event->button`
already is.
2020-05-02 21:16:21 +02:00
Tudor Brindus e262f93d0a input: rename pointer handlers to be unambiguous
This commit renames `motion` and `axis` handlers to `pointer_motion` and
`pointer_axis`, respectively, to disambiguate them from their tablet
(and future touch) handlers. `button` is left as-is, as it is generic
across input devices.
2020-05-02 18:28:06 +02:00
Tudor Brindus ae3ec745f8 input: refactor tablet motion into seatop handler
This commit moves tablet motion logic into a seatop handler.

As a side-effect of seatop implementations being able to receive
tablet motion events, fixes #5232.
2020-05-02 13:32:28 +02:00
Tudor Brindus 9362003cba input/cursor: disambiguate cursor functions from pointer functions 2020-05-02 13:32:28 +02:00
Tudor Brindus 0dc1863dce input/cursor: make cursor rebasing cursor type-agnostic
This commit refactors `cursor_rebase` into `cursor_update_image`, and
moves sending pointer events to the two existing call sites. This will
enable this code to be reused for tablets.

Refs #5232
2020-05-02 13:32:28 +02:00
Tudor Brindus 2913f39dcb input/cursor: release simulated tool tip button when over v2 surface
d88460f addressed sending v2 tool tip up when over a non-v2 surface.
This commit addresses the other direction.

Fixes #5230.
2020-05-01 11:00:49 +02:00
Tudor Brindus d77247117c input/cursor: correctly transfer focus when using tablet pen
Fixes #4819.

This commit ensures that `seat_set_focus` is called to transfer focus
when a window is selected via a pen. Previously, it would race with
`node_at_coords`, and only properly transfer focus if its returned
`surface` was NULL.
2020-04-24 18:54:48 +02:00
Tudor Brindus 44b2d3ad81 input/cursor: fix hide cursor timeouts on tablets and touchscreens
This commit refactors `cursor_handle_activity` to also take the idle
source, so that it can be reused for tablet and touch activity.
Previously, the timeouts would be tracked, but the cursor would never be
un-hidden for anything but pointers.

Fixes #5169.
2020-04-22 17:30:08 +02:00