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:
parent
8f33e86cda
commit
583fbcda3b
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 &&
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue