diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index eeb24aa8..f3ff0a1d 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -982,8 +982,9 @@ touch_move_grab_motion(struct weston_touch_grab *grab, es = weston_desktop_surface_get_surface(shsurf->desktop_surface); - 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)); + pos.c.x = pos.c.x + wl_fixed_to_double(move->dx); + pos.c.y = pos.c.y + wl_fixed_to_double(move->dy); + pos.c = weston_coord_truncate(pos.c); weston_view_set_position(shsurf->view, pos); weston_compositor_schedule_repaint(es->compositor); diff --git a/include/libweston/matrix.h b/include/libweston/matrix.h index 842d9688..7b4adee1 100644 --- a/include/libweston/matrix.h +++ b/include/libweston/matrix.h @@ -166,6 +166,12 @@ weston_coord_sub(struct weston_coord a, struct weston_coord b) return weston_coord(a.x - b.x, a.y - b.y); } +static inline struct weston_coord __attribute__ ((warn_unused_result)) +weston_coord_truncate(struct weston_coord in) +{ + return (struct weston_coord){ (int)in.x, (int)in.y }; +} + #ifdef __cplusplus } #endif diff --git a/kiosk-shell/kiosk-shell-grab.c b/kiosk-shell/kiosk-shell-grab.c index 8193b250..73bf44b1 100644 --- a/kiosk-shell/kiosk-shell-grab.c +++ b/kiosk-shell/kiosk-shell-grab.c @@ -171,10 +171,11 @@ touch_move_grab_motion(struct weston_touch_grab *touch_grab, surface = weston_desktop_surface_get_surface(shsurf->desktop_surface); - 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)); + 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.c = weston_coord_truncate(pos.c); weston_view_set_position(shsurf->view, pos); weston_compositor_schedule_repaint(surface->compositor);