libweston: Add weston_coord_truncate()
Truncating a weston coord to integer values is something we do frequently enough to warrant a helper function. Use this in the kiosk and desktop shells where appropriate. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
ca1f6936c4
commit
1f81c082b5
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue