libweston: Use weston_coord space conversion functions
Update users of the old coordinate space conversion functions that take x, y pairs to the new weston_coord versions. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
0b78ec96f7
commit
64d9270804
|
@ -316,15 +316,20 @@ get_panel_size(struct desktop_shell *shell,
|
|||
int *width,
|
||||
int *height)
|
||||
{
|
||||
float x1, y1;
|
||||
float x2, y2;
|
||||
weston_view_to_global_float(view, 0, 0, &x1, &y1);
|
||||
weston_view_to_global_float(view,
|
||||
view->surface->width,
|
||||
view->surface->height,
|
||||
&x2, &y2);
|
||||
*width = (int)(x2 - x1);
|
||||
*height = (int)(y2 - y1);
|
||||
struct weston_coord_global a, b;
|
||||
struct weston_coord_surface tmp_s;
|
||||
|
||||
tmp_s = weston_coord_surface(0, 0, view->surface);
|
||||
a = weston_coord_surface_to_global(view, tmp_s);
|
||||
|
||||
tmp_s = weston_coord_surface(view->surface->width,
|
||||
view->surface->height,
|
||||
view->surface);
|
||||
b = weston_coord_surface_to_global(view, tmp_s);
|
||||
|
||||
a.c = weston_coord_sub(b.c, a.c);
|
||||
*width = a.c.x;
|
||||
*height = a.c.y;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1146,6 +1151,8 @@ resize_grab_motion(struct weston_pointer_grab *grab,
|
|||
struct shell_surface *shsurf = resize->base.shsurf;
|
||||
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;
|
||||
|
||||
|
@ -1156,11 +1163,14 @@ resize_grab_motion(struct weston_pointer_grab *grab,
|
|||
|
||||
weston_view_update_transform(shsurf->view);
|
||||
|
||||
weston_view_from_global_fixed(shsurf->view,
|
||||
pointer->grab_x, pointer->grab_y,
|
||||
&from_x, &from_y);
|
||||
weston_view_from_global_fixed(shsurf->view,
|
||||
pointer->x, pointer->y, &to_x, &to_y);
|
||||
tmp_g.c = weston_coord_from_fixed(pointer->grab_x, pointer->grab_y);
|
||||
tmp_s = weston_coord_global_to_surface(shsurf->view, tmp_g);
|
||||
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);
|
||||
to_x = wl_fixed_from_double(tmp_s.c.x);
|
||||
to_y = wl_fixed_from_double(tmp_s.c.y);
|
||||
|
||||
width = resize->width;
|
||||
if (resize->edges & WESTON_DESKTOP_SURFACE_EDGE_LEFT) {
|
||||
|
@ -2120,10 +2130,12 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
set_maximized_position(shell, shsurf);
|
||||
surface->output = shsurf->output;
|
||||
} else {
|
||||
float from_x, from_y;
|
||||
float to_x, to_y;
|
||||
struct weston_coord_surface from_s, to_s;
|
||||
struct weston_coord_global to_g, from_g;
|
||||
float x, y;
|
||||
|
||||
from_s = weston_coord_surface(0, 0, view->surface);
|
||||
|
||||
if (shsurf->resize_edges) {
|
||||
sx = 0;
|
||||
sy = 0;
|
||||
|
@ -2134,10 +2146,12 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
if (shsurf->resize_edges & WESTON_DESKTOP_SURFACE_EDGE_TOP)
|
||||
sy = shsurf->last_height - surface->height;
|
||||
|
||||
weston_view_to_global_float(shsurf->view, 0, 0, &from_x, &from_y);
|
||||
weston_view_to_global_float(shsurf->view, sx, sy, &to_x, &to_y);
|
||||
x = shsurf->view->geometry.x + to_x - from_x;
|
||||
y = shsurf->view->geometry.y + to_y - from_y;
|
||||
to_s = weston_coord_surface(sx, sy, view->surface);
|
||||
|
||||
from_g = weston_coord_surface_to_global(view, from_s);
|
||||
to_g = weston_coord_surface_to_global(view, to_s);
|
||||
x = view->geometry.x + to_g.c.x - from_g.c.x;
|
||||
y = view->geometry.y + to_g.c.y - from_g.c.y;
|
||||
|
||||
weston_view_set_position(shsurf->view, x, y);
|
||||
}
|
||||
|
@ -3041,6 +3055,8 @@ 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)
|
||||
return;
|
||||
|
@ -3057,10 +3073,10 @@ resize_binding(struct weston_pointer *pointer, const struct timespec *time,
|
|||
weston_desktop_surface_get_maximized(shsurf->desktop_surface))
|
||||
return;
|
||||
|
||||
weston_view_from_global(shsurf->view,
|
||||
wl_fixed_to_int(pointer->grab_x),
|
||||
wl_fixed_to_int(pointer->grab_y),
|
||||
&x, &y);
|
||||
tmp_g.c = weston_coord_from_fixed(pointer->grab_x, pointer->grab_y);
|
||||
surf_pos = weston_coord_global_to_surface(shsurf->view, tmp_g);
|
||||
x = surf_pos.c.x;
|
||||
y = surf_pos.c.y;
|
||||
|
||||
if (x < surface->width / 3)
|
||||
edges |= WESTON_DESKTOP_SURFACE_EDGE_LEFT;
|
||||
|
@ -3235,6 +3251,8 @@ surface_rotate(struct shell_surface *shsurf, struct weston_pointer *pointer)
|
|||
struct weston_surface *surface =
|
||||
weston_desktop_surface_get_surface(shsurf->desktop_surface);
|
||||
struct rotate_grab *rotate;
|
||||
struct weston_coord_surface center;
|
||||
struct weston_coord_global center_g;
|
||||
float dx, dy;
|
||||
float r;
|
||||
|
||||
|
@ -3242,10 +3260,13 @@ surface_rotate(struct shell_surface *shsurf, struct weston_pointer *pointer)
|
|||
if (!rotate)
|
||||
return;
|
||||
|
||||
weston_view_to_global_float(shsurf->view,
|
||||
surface->width * 0.5f,
|
||||
surface->height * 0.5f,
|
||||
&rotate->center.x, &rotate->center.y);
|
||||
center = weston_coord_surface(surface->width * 0.5f,
|
||||
surface->height * 0.5f,
|
||||
shsurf->view->surface);
|
||||
center_g = weston_coord_surface_to_global(shsurf->view, center);
|
||||
|
||||
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;
|
||||
|
|
|
@ -809,14 +809,19 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
|
|||
}
|
||||
|
||||
if (!is_fullscreen && (sx != 0 || sy != 0)) {
|
||||
float from_x, from_y;
|
||||
float to_x, to_y;
|
||||
struct weston_coord_surface from_s, to_s;
|
||||
struct weston_coord_global from_g, to_g;
|
||||
float x, y;
|
||||
|
||||
weston_view_to_global_float(shsurf->view, 0, 0, &from_x, &from_y);
|
||||
weston_view_to_global_float(shsurf->view, sx, sy, &to_x, &to_y);
|
||||
x = shsurf->view->geometry.x + to_x - from_x;
|
||||
y = shsurf->view->geometry.y + to_y - from_y;
|
||||
from_s = weston_coord_surface(0, 0,
|
||||
shsurf->view->surface);
|
||||
to_s = weston_coord_surface(sx, sy,
|
||||
shsurf->view->surface);
|
||||
|
||||
from_g = weston_coord_surface_to_global(shsurf->view, from_s);
|
||||
to_g = weston_coord_surface_to_global(shsurf->view, to_s);
|
||||
x = shsurf->view->geometry.x + to_g.c.x - from_g.c.x;
|
||||
y = shsurf->view->geometry.y + to_g.c.y - from_g.c.y;
|
||||
|
||||
weston_view_set_position(shsurf->view, x, y);
|
||||
weston_view_update_transform(shsurf->view);
|
||||
|
|
|
@ -213,7 +213,7 @@ drm_plane_state_coords_for_paint_node(struct drm_plane_state *state,
|
|||
struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
|
||||
pixman_region32_t dest_rect;
|
||||
pixman_box32_t *box;
|
||||
struct weston_vector corners[2];
|
||||
struct weston_coord corners[2];
|
||||
float sxf1, syf1, sxf2, syf2;
|
||||
|
||||
if (!drm_paint_node_transform_supported(node, &output->base))
|
||||
|
@ -241,14 +241,16 @@ drm_plane_state_coords_for_paint_node(struct drm_plane_state *state,
|
|||
|
||||
/* Now calculate the source rectangle, by transforming the destination
|
||||
* rectangle by the output to buffer matrix. */
|
||||
corners[0] = (struct weston_vector){ { box->x1, box->y1, 0, 1 } };
|
||||
corners[1] = (struct weston_vector){ { box->x2, box->y2, 0, 1 } };
|
||||
weston_matrix_transform(&node->output_to_buffer_matrix, &corners[0]);
|
||||
weston_matrix_transform(&node->output_to_buffer_matrix, &corners[1]);
|
||||
sxf1 = corners[0].f[0] / corners[0].f[3];
|
||||
syf1 = corners[0].f[1] / corners[0].f[3];
|
||||
sxf2 = corners[1].f[0] / corners[1].f[3];
|
||||
syf2 = corners[1].f[1] / corners[1].f[3];
|
||||
corners[0] = weston_matrix_transform_coord(
|
||||
&node->output_to_buffer_matrix,
|
||||
weston_coord(box->x1, box->y1));
|
||||
corners[1] = weston_matrix_transform_coord(
|
||||
&node->output_to_buffer_matrix,
|
||||
weston_coord(box->x2, box->y2));
|
||||
sxf1 = corners[0].x;
|
||||
syf1 = corners[0].y;
|
||||
sxf2 = corners[1].x;
|
||||
syf2 = corners[1].y;
|
||||
pixman_region32_fini(&dest_rect);
|
||||
|
||||
/* We currently only support WL_OUTPUT_TRANSFORM_NORMAL, so it's
|
||||
|
|
|
@ -1223,13 +1223,15 @@ static void
|
|||
weston_view_to_view_map(struct weston_view *from, struct weston_view *to,
|
||||
int from_x, int from_y, int *to_x, int *to_y)
|
||||
{
|
||||
float x, y;
|
||||
struct weston_coord_surface cs;
|
||||
struct weston_coord_global cg;
|
||||
|
||||
weston_view_to_global_float(from, from_x, from_y, &x, &y);
|
||||
weston_view_from_global_float(to, x, y, &x, &y);
|
||||
cs = weston_coord_surface(from_x, from_y, from->surface);
|
||||
cg = weston_coord_surface_to_global(from, cs);
|
||||
cs = weston_coord_global_to_surface(to, cg);
|
||||
|
||||
*to_x = round(x);
|
||||
*to_y = round(y);
|
||||
*to_x = round(cs.c.x);
|
||||
*to_y = round(cs.c.y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1269,16 +1271,20 @@ view_compute_bbox(struct weston_view *view, const pixman_box32_t *inbox,
|
|||
}
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
float x, y;
|
||||
weston_view_to_global_float(view, s[i][0], s[i][1], &x, &y);
|
||||
if (x < min_x)
|
||||
min_x = x;
|
||||
if (x > max_x)
|
||||
max_x = x;
|
||||
if (y < min_y)
|
||||
min_y = y;
|
||||
if (y > max_y)
|
||||
max_y = y;
|
||||
struct weston_coord_surface cs;
|
||||
struct weston_coord_global cg;
|
||||
|
||||
cs = weston_coord_surface(s[i][0], s[i][1],
|
||||
view->surface);
|
||||
cg = weston_coord_surface_to_global(view, cs);
|
||||
if (cg.c.x < min_x)
|
||||
min_x = cg.c.x;
|
||||
if (cg.c.x > max_x)
|
||||
max_x = cg.c.x;
|
||||
if (cg.c.y < min_y)
|
||||
min_y = cg.c.y;
|
||||
if (cg.c.y > max_y)
|
||||
max_y = cg.c.y;
|
||||
}
|
||||
|
||||
int_x = floorf(min_x);
|
||||
|
@ -1505,14 +1511,14 @@ weston_view_to_global_fixed(struct weston_view *view,
|
|||
wl_fixed_t vx, wl_fixed_t vy,
|
||||
wl_fixed_t *x, wl_fixed_t *y)
|
||||
{
|
||||
float xf, yf;
|
||||
struct weston_coord_surface cs;
|
||||
struct weston_coord_global cg;
|
||||
|
||||
weston_view_to_global_float(view,
|
||||
wl_fixed_to_double(vx),
|
||||
wl_fixed_to_double(vy),
|
||||
&xf, &yf);
|
||||
*x = wl_fixed_from_double(xf);
|
||||
*y = wl_fixed_from_double(yf);
|
||||
cs = weston_coord_surface_from_fixed(vx, vy, view->surface);
|
||||
cg = weston_coord_surface_to_global(view, cs);
|
||||
|
||||
*x = wl_fixed_from_double(cg.c.x);
|
||||
*y = wl_fixed_from_double(cg.c.y);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
|
@ -2017,24 +2023,23 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
|
|||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_view *view;
|
||||
wl_fixed_t view_x, view_y;
|
||||
int view_ix, view_iy;
|
||||
int ix = wl_fixed_to_int(x);
|
||||
int iy = wl_fixed_to_int(y);
|
||||
|
||||
/* Can't use paint node list: occlusion by input regions, not opaque. */
|
||||
wl_list_for_each(view, &compositor->view_list, link) {
|
||||
struct weston_coord_global pos_g;
|
||||
struct weston_coord_surface pos_s;
|
||||
|
||||
weston_view_update_transform(view);
|
||||
|
||||
if (!pixman_region32_contains_point(
|
||||
&view->transform.boundingbox, ix, iy, NULL))
|
||||
continue;
|
||||
|
||||
weston_view_from_global_fixed(view, x, y, &view_x, &view_y);
|
||||
view_ix = wl_fixed_to_int(view_x);
|
||||
view_iy = wl_fixed_to_int(view_y);
|
||||
|
||||
if (!weston_view_takes_input_at_point(view, view_ix, view_iy))
|
||||
pos_g.c = weston_coord_from_fixed(x, y);
|
||||
pos_s = weston_coord_global_to_surface(view, pos_g);
|
||||
if (!weston_view_takes_input_at_point(view, pos_s.c.x, pos_s.c.y))
|
||||
continue;
|
||||
|
||||
return view;
|
||||
|
|
|
@ -580,15 +580,20 @@ drag_grab_focus_internal(struct weston_drag *drag, struct weston_seat *seat,
|
|||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_view *view;
|
||||
wl_fixed_t sx, sy;
|
||||
|
||||
view = weston_compositor_pick_view(seat->compositor, x, y);
|
||||
if (drag->focus == view)
|
||||
return;
|
||||
|
||||
if (view) {
|
||||
weston_view_from_global_fixed(view, x, y, &sx, &sy);
|
||||
weston_drag_set_focus(drag, seat, view, sx, sy);
|
||||
struct weston_coord_global tmp_g;
|
||||
struct weston_coord_surface tmp_s;
|
||||
|
||||
tmp_g.c = weston_coord_from_fixed(x, y);
|
||||
tmp_s = weston_coord_global_to_surface(view, tmp_g);
|
||||
weston_drag_set_focus(drag, seat, view,
|
||||
wl_fixed_from_double(tmp_s.c.x),
|
||||
wl_fixed_from_double(tmp_s.c.y));
|
||||
} else
|
||||
weston_drag_clear_focus(drag);
|
||||
}
|
||||
|
@ -613,7 +618,6 @@ drag_grab_motion(struct weston_pointer_grab *grab,
|
|||
container_of(grab, struct weston_pointer_drag, grab);
|
||||
struct weston_pointer *pointer = drag->grab.pointer;
|
||||
float fx, fy;
|
||||
wl_fixed_t sx, sy;
|
||||
uint32_t msecs;
|
||||
|
||||
weston_pointer_move(pointer, event);
|
||||
|
@ -626,12 +630,17 @@ drag_grab_motion(struct weston_pointer_grab *grab,
|
|||
}
|
||||
|
||||
if (drag->base.focus_resource) {
|
||||
msecs = timespec_to_msec(time);
|
||||
weston_view_from_global_fixed(drag->base.focus,
|
||||
pointer->x, pointer->y,
|
||||
&sx, &sy);
|
||||
struct weston_coord_global pos;
|
||||
struct weston_coord_surface surf_pos;
|
||||
|
||||
wl_data_device_send_motion(drag->base.focus_resource, msecs, sx, sy);
|
||||
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);
|
||||
|
||||
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.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -803,7 +812,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;
|
||||
wl_fixed_t view_x, view_y;
|
||||
float fx, fy;
|
||||
uint32_t msecs;
|
||||
|
||||
|
@ -819,12 +827,15 @@ drag_grab_touch_motion(struct weston_touch_grab *grab,
|
|||
}
|
||||
|
||||
if (touch_drag->base.focus_resource) {
|
||||
struct weston_coord_global tmp_g;
|
||||
struct weston_coord_surface c;
|
||||
|
||||
tmp_g.c = weston_coord_from_fixed(touch->grab_x, touch->grab_y);
|
||||
msecs = timespec_to_msec(time);
|
||||
weston_view_from_global_fixed(touch_drag->base.focus,
|
||||
touch->grab_x, touch->grab_y,
|
||||
&view_x, &view_y);
|
||||
c = weston_coord_global_to_surface(touch_drag->base.focus, tmp_g);
|
||||
wl_data_device_send_motion(touch_drag->base.focus_resource,
|
||||
msecs, view_x, view_y);
|
||||
msecs, wl_fixed_from_double(c.c.x),
|
||||
wl_fixed_from_double(c.c.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -455,7 +455,6 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab)
|
|||
{
|
||||
struct weston_pointer *pointer = grab->pointer;
|
||||
struct weston_view *view;
|
||||
wl_fixed_t sx, sy;
|
||||
bool surface_jump = false;
|
||||
|
||||
if (pointer->button_count > 0)
|
||||
|
@ -463,12 +462,16 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab)
|
|||
|
||||
view = weston_compositor_pick_view(pointer->seat->compositor,
|
||||
pointer->x, pointer->y);
|
||||
|
||||
if (view && view == pointer->focus) {
|
||||
struct weston_coord_global tmp_g;
|
||||
struct weston_coord_surface tmp_s;
|
||||
|
||||
weston_view_update_transform(view);
|
||||
weston_view_from_global_fixed(view, pointer->x, pointer->y,
|
||||
&sx, &sy);
|
||||
if (pointer->sx != sx || pointer->sy != sy)
|
||||
|
||||
tmp_g.c = weston_coord_from_fixed(pointer->x, pointer->y);
|
||||
tmp_s = weston_coord_global_to_surface(view, tmp_g);
|
||||
if (pointer->sx != wl_fixed_from_double(tmp_s.c.x) ||
|
||||
pointer->sy != wl_fixed_from_double(tmp_s.c.y))
|
||||
surface_jump = true;
|
||||
}
|
||||
if (pointer->focus != view || surface_jump)
|
||||
|
@ -547,12 +550,19 @@ weston_pointer_send_motion(struct weston_pointer *pointer,
|
|||
struct weston_view *old_focus = pointer->focus;
|
||||
|
||||
if (pointer->focus) {
|
||||
struct weston_coord_global tmp_g;
|
||||
struct weston_coord_surface surf_pos;
|
||||
|
||||
weston_pointer_motion_to_abs(pointer, event, &x, &y);
|
||||
old_sx = pointer->sx;
|
||||
old_sy = pointer->sy;
|
||||
weston_view_update_transform(pointer->focus);
|
||||
weston_view_from_global_fixed(pointer->focus, x, y,
|
||||
&pointer->sx, &pointer->sy);
|
||||
|
||||
tmp_g.c = weston_coord_from_fixed(x, y);
|
||||
surf_pos = weston_coord_global_to_surface(pointer->focus,
|
||||
tmp_g);
|
||||
pointer->sx = wl_fixed_from_double(surf_pos.c.x);
|
||||
pointer->sy = wl_fixed_from_double(surf_pos.c.y);
|
||||
}
|
||||
|
||||
weston_pointer_move(pointer, event);
|
||||
|
@ -829,7 +839,8 @@ weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
|
|||
uint32_t serial;
|
||||
struct wl_resource *resource;
|
||||
struct wl_list *resource_list;
|
||||
wl_fixed_t sx, sy;
|
||||
struct weston_coord_global tmp_g;
|
||||
struct weston_coord_surface surf_pos;
|
||||
uint32_t msecs;
|
||||
|
||||
if (!weston_touch_has_focus_resource(touch))
|
||||
|
@ -837,7 +848,8 @@ weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
|
|||
|
||||
weston_view_update_transform(touch->focus);
|
||||
|
||||
weston_view_from_global_fixed(touch->focus, x, y, &sx, &sy);
|
||||
tmp_g.c = weston_coord_from_fixed(x, y);
|
||||
surf_pos = weston_coord_global_to_surface(touch->focus, tmp_g);
|
||||
|
||||
resource_list = &touch->focus_resource_list;
|
||||
serial = wl_display_next_serial(display);
|
||||
|
@ -848,7 +860,9 @@ weston_touch_send_down(struct weston_touch *touch, const struct timespec *time,
|
|||
time);
|
||||
wl_touch_send_down(resource, serial, msecs,
|
||||
touch->focus->surface->resource,
|
||||
touch_id, sx, sy);
|
||||
touch_id,
|
||||
wl_fixed_from_double(surf_pos.c.x),
|
||||
wl_fixed_from_double(surf_pos.c.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,13 +934,15 @@ weston_touch_send_motion(struct weston_touch *touch,
|
|||
{
|
||||
struct wl_resource *resource;
|
||||
struct wl_list *resource_list;
|
||||
wl_fixed_t sx, sy;
|
||||
uint32_t msecs;
|
||||
struct weston_coord_global tmp_g;
|
||||
struct weston_coord_surface surf_pos;
|
||||
|
||||
if (!weston_touch_has_focus_resource(touch))
|
||||
return;
|
||||
|
||||
weston_view_from_global_fixed(touch->focus, x, y, &sx, &sy);
|
||||
tmp_g.c = weston_coord_from_fixed(x, y);
|
||||
surf_pos = weston_coord_global_to_surface(touch->focus, tmp_g);
|
||||
|
||||
resource_list = &touch->focus_resource_list;
|
||||
msecs = timespec_to_msec(time);
|
||||
|
@ -934,8 +950,9 @@ weston_touch_send_motion(struct weston_touch *touch,
|
|||
send_timestamps_for_input_resource(resource,
|
||||
&touch->timestamps_list,
|
||||
time);
|
||||
wl_touch_send_motion(resource, msecs,
|
||||
touch_id, sx, sy);
|
||||
wl_touch_send_motion(resource, msecs, touch_id,
|
||||
wl_fixed_from_double(surf_pos.c.x),
|
||||
wl_fixed_from_double(surf_pos.c.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1448,11 +1465,15 @@ 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;
|
||||
int ix;
|
||||
int iy;
|
||||
|
||||
weston_view_from_global_fixed(view, pointer->x, pointer->y,
|
||||
&sx, &sy);
|
||||
tmp_g.c = weston_coord_from_fixed(pointer->x, pointer->y);
|
||||
surf_pos = weston_coord_global_to_surface(view, tmp_g);
|
||||
sx = wl_fixed_from_double(surf_pos.c.x);
|
||||
sy = wl_fixed_from_double(surf_pos.c.y);
|
||||
ix = wl_fixed_to_int(sx);
|
||||
iy = wl_fixed_to_int(sy);
|
||||
if (!weston_view_takes_input_at_point(view, ix, iy))
|
||||
|
@ -2844,19 +2865,20 @@ 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) {
|
||||
wl_fixed_t sx, sy;
|
||||
struct weston_coord_global tmp_g;
|
||||
struct weston_coord_surface surf_pos;
|
||||
|
||||
weston_view_update_transform(pointer->focus);
|
||||
|
||||
weston_view_from_global_fixed(pointer->focus,
|
||||
pointer->x,
|
||||
pointer->y,
|
||||
&sx, &sy);
|
||||
tmp_g.c = weston_coord_from_fixed(pointer->x, pointer->y);
|
||||
surf_pos = weston_coord_global_to_surface(pointer->focus,
|
||||
tmp_g);
|
||||
|
||||
wl_pointer_send_enter(cr,
|
||||
pointer->focus_serial,
|
||||
pointer->focus->surface->resource,
|
||||
sx, sy);
|
||||
wl_fixed_from_double(surf_pos.c.x),
|
||||
wl_fixed_from_double(surf_pos.c.y));
|
||||
pointer_send_frame(cr);
|
||||
}
|
||||
}
|
||||
|
@ -3758,7 +3780,8 @@ 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;
|
||||
int32_t x, y;
|
||||
struct weston_coord_global tmp;
|
||||
struct weston_coord_surface c;
|
||||
|
||||
/* Postpone if no view of the surface was most recently clicked. */
|
||||
wl_list_for_each(vit, &surface->views, surface_link) {
|
||||
|
@ -3779,13 +3802,11 @@ maybe_enable_pointer_constraint(struct weston_pointer_constraint *constraint)
|
|||
/* Postpone constraint if the pointer is not within the
|
||||
* constraint region.
|
||||
*/
|
||||
weston_view_from_global(view,
|
||||
wl_fixed_to_int(pointer->x),
|
||||
wl_fixed_to_int(pointer->y),
|
||||
&x, &y);
|
||||
tmp.c = weston_coord_from_fixed(pointer->x, pointer->y);
|
||||
c = weston_coord_global_to_surface(view, tmp);
|
||||
if (!is_within_constraint_region(constraint,
|
||||
wl_fixed_from_int(x),
|
||||
wl_fixed_from_int(y)))
|
||||
wl_fixed_from_double(c.c.x),
|
||||
wl_fixed_from_double(c.c.y)))
|
||||
return;
|
||||
|
||||
enable_pointer_constraint(constraint, view);
|
||||
|
@ -4058,17 +4079,21 @@ locked_pointer_destroy(struct wl_client *client,
|
|||
{
|
||||
struct weston_pointer_constraint *constraint =
|
||||
wl_resource_get_user_data(resource);
|
||||
wl_fixed_t x, y;
|
||||
|
||||
if (constraint && constraint->view && constraint->hint_is_pending &&
|
||||
is_within_constraint_region(constraint,
|
||||
constraint->hint_x,
|
||||
constraint->hint_y)) {
|
||||
weston_view_to_global_fixed(constraint->view,
|
||||
constraint->hint_x,
|
||||
constraint->hint_y,
|
||||
&x, &y);
|
||||
weston_pointer_move_to(constraint->pointer, x, y);
|
||||
struct weston_coord_global cg;
|
||||
struct weston_coord_surface cs;
|
||||
|
||||
cs = weston_coord_surface_from_fixed(constraint->hint_x,
|
||||
constraint->hint_y,
|
||||
constraint->view->surface);
|
||||
cg = weston_coord_surface_to_global(constraint->view, cs);
|
||||
weston_pointer_move_to(constraint->pointer,
|
||||
wl_fixed_from_double(cg.c.x),
|
||||
wl_fixed_from_double(cg.c.y));
|
||||
}
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
@ -4616,19 +4641,21 @@ weston_pointer_clamp_event_to_region(struct weston_pointer *pointer,
|
|||
wl_fixed_t *clamped_y)
|
||||
{
|
||||
wl_fixed_t x, y;
|
||||
wl_fixed_t sx, sy;
|
||||
wl_fixed_t old_sx = pointer->sx;
|
||||
wl_fixed_t old_sy = pointer->sy;
|
||||
struct wl_array borders;
|
||||
struct line motion;
|
||||
struct border *closest_border;
|
||||
float new_x_f, new_y_f;
|
||||
uint32_t directions;
|
||||
struct weston_coord_surface motion_coord;
|
||||
struct weston_coord_global cg, clamped;
|
||||
struct weston_coord_surface cs;
|
||||
|
||||
assert(pointer->focus);
|
||||
|
||||
weston_pointer_motion_to_abs(pointer, event, &x, &y);
|
||||
weston_view_from_global_fixed(pointer->focus, x, y, &sx, &sy);
|
||||
cg.c = weston_coord_from_fixed(x, y);
|
||||
cs = weston_coord_global_to_surface(pointer->focus, cg);
|
||||
|
||||
wl_array_init(&borders);
|
||||
|
||||
|
@ -4647,8 +4674,8 @@ weston_pointer_clamp_event_to_region(struct weston_pointer *pointer,
|
|||
.y = wl_fixed_to_double(old_sy),
|
||||
},
|
||||
.b = (struct vec2d) {
|
||||
.x = wl_fixed_to_double(sx),
|
||||
.y = wl_fixed_to_double(sy),
|
||||
.x = cs.c.x,
|
||||
.y = cs.c.y,
|
||||
},
|
||||
};
|
||||
directions = get_motion_directions(&motion);
|
||||
|
@ -4662,12 +4689,12 @@ weston_pointer_clamp_event_to_region(struct weston_pointer *pointer,
|
|||
else
|
||||
break;
|
||||
}
|
||||
|
||||
weston_view_to_global_float(pointer->focus,
|
||||
(float) motion.b.x, (float) motion.b.y,
|
||||
&new_x_f, &new_y_f);
|
||||
*clamped_x = wl_fixed_from_double(new_x_f);
|
||||
*clamped_y = wl_fixed_from_double(new_y_f);
|
||||
motion_coord = weston_coord_surface(motion.b.x, motion.b.y,
|
||||
pointer->focus->surface);
|
||||
clamped = weston_coord_surface_to_global(pointer->focus,
|
||||
motion_coord);
|
||||
*clamped_x = wl_fixed_from_double(clamped.c.x);
|
||||
*clamped_y = wl_fixed_from_double(clamped.c.y);
|
||||
|
||||
wl_array_release(&borders);
|
||||
}
|
||||
|
@ -4734,16 +4761,16 @@ warp_to_behind_border(struct border *border, wl_fixed_t *sx, wl_fixed_t *sy)
|
|||
static void
|
||||
maybe_warp_confined_pointer(struct weston_pointer_constraint *constraint)
|
||||
{
|
||||
wl_fixed_t x;
|
||||
wl_fixed_t y;
|
||||
wl_fixed_t sx;
|
||||
wl_fixed_t sy;
|
||||
struct weston_coord_global tmp;
|
||||
struct weston_coord_surface c;
|
||||
|
||||
weston_view_from_global_fixed(constraint->view,
|
||||
constraint->pointer->x,
|
||||
constraint->pointer->y,
|
||||
&sx,
|
||||
&sy);
|
||||
tmp.c = weston_coord_from_fixed(constraint->pointer->x,
|
||||
constraint->pointer->y);
|
||||
c = weston_coord_global_to_surface(constraint->view, tmp);
|
||||
sx = wl_fixed_from_double(c.c.x);
|
||||
sy = wl_fixed_from_double(c.c.y);
|
||||
|
||||
if (!is_within_constraint_region(constraint, sx, sy)) {
|
||||
double xf = wl_fixed_to_double(sx);
|
||||
|
@ -4753,6 +4780,8 @@ maybe_warp_confined_pointer(struct weston_pointer_constraint *constraint)
|
|||
struct border *border;
|
||||
double closest_distance_2 = DBL_MAX;
|
||||
struct border *closest_border = NULL;
|
||||
struct weston_coord_global cg;
|
||||
struct weston_coord_surface cs;
|
||||
|
||||
wl_array_init(&borders);
|
||||
|
||||
|
@ -4778,8 +4807,12 @@ maybe_warp_confined_pointer(struct weston_pointer_constraint *constraint)
|
|||
|
||||
wl_array_release(&borders);
|
||||
|
||||
weston_view_to_global_fixed(constraint->view, sx, sy, &x, &y);
|
||||
weston_pointer_move_to(constraint->pointer, x, y);
|
||||
cs = weston_coord_surface_from_fixed(sx, sy,
|
||||
constraint->view->surface);
|
||||
cg = weston_coord_surface_to_global(constraint->view, cs);
|
||||
weston_pointer_move_to(constraint->pointer,
|
||||
wl_fixed_from_double(cg.c.x),
|
||||
wl_fixed_from_double(cg.c.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4796,6 +4829,8 @@ confined_pointer_grab_pointer_motion(struct weston_pointer_grab *grab,
|
|||
wl_fixed_t old_sx = pointer->sx;
|
||||
wl_fixed_t old_sy = pointer->sy;
|
||||
pixman_region32_t confine_region;
|
||||
struct weston_coord_global c;
|
||||
struct weston_coord_surface tmp;
|
||||
|
||||
assert(pointer->focus);
|
||||
assert(pointer->focus->surface == constraint->surface);
|
||||
|
@ -4813,8 +4848,10 @@ confined_pointer_grab_pointer_motion(struct weston_pointer_grab *grab,
|
|||
weston_pointer_move_to(pointer, x, y);
|
||||
pixman_region32_fini(&confine_region);
|
||||
|
||||
weston_view_from_global_fixed(pointer->focus, x, y,
|
||||
&pointer->sx, &pointer->sy);
|
||||
c.c = weston_coord_from_fixed(x, y);
|
||||
tmp = weston_coord_global_to_surface(pointer->focus, c);
|
||||
pointer->sx = wl_fixed_from_double(tmp.c.x);
|
||||
pointer->sy = wl_fixed_from_double(tmp.c.y);
|
||||
|
||||
if (old_sx != pointer->sx || old_sy != pointer->sy) {
|
||||
pointer_send_motion(pointer, time,
|
||||
|
|
|
@ -186,14 +186,16 @@ region_intersect_only_translation(pixman_region32_t *result_global,
|
|||
pixman_region32_t *surf,
|
||||
struct weston_view *view)
|
||||
{
|
||||
float view_x, view_y;
|
||||
struct weston_coord_surface cs;
|
||||
struct weston_coord_global cg;
|
||||
|
||||
cs = weston_coord_surface(0, 0, view->surface);
|
||||
assert(view_transformation_is_translation(view));
|
||||
|
||||
/* Convert from surface to global coordinates */
|
||||
pixman_region32_copy(result_global, surf);
|
||||
weston_view_to_global_float(view, 0, 0, &view_x, &view_y);
|
||||
pixman_region32_translate(result_global, (int)view_x, (int)view_y);
|
||||
cg = weston_coord_surface_to_global(view, cs);
|
||||
pixman_region32_translate(result_global, cg.c.x, cg.c.y);
|
||||
|
||||
pixman_region32_intersect(result_global, result_global, global);
|
||||
}
|
||||
|
|
|
@ -429,9 +429,15 @@ calculate_edges(struct weston_view *ev, pixman_box32_t *rect,
|
|||
ctx.clip.y2 = rect->y2;
|
||||
|
||||
/* transform surface to screen space: */
|
||||
for (i = 0; i < surf.n; i++)
|
||||
weston_view_to_global_float(ev, surf.x[i], surf.y[i],
|
||||
&surf.x[i], &surf.y[i]);
|
||||
for (i = 0; i < surf.n; i++) {
|
||||
struct weston_coord_global cg;
|
||||
struct weston_coord_surface cs;
|
||||
|
||||
cs = weston_coord_surface(surf.x[i], surf.y[i], ev->surface);
|
||||
cg = weston_coord_surface_to_global(ev, cs);
|
||||
surf.x[i] = cg.c.x;
|
||||
surf.y[i] = cg.c.y;
|
||||
}
|
||||
|
||||
/* find bounding box: */
|
||||
min_x = max_x = surf.x[0];
|
||||
|
@ -560,7 +566,6 @@ texture_region(struct weston_paint_node *pnode,
|
|||
pixman_box32_t *rect = &rects[i];
|
||||
for (j = 0; j < nsurf; j++) {
|
||||
pixman_box32_t *surf_rect = &surf_rects[j];
|
||||
GLfloat sx, sy, bx, by;
|
||||
GLfloat ex[8], ey[8]; /* edge points in screen space */
|
||||
int n;
|
||||
|
||||
|
@ -584,20 +589,22 @@ texture_region(struct weston_paint_node *pnode,
|
|||
|
||||
/* emit edge points: */
|
||||
for (k = 0; k < n; k++) {
|
||||
weston_view_from_global_float(ev, ex[k], ey[k],
|
||||
&sx, &sy);
|
||||
struct weston_coord_global cg;
|
||||
struct weston_coord_surface cs;
|
||||
struct weston_coord_buffer cb;
|
||||
|
||||
cg.c = weston_coord(ex[k], ey[k]);
|
||||
cs = weston_coord_global_to_surface(ev, cg);
|
||||
/* position: */
|
||||
*(v++) = ex[k];
|
||||
*(v++) = ey[k];
|
||||
/* texcoord: */
|
||||
weston_surface_to_buffer_float(ev->surface,
|
||||
sx, sy,
|
||||
&bx, &by);
|
||||
*(v++) = bx * inv_width;
|
||||
cb = weston_coord_surface_to_buffer(ev->surface, cs);
|
||||
*(v++) = cb.c.x * inv_width;
|
||||
if (buffer->buffer_origin == ORIGIN_TOP_LEFT) {
|
||||
*(v++) = by * inv_height;
|
||||
*(v++) = cb.c.y * inv_height;
|
||||
} else {
|
||||
*(v++) = (buffer->height - by) * inv_height;
|
||||
*(v++) = (buffer->height - cb.c.y) * inv_height;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -286,7 +286,8 @@ touch_calibrator_convert(struct wl_client *client,
|
|||
struct weston_output *output;
|
||||
struct weston_surface *surface;
|
||||
uint32_t version;
|
||||
struct weston_vector p = { { 0.0, 0.0, 0.0, 1.0 } };
|
||||
struct weston_coord_surface ps;
|
||||
struct weston_coord_global pg;
|
||||
struct weston_point2d_device_normalized norm;
|
||||
|
||||
version = wl_resource_get_version(resource);
|
||||
|
@ -328,10 +329,11 @@ touch_calibrator_convert(struct wl_client *client,
|
|||
/* Convert from surface-local coordinates into global, from global
|
||||
* into output-raw, do perspective division and normalize.
|
||||
*/
|
||||
weston_view_to_global_float(calibrator->view, x, y, &p.f[0], &p.f[1]);
|
||||
weston_matrix_transform(&output->matrix, &p);
|
||||
norm.x = p.f[0] / (p.f[3] * output->current_mode->width);
|
||||
norm.y = p.f[1] / (p.f[3] * output->current_mode->height);
|
||||
ps = weston_coord_surface(x, y, calibrator->view->surface);
|
||||
pg = weston_coord_surface_to_global(calibrator->view, ps);
|
||||
pg.c = weston_matrix_transform_coord(&output->matrix, pg.c);
|
||||
norm.x = pg.c.x / output->current_mode->width;
|
||||
norm.y = pg.c.y / output->current_mode->height;
|
||||
|
||||
if (!normalized_is_valid(&norm)) {
|
||||
wl_resource_post_error(resource,
|
||||
|
|
|
@ -51,9 +51,8 @@ PLUGIN_TEST(surface_to_from_global)
|
|||
/* struct weston_compositor *compositor; */
|
||||
struct weston_surface *surface;
|
||||
struct weston_view *view;
|
||||
float x, y;
|
||||
wl_fixed_t fx, fy;
|
||||
int32_t ix, iy;
|
||||
struct weston_coord_global cg;
|
||||
struct weston_coord_surface cs;
|
||||
|
||||
surface = weston_surface_create(compositor);
|
||||
assert(surface);
|
||||
|
@ -64,31 +63,41 @@ PLUGIN_TEST(surface_to_from_global)
|
|||
weston_view_set_position(view, 5, 10);
|
||||
weston_view_update_transform(view);
|
||||
|
||||
weston_view_to_global_float(view, 33, 22, &x, &y);
|
||||
assert(x == 38 && y == 32);
|
||||
cs = weston_coord_surface(33, 22, surface);
|
||||
cg = weston_coord_surface_to_global(view, cs);
|
||||
assert(cg.c.x == 38 && cg.c.y == 32);
|
||||
|
||||
weston_view_to_global_float(view, -8, -2, &x, &y);
|
||||
assert(x == -3 && y == 8);
|
||||
cs = weston_coord_surface(-8, -2, surface);
|
||||
cg = weston_coord_surface_to_global(view, cs);
|
||||
assert(cg.c.x == -3 && cg.c.y == 8);
|
||||
|
||||
weston_view_to_global_fixed(view, wl_fixed_from_int(12),
|
||||
wl_fixed_from_int(5), &fx, &fy);
|
||||
assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15));
|
||||
cs = weston_coord_surface_from_fixed(wl_fixed_from_int(12),
|
||||
wl_fixed_from_int(5), surface);
|
||||
cg = weston_coord_surface_to_global(view, cs);
|
||||
assert(wl_fixed_from_double(cg.c.x) == wl_fixed_from_int(17) &&
|
||||
wl_fixed_from_double(cg.c.y) == wl_fixed_from_int(15));
|
||||
|
||||
weston_view_from_global_float(view, 38, 32, &x, &y);
|
||||
assert(x == 33 && y == 22);
|
||||
cg.c = weston_coord(38, 32);
|
||||
cs = weston_coord_global_to_surface(view, cg);
|
||||
assert(cs.c.x == 33 && cs.c.y == 22);
|
||||
|
||||
weston_view_from_global_float(view, 42, 5, &x, &y);
|
||||
assert(x == 37 && y == -5);
|
||||
cg.c = weston_coord(42, 5);
|
||||
cs = weston_coord_global_to_surface(view, cg);
|
||||
assert(cs.c.x == 37 && cs.c.y == -5);
|
||||
|
||||
weston_view_from_global_fixed(view, wl_fixed_from_int(21),
|
||||
wl_fixed_from_int(100), &fx, &fy);
|
||||
assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90));
|
||||
cg.c = weston_coord_from_fixed(wl_fixed_from_int(21),
|
||||
wl_fixed_from_int(100));
|
||||
cs = weston_coord_global_to_surface(view, cg);
|
||||
assert(wl_fixed_from_double(cs.c.x) == wl_fixed_from_int(16) &&
|
||||
wl_fixed_from_double(cs.c.y) == wl_fixed_from_int(90));
|
||||
|
||||
weston_view_from_global(view, 0, 0, &ix, &iy);
|
||||
assert(ix == -5 && iy == -10);
|
||||
cg.c = weston_coord(0, 0);
|
||||
cs = weston_coord_global_to_surface(view, cg);
|
||||
assert(cs.c.x == -5 && cs.c.y == -10);
|
||||
|
||||
weston_view_from_global(view, 5, 10, &ix, &iy);
|
||||
assert(ix == 0 && iy == 0);
|
||||
cg.c = weston_coord(5, 10);
|
||||
cs = weston_coord_global_to_surface(view, cg);
|
||||
assert(cs.c.x == 0 && cs.c.y == 0);
|
||||
|
||||
/* Destroys all views too. */
|
||||
weston_surface_unref(surface);
|
||||
|
|
|
@ -50,7 +50,8 @@ PLUGIN_TEST(surface_transform)
|
|||
/* struct weston_compositor *compositor; */
|
||||
struct weston_surface *surface;
|
||||
struct weston_view *view;
|
||||
float x, y;
|
||||
struct weston_coord_surface coord_s;
|
||||
struct weston_coord_global coord_g;
|
||||
|
||||
surface = weston_surface_create(compositor);
|
||||
assert(surface);
|
||||
|
@ -60,15 +61,17 @@ PLUGIN_TEST(surface_transform)
|
|||
surface->height = 200;
|
||||
weston_view_set_position(view, 100, 100);
|
||||
weston_view_update_transform(view);
|
||||
weston_view_to_global_float(view, 20, 20, &x, &y);
|
||||
coord_s = weston_coord_surface(20, 20, surface);
|
||||
coord_g = weston_coord_surface_to_global(view, coord_s);
|
||||
|
||||
fprintf(stderr, "20,20 maps to %f, %f\n", x, y);
|
||||
assert(x == 120 && y == 120);
|
||||
fprintf(stderr, "20,20 maps to %f, %f\n", coord_g.c.x, coord_g.c.y);
|
||||
assert(coord_g.c.x == 120 && coord_g.c.y == 120);
|
||||
|
||||
weston_view_set_position(view, 150, 300);
|
||||
weston_view_update_transform(view);
|
||||
weston_view_to_global_float(view, 50, 40, &x, &y);
|
||||
assert(x == 200 && y == 340);
|
||||
coord_s = weston_coord_surface(50, 40, surface);
|
||||
coord_g = weston_coord_surface_to_global(view, coord_s);
|
||||
assert(coord_g.c.x == 200 && coord_g.c.y == 340);
|
||||
|
||||
/* Destroys all views too. */
|
||||
weston_surface_unref(surface);
|
||||
|
|
Loading…
Reference in New Issue