libweston: Split weston_view_set_position() into rel and abs variants
One variant is used when a view is being positioned relative to a parent, the other is when the view is being given an absolute position in the global space. This will help later when surface and global coordinates are different data types, but for now the two functions do essentially the same thing. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
4eea291512
commit
fe4d5711bf
|
@ -1961,6 +1961,10 @@ weston_surface_has_content(struct weston_surface *surface);
|
|||
void
|
||||
weston_view_destroy(struct weston_view *view);
|
||||
|
||||
void
|
||||
weston_view_set_rel_position(struct weston_view *view,
|
||||
float x, float y);
|
||||
|
||||
void
|
||||
weston_view_set_position(struct weston_view *view,
|
||||
float x, float y);
|
||||
|
|
|
@ -104,6 +104,9 @@ weston_compositor_build_view_list(struct weston_compositor *compositor,
|
|||
static char *
|
||||
weston_output_create_heads_string(struct weston_output *output);
|
||||
|
||||
static void
|
||||
subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy);
|
||||
|
||||
static void
|
||||
paint_node_update(struct weston_paint_node *pnode)
|
||||
{
|
||||
|
@ -1569,9 +1572,25 @@ weston_surface_damage(struct weston_surface *surface)
|
|||
weston_surface_schedule_repaint(surface);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_view_set_rel_position(struct weston_view *view, float x, float y)
|
||||
{
|
||||
assert(view->geometry.parent);
|
||||
|
||||
if (view->geometry.x == x && view->geometry.y == y)
|
||||
return;
|
||||
|
||||
view->geometry.x = x;
|
||||
view->geometry.y = y;
|
||||
weston_view_geometry_dirty(view);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_view_set_position(struct weston_view *view, float x, float y)
|
||||
{
|
||||
assert(view->surface->committed != subsurface_committed);
|
||||
assert(!view->geometry.parent);
|
||||
|
||||
if (view->geometry.x == x && view->geometry.y == y)
|
||||
return;
|
||||
|
||||
|
@ -2847,10 +2866,10 @@ view_list_add_subsurface_view(struct weston_compositor *compositor,
|
|||
wl_list_insert(&sub->surface->views, &view->surface_link);
|
||||
} else {
|
||||
view = weston_view_create(sub->surface);
|
||||
weston_view_set_position(view,
|
||||
sub->position.x,
|
||||
sub->position.y);
|
||||
weston_view_set_transform_parent(view, parent);
|
||||
weston_view_set_rel_position(view,
|
||||
sub->position.x,
|
||||
sub->position.y);
|
||||
}
|
||||
|
||||
view->parent_view = parent;
|
||||
|
@ -4438,9 +4457,9 @@ weston_subsurface_parent_commit(struct weston_subsurface *sub,
|
|||
struct weston_view *view;
|
||||
if (sub->position.set) {
|
||||
wl_list_for_each(view, &sub->surface->views, surface_link)
|
||||
weston_view_set_position(view,
|
||||
sub->position.x,
|
||||
sub->position.y);
|
||||
weston_view_set_rel_position(view,
|
||||
sub->position.x,
|
||||
sub->position.y);
|
||||
|
||||
sub->position.set = 0;
|
||||
}
|
||||
|
@ -4461,9 +4480,9 @@ subsurface_committed(struct weston_surface *surface, int32_t dx, int32_t dy)
|
|||
struct weston_view *view;
|
||||
|
||||
wl_list_for_each(view, &surface->views, surface_link)
|
||||
weston_view_set_position(view,
|
||||
view->geometry.x + dx,
|
||||
view->geometry.y + dy);
|
||||
weston_view_set_rel_position(view,
|
||||
view->geometry.x + dx,
|
||||
view->geometry.y + dy);
|
||||
|
||||
/* No need to check parent mappedness, because if parent is not
|
||||
* mapped, parent is not in a visible layer, so this sub-surface
|
||||
|
|
|
@ -96,9 +96,13 @@ weston_desktop_surface_update_view_position(struct weston_desktop_surface *surfa
|
|||
|
||||
x += parent_geometry.x - geometry.x;
|
||||
y += parent_geometry.y - geometry.y;
|
||||
|
||||
wl_list_for_each(view, &surface->view_list, link)
|
||||
weston_view_set_rel_position(view->view, x, y);
|
||||
} else {
|
||||
wl_list_for_each(view, &surface->view_list, link)
|
||||
weston_view_set_position(view->view, x, y);
|
||||
}
|
||||
wl_list_for_each(view, &surface->view_list, link)
|
||||
weston_view_set_position(view->view, x, y);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue