libweston: Add more weston_coord arithmetic helpers
Until now we've only had the unadorned arithmetic functions, but they're easy to abuse and tedious to use. For now, we just add weston_coord_global_add/sub functions and use them where appropriate. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
d961e59d4a
commit
2ac566d281
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue