diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index a8fb451f..53e0071a 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -344,7 +344,7 @@ get_panel_size(struct desktop_shell *shell, view->surface); b = weston_coord_surface_to_global(view, tmp_s); - a.c = weston_coord_sub(b.c, a.c); + a = weston_coord_global_sub(b, a); *width = a.c.x; *height = a.c.y; } @@ -2498,10 +2498,10 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, from_g = weston_coord_surface_to_global(view, from_s); to_g = weston_coord_surface_to_global(view, to_s); - offset.c = weston_coord_sub(to_g.c, from_g.c); - pos.c = weston_coord_add( - weston_view_get_pos_offset_global(view).c, - offset.c); + offset = weston_coord_global_sub(to_g, from_g); + pos = weston_coord_global_add( + weston_view_get_pos_offset_global(view), + offset); weston_view_set_position(shsurf->view, pos); } diff --git a/include/libweston/matrix.h b/include/libweston/matrix.h index 7b4adee1..2bee61fa 100644 --- a/include/libweston/matrix.h +++ b/include/libweston/matrix.h @@ -160,12 +160,26 @@ weston_coord_add(struct weston_coord a, struct weston_coord b) return weston_coord(a.x + b.x, a.y + b.y); } +static inline struct weston_coord_global __attribute__ ((warn_unused_result)) +weston_coord_global_add(struct weston_coord_global a, + struct weston_coord_global b) +{ + return (struct weston_coord_global){ .c = weston_coord_add(a.c, b.c) }; +} + static inline struct weston_coord __attribute__ ((warn_unused_result)) 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_global __attribute__ ((warn_unused_result)) +weston_coord_global_sub(struct weston_coord_global a, + struct weston_coord_global b) +{ + return (struct weston_coord_global){ .c = weston_coord_sub(a.c, b.c) }; +} + static inline struct weston_coord __attribute__ ((warn_unused_result)) weston_coord_truncate(struct weston_coord in) { diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index 14bb78a5..960c4e91 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -820,10 +820,10 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, from_g = weston_coord_surface_to_global(shsurf->view, from_s); to_g = weston_coord_surface_to_global(shsurf->view, to_s); - offset.c = weston_coord_sub(to_g.c, from_g.c); - pos.c = weston_coord_add( - weston_view_get_pos_offset_global(shsurf->view).c, - offset.c); + offset = weston_coord_global_sub(to_g, from_g); + pos = weston_coord_global_add( + weston_view_get_pos_offset_global(shsurf->view), + offset); weston_view_set_position(shsurf->view, pos); weston_view_update_transform(shsurf->view); diff --git a/libweston/compositor.c b/libweston/compositor.c index c241ee35..b70878b9 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -6496,7 +6496,7 @@ weston_output_set_position(struct weston_output *output, return; } - output->move.c = weston_coord_sub(pos.c, output->pos.c); + output->move = weston_coord_global_sub(pos, output->pos); if (output->move.c.x == 0 && output->move.c.y == 0) return;