summaryrefslogtreecommitdiff
path: root/libweston
diff options
context:
space:
mode:
Diffstat (limited to 'libweston')
-rw-r--r--libweston/compositor.c44
-rw-r--r--libweston/data-device.c38
-rw-r--r--libweston/desktop/surface.c26
-rw-r--r--libweston/desktop/xwayland.c5
-rw-r--r--libweston/input.c17
-rw-r--r--libweston/shell-utils/shell-utils.c16
-rw-r--r--libweston/touch-calibration.c6
7 files changed, 86 insertions, 66 deletions
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 379cf391..aa9f3acb 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -1584,29 +1584,32 @@ weston_surface_damage(struct weston_surface *surface)
}
WL_EXPORT void
-weston_view_set_rel_position(struct weston_view *view, float x, float y)
+weston_view_set_rel_position(struct weston_view *view,
+ struct weston_coord_surface offset)
{
assert(view->geometry.parent);
+ assert(offset.coordinate_space_id == view->geometry.parent->surface);
- if (view->geometry.pos_offset.x == x &&
- view->geometry.pos_offset.y == y)
+ if (view->geometry.pos_offset.x == offset.c.x &&
+ view->geometry.pos_offset.y == offset.c.y)
return;
- view->geometry.pos_offset = weston_coord(x, y);
+ view->geometry.pos_offset = offset.c;
weston_view_geometry_dirty(view);
}
WL_EXPORT void
-weston_view_set_position(struct weston_view *view, float x, float y)
+weston_view_set_position(struct weston_view *view,
+ struct weston_coord_global pos)
{
assert(view->surface->committed != subsurface_committed);
assert(!view->geometry.parent);
- if (view->geometry.pos_offset.x == x &&
- view->geometry.pos_offset.y == y)
+ if (view->geometry.pos_offset.x == pos.c.x &&
+ view->geometry.pos_offset.y == pos.c.y)
return;
- view->geometry.pos_offset = weston_coord(x, y);
+ view->geometry.pos_offset = pos.c;
weston_view_geometry_dirty(view);
}
@@ -2901,9 +2904,7 @@ view_list_add_subsurface_view(struct weston_compositor *compositor,
} else {
view = weston_view_create(sub->surface);
weston_view_set_transform_parent(view, parent);
- weston_view_set_rel_position(view,
- sub->position.offset.c.x,
- sub->position.offset.c.y);
+ weston_view_set_rel_position(view, sub->position.offset);
}
view->parent_view = parent;
@@ -4524,8 +4525,7 @@ weston_subsurface_parent_commit(struct weston_subsurface *sub,
if (sub->position.changed) {
wl_list_for_each(view, &sub->surface->views, surface_link)
weston_view_set_rel_position(view,
- sub->position.offset.c.x,
- sub->position.offset.c.y);
+ sub->position.offset);
sub->position.changed = false;
}
@@ -4546,8 +4546,10 @@ subsurface_committed(struct weston_surface *surface,
{
struct weston_view *view;
+ assert(new_origin.coordinate_space_id == surface);
+
wl_list_for_each(view, &surface->views, surface_link) {
- struct weston_coord_surface tmp = new_origin;
+ struct weston_coord_surface tmp;
if (!view->geometry.parent) {
weston_log_paced(&view->subsurface_parent_log_pacer,
@@ -4556,9 +4558,11 @@ subsurface_committed(struct weston_surface *surface,
continue;
}
- tmp.c = weston_coord_add(tmp.c,
- view->geometry.pos_offset);
- weston_view_set_rel_position(view, tmp.c.x, tmp.c.y);
+ tmp = weston_coord_surface(view->geometry.pos_offset.x,
+ view->geometry.pos_offset.y,
+ view->geometry.parent->surface);
+ tmp.c = weston_coord_add(tmp.c, new_origin.c);
+ weston_view_set_rel_position(view, tmp);
}
/* No need to check parent mappedness, because if parent is not
* mapped, parent is not in a visible layer, so this sub-surface
@@ -4788,7 +4792,9 @@ subsurface_set_position(struct wl_client *client,
if (!sub)
return;
- sub->position.offset = weston_coord_surface(x, y, sub->surface);
+ assert(sub->parent);
+
+ sub->position.offset = weston_coord_surface(x, y, sub->parent);
sub->position.changed = true;
}
@@ -5048,7 +5054,7 @@ weston_subsurface_create(uint32_t id, struct weston_surface *surface,
return NULL;
}
- sub->position.offset = weston_coord_surface(0, 0, surface);
+ sub->position.offset = weston_coord_surface(0, 0, parent);
wl_resource_set_implementation(sub->resource,
&subsurface_implementation,
diff --git a/libweston/data-device.c b/libweston/data-device.c
index fbec4e18..e786eb89 100644
--- a/libweston/data-device.c
+++ b/libweston/data-device.c
@@ -415,7 +415,7 @@ drag_surface_configure(struct weston_drag *drag,
struct weston_coord_surface new_origin)
{
struct weston_layer_entry *list;
- float fx, fy;
+ struct weston_coord_global pos;
assert((pointer != NULL && touch == NULL) ||
(pointer == NULL && touch != NULL));
@@ -440,15 +440,14 @@ drag_surface_configure(struct weston_drag *drag,
drag->offset.c = weston_coord_add(drag->offset.c, new_origin.c);
/* init to 0 for avoiding a compile warning */
- fx = fy = 0;
- if (pointer) {
- fx = pointer->pos.c.x + drag->offset.c.x;
- fy = pointer->pos.c.y + drag->offset.c.y;
- } else if (touch) {
- fx = wl_fixed_to_double(touch->grab_x) + drag->offset.c.x;
- fy = wl_fixed_to_double(touch->grab_y) + drag->offset.c.y;
- }
- weston_view_set_position(drag->icon, fx, fy);
+ pos.c = weston_coord(0, 0);
+ if (pointer)
+ pos = pointer->pos;
+ else if (touch)
+ pos.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
+
+ pos.c = weston_coord_add(pos.c, drag->offset.c);
+ weston_view_set_position(drag->icon, pos);
}
static int
@@ -617,15 +616,15 @@ drag_grab_motion(struct weston_pointer_grab *grab,
struct weston_pointer_drag *drag =
container_of(grab, struct weston_pointer_drag, grab);
struct weston_pointer *pointer = drag->grab.pointer;
- float fx, fy;
uint32_t msecs;
weston_pointer_move(pointer, event);
if (drag->base.icon) {
- fx = pointer->pos.c.x + drag->base.offset.c.x;
- fy = pointer->pos.c.y + drag->base.offset.c.y;
- weston_view_set_position(drag->base.icon, fx, fy);
+ struct weston_coord_global pos;
+
+ pos.c = weston_coord_add(pointer->pos.c, drag->base.offset.c);
+ weston_view_set_position(drag->base.icon, pos);
weston_view_schedule_repaint(drag->base.icon);
}
@@ -812,7 +811,6 @@ drag_grab_touch_motion(struct weston_touch_grab *grab,
struct weston_touch_drag *touch_drag =
container_of(grab, struct weston_touch_drag, grab);
struct weston_touch *touch = grab->touch;
- float fx, fy;
uint32_t msecs;
if (touch_id != touch->grab_touch_id)
@@ -820,11 +818,11 @@ drag_grab_touch_motion(struct weston_touch_grab *grab,
drag_grab_touch_focus(touch_drag);
if (touch_drag->base.icon) {
- fx = wl_fixed_to_double(touch->grab_x) +
- touch_drag->base.offset.c.x;
- fy = wl_fixed_to_double(touch->grab_y) +
- touch_drag->base.offset.c.y;
- weston_view_set_position(touch_drag->base.icon, fx, fy);
+ struct weston_coord_global pos;
+
+ pos.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
+ pos.c = weston_coord_add(pos.c, touch_drag->base.offset.c);
+ weston_view_set_position(touch_drag->base.icon, pos);
weston_view_schedule_repaint(touch_drag->base.icon);
}
diff --git a/libweston/desktop/surface.c b/libweston/desktop/surface.c
index 74707f6a..e61f50aa 100644
--- a/libweston/desktop/surface.c
+++ b/libweston/desktop/surface.c
@@ -81,27 +81,35 @@ static void
weston_desktop_surface_update_view_position(struct weston_desktop_surface *surface)
{
struct weston_desktop_view *view;
- int32_t x, y;
-
- x = surface->position.x;
- y = surface->position.y;
if (surface->use_geometry) {
struct weston_desktop_surface *parent =
weston_desktop_surface_get_parent(surface);
struct weston_geometry geometry, parent_geometry;
+ struct weston_coord offset;
+
+ offset = weston_coord(surface->position.x, surface->position.y);
geometry = weston_desktop_surface_get_geometry(surface);
parent_geometry = weston_desktop_surface_get_geometry(parent);
- x += parent_geometry.x - geometry.x;
- y += parent_geometry.y - geometry.y;
+ offset.x += parent_geometry.x - geometry.x;
+ offset.y += parent_geometry.y - geometry.y;
+ wl_list_for_each(view, &surface->view_list, link) {
+ struct weston_view *wv = view->view;
+ struct weston_coord_surface surf_offset;
- wl_list_for_each(view, &surface->view_list, link)
- weston_view_set_rel_position(view->view, x, y);
+ surf_offset.c = offset;
+ surf_offset.coordinate_space_id = wv->geometry.parent->surface;
+ weston_view_set_rel_position(wv, surf_offset);
+ }
} else {
+ struct weston_coord_global pos;
+
+ pos.c = weston_coord(surface->position.x, surface->position.y);
+
wl_list_for_each(view, &surface->view_list, link)
- weston_view_set_position(view->view, x, y);
+ weston_view_set_position(view->view, pos);
}
}
diff --git a/libweston/desktop/xwayland.c b/libweston/desktop/xwayland.c
index b4bc9ee6..fd7300b5 100644
--- a/libweston/desktop/xwayland.c
+++ b/libweston/desktop/xwayland.c
@@ -354,9 +354,12 @@ set_fullscreen(struct weston_desktop_xwayland_surface *surface,
static void
set_xwayland(struct weston_desktop_xwayland_surface *surface, int x, int y)
{
+ struct weston_coord_global pos;
+
+ pos.c = weston_coord(x, y);
weston_desktop_xwayland_surface_change_state(surface, XWAYLAND, NULL,
x, y);
- weston_view_set_position(surface->view, x, y);
+ weston_view_set_position(surface->view, pos);
}
static int
diff --git a/libweston/input.c b/libweston/input.c
index 164dbf36..d335346d 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1863,9 +1863,10 @@ weston_tablet_tool_cursor_move(struct weston_tablet_tool *tool,
tool->pos = pos;
if (tool->sprite) {
- weston_view_set_position(tool->sprite,
- pos.c.x - tool->hotspot.c.x,
- pos.c.y - tool->hotspot.c.y);
+ struct weston_coord_global hotspot;
+
+ hotspot.c = weston_coord_sub(pos.c, tool->hotspot.c);
+ weston_view_set_position(tool->sprite, hotspot);
weston_view_schedule_repaint(tool->sprite);
}
}
@@ -2197,9 +2198,9 @@ weston_pointer_move_to(struct weston_pointer *pointer,
pointer->pos = pos;
if (pointer->sprite) {
- weston_view_set_position(pointer->sprite,
- pos.c.x - pointer->hotspot.c.x,
- pos.c.y - pointer->hotspot.c.y);
+ pos.c = weston_coord_sub(pointer->pos.c,
+ pointer->hotspot.c);
+ weston_view_set_position(pointer->sprite, pos);
weston_view_schedule_repaint(pointer->sprite);
}
@@ -3241,7 +3242,7 @@ tablet_tool_cursor_surface_committed(struct weston_surface *es,
tool->hotspot.c = weston_coord_sub(tool->hotspot.c, new_origin.c);
pos.c = weston_coord_sub(tool->pos.c, tool->hotspot.c);
- weston_view_set_position(tool->sprite, pos.c.x, pos.c.y);
+ weston_view_set_position(tool->sprite, pos);
empty_region(&es->pending.input);
empty_region(&es->input);
@@ -3537,7 +3538,7 @@ pointer_cursor_surface_committed(struct weston_surface *es,
new_origin.c);
pos.c = weston_coord_sub(pointer->pos.c, pointer->hotspot.c);
- weston_view_set_position(pointer->sprite, pos.c.x, pos.c.y);
+ weston_view_set_position(pointer->sprite, pos);
empty_region(&es->pending.input);
empty_region(&es->input);
diff --git a/libweston/shell-utils/shell-utils.c b/libweston/shell-utils/shell-utils.c
index 6665062f..98c3d1d2 100644
--- a/libweston/shell-utils/shell-utils.c
+++ b/libweston/shell-utils/shell-utils.c
@@ -130,20 +130,22 @@ weston_shell_utils_center_on_output(struct weston_view *view,
struct weston_output *output)
{
int32_t surf_x, surf_y, width, height;
- float x, y;
+ struct weston_coord_global pos;
if (!output) {
- weston_view_set_position(view, 0, 0);
+ pos.c = weston_coord(0, 0);
+ weston_view_set_position(view, pos);
return;
}
weston_shell_utils_subsurfaces_boundingbox(view->surface, &surf_x,
&surf_y, &width, &height);
- x = output->x + (output->width - width) / 2 - surf_x / 2;
- y = output->y + (output->height - height) / 2 - surf_y / 2;
+ pos.c = weston_coord(output->x, output->y);
+ pos.c.x += (output->width - width) / 2 - surf_x / 2;
+ pos.c.y += (output->height - height) / 2 - surf_y / 2;
- weston_view_set_position(view, x, y);
+ weston_view_set_position(view, pos);
}
/**
@@ -177,6 +179,7 @@ weston_shell_utils_curtain_create(struct weston_compositor *compositor,
struct weston_surface *surface = NULL;
struct weston_buffer_reference *buffer_ref;
struct weston_view *view;
+ struct weston_coord_global pos;
curtain = zalloc(sizeof(*curtain));
if (curtain == NULL)
@@ -218,7 +221,8 @@ weston_shell_utils_curtain_create(struct weston_compositor *compositor,
weston_surface_map(surface);
- weston_view_set_position(view, params->x, params->y);
+ pos.c = weston_coord(params->x, params->y);
+ weston_view_set_position(view, pos);
return curtain;
diff --git a/libweston/touch-calibration.c b/libweston/touch-calibration.c
index bbef89fc..67725548 100644
--- a/libweston/touch-calibration.c
+++ b/libweston/touch-calibration.c
@@ -181,6 +181,7 @@ map_calibrator(struct weston_touch_calibrator *calibrator)
{
struct weston_compositor *c = calibrator->compositor;
struct weston_touch_device *device = calibrator->device;
+ struct weston_coord_global pos;
static const struct weston_touch_device_matrix identity = {
.m = { 1, 0, 0, 0, 1, 0}
};
@@ -199,9 +200,8 @@ map_calibrator(struct weston_touch_calibrator *calibrator)
weston_layer_entry_insert(&c->calibrator_layer.view_list,
&calibrator->view->layer_link);
- weston_view_set_position(calibrator->view,
- calibrator->output->x,
- calibrator->output->y);
+ pos.c = weston_coord(calibrator->output->x, calibrator->output->y);
+ weston_view_set_position(calibrator->view, pos);
calibrator->view->output = calibrator->surface->output;
calibrator->view->is_mapped = true;