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

rootston/surface_layers: fix clicking after surface moved #1196

Merged
merged 1 commit into from Aug 29, 2018

Conversation

Projects
None yet
4 participants
@dcz-purism
Contributor

dcz-purism commented Aug 22, 2018

Surfaces are not notified of cursor position changes if the surface moves, only if the cursor moves. This workaround emits an extra cursor position event before every click to make sure the click lands in the right place.

A better solution would be to update the cursor position while the surface is moving, but it's difficult to provide a correct time value on input events, because the time values are taken from external sources.

Another solution is to set a flag when the surface is moved and clear it on click, after sending the motion event. This reduces the number of motion events: from 1 every click to 1 every click after movement.

@ddevault

This comment has been minimized.

Member

ddevault commented Aug 22, 2018

A better solution would be to update the cursor position while the surface is moving, but it's difficult to provide a correct time value on input events, because the time values are taken from external sources.

The external sources always just use CLOCK_MONOTONIC and we can too.

@dcz-purism dcz-purism changed the title from WIP: rootston/cursor: fix clicking after surface moved to rootston/surface_layers: fix clicking after surface moved Aug 22, 2018

@dcz-purism

This comment has been minimized.

Contributor

dcz-purism commented Aug 22, 2018

I accidentally pushed to much... please ignore until I test this.

@dcz-purism

This comment has been minimized.

Contributor

dcz-purism commented Aug 22, 2018

Handling of moving surfaces is now in 2 places: in arrange_layers and handle_surface_commit. A naive implementation would send 2 cursor move events on each resize: when the layer_surface is resized, and then when the surface inside is changed. I eliminated that by not sending any cursor move events when a layer_surface changes size, only when it moves.

rootston/layer_shell: fix clicking after surface moved/resized
Layer surfaces are not notified of cursor position changes if the surface moves, only if the cursor moves. This workaround emits a cursor position event every time a cursor ends up over a newly resized layer surface to make sure the following clicks land in the right place.

This change doesn't address sending leave events when a cursor previously present over the surface becomes away.

There are 2 separate mechanisms in play, because a layer surface gets resized in 2 steps:

1. Layer surface resize & rearrange.
2. Underlying surface resize.

The first step may affect all layer surfaces. The cursor events are sent to cursors placed over all layer surfaces which have moved (not been resized). The second step affects any layer surface whose surface changed size. The cursor event is sent only to that surface.

Together, these events cover all surfaces: those which moves, and those which changed size, as long as each layer surface resize is accompanied by an immediate surface resize.
@agx

This comment has been minimized.

Contributor

agx commented Aug 28, 2018

@dcz-purism is this testable via the layer-shell example?

@dcz-purism

This comment has been minimized.

Contributor

dcz-purism commented Aug 28, 2018

The layer-shell example doesn't move on its own; I've been testing it using virtboard: https://source.puri.sm/Librem5/virtboard/tree/input_method revision 81c74611

To see the issue:

  1. Run virtboard as the only application
  2. Click the arrow button (nothing else should be visible before clicking)
  3. Without moving the cursor, click again (the keyboard should be expanded before clicking)

Before the patch, the keyboard will register a key press close to its top left (q).

After the patch, the keyboard will register a key press in the bottom part (the arrow button), and hide back again.

@ddevault ddevault requested a review from RedSoxFan Aug 29, 2018

@RedSoxFan RedSoxFan merged commit 939a4ea into swaywm:master Aug 29, 2018

1 check passed

builds.sr.ht builds.sr.ht job completed successfully
Details
@RedSoxFan

This comment has been minimized.

Contributor

RedSoxFan commented Aug 29, 2018

Thanks!

@dcz-purism dcz-purism deleted the dcz-purism:surface_move branch Aug 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment