kiosk-shell: Use weston_coord for grabs

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-02-07 14:18:05 -06:00 committed by Pekka Paalanen
parent 643c9b929f
commit aea5ca97ae

View file

@ -32,7 +32,7 @@ struct kiosk_shell_grab {
struct weston_pointer_grab pointer_grab;
struct weston_touch_grab touch_grab;
wl_fixed_t dx, dy;
struct weston_coord_global delta;
bool active;
};
@ -85,9 +85,7 @@ pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab,
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
pos = pointer->pos;
pos.c.x += wl_fixed_to_double(shgrab->dx);
pos.c.y += wl_fixed_to_double(shgrab->dy);
pos = weston_coord_global_add(pointer->pos, shgrab->delta);
weston_view_set_position(shsurf->view, pos);
@ -164,17 +162,13 @@ touch_move_grab_motion(struct weston_touch_grab *touch_grab,
struct kiosk_shell_surface *shsurf = shgrab->shsurf;
struct weston_surface *surface;
struct weston_coord_global pos;
int dx, dy;
if (!shsurf || !shgrab->active)
return;
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
dx = touch->grab_pos.c.x + wl_fixed_to_double(shgrab->dx);
dy = touch->grab_pos.c.y + wl_fixed_to_double(shgrab->dy);
pos.c = weston_coord(dx, dy);
pos = weston_coord_global_add(touch->grab_pos, shgrab->delta);
pos.c = weston_coord_truncate(pos.c);
weston_view_set_position(shsurf->view, pos);
@ -242,7 +236,6 @@ kiosk_shell_grab_start_for_pointer_move(struct kiosk_shell_surface *shsurf,
struct weston_pointer *pointer)
{
struct kiosk_shell_grab *shgrab;
struct weston_coord_global offset;
if (!shsurf)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
@ -256,11 +249,9 @@ kiosk_shell_grab_start_for_pointer_move(struct kiosk_shell_surface *shsurf,
if (!shgrab)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
offset.c = weston_coord_sub(
weston_view_get_pos_offset_global(shsurf->view).c,
pointer->grab_pos.c);
shgrab->dx = wl_fixed_from_double(offset.c.x);
shgrab->dy = wl_fixed_from_double(offset.c.y);
shgrab->delta = weston_coord_global_sub(
weston_view_get_pos_offset_global(shsurf->view),
pointer->grab_pos);
shgrab->active = true;
weston_seat_break_desktop_grabs(pointer->seat);
@ -276,7 +267,6 @@ 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;
@ -290,11 +280,9 @@ kiosk_shell_grab_start_for_touch_move(struct kiosk_shell_surface *shsurf,
if (!shgrab)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
pos.c = weston_coord_sub(
weston_view_get_pos_offset_global(shsurf->view).c,
touch->grab_pos.c);
shgrab->dx = wl_fixed_from_double(pos.c.x);
shgrab->dy = wl_fixed_from_double(pos.c.y);
shgrab->delta = weston_coord_global_sub(
weston_view_get_pos_offset_global(shsurf->view),
touch->grab_pos);
shgrab->active = true;
weston_seat_break_desktop_grabs(touch->seat);