Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass gesture events to clients #4794

Merged
merged 1 commit into from
Dec 7, 2019
Merged

Pass gesture events to clients #4794

merged 1 commit into from
Dec 7, 2019

Conversation

lolzballs
Copy link
Contributor

Fixes #4724.

This change can be tested quite easily if you use a backend which supports gestures (i.e. libinput). Open evince and your favourite pdf and you shall now see that pinch-to-zoom works properly. Prior to this, pinch-to-zoom would not do anything since the pinch and swipe events generated by the libinput backend are not handled anywhere (i.e. passed to the active client).

I'm not too sure how this will affect #1904 but I think there shouldn't be a huge change, as this change is solely passing pointer gestures to clients, rather than detecting a configurable gesture and executing a sway routine.

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 swaywm#4724
@ddevault
Copy link
Contributor

ddevault commented Dec 7, 2019

Thanks! This doesn't effect touch gestures, which are a different animal entirely.

@ddevault ddevault merged commit 9ef026e into swaywm:master Dec 7, 2019
@@ -825,6 +879,20 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
cursor->hide_source = wl_event_loop_add_timer(server.wl_event_loop,
hide_notify, cursor);

cursor->pointer_gestures = wlr_pointer_gestures_v1_create(server.wl_display);
cursor->pinch_begin.notify = handle_pointer_pinch_begin;
wl_signal_add(&wlr_cursor->events.pinch_begin, &cursor->pinch_begin);
Copy link
Member

@emersion emersion Dec 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These listeners are not removed when the cursor is destroyed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry about that. I made a change to correct this, although since the pull request was merged already I'm not sure what the best path to fixing this is.

Also on a sidenote, wlr_pointer_gestures_v1 doesn't have a destroy or free function. It seems it handles destroying itself when the display is destroyed. Is this something worth worrying about?

Copy link
Member

@emersion emersion Dec 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry about that. I made a change to correct this, although since the pull request was merged already I'm not sure what the best path to fixing this is.

If you could submit a new PR to fix this, that would be great.

Also on a sidenote, wlr_pointer_gestures_v1 doesn't have a destroy or free function. It seems it handles destroying itself when the display is destroyed. Is this something worth worrying about?

Yeah, wlr_pointer_gestures_v1 is destroyed when the display is. It should be fine.

lolzballs added a commit to lolzballs/sway that referenced this pull request Dec 7, 2019
Part of swaywm#4794. Forgot to remove gesture listeners when the
cursor is destroyed.
ddevault pushed a commit that referenced this pull request Dec 7, 2019
Part of #4794. Forgot to remove gesture listeners when the
cursor is destroyed.
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Jan 25, 2020
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Jan 26, 2020
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Feb 19, 2020
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Mar 8, 2020
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Mar 8, 2020
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Jul 21, 2020
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Apr 13, 2021
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Apr 18, 2021
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Apr 21, 2021
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Still we opt to export the event to the user because it
simplifies processing and may be of actual benefit to some unforeseen
usecase.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window --release SWIPE_LEFT workspace prev_on_output
bindsym --whole-window --release SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Apr 22, 2021
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Jul 6, 2021
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Jul 24, 2021
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
michaelweiser added a commit to michaelweiser/sway that referenced this pull request Aug 5, 2021
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
FlorianFranzen pushed a commit to FlorianFranzen/sway that referenced this pull request Jan 20, 2022
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
FlorianFranzen pushed a commit to FlorianFranzen/sway that referenced this pull request Jan 21, 2022
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
FlorianFranzen pushed a commit to FlorianFranzen/sway that referenced this pull request Feb 11, 2022
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
David96 added a commit to David96/sway that referenced this pull request Mar 20, 2022
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
David96 pushed a commit to David96/sway that referenced this pull request Mar 20, 2022
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
FlorianFranzen pushed a commit to FlorianFranzen/sway that referenced this pull request Apr 9, 2022
Passing of gesture events added in swaywm#4794 allows to use them in clients
but not in sway itself, for example to switch workspaces using
three-finger swipes.

Add support for binding four basic directional swipes to arbitrary sway
commands. Add the necessary handling to default seatops to execute them
at the beginning or end of a swipe gesture. This for now responds to all
swipes, ignoring the number of fingers used.

The former throws up the intrinsic conundrum that we can not know the
kind of swipe that's going to happen because it can change all through
its lifecylce. Therefore we can only execute bindings on release.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three-finger swipes, observing
  that vertical swipes won't

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Implement pointer-gestures wayland protocol [Former: Trackpad (pinch) gestures are not passed to clients]
3 participants