libweston: Use weston_coord in struct weston_touch

Convert the grab coordinate to a weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-02-07 13:56:28 -06:00
parent e8208d21d7
commit 0bf2d82e0c
6 changed files with 37 additions and 38 deletions

View file

@ -973,16 +973,15 @@ touch_move_grab_motion(struct weston_touch_grab *grab,
struct weston_touch_move_grab *move = (struct weston_touch_move_grab *) grab;
struct shell_surface *shsurf = move->base.shsurf;
struct weston_surface *es;
int dx = wl_fixed_to_int(grab->touch->grab_x + move->dx);
int dy = wl_fixed_to_int(grab->touch->grab_y + move->dy);
struct weston_coord_global pos;
struct weston_coord_global pos = grab->touch->grab_pos;
if (!shsurf || !shsurf->desktop_surface || !move->active)
return;
es = weston_desktop_surface_get_surface(shsurf->desktop_surface);
pos.c = weston_coord(dx, dy);
pos.c.x = (int)(pos.c.x + wl_fixed_to_double(move->dx));
pos.c.y = (int)(pos.c.y + wl_fixed_to_double(move->dy));
weston_view_set_position(shsurf->view, pos);
weston_compositor_schedule_repaint(es->compositor);
@ -1016,6 +1015,7 @@ static int
surface_touch_move(struct shell_surface *shsurf, struct weston_touch *touch)
{
struct weston_touch_move_grab *move;
struct weston_coord_global pos;
if (!shsurf)
return -1;
@ -1029,10 +1029,10 @@ surface_touch_move(struct shell_surface *shsurf, struct weston_touch *touch)
return -1;
move->active = 1;
move->dx = wl_fixed_from_double(shsurf->view->geometry.pos_offset.x) -
touch->grab_x;
move->dy = wl_fixed_from_double(shsurf->view->geometry.pos_offset.y) -
touch->grab_y;
pos.c = weston_coord_sub(shsurf->view->geometry.pos_offset,
touch->grab_pos.c);
move->dx = wl_fixed_from_double(pos.c.x);
move->dy = wl_fixed_from_double(pos.c.y);
shell_touch_grab_start(&move->base, &touch_move_grab_interface, shsurf,
touch);

View file

@ -876,7 +876,7 @@ struct weston_touch {
struct weston_touch_grab *grab;
struct weston_touch_grab default_grab;
int grab_touch_id;
wl_fixed_t grab_x, grab_y;
struct weston_coord_global grab_pos;
uint32_t grab_serial;
struct timespec grab_time;

View file

@ -1603,7 +1603,8 @@ touch_move_workspace_grab_end(struct touch_grab *grab)
struct ivi_layout_layer *layer = tch_move_grab->base.layer;
move_workspace_grab_end(&tch_move_grab->move, grab->resource,
grab->grab.touch->grab_x, layer);
wl_fixed_from_double(grab->grab.touch->grab_pos.c.x),
layer);
weston_touch_end_grab(grab->grab.touch);
}
@ -1721,8 +1722,8 @@ touch_move_grab_motion(struct weston_touch_grab *grab,
return;
wl_fixed_t pointer_pos[2] = {
grab->touch->grab_x,
grab->touch->grab_y
wl_fixed_from_double(grab->touch->grab_pos.c.x),
wl_fixed_from_double(grab->touch->grab_pos.c.y)
};
move_grab_update(&tch_move_grab->move, pointer_pos);
@ -1907,8 +1908,10 @@ create_workspace_touch_move(struct weston_touch *touch,
tch_move_grab->base.resource = resource;
tch_move_grab->is_active = 1;
move_grab_init_workspace(&tch_move_grab->move, touch->grab_x,
touch->grab_y, resource);
move_grab_init_workspace(&tch_move_grab->move,
wl_fixed_from_double(touch->grab_pos.c.x),
wl_fixed_from_double(touch->grab_pos.c.y),
resource);
return tch_move_grab;
}

View file

@ -171,8 +171,8 @@ touch_move_grab_motion(struct weston_touch_grab *touch_grab,
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
dx = wl_fixed_to_int(touch->grab_x + shgrab->dx);
dy = wl_fixed_to_int(touch->grab_y + shgrab->dy);
dx = (int)(touch->grab_pos.c.x + wl_fixed_to_double(shgrab->dx));
dy = (int)(touch->grab_pos.c.y + wl_fixed_to_double(shgrab->dy));
pos.c = weston_coord(dx, dy);
weston_view_set_position(shsurf->view, pos);
@ -274,6 +274,7 @@ kiosk_shell_grab_start_for_touch_move(struct kiosk_shell_surface *shsurf,
struct weston_touch *touch)
{
struct kiosk_shell_grab *shgrab;
struct weston_coord_global pos;
if (!shsurf)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
@ -287,10 +288,10 @@ kiosk_shell_grab_start_for_touch_move(struct kiosk_shell_surface *shsurf,
if (!shgrab)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
shgrab->dx = wl_fixed_from_double(shsurf->view->geometry.pos_offset.x) -
touch->grab_x;
shgrab->dy = wl_fixed_from_double(shsurf->view->geometry.pos_offset.y) -
touch->grab_y;
pos.c = weston_coord_sub(shsurf->view->geometry.pos_offset,
touch->grab_pos.c);
shgrab->dx = wl_fixed_from_double(pos.c.x);
shgrab->dy = wl_fixed_from_double(pos.c.y);
shgrab->active = true;
weston_seat_break_desktop_grabs(touch->seat);

View file

@ -444,7 +444,7 @@ drag_surface_configure(struct weston_drag *drag,
if (pointer)
pos = pointer->pos;
else if (touch)
pos.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
pos = touch->grab_pos;
pos.c = weston_coord_add(pos.c, drag->offset.c);
weston_view_set_position(drag->icon, pos);
@ -797,10 +797,8 @@ static void
drag_grab_touch_focus(struct weston_touch_drag *drag)
{
struct weston_touch *touch = drag->grab.touch;
struct weston_coord_global pos;
pos.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
drag_grab_focus_internal(&drag->base, touch->seat, pos);
drag_grab_focus_internal(&drag->base, touch->seat, touch->grab_pos);
}
static void
@ -820,22 +818,22 @@ drag_grab_touch_motion(struct weston_touch_grab *grab,
if (touch_drag->base.icon) {
struct weston_coord_global pos;
pos.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
pos.c = weston_coord_add(pos.c, touch_drag->base.offset.c);
pos.c = weston_coord_add(touch_drag->base.offset.c,
touch->grab_pos.c);
weston_view_set_position(touch_drag->base.icon, pos);
weston_view_schedule_repaint(touch_drag->base.icon);
}
if (touch_drag->base.focus_resource) {
struct weston_coord_global tmp_g;
struct weston_coord_surface c;
struct weston_coord_surface surf_pos;
tmp_g.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
msecs = timespec_to_msec(time);
c = weston_coord_global_to_surface(touch_drag->base.focus, tmp_g);
surf_pos = weston_coord_global_to_surface(touch_drag->base.focus,
touch->grab_pos);
wl_data_device_send_motion(touch_drag->base.focus_resource,
msecs, wl_fixed_from_double(c.c.x),
wl_fixed_from_double(c.c.y));
msecs,
wl_fixed_from_double(surf_pos.c.x),
wl_fixed_from_double(surf_pos.c.y));
}
}

View file

@ -2888,10 +2888,8 @@ process_touch_normal(struct weston_touch_device *device,
}
/* Update grab's global coordinates. */
if (touch_id == touch->grab_touch_id && touch_type != WL_TOUCH_UP) {
touch->grab_x = x;
touch->grab_y = y;
}
if (touch_id == touch->grab_touch_id && touch_type != WL_TOUCH_UP)
touch->grab_pos = *pos;
switch (touch_type) {
case WL_TOUCH_DOWN:
@ -2919,8 +2917,7 @@ process_touch_normal(struct weston_touch_device *device,
wl_display_get_serial(ec->wl_display);
touch->grab_touch_id = touch_id;
touch->grab_time = *time;
touch->grab_x = x;
touch->grab_y = y;
touch->grab_pos = *pos;
}
break;