[PATCH weston 4/4] compositor-wayland: Add touch support
Daniel Stone
daniel at fooishbar.org
Fri Oct 9 09:40:50 PDT 2015
Hi,
On 9 October 2015 at 17:28, Derek Foreman <derekf at osg.samsung.com> wrote:
> @@ -1617,6 +1620,137 @@ static const struct wl_keyboard_listener keyboard_listener = {
> };
>
> static void
> +input_handle_touch_down(void *data, struct wl_touch *wl_touch,
> + uint32_t serial, uint32_t time,
> + struct wl_surface *surface, int32_t id, wl_fixed_t x,
> + wl_fixed_t y)
> +{
> + struct wayland_input *input = data;
> + struct wayland_output *output;
> + enum theme_location location;
> + bool first_touch;
> + int32_t fx, fy;
> +
> + first_touch = input->touch_points == 0;
> + input->touch_points++;
> +
> + input->touch_focus = wl_surface_get_user_data(surface);
> + output = input->touch_focus;
> + if (!output->frame || (!first_touch && !input->touch_active))
> + return;
This breaks for fullscreen windows; instead the below blocks should be
made conditional on output->frame.
> + location = frame_touch_down(output->frame, input, id,
> + wl_fixed_to_int(x),
> + wl_fixed_to_int(y));
> +
> + frame_interior(output->frame, &fx, &fy, NULL, NULL);
> + x -= wl_fixed_from_int(fx);
> + y -= wl_fixed_from_int(fy);
> +
> + if (frame_status(output->frame) & FRAME_STATUS_REPAINT)
> + weston_output_schedule_repaint(&output->base);
> +
> + if (first_touch && (frame_status(output->frame) & FRAME_STATUS_MOVE)) {
> + input->touch_points--;
> + wl_shell_surface_move(output->parent.shell_surface,
> + input->parent.seat, serial);
> + frame_status_clear(output->frame,
> + FRAME_STATUS_MOVE);
> + return;
> + }
> +
> + if (first_touch && location != THEME_LOCATION_CLIENT_AREA)
> + return;
> +
> + weston_output_transform_coordinate(&output->base, x, y, &x, &y);
> +
> + notify_touch(&input->base, time, id, x, y, WL_TOUCH_DOWN);
> + input->touch_active = true;
> +}
> +
> +static void
> +input_handle_touch_up(void *data, struct wl_touch *wl_touch,
> + uint32_t serial, uint32_t time, int32_t id)
> +{
> + struct wayland_input *input = data;
> + struct wayland_output *output = input->touch_focus;
> + bool active = input->touch_active;
> +
> + input->touch_points--;
> + if (input->touch_points == 0) {
> + input->touch_focus = NULL;
> + input->touch_active = false;
> + }
> +
> + if (!output || !output->frame)
> + return;
Ditto.
> + frame_touch_up(output->frame, input, id);
> +
> + if (frame_status(output->frame) & FRAME_STATUS_CLOSE) {
> + wayland_output_destroy(&output->base);
> + input->touch_focus = NULL;
> + input->keyboard_focus = NULL;
> + if (wl_list_empty(&input->backend->compositor->output_list))
> + weston_compositor_exit(input->backend->compositor);
> +
> + return;
> + }
> +
> + if (frame_status(output->frame) & FRAME_STATUS_REPAINT)
> + weston_output_schedule_repaint(&output->base);
> +
> + if (active)
> + notify_touch(&input->base, time, id, 0, 0, WL_TOUCH_UP);
> +}
Doesn't this break for multiple touches, in that we'll only report
TOUCH_UP for the last touch, and leave the others hanging?
> +static void
> +input_handle_touch_motion(void *data, struct wl_touch *wl_touch,
> + uint32_t time, int32_t id, wl_fixed_t x,
> + wl_fixed_t y)
> +{
> + struct wayland_input *input = data;
> + struct wayland_output *output = input->touch_focus;
> + int32_t fx, fy;
> +
> + if (!output || !output->frame || !input->touch_active)
> + return;
Blah blah frame blah.
Cheers,
Daniel
More information about the wayland-devel
mailing list