libweston: Use weston_coord in struct weston_pointer

Convert the bare x,y coordinates into struct weston_coord and update all
users.

We keep the surface position in wl_fixed_t for now so it still exactly
matches the position most recently sent to clients.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-02-03 16:40:10 -06:00 committed by Pekka Paalanen
parent 8f33e86cda
commit 583fbcda3b
12 changed files with 89 additions and 123 deletions

View File

@ -1171,8 +1171,8 @@ share_output_binding(struct weston_keyboard *keyboard,
pointer = weston_seat_get_pointer(keyboard->seat); pointer = weston_seat_get_pointer(keyboard->seat);
if (pointer) { if (pointer) {
output = weston_output_find(pointer->seat->compositor, output = weston_output_find(pointer->seat->compositor,
wl_fixed_to_int(pointer->x), pointer->pos.c.x,
wl_fixed_to_int(pointer->y)); pointer->pos.c.y);
} else { } else {
output = weston_shell_utils_get_focused_output(keyboard->seat->compositor); output = weston_shell_utils_get_focused_output(keyboard->seat->compositor);
if (!output) if (!output)

View File

@ -1019,8 +1019,8 @@ constrain_position(struct weston_move_grab *move, int *cx, int *cy)
pixman_rectangle32_t area; pixman_rectangle32_t area;
struct weston_geometry geometry; struct weston_geometry geometry;
x = wl_fixed_to_int(pointer->x + move->dx); x = pointer->pos.c.x + wl_fixed_to_double(move->dx);
y = wl_fixed_to_int(pointer->y + move->dy); y = pointer->pos.c.y + wl_fixed_to_double(move->dy);
if (shsurf->shell->panel_position == if (shsurf->shell->panel_position ==
WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP) { WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP) {
@ -1120,10 +1120,10 @@ surface_move(struct shell_surface *shsurf, struct weston_pointer *pointer,
if (!move) if (!move)
return -1; return -1;
move->dx = wl_fixed_from_double(shsurf->view->geometry.x) - move->dx = wl_fixed_from_double(shsurf->view->geometry.x -
pointer->grab_x; pointer->grab_pos.c.x);
move->dy = wl_fixed_from_double(shsurf->view->geometry.y) - move->dy = wl_fixed_from_double(shsurf->view->geometry.y -
pointer->grab_y; pointer->grab_pos.c.y);
move->client_initiated = client_initiated; move->client_initiated = client_initiated;
weston_desktop_surface_set_orientation(shsurf->desktop_surface, weston_desktop_surface_set_orientation(shsurf->desktop_surface,
@ -1152,7 +1152,6 @@ resize_grab_motion(struct weston_pointer_grab *grab,
int32_t width, height; int32_t width, height;
struct weston_size min_size, max_size; struct weston_size min_size, max_size;
struct weston_coord_surface tmp_s; struct weston_coord_surface tmp_s;
struct weston_coord_global tmp_g;
wl_fixed_t from_x, from_y; wl_fixed_t from_x, from_y;
wl_fixed_t to_x, to_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); 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, pointer->grab_pos);
tmp_s = weston_coord_global_to_surface(shsurf->view, tmp_g);
from_x = wl_fixed_from_double(tmp_s.c.x); from_x = wl_fixed_from_double(tmp_s.c.x);
from_y = wl_fixed_from_double(tmp_s.c.y); 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, pointer->pos);
tmp_s = weston_coord_global_to_surface(shsurf->view, tmp_g);
to_x = wl_fixed_from_double(tmp_s.c.x); to_x = wl_fixed_from_double(tmp_s.c.x);
to_y = wl_fixed_from_double(tmp_s.c.y); 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_pointer *pointer = base->pointer;
struct weston_desktop_surface *desktop_surface; struct weston_desktop_surface *desktop_surface;
struct weston_view *view; 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,
view = weston_compositor_pick_view(pointer->seat->compositor, pos); pointer->pos);
desktop_surface = weston_surface_get_desktop_surface(view->surface); desktop_surface = weston_surface_get_desktop_surface(view->surface);
if (!grab->shsurf || grab->shsurf->desktop_surface != desktop_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; uint32_t edges = 0;
int32_t x, y; int32_t x, y;
struct shell_surface *shsurf; struct shell_surface *shsurf;
struct weston_coord_global tmp_g;
struct weston_coord_surface surf_pos; struct weston_coord_surface surf_pos;
if (pointer->focus == NULL) 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)) weston_desktop_surface_get_maximized(shsurf->desktop_surface))
return; return;
tmp_g.c = weston_coord_from_fixed(pointer->grab_x, pointer->grab_y); surf_pos = weston_coord_global_to_surface(shsurf->view, pointer->grab_pos);
surf_pos = weston_coord_global_to_surface(shsurf->view, tmp_g);
x = surf_pos.c.x; x = surf_pos.c.x;
y = surf_pos.c.y; y = surf_pos.c.y;
@ -3161,8 +3155,8 @@ rotate_grab_motion(struct weston_pointer_grab *grab,
cx = 0.5f * surface->width; cx = 0.5f * surface->width;
cy = 0.5f * surface->height; cy = 0.5f * surface->height;
dx = wl_fixed_to_double(pointer->x) - rotate->center.x; dx = pointer->pos.c.x - rotate->center.x;
dy = wl_fixed_to_double(pointer->y) - rotate->center.y; dy = pointer->pos.c.y - rotate->center.y;
r = sqrtf(dx * dx + dy * dy); r = sqrtf(dx * dx + dy * dy);
wl_list_remove(&shsurf->rotation.transform.link); 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.x = center_g.c.x;
rotate->center.y = center_g.c.y; rotate->center.y = center_g.c.y;
dx = wl_fixed_to_double(pointer->x) - rotate->center.x; dx = pointer->pos.c.x - rotate->center.x;
dy = wl_fixed_to_double(pointer->y) - rotate->center.y; dy = pointer->pos.c.y - rotate->center.y;
r = sqrtf(dx * dx + dy * dy); r = sqrtf(dx * dx + dy * dy);
if (r > 20.0f) { if (r > 20.0f) {
struct weston_matrix inverse; 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); struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (pointer) { if (pointer) {
ix = wl_fixed_to_int(pointer->x); ix = pointer->pos.c.x;
iy = wl_fixed_to_int(pointer->y); iy = pointer->pos.c.y;
break; break;
} }
} }

View File

@ -717,16 +717,16 @@ struct weston_pointer {
struct weston_view *sprite; struct weston_view *sprite;
struct wl_listener sprite_destroy_listener; 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 *grab;
struct weston_pointer_grab default_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_button;
uint32_t grab_serial; uint32_t grab_serial;
struct timespec grab_time; struct timespec grab_time;
wl_fixed_t x, y; struct weston_coord_global pos;
wl_fixed_t sx, sy; wl_fixed_t sx, sy;
uint32_t button_count; uint32_t button_count;

View File

@ -1464,9 +1464,11 @@ pointer_move_workspace_grab_end(struct pointer_grab *grab)
struct pointer_move_grab *pnt_move_grab = struct pointer_move_grab *pnt_move_grab =
(struct pointer_move_grab *)grab; (struct pointer_move_grab *)grab;
struct ivi_layout_layer *layer = pnt_move_grab->base.layer; 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, 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); weston_pointer_end_grab(grab->grab.pointer);
} }
@ -1765,8 +1767,10 @@ create_workspace_pointer_move(struct weston_pointer *pointer,
xzalloc(sizeof(*pnt_move_grab)); xzalloc(sizeof(*pnt_move_grab));
pnt_move_grab->base.resource = resource; pnt_move_grab->base.resource = resource;
move_grab_init_workspace(&pnt_move_grab->move, pointer->grab_x, move_grab_init_workspace(&pnt_move_grab->move,
pointer->grab_y, resource); wl_fixed_from_double(pointer->grab_pos.c.x),
wl_fixed_from_double(pointer->grab_pos.c.y),
resource);
return pnt_move_grab; return pnt_move_grab;
} }

View File

@ -85,8 +85,8 @@ pointer_move_grab_motion(struct weston_pointer_grab *pointer_grab,
surface = weston_desktop_surface_get_surface(shsurf->desktop_surface); surface = weston_desktop_surface_get_surface(shsurf->desktop_surface);
dx = wl_fixed_to_int(pointer->x + shgrab->dx); dx = pointer->pos.c.x + wl_fixed_to_double(shgrab->dx);
dy = wl_fixed_to_int(pointer->y + shgrab->dy); dy = pointer->pos.c.y + wl_fixed_to_double(shgrab->dy);
weston_view_set_position(shsurf->view, dx, 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) if (!shgrab)
return KIOSK_SHELL_GRAB_RESULT_ERROR; return KIOSK_SHELL_GRAB_RESULT_ERROR;
shgrab->dx = wl_fixed_from_double(shsurf->view->geometry.x) - shgrab->dx = wl_fixed_from_double(shsurf->view->geometry.x -
pointer->grab_x; pointer->grab_pos.c.x);
shgrab->dy = wl_fixed_from_double(shsurf->view->geometry.y) - shgrab->dy = wl_fixed_from_double(shsurf->view->geometry.y -
pointer->grab_y; pointer->grab_pos.c.y);
shgrab->active = true; shgrab->active = true;
weston_seat_break_desktop_grabs(pointer->seat); weston_seat_break_desktop_grabs(pointer->seat);

View File

@ -1293,14 +1293,9 @@ setup_output_seat_constraint(struct drm_backend *b,
seat->base.output = output; seat->base.output = output;
pointer = weston_seat_get_pointer(&seat->base); pointer = weston_seat_get_pointer(&seat->base);
if (pointer) { if (pointer)
struct weston_coord_global pos; pointer->pos = weston_pointer_clamp(pointer,
pointer->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);
}
} }
} }

View File

@ -307,9 +307,8 @@ weston_mode_switch_finish(struct weston_output *output,
if (!pointer) if (!pointer)
continue; continue;
x = wl_fixed_to_int(pointer->x); x = pointer->pos.c.x;
y = wl_fixed_to_int(pointer->y); y = pointer->pos.c.y;
if (!pixman_region32_contains_point(&old_output_region, if (!pixman_region32_contains_point(&old_output_region,
x, y, NULL) || x, y, NULL) ||
weston_output_contains_point(output, x, y)) 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) if (y >= output->y + output->height)
y = output->y + output->height - 1; y = output->y + output->height - 1;
pointer->x = wl_fixed_from_int(x); pointer->pos.c = weston_coord(x, y);
pointer->y = wl_fixed_from_int(y);
} }
pixman_region32_fini(&old_output_region); 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); struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (pointer && pixman_region32_contains_point(&old_region, if (pointer && pixman_region32_contains_point(&old_region,
wl_fixed_to_int(pointer->x), pointer->pos.c.x,
wl_fixed_to_int(pointer->y), pointer->pos.c.y,
NULL)) NULL))
weston_pointer_move(pointer, &ev); weston_pointer_move(pointer, &ev);
} }

View File

@ -441,8 +441,8 @@ drag_surface_configure(struct weston_drag *drag,
/* init to 0 for avoiding a compile warning */ /* init to 0 for avoiding a compile warning */
fx = fy = 0; fx = fy = 0;
if (pointer) { if (pointer) {
fx = wl_fixed_to_double(pointer->x) + drag->dx; fx = pointer->pos.c.x + drag->dx;
fy = wl_fixed_to_double(pointer->y) + drag->dy; fy = pointer->pos.c.y + drag->dy;
} else if (touch) { } else if (touch) {
fx = wl_fixed_to_double(touch->grab_x) + drag->dx; fx = wl_fixed_to_double(touch->grab_x) + drag->dx;
fy = wl_fixed_to_double(touch->grab_y) + drag->dy; 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 = struct weston_pointer_drag *drag =
container_of(grab, struct weston_pointer_drag, grab); container_of(grab, struct weston_pointer_drag, grab);
struct weston_pointer *pointer = grab->pointer; 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, pointer->pos);
drag_grab_focus_internal(&drag->base, pointer->seat, pos);
} }
static void static void
@ -623,20 +621,18 @@ drag_grab_motion(struct weston_pointer_grab *grab,
weston_pointer_move(pointer, event); weston_pointer_move(pointer, event);
if (drag->base.icon) { if (drag->base.icon) {
fx = wl_fixed_to_double(pointer->x) + drag->base.dx; fx = pointer->pos.c.x + drag->base.dx;
fy = wl_fixed_to_double(pointer->y) + drag->base.dy; fy = pointer->pos.c.y + drag->base.dy;
weston_view_set_position(drag->base.icon, fx, fy); weston_view_set_position(drag->base.icon, fx, fy);
weston_view_schedule_repaint(drag->base.icon); weston_view_schedule_repaint(drag->base.icon);
} }
if (drag->base.focus_resource) { if (drag->base.focus_resource) {
struct weston_coord_global pos;
struct weston_coord_surface surf_pos; struct weston_coord_surface surf_pos;
msecs = timespec_to_msec(time); 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, surf_pos = weston_coord_global_to_surface(drag->base.focus,
pos); pointer->pos);
wl_data_device_send_motion(drag->base.focus_resource, msecs, wl_data_device_send_motion(drag->base.focus_resource, msecs,
wl_fixed_from_double(surf_pos.c.x), wl_fixed_from_double(surf_pos.c.x),

View File

@ -95,10 +95,9 @@ weston_desktop_seat_popup_grab_pointer_focus(struct weston_pointer_grab *grab)
wl_container_of(grab, seat, popup_grab.pointer); wl_container_of(grab, seat, popup_grab.pointer);
struct weston_pointer *pointer = grab->pointer; struct weston_pointer *pointer = grab->pointer;
struct weston_view *view; 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,
view = weston_compositor_pick_view(pointer->seat->compositor, pos); pointer->pos);
/* Ignore views that don't belong to the grabbing client */ /* Ignore views that don't belong to the grabbing client */
if (view != NULL && if (view != NULL &&

View File

@ -315,8 +315,7 @@ weston_pointer_motion_to_abs(struct weston_pointer *pointer,
if (event->mask & WESTON_POINTER_MOTION_ABS) { if (event->mask & WESTON_POINTER_MOTION_ABS) {
return event->abs; return event->abs;
} else if (event->mask & WESTON_POINTER_MOTION_REL) { } else if (event->mask & WESTON_POINTER_MOTION_REL) {
pos.c = weston_coord_from_fixed(pointer->x, pointer->y); pos.c = weston_coord_add(pointer->pos.c, event->rel);
pos.c = weston_coord_add(pos.c, event->rel);
return pos; return pos;
} }
@ -451,20 +450,19 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab)
{ {
struct weston_pointer *pointer = grab->pointer; struct weston_pointer *pointer = grab->pointer;
struct weston_view *view; struct weston_view *view;
struct weston_coord_global pos;
bool surface_jump = false; bool surface_jump = false;
if (pointer->button_count > 0) if (pointer->button_count > 0)
return; return;
pos.c = weston_coord_from_fixed(pointer->x, pointer->y); view = weston_compositor_pick_view(pointer->seat->compositor,
view = weston_compositor_pick_view(pointer->seat->compositor, pos); pointer->pos);
if (view && view == pointer->focus) { if (view && view == pointer->focus) {
struct weston_coord_surface surf_pos; struct weston_coord_surface surf_pos;
weston_view_update_transform(view); 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) || if (pointer->sx != wl_fixed_from_double(surf_pos.c.x) ||
pointer->sy != wl_fixed_from_double(surf_pos.c.y)) pointer->sy != wl_fixed_from_double(surf_pos.c.y))
surface_jump = true; surface_jump = true;
@ -638,10 +636,8 @@ default_grab_pointer_button(struct weston_pointer_grab *grab,
if (pointer->button_count == 0 && if (pointer->button_count == 0 &&
state == WL_POINTER_BUTTON_STATE_RELEASED) { state == WL_POINTER_BUTTON_STATE_RELEASED) {
struct weston_coord_global pos; view = weston_compositor_pick_view(compositor,
pointer->pos);
pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
view = weston_compositor_pick_view(compositor, pos);
weston_pointer_set_focus(pointer, view); 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; pointer->sprite_destroy_listener.notify = pointer_handle_sprite_destroy;
/* FIXME: Pick better co-ords. */ /* FIXME: Pick better co-ords. */
pointer->x = wl_fixed_from_int(100); pointer->pos.c = weston_coord(100, 100);
pointer->y = wl_fixed_from_int(100);
pointer->output_destroy_listener.notify = pointer->output_destroy_listener.notify =
weston_pointer_handle_output_destroy; weston_pointer_handle_output_destroy;
@ -1457,13 +1452,12 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
wl_fixed_t sx, sy; wl_fixed_t sx, sy;
if (view) { if (view) {
struct weston_coord_global tmp_g;
struct weston_coord_surface surf_pos; 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, pointer->pos);
surf_pos = weston_coord_global_to_surface(view, tmp_g);
sx = wl_fixed_from_double(surf_pos.c.x); sx = wl_fixed_from_double(surf_pos.c.x);
sy = wl_fixed_from_double(surf_pos.c.y); sy = wl_fixed_from_double(surf_pos.c.y);
if (!weston_view_takes_input_at_point(view, surf_pos)) if (!weston_view_takes_input_at_point(view, surf_pos))
weston_log("View focused with external coordinate %d, %d\n", weston_log("View focused with external coordinate %d, %d\n",
(int)surf_pos.c.x, (int)surf_pos.c.y); (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_compositor *ec = pointer->seat->compositor;
struct weston_output *output, *prev = NULL; struct weston_output *output, *prev = NULL;
int old_x, old_y, valid = 0; int valid = 0;
old_x = wl_fixed_to_int(pointer->x);
old_y = wl_fixed_to_int(pointer->y);
wl_list_for_each(output, &ec->output_list, link) { wl_list_for_each(output, &ec->output_list, link) {
if (pointer->seat->output && pointer->seat->output != output) if (pointer->seat->output && pointer->seat->output != output)
continue; continue;
if (weston_output_contains_point(output, pos.c.x, pos.c.y)) if (weston_output_contains_point(output, pos.c.x, pos.c.y))
valid = 1; 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; prev = output;
} }
@ -1733,13 +1725,12 @@ weston_pointer_move_to(struct weston_pointer *pointer,
{ {
pos = weston_pointer_clamp(pointer, pos); pos = weston_pointer_clamp(pointer, pos);
pointer->x = wl_fixed_from_double(pos.c.x); pointer->pos = pos;
pointer->y = wl_fixed_from_double(pos.c.y);
if (pointer->sprite) { if (pointer->sprite) {
weston_view_set_position(pointer->sprite, weston_view_set_position(pointer->sprite,
pos.c.x - pointer->hotspot_x, pos.c.x - pointer->hotspot.c.x,
pos.c.y - pointer->hotspot_y); pos.c.y - pointer->hotspot.c.y);
weston_view_schedule_repaint(pointer->sprite); weston_view_schedule_repaint(pointer->sprite);
} }
@ -1772,8 +1763,8 @@ weston_pointer_handle_output_destroy(struct wl_listener *listener, void *data)
output_destroy_listener); output_destroy_listener);
ec = pointer->seat->compositor; ec = pointer->seat->compositor;
x = wl_fixed_to_int(pointer->x); x = pointer->pos.c.x;
y = wl_fixed_to_int(pointer->y); y = pointer->pos.c.y;
wl_list_for_each(output, &ec->output_list, link) { wl_list_for_each(output, &ec->output_list, link) {
if (weston_output_contains_point(output, x, y)) 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) if (!closest)
return; return;
pos.c = weston_coord_from_fixed(pointer->x, pointer->y); pos = weston_pointer_clamp_for_output(pointer, closest, pointer->pos);
pos = weston_pointer_clamp_for_output(pointer, closest, pos);
weston_pointer_move_to(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) { if (pointer->button_count == 0) {
pointer->grab_button = button; pointer->grab_button = button;
pointer->grab_time = *time; pointer->grab_time = *time;
pointer->grab_x = pointer->x; pointer->grab_pos = pointer->pos;
pointer->grab_y = pointer->y;
} }
pointer->button_count++; pointer->button_count++;
} else { } else {
@ -2712,11 +2701,11 @@ pointer_cursor_surface_committed(struct weston_surface *es,
assert(es == pointer->sprite->surface); assert(es == pointer->sprite->surface);
pointer->hotspot_x -= dx; pointer->hotspot.c.x -= dx;
pointer->hotspot_y -= dy; pointer->hotspot.c.y -= dy;
x = wl_fixed_to_int(pointer->x) - pointer->hotspot_x; x = pointer->pos.c.x - pointer->hotspot.c.x;
y = wl_fixed_to_int(pointer->y) - pointer->hotspot_y; y = pointer->pos.c.y - pointer->hotspot.c.y;
weston_view_set_position(pointer->sprite, x, 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 && 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; return;
if (!pointer->sprite || pointer->sprite->surface != surface) { 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->sprite = weston_view_create(surface);
} }
pointer->hotspot_x = x; pointer->hotspot.c = weston_coord(x, y);
pointer->hotspot_y = y;
if (surface->width != 0) { if (surface->width != 0) {
pointer_cursor_surface_committed(surface, 0, 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 && if (pointer->focus && pointer->focus->surface->resource &&
wl_resource_get_client(pointer->focus->surface->resource) == client) { wl_resource_get_client(pointer->focus->surface->resource) == client) {
struct weston_coord_global tmp_g;
struct weston_coord_surface surf_pos; struct weston_coord_surface surf_pos;
weston_view_update_transform(pointer->focus); 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, surf_pos = weston_coord_global_to_surface(pointer->focus,
tmp_g); pointer->pos);
wl_pointer_send_enter(cr, wl_pointer_send_enter(cr,
pointer->focus_serial, pointer->focus_serial,
@ -3766,7 +3752,6 @@ maybe_enable_pointer_constraint(struct weston_pointer_constraint *constraint)
struct weston_pointer *pointer = constraint->pointer; struct weston_pointer *pointer = constraint->pointer;
struct weston_keyboard *keyboard; struct weston_keyboard *keyboard;
struct weston_seat *seat = pointer->seat; struct weston_seat *seat = pointer->seat;
struct weston_coord_global tmp;
struct weston_coord_surface c; struct weston_coord_surface c;
/* Postpone if no view of the surface was most recently clicked. */ /* 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 /* Postpone constraint if the pointer is not within the
* constraint region. * constraint region.
*/ */
tmp.c = weston_coord_from_fixed(pointer->x, pointer->y); c = weston_coord_global_to_surface(view, pointer->pos);
c = weston_coord_global_to_surface(view, tmp);
if (!is_within_constraint_region(constraint, if (!is_within_constraint_region(constraint,
wl_fixed_from_double(c.c.x), wl_fixed_from_double(c.c.x),
wl_fixed_from_double(c.c.y))) 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 sx;
wl_fixed_t sy; wl_fixed_t sy;
struct weston_coord_global tmp;
struct weston_coord_surface c; struct weston_coord_surface c;
tmp.c = weston_coord_from_fixed(constraint->pointer->x, c = weston_coord_global_to_surface(constraint->view,
constraint->pointer->y); constraint->pointer->pos);
c = weston_coord_global_to_surface(constraint->view, tmp);
sx = wl_fixed_from_double(c.c.x); sx = wl_fixed_from_double(c.c.x);
sy = wl_fixed_from_double(c.c.y); sy = wl_fixed_from_double(c.c.y);

View File

@ -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); wl_list_insert(udev_seat->devices_list.prev, &device->link);
pointer = weston_seat_get_pointer(seat); pointer = weston_seat_get_pointer(seat);
if (seat->output && pointer) { if (seat->output && pointer)
struct weston_coord_global pos; pointer->pos = weston_pointer_clamp(pointer, pointer->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);
}
output_name = libinput_device_get_output_name(libinput_device); output_name = libinput_device_get_output_name(libinput_device);
if (output_name) { if (output_name) {

View File

@ -146,7 +146,9 @@ notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
struct weston_seat *seat = get_seat(test); struct weston_seat *seat = get_seat(test);
struct weston_pointer *pointer = weston_seat_get_pointer(seat); 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 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_seat *seat = get_seat(test);
struct weston_pointer *pointer = weston_seat_get_pointer(seat); struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_pointer_motion_event event = { 0 }; struct weston_pointer_motion_event event = { 0 };
struct weston_coord_global pos;
struct timespec time; struct timespec time;
pos.c = weston_coord(x, y);
event = (struct weston_pointer_motion_event) { event = (struct weston_pointer_motion_event) {
.mask = WESTON_POINTER_MOTION_REL, .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); timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
notify_motion(seat, &time, &event); notify_motion(seat, &time, &event);