Commit Graph

258 Commits

Author SHA1 Message Date
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
Tudor Brindus c23182fd7a input/cursor: fix jerky resizing of non-tablet_v2 surfaces
This fixes resizing containers being very jerky under pointer emulation.

Refs #5232.
2020-04-22 17:24:01 +02:00
Tudor Brindus d88460f716 input/cursor: correctly send tablet_v2 up event when over non-v2 surface
If we started holding the tool tip down on a surface that accepts tablet
v2, we should notify that surface if it gets released over a surface
that doesn't support v2.

Since GTK supports tablet v2, this fixes the common case of starting a
drag over a GTK surface (e.g. scrollbar) and releasing it outside (e.g.
over the gaps between sway containers, or in a terminal).

Refs #5230.
2020-04-22 17:22:40 +02:00
David96 2b15cf453e Don't transfer focus to NULL node on touch
Fixes #5185
2020-04-17 15:49:17 +02:00
Aleksei Bavshin 525b48ede7 Adjust focus order to match rendering order of layer shell popups. 2020-04-10 10:45:47 +02:00
Some Chinese Guy 7c44c76989 swapped hiding the cursor and sending a touch event as a more logical sequence 2020-04-03 16:47:11 +02:00
Some Chinese Guy 63e45bf321 switched to setting focus with seat_set_focus 2020-03-29 20:50:36 +02:00
Some Chinese Guy 798fc24081 Added focus following for touch_down 2020-03-29 20:50:36 +02:00
Jason Nader fcd524bb0d sway/input/cursor.c: fix undefined behaviour when event is NULL 2020-03-16 14:27:36 +01:00
Jason Nader 3ed780c783 sway/input/cursor.c: move NULL check to where it should be 2020-03-15 14:30:32 +01:00
Brian Ashworth 1e2a2b0778 input/cursor: handle setting a NULL image surface
This fixes a crash when attempting to listen to a signal on a NULL
cursor image surface. If the surface is NULL, the listener is just
reinitialized using wl_list_init.
2020-01-06 10:12:28 +01:00
Brian Ashworth 897c36b12c input/cursor: handle image surface destroy
This adds a listener for the destroy event of the cursor image surface.
This prevents a use-after-free when the last visible image surface is
freed, there has not been a new cursor set, and the cursor is reshown.
2020-01-05 23:03:34 +01:00
Drew DeVault 2f3c6cccf5 Add seat <seat> idle_{inhibit,wake} <sources...>
This adds seat configuration options which can be used to configure what
events affect the idle behavior of sway.

An example use-case is mobile devices: you would remove touch from the
list of idle_wake events. This allows the phone to stay on while you're
actively using it, but doesn't wake from idle on touch events while it's
sleeping in your pocket.
2019-12-12 10:37:30 -05:00
Benjamin Cheng 2d0f15debb input/cursor: remove gesture listeners in destroy
Part of #4794. Forgot to remove gesture listeners when the
cursor is destroyed.
2019-12-07 12:55:37 -05:00
Benjamin Cheng 9ef026e804 input/cursor: pass gesture events to clients
Some wayland clients (mostly GTK3 apps) like eog or evince support
gestures like pinch-to-zoom. These gestures are given to clients
via the pointer_gestures_v1 protocol. This is already supported in
wlroots, so we just need to hook up the events here in sway.

Fixes #4724
2019-12-07 12:26:21 -05:00
John Chadwick 7e420cb6e4 input: Add support for tablet protocol.
Sway has basic support for drawing tablets, but does not expose
properties such as pressure sensitivity. This implements the wlr tablet
v2 protocol, providing tablet events to Wayland clients.
2019-09-25 23:10:33 -04:00
Drew DeVault cb8f68d74b layer-shell: add support for popups 2019-08-14 22:10:05 +03:00
Brian Ashworth 56b5ad777c input/cursor: do not hide when buttons are pressed
This just adds a small quality of life improvement to the cursor hiding
functionality. The cursor will no longer be hidden unless all buttons
are released.
2019-08-06 11:31:12 +09:00
Alex Maese 4d93b96b6e Unhide cursor on cursor activity after touch 2019-06-08 12:02:28 -04:00
Ryan Dwyer 7b9ae42331 Introduce default seatop
This introduces a `default` seat operation which is used when no mouse
buttons are being held. This means there is now always a seat operation
in progress. It allows us to separate `default` code from the standard
cursor management code.

The sway_seatop_impl struct has gained callbacks `axis`, `rebase` and
`end`, and lost callbacks `finish` and `abort`. `axis` and `rebase` are
only used by the default seatop. `end` is called when a seatop is being
replaced by another one and allows the seatop to free any resources,
though no seatop currently needs to do this. `finish` is no longer
required, as each seatop can gracefully finish in their `button`
callback. And `abort` is not needed, as calling `end` would achieve the
same thing. The struct has also gained a bool named allow_set_cursor
which allows the client to set a new cursor during `default` and `down`
seatops.

Seatops would previously store which button they were started with and
stop when that button was released. This behaviour is changed so that it
only ends once all buttons are released. So you can start a drag with
$mod+left, then click and hold right, release left and it'll continue
dragging while the right button is held.

The motion callback now accepts dx and dy. Most seatops don't use this
as they store the cursor position when the seatop is started and compare
it with the current cursor position. This approach doesn't make sense
for the default seatop though, hence why dx and dy are needed.

The pressed_buttons array has been moved from the sway_cursor struct to
the default seatop's data. This is only used for the default seatop to
check bindings. The total pressed button count remains in the
sway_cursor struct though, because all the other seatops check it to
know if they should end.

The `down` seatop no longer has a `moved` property. This was used to
track if the cursor moved and to recheck focus_follows_mouse, but seems
to work without it.

The logic for focus_follows_mouse has been refactored. As part of this
I've removed the call to wlr_seat_keyboard_has_grab as we don't appear
to use keyboard grabs.

The functions for handling relative motion, absolute motion and tool
axis have been changed. Previously the handler functions were
handle_cursor_motion, handle_cursor_motion_absolute and
handle_tool_axis. The latter two both called cursor_motion_absolute.
Both handle_cursor_motion and cursor_motion_absolute did very similar
things. These are now simplified into three handlers and a single common
function called cursor_motion. All three handlers call cursor_motion. As
cursor_motion works with relative distances, the absolute and tool axis
handlers convert them to relative first.
2019-03-17 10:02:04 -06:00
Ryan Dwyer fb3475e291 Replace seatup allows_events with button callback 2019-03-17 10:02:04 -06:00
Ryan Dwyer 783b3d6b37 Fix click behaviour
By the time seatop_allows_events was called, seatop_impl was already
NULL, causing the function to always return false. This means a press
event was sent to clients without a corresponding release event.

This patch moves the call to seatop_finish to after the
seatop_allows_events check.
2019-03-11 14:55:54 +01:00
Ryan Dwyer d16845d5f0 Don't send button events to surfaces when dragging or resizing
It turns out sending button events during all seat operations is not
desirable. This patch introduces a new property
`seatop_impl.allows_events` which allows each operation to define
whether button events should be passed to the surface or not.

The `down` seat operation is the only one that supports this. As all the
other seatops don't support it, the calls to seat_pointer_notify_button
prior to starting them have been removed.
2019-03-11 14:55:54 +01:00
Ryan Dwyer bdac0df4f8 Allow concurrent clicks
If two cursor buttons are pressed at the same time, the client will now
be notified of the second button press.

The main reason for not sending the concurrent presses was due to an
early return in dispatch_cursor_button if a seatop is in progress. This
patch makes it call seat_pointer_notify_button prior to returning. But
it also has to make sure there's not a mismatch in events such as a
release without a press.

Prior to this patch, the down seatop would send press and release events
in its begin and finish functions. No other seatops did this. A press
event would be sent prior to starting tiling drag, but never an
associated release.

After this patch, no seatops send their own press or release events. We
send them prior to calling the seatop begin functions, then the first
part of dispatch_cursor_button handles all presses during seatops and
when releasing the seatop.
2019-03-04 07:51:22 -07:00
emersion 88b283c557 seat: don't send button release when not pressed
All seat operations except "down" eat the button pressed event and don't send
it to clients. Thus, when ending such seat operations we shouldn't send the
button released event.

This commit moves the logic used to send pressed/released into the "down"
operation.
2019-02-28 23:02:06 -05:00
Rouven Czerwinski 4e028dba47 cursor: intitialize sx and sy to zero
If node_at_coords does an early return without setting these values, they can be
used uninitialized later. Initialize both to zero.
2019-02-27 00:35:51 -05:00
Rouven Czerwinski 35d610a43c cursor: remove unused node assignement
The node variable is not used before its reassigned later in the function,
remove the assignement.
2019-02-27 00:35:51 -05:00
emersion 656541bcc4
Update for swaywm/wlroots#1517 2019-02-23 19:04:10 +01:00
Brian Ashworth f078a1ccb8 input/cursor: allow whole-window bindings on ws
To match i3's behavior, this allows mouse bindings to be triggered over
a workspace when `--whole-window` is given.
2019-02-22 13:32:34 +01:00
Brian Ashworth d3d7956576 Handle NULL from output_get_active_workspace
This modifies the places where output_get_active_workspace is called to
handle a NULL result. Some places already handled it and did not need a
change, some just have guard off code blocks, others return errors, and
some have sway_asserts since the case should never happen. A lot of this
is probably just safety precautions since they probably will never be
called when `output_get_active_workspace` is not fully configured with a
workspace.
2019-02-21 21:18:03 +01:00
Vincent Vanlaer cfacf85755 Check layout before getting pointer surface coords
This fixes issues of clients at the edge of the screen, like swaybar,
ignoring buttons.
2019-02-16 21:46:19 +01:00
Brian Ashworth 1bccde68a4 cursor: relative-pointer-v1 time is usec
In handle_cursor_motion, the timestamp passed to
`wlr_relative_pointer_manager_v1_send_relative_motion` should be
microseconds (not milliseconds) according to relative-pointer-v1 spec.
2019-02-13 09:49:34 +01:00
emersion 97c89b24b8
Rebase cursor when a layer surface maps
Also removes an extraneous arrange_outputs call, it's already called if
necessary in arrange_layers.

Updates https://github.com/swaywm/sway/issues/3080
2019-02-12 22:57:23 +01:00
Drew DeVault a1a99421a1
Merge pull request #3562 from vilhalmer/focus_follows_mouse-workspace-last-inactive
Focus workspace inactive node with focus_follows_mouse
2019-02-03 20:15:21 +01:00
vilhalmer f8a9117149
Fall back to wildcard in sway_cursor_constrain 2019-02-03 13:46:44 -05:00
vilhalmer 907595b10d
Skip constraining cursor if no seat config 2019-02-03 13:44:37 -05:00
vilhalmer a3332c70bf
Focus ws inactive node with focus_follows_mouse 2019-02-03 12:12:40 -05:00
Drew DeVault de76c4e071
Merge pull request #3543 from emersion/relative-pointer-usec
relative-pointer-v1: time is in usec, not msec
2019-02-01 09:27:00 +01:00
Brian Ashworth ebe5399ed6 pointer_constraint: change to a seat subcommand
This changes the `pointer_constraint` command to be a subcommand of seat
to allow for per-seat settings. The current implementation that is not a
seat subcommand will only operate on the current seat and will segfault
in the config due to `config->handler_context.seat` only being set at
runtime.

This also allows for the wildcard identifier to be used to alter the
pointer constraint settings on all seats and allows for the setting to
be merged with the rest of the seat config.
2019-01-31 22:58:52 -05:00
emersion dde9fc19de
relative-pointer-v1: time is in usec, not msec 2019-01-30 21:30:44 +01:00
Drew DeVault 0c975af1fb Send pointer frames on tool events 2019-01-30 14:09:50 -05:00
Drew DeVault 4b87edeba4 Missed a spot in pointer constraints 2019-01-30 14:06:44 -05:00
Drew DeVault a6d41254c9 Add pointer_constraint command 2019-01-30 19:53:59 +01:00
absrd ee4b8a3938 Add relative pointer 2019-01-30 19:53:59 +01:00
Las cedde21c96 Implement pointer-constraints-unstable-v1 2019-01-30 19:53:59 +01:00
Drew DeVault 783fadab28
Merge pull request #3423 from RyanDwyer/fullscreen-global
Implement fullscreen global
2019-01-27 18:06:50 -05:00
emersion a452f8f822
Update for swaywm/wlroots#1503 2019-01-27 12:59:46 +01:00
Ryan Dwyer 20aa8ee67d Implement fullscreen global 2019-01-25 08:29:21 +10:00