summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compositor/screen-share.c4
-rw-r--r--desktop-shell/shell.c40
-rw-r--r--include/libweston/libweston.h6
-rw-r--r--ivi-shell/hmi-controller.c10
-rw-r--r--kiosk-shell/kiosk-shell-grab.c12
-rw-r--r--libweston/backend-drm/drm.c11
-rw-r--r--libweston/compositor.c12
-rw-r--r--libweston/data-device.c16
-rw-r--r--libweston/desktop/seat.c5
-rw-r--r--libweston/input.c76
-rw-r--r--libweston/libinput-seat.c10
-rw-r--r--tests/weston-test.c10
12 files changed, 89 insertions, 123 deletions
diff --git a/compositor/screen-share.c b/compositor/screen-share.c
index 29d4e6eb..9ba64cf7 100644
--- a/compositor/screen-share.c
+++ b/compositor/screen-share.c
@@ -1171,8 +1171,8 @@ share_output_binding(struct weston_keyboard *keyboard,
pointer = weston_seat_get_pointer(keyboard->seat);
if (pointer) {
output = weston_output_find(pointer->seat->compositor,
- wl_fixed_to_int(pointer->x),
- wl_fixed_to_int(pointer->y));
+ pointer->pos.c.x,
+ pointer->pos.c.y);
} else {
output = weston_shell_utils_get_focused_output(keyboard->seat->compositor);
if (!output)
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 9306c0f9..967b9712 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1019,8 +1019,8 @@ constrain_position(struct weston_move_grab *move, int *cx, int *cy)
pixman_rectangle32_t area;
struct weston_geometry geometry;
- x = wl_fixed_to_int(pointer->x + move->dx);
- y = wl_fixed_to_int(pointer->y + move->dy);
+ x = pointer->pos.c.x + wl_fixed_to_double(move->dx);
+ y = pointer->pos.c.y + wl_fixed_to_double(move->dy);
if (shsurf->shell->panel_position ==
WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP) {
@@ -1120,10 +1120,10 @@ surface_move(struct shell_surface *shsurf, struct weston_pointer *pointer,
if (!move)
return -1;
- move->dx = wl_fixed_from_double(shsurf->view->geometry.x) -
- pointer->grab_x;
- move->dy = wl_fixed_from_double(shsurf->view->geometry.y) -
- pointer->grab_y;
+ move->dx = wl_fixed_from_double(shsurf->view->geometry.x -
+ pointer->grab_pos.c.x);
+ move->dy = wl_fixed_from_double(shsurf->view->geometry.y -
+ pointer->grab_pos.c.y);
move->client_initiated = client_initiated;
weston_desktop_surface_set_orientation(shsurf->desktop_surface,
@@ -1152,7 +1152,6 @@ resize_grab_motion(struct weston_pointer_grab *grab,
int32_t width, height;
struct weston_size min_size, max_size;
struct weston_coord_surface tmp_s;
- struct weston_coord_global tmp_g;
wl_fixed_t from_x, from_y;
wl_fixed_t to_x, to_y;
@@ -1163,12 +1162,10 @@ resize_grab_motion(struct weston_pointer_grab *grab,
weston_view_update_transform(shsurf->view);
- tmp_g.c = weston_coord_from_fixed(pointer->grab_x, pointer->grab_y);
- tmp_s = weston_coord_global_to_surface(shsurf->view, tmp_g);
+ tmp_s = weston_coord_global_to_surface(shsurf->view, pointer->grab_pos);
from_x = wl_fixed_from_double(tmp_s.c.x);
from_y = wl_fixed_from_double(tmp_s.c.y);
- tmp_g.c = weston_coord_from_fixed(pointer->x, pointer->y);
- tmp_s = weston_coord_global_to_surface(shsurf->view, tmp_g);
+ tmp_s = weston_coord_global_to_surface(shsurf->view, pointer->pos);
to_x = wl_fixed_from_double(tmp_s.c.x);
to_y = wl_fixed_from_double(tmp_s.c.y);
@@ -1305,10 +1302,9 @@ busy_cursor_grab_focus(struct weston_pointer_grab *base)
struct weston_pointer *pointer = base->pointer;
struct weston_desktop_surface *desktop_surface;
struct weston_view *view;
- struct weston_coord_global pos;
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- view = weston_compositor_pick_view(pointer->seat->compositor, pos);
+ view = weston_compositor_pick_view(pointer->seat->compositor,
+ pointer->pos);
desktop_surface = weston_surface_get_desktop_surface(view->surface);
if (!grab->shsurf || grab->shsurf->desktop_surface != desktop_surface) {
@@ -3059,7 +3055,6 @@ resize_binding(struct weston_pointer *pointer, const struct timespec *time,
uint32_t edges = 0;
int32_t x, y;
struct shell_surface *shsurf;
- struct weston_coord_global tmp_g;
struct weston_coord_surface surf_pos;
if (pointer->focus == NULL)
@@ -3077,8 +3072,7 @@ resize_binding(struct weston_pointer *pointer, const struct timespec *time,
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return;
- tmp_g.c = weston_coord_from_fixed(pointer->grab_x, pointer->grab_y);
- surf_pos = weston_coord_global_to_surface(shsurf->view, tmp_g);
+ surf_pos = weston_coord_global_to_surface(shsurf->view, pointer->grab_pos);
x = surf_pos.c.x;
y = surf_pos.c.y;
@@ -3161,8 +3155,8 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
cx = 0.5f * surface->width;
cy = 0.5f * surface->height;
- dx = wl_fixed_to_double(pointer->x) - rotate->center.x;
- dy = wl_fixed_to_double(pointer->y) - rotate->center.y;
+ dx = pointer->pos.c.x - rotate->center.x;
+ dy = pointer->pos.c.y - rotate->center.y;
r = sqrtf(dx * dx + dy * dy);
wl_list_remove(&shsurf->rotation.transform.link);
@@ -3272,8 +3266,8 @@ surface_rotate(struct shell_surface *shsurf, struct weston_pointer *pointer)
rotate->center.x = center_g.c.x;
rotate->center.y = center_g.c.y;
- dx = wl_fixed_to_double(pointer->x) - rotate->center.x;
- dy = wl_fixed_to_double(pointer->y) - rotate->center.y;
+ dx = pointer->pos.c.x - rotate->center.x;
+ dy = pointer->pos.c.y - rotate->center.y;
r = sqrtf(dx * dx + dy * dy);
if (r > 20.0f) {
struct weston_matrix inverse;
@@ -3871,8 +3865,8 @@ weston_view_set_initial_position(struct weston_view *view,
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (pointer) {
- ix = wl_fixed_to_int(pointer->x);
- iy = wl_fixed_to_int(pointer->y);
+ ix = pointer->pos.c.x;
+ iy = pointer->pos.c.y;
break;
}
}
diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
index 6965a661..8bf6d369 100644
--- a/include/libweston/libweston.h
+++ b/include/libweston/libweston.h
@@ -717,16 +717,16 @@ struct weston_pointer {
struct weston_view *sprite;
struct wl_listener sprite_destroy_listener;
- int32_t hotspot_x, hotspot_y;
+ struct weston_coord_surface hotspot;
struct weston_pointer_grab *grab;
struct weston_pointer_grab default_grab;
- wl_fixed_t grab_x, grab_y;
+ struct weston_coord_global grab_pos;
uint32_t grab_button;
uint32_t grab_serial;
struct timespec grab_time;
- wl_fixed_t x, y;
+ struct weston_coord_global pos;
wl_fixed_t sx, sy;
uint32_t button_count;
diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 65a6107b..e1830179 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -1464,9 +1464,11 @@ pointer_move_workspace_grab_end(struct pointer_grab *grab)
struct pointer_move_grab *pnt_move_grab =
(struct pointer_move_grab *)grab;
struct ivi_layout_layer *layer = pnt_move_grab->base.layer;
+ wl_fixed_t x;
+ x = wl_fixed_from_double(grab->grab.pointer->grab_pos.c.x);
move_workspace_grab_end(&pnt_move_grab->move, grab->resource,
- grab->grab.pointer->grab_x, layer);
+ x, layer);
weston_pointer_end_grab(grab->grab.pointer);
}
@@ -1765,8 +1767,10 @@ create_workspace_pointer_move(struct weston_pointer *pointer,
xzalloc(sizeof(*pnt_move_grab));
pnt_move_grab->base.resource = resource;
- move_grab_init_workspace(&pnt_move_grab->move, pointer->grab_x,
- pointer->grab_y, resource);
+ move_grab_init_workspace(&pnt_move_grab->move,
+ wl_fixed_from_double(pointer->grab_pos.c.x),
+ wl_fixed_from_double(pointer->grab_pos.c.y),
+ resource);
return pnt_move_grab;
}
diff --git a/kiosk-shell/kiosk-shell-grab.c b/kiosk-shell/kiosk-shell-grab.c
index 3ea0156c..362694d2 100644
--- a/kiosk-shell/kiosk-shell-grab.c
+++ b/kiosk-shell/kiosk-shell-grab.c
@@ -85,8 +85,8 @@ pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab,
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
- dx = wl_fixed_to_int(pointer->x + shgrab->dx);
- dy = wl_fixed_to_int(pointer->y + shgrab->dy);
+ dx = pointer->pos.c.x + wl_fixed_to_double(shgrab->dx);
+ dy = pointer->pos.c.y + wl_fixed_to_double(shgrab->dy);
weston_view_set_position(shsurf->view, dx, dy);
@@ -251,10 +251,10 @@ kiosk_shell_grab_start_for_pointer_move(struct kiosk_shell_surface *shsurf,
if (!shgrab)
return KIOSK_SHELL_GRAB_RESULT_ERROR;
- shgrab->dx = wl_fixed_from_double(shsurf->view->geometry.x) -
- pointer->grab_x;
- shgrab->dy = wl_fixed_from_double(shsurf->view->geometry.y) -
- pointer->grab_y;
+ shgrab->dx = wl_fixed_from_double(shsurf->view->geometry.x -
+ pointer->grab_pos.c.x);
+ shgrab->dy = wl_fixed_from_double(shsurf->view->geometry.y -
+ pointer->grab_pos.c.y);
shgrab->active = true;
weston_seat_break_desktop_grabs(pointer->seat);
diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
index ddfa5959..27bfaaff 100644
--- a/libweston/backend-drm/drm.c
+++ b/libweston/backend-drm/drm.c
@@ -1293,14 +1293,9 @@ setup_output_seat_constraint(struct drm_backend *b,
seat->base.output = output;
pointer = weston_seat_get_pointer(&seat->base);
- if (pointer) {
- struct weston_coord_global pos;
-
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- pos = weston_pointer_clamp(pointer, pos);
- pointer->x = wl_fixed_from_double(pos.c.x);
- pointer->y = wl_fixed_from_double(pos.c.y);
- }
+ if (pointer)
+ pointer->pos = weston_pointer_clamp(pointer,
+ pointer->pos);
}
}
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 3e1b3cd2..d2b7379b 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -307,9 +307,8 @@ weston_mode_switch_finish(struct weston_output *output,
if (!pointer)
continue;
- x = wl_fixed_to_int(pointer->x);
- y = wl_fixed_to_int(pointer->y);
-
+ x = pointer->pos.c.x;
+ y = pointer->pos.c.y;
if (!pixman_region32_contains_point(&old_output_region,
x, y, NULL) ||
weston_output_contains_point(output, x, y))
@@ -320,8 +319,7 @@ weston_mode_switch_finish(struct weston_output *output,
if (y >= output->y + output->height)
y = output->y + output->height - 1;
- pointer->x = wl_fixed_from_int(x);
- pointer->y = wl_fixed_from_int(y);
+ pointer->pos.c = weston_coord(x, y);
}
pixman_region32_fini(&old_output_region);
@@ -6782,8 +6780,8 @@ weston_output_set_transform(struct weston_output *output,
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (pointer && pixman_region32_contains_point(&old_region,
- wl_fixed_to_int(pointer->x),
- wl_fixed_to_int(pointer->y),
+ pointer->pos.c.x,
+ pointer->pos.c.y,
NULL))
weston_pointer_move(pointer, &ev);
}
diff --git a/libweston/data-device.c b/libweston/data-device.c
index 35b7fb41..65b138dd 100644
--- a/libweston/data-device.c
+++ b/libweston/data-device.c
@@ -441,8 +441,8 @@ drag_surface_configure(struct weston_drag *drag,
/* init to 0 for avoiding a compile warning */
fx = fy = 0;
if (pointer) {
- fx = wl_fixed_to_double(pointer->x) + drag->dx;
- fy = wl_fixed_to_double(pointer->y) + drag->dy;
+ fx = pointer->pos.c.x + drag->dx;
+ fy = pointer->pos.c.y + drag->dy;
} else if (touch) {
fx = wl_fixed_to_double(touch->grab_x) + drag->dx;
fy = wl_fixed_to_double(touch->grab_y) + drag->dy;
@@ -603,10 +603,8 @@ drag_grab_focus(struct weston_pointer_grab *grab)
struct weston_pointer_drag *drag =
container_of(grab, struct weston_pointer_drag, grab);
struct weston_pointer *pointer = grab->pointer;
- struct weston_coord_global pos;
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- drag_grab_focus_internal(&drag->base, pointer->seat, pos);
+ drag_grab_focus_internal(&drag->base, pointer->seat, pointer->pos);
}
static void
@@ -623,20 +621,18 @@ drag_grab_motion(struct weston_pointer_grab *grab,
weston_pointer_move(pointer, event);
if (drag->base.icon) {
- fx = wl_fixed_to_double(pointer->x) + drag->base.dx;
- fy = wl_fixed_to_double(pointer->y) + drag->base.dy;
+ fx = pointer->pos.c.x + drag->base.dx;
+ fy = pointer->pos.c.y + drag->base.dy;
weston_view_set_position(drag->base.icon, fx, fy);
weston_view_schedule_repaint(drag->base.icon);
}
if (drag->base.focus_resource) {
- struct weston_coord_global pos;
struct weston_coord_surface surf_pos;
msecs = timespec_to_msec(time);
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
surf_pos = weston_coord_global_to_surface(drag->base.focus,
- pos);
+ pointer->pos);
wl_data_device_send_motion(drag->base.focus_resource, msecs,
wl_fixed_from_double(surf_pos.c.x),
diff --git a/libweston/desktop/seat.c b/libweston/desktop/seat.c
index fd55c883..4887ba9f 100644
--- a/libweston/desktop/seat.c
+++ b/libweston/desktop/seat.c
@@ -95,10 +95,9 @@ weston_desktop_seat_popup_grab_pointer_focus(struct weston_pointer_grab *grab)
wl_container_of(grab, seat, popup_grab.pointer);
struct weston_pointer *pointer = grab->pointer;
struct weston_view *view;
- struct weston_coord_global pos;
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- view = weston_compositor_pick_view(pointer->seat->compositor, pos);
+ view = weston_compositor_pick_view(pointer->seat->compositor,
+ pointer->pos);
/* Ignore views that don't belong to the grabbing client */
if (view != NULL &&
diff --git a/libweston/input.c b/libweston/input.c
index 0e90590f..6c61bdd3 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -315,8 +315,7 @@ weston_pointer_motion_to_abs(struct weston_pointer *pointer,
if (event->mask & WESTON_POINTER_MOTION_ABS) {
return event->abs;
} else if (event->mask & WESTON_POINTER_MOTION_REL) {
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- pos.c = weston_coord_add(pos.c, event->rel);
+ pos.c = weston_coord_add(pointer->pos.c, event->rel);
return pos;
}
@@ -451,20 +450,19 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab)
{
struct weston_pointer *pointer = grab->pointer;
struct weston_view *view;
- struct weston_coord_global pos;
bool surface_jump = false;
if (pointer->button_count > 0)
return;
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- view = weston_compositor_pick_view(pointer->seat->compositor, pos);
+ view = weston_compositor_pick_view(pointer->seat->compositor,
+ pointer->pos);
if (view && view == pointer->focus) {
struct weston_coord_surface surf_pos;
weston_view_update_transform(view);
- surf_pos = weston_coord_global_to_surface(view, pos);
+ surf_pos = weston_coord_global_to_surface(view, pointer->pos);
if (pointer->sx != wl_fixed_from_double(surf_pos.c.x) ||
pointer->sy != wl_fixed_from_double(surf_pos.c.y))
surface_jump = true;
@@ -638,10 +636,8 @@ default_grab_pointer_button(struct weston_pointer_grab *grab,
if (pointer->button_count == 0 &&
state == WL_POINTER_BUTTON_STATE_RELEASED) {
- struct weston_coord_global pos;
-
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- view = weston_compositor_pick_view(compositor, pos);
+ view = weston_compositor_pick_view(compositor,
+ pointer->pos);
weston_pointer_set_focus(pointer, view);
}
@@ -1254,8 +1250,7 @@ weston_pointer_create(struct weston_seat *seat)
pointer->sprite_destroy_listener.notify = pointer_handle_sprite_destroy;
/* FIXME: Pick better co-ords. */
- pointer->x = wl_fixed_from_int(100);
- pointer->y = wl_fixed_from_int(100);
+ pointer->pos.c = weston_coord(100, 100);
pointer->output_destroy_listener.notify =
weston_pointer_handle_output_destroy;
@@ -1457,13 +1452,12 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
wl_fixed_t sx, sy;
if (view) {
- struct weston_coord_global tmp_g;
struct weston_coord_surface surf_pos;
- tmp_g.c = weston_coord_from_fixed(pointer->x, pointer->y);
- surf_pos = weston_coord_global_to_surface(view, tmp_g);
+ surf_pos = weston_coord_global_to_surface(view, pointer->pos);
sx = wl_fixed_from_double(surf_pos.c.x);
sy = wl_fixed_from_double(surf_pos.c.y);
+
if (!weston_view_takes_input_at_point(view, surf_pos))
weston_log("View focused with external coordinate %d, %d\n",
(int)surf_pos.c.x, (int)surf_pos.c.y);
@@ -1704,17 +1698,15 @@ weston_pointer_clamp(struct weston_pointer *pointer, struct weston_coord_global
{
struct weston_compositor *ec = pointer->seat->compositor;
struct weston_output *output, *prev = NULL;
- int old_x, old_y, valid = 0;
-
- old_x = wl_fixed_to_int(pointer->x);
- old_y = wl_fixed_to_int(pointer->y);
+ int valid = 0;
wl_list_for_each(output, &ec->output_list, link) {
if (pointer->seat->output && pointer->seat->output != output)
continue;
if (weston_output_contains_point(output, pos.c.x, pos.c.y))
valid = 1;
- if (weston_output_contains_point(output, old_x, old_y))
+ if (weston_output_contains_point(output, pointer->pos.c.x,
+ pointer->pos.c.y))
prev = output;
}
@@ -1733,13 +1725,12 @@ weston_pointer_move_to(struct weston_pointer *pointer,
{
pos = weston_pointer_clamp(pointer, pos);
- pointer->x = wl_fixed_from_double(pos.c.x);
- pointer->y = wl_fixed_from_double(pos.c.y);
+ pointer->pos = pos;
if (pointer->sprite) {
weston_view_set_position(pointer->sprite,
- pos.c.x - pointer->hotspot_x,
- pos.c.y - pointer->hotspot_y);
+ pos.c.x - pointer->hotspot.c.x,
+ pos.c.y - pointer->hotspot.c.y);
weston_view_schedule_repaint(pointer->sprite);
}
@@ -1772,8 +1763,8 @@ weston_pointer_handle_output_destroy(struct wl_listener *listener, void *data)
output_destroy_listener);
ec = pointer->seat->compositor;
- x = wl_fixed_to_int(pointer->x);
- y = wl_fixed_to_int(pointer->y);
+ x = pointer->pos.c.x;
+ y = pointer->pos.c.y;
wl_list_for_each(output, &ec->output_list, link) {
if (weston_output_contains_point(output, x, y))
@@ -1793,8 +1784,7 @@ weston_pointer_handle_output_destroy(struct wl_listener *listener, void *data)
if (!closest)
return;
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- pos = weston_pointer_clamp_for_output(pointer, closest, pos);
+ pos = weston_pointer_clamp_for_output(pointer, closest, pointer->pos);
weston_pointer_move_to(pointer, pos);
}
@@ -1904,8 +1894,7 @@ notify_button(struct weston_seat *seat, const struct timespec *time,
if (pointer->button_count == 0) {
pointer->grab_button = button;
pointer->grab_time = *time;
- pointer->grab_x = pointer->x;
- pointer->grab_y = pointer->y;
+ pointer->grab_pos = pointer->pos;
}
pointer->button_count++;
} else {
@@ -2712,11 +2701,11 @@ pointer_cursor_surface_committed(struct weston_surface *es,
assert(es == pointer->sprite->surface);
- pointer->hotspot_x -= dx;
- pointer->hotspot_y -= dy;
+ pointer->hotspot.c.x -= dx;
+ pointer->hotspot.c.y -= dy;
- x = wl_fixed_to_int(pointer->x) - pointer->hotspot_x;
- y = wl_fixed_to_int(pointer->y) - pointer->hotspot_y;
+ x = pointer->pos.c.x - pointer->hotspot.c.x;
+ y = pointer->pos.c.y - pointer->hotspot.c.y;
weston_view_set_position(pointer->sprite, x, y);
@@ -2765,7 +2754,7 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
}
if (pointer->sprite && pointer->sprite->surface == surface &&
- pointer->hotspot_x == x && pointer->hotspot_y == y)
+ pointer->hotspot.c.x == x && pointer->hotspot.c.y == y)
return;
if (!pointer->sprite || pointer->sprite->surface != surface) {
@@ -2787,8 +2776,7 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource,
pointer->sprite = weston_view_create(surface);
}
- pointer->hotspot_x = x;
- pointer->hotspot_y = y;
+ pointer->hotspot.c = weston_coord(x, y);
if (surface->width != 0) {
pointer_cursor_surface_committed(surface, 0, 0);
@@ -2851,14 +2839,12 @@ seat_get_pointer(struct wl_client *client, struct wl_resource *resource,
if (pointer->focus && pointer->focus->surface->resource &&
wl_resource_get_client(pointer->focus->surface->resource) == client) {
- struct weston_coord_global tmp_g;
struct weston_coord_surface surf_pos;
weston_view_update_transform(pointer->focus);
- tmp_g.c = weston_coord_from_fixed(pointer->x, pointer->y);
surf_pos = weston_coord_global_to_surface(pointer->focus,
- tmp_g);
+ pointer->pos);
wl_pointer_send_enter(cr,
pointer->focus_serial,
@@ -3766,7 +3752,6 @@ maybe_enable_pointer_constraint(struct weston_pointer_constraint *constraint)
struct weston_pointer *pointer = constraint->pointer;
struct weston_keyboard *keyboard;
struct weston_seat *seat = pointer->seat;
- struct weston_coord_global tmp;
struct weston_coord_surface c;
/* Postpone if no view of the surface was most recently clicked. */
@@ -3788,8 +3773,7 @@ maybe_enable_pointer_constraint(struct weston_pointer_constraint *constraint)
/* Postpone constraint if the pointer is not within the
* constraint region.
*/
- tmp.c = weston_coord_from_fixed(pointer->x, pointer->y);
- c = weston_coord_global_to_surface(view, tmp);
+ c = weston_coord_global_to_surface(view, pointer->pos);
if (!is_within_constraint_region(constraint,
wl_fixed_from_double(c.c.x),
wl_fixed_from_double(c.c.y)))
@@ -4722,12 +4706,10 @@ maybe_warp_confined_pointer(struct weston_pointer_constraint *constraint)
{
wl_fixed_t sx;
wl_fixed_t sy;
- struct weston_coord_global tmp;
struct weston_coord_surface c;
- tmp.c = weston_coord_from_fixed(constraint->pointer->x,
- constraint->pointer->y);
- c = weston_coord_global_to_surface(constraint->view, tmp);
+ c = weston_coord_global_to_surface(constraint->view,
+ constraint->pointer->pos);
sx = wl_fixed_from_double(c.c.x);
sy = wl_fixed_from_double(c.c.y);
diff --git a/libweston/libinput-seat.c b/libweston/libinput-seat.c
index 1228ab59..5ecb9741 100644
--- a/libweston/libinput-seat.c
+++ b/libweston/libinput-seat.c
@@ -122,14 +122,8 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
wl_list_insert(udev_seat->devices_list.prev, &device->link);
pointer = weston_seat_get_pointer(seat);
- if (seat->output && pointer) {
- struct weston_coord_global pos;
-
- pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
- pos = weston_pointer_clamp(pointer, pos);
- pointer->x = wl_fixed_from_double(pos.c.x);
- pointer->y = wl_fixed_from_double(pos.c.y);
- }
+ if (seat->output && pointer)
+ pointer->pos = weston_pointer_clamp(pointer, pointer->pos);
output_name = libinput_device_get_output_name(libinput_device);
if (output_name) {
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 6d39e44e..2f7a2f8c 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -146,7 +146,9 @@ notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
struct weston_seat *seat = get_seat(test);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
- weston_test_send_pointer_position(resource, pointer->x, pointer->y);
+ weston_test_send_pointer_position(resource,
+ wl_fixed_from_double(pointer->pos.c.x),
+ wl_fixed_from_double(pointer->pos.c.y));
}
static void
@@ -285,13 +287,15 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
struct weston_seat *seat = get_seat(test);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_pointer_motion_event event = { 0 };
+ struct weston_coord_global pos;
struct timespec time;
+ pos.c = weston_coord(x, y);
event = (struct weston_pointer_motion_event) {
.mask = WESTON_POINTER_MOTION_REL,
+ .rel = weston_coord_sub(pos.c, pointer->pos.c),
};
- event.rel = weston_coord_from_fixed(wl_fixed_from_int(x) - pointer->x,
- wl_fixed_from_int(y) - pointer->y);
+
timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
notify_motion(seat, &time, &event);