libweston: Pass weston_coords to weston_compositor_pick_view

Continuing to convert things to weston_coord.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-02-02 17:23:33 -06:00 committed by Pekka Paalanen
parent 39796f88e6
commit c3cd8306c9
6 changed files with 31 additions and 33 deletions

View File

@ -1305,9 +1305,10 @@ 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;
view = weston_compositor_pick_view(pointer->seat->compositor,
pointer->x, pointer->y);
pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
view = weston_compositor_pick_view(pointer->seat->compositor, pos);
desktop_surface = weston_surface_get_desktop_surface(view->surface);
if (!grab->shsurf || grab->shsurf->desktop_surface != desktop_surface) {

View File

@ -1869,7 +1869,7 @@ void
weston_compositor_sleep(struct weston_compositor *compositor);
struct weston_view *
weston_compositor_pick_view(struct weston_compositor *compositor,
wl_fixed_t x, wl_fixed_t y);
struct weston_coord_global pos);
struct weston_binding;
typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,

View File

@ -2000,31 +2000,26 @@ weston_view_takes_input_at_point(struct weston_view *view, int x, int y)
*/
WL_EXPORT struct weston_view *
weston_compositor_pick_view(struct weston_compositor *compositor,
wl_fixed_t x, wl_fixed_t y)
struct weston_coord_global pos)
{
struct weston_view *view;
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;
struct weston_coord_surface surf_pos;
weston_view_update_transform(view);
if (!pixman_region32_contains_point(
&view->transform.boundingbox, ix, iy, NULL))
&view->transform.boundingbox, pos.c.x, pos.c.y, NULL))
continue;
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))
surf_pos = weston_coord_global_to_surface(view, pos);
if (!weston_view_takes_input_at_point(view, surf_pos.c.x, surf_pos.c.y))
continue;
return view;
}
return NULL;
}

View File

@ -580,20 +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;
struct weston_coord_global pos;
view = weston_compositor_pick_view(seat->compositor, x, y);
pos.c = weston_coord_from_fixed(x, y);
view = weston_compositor_pick_view(seat->compositor, pos);
if (drag->focus == view)
return;
if (view) {
struct weston_coord_global tmp_g;
struct weston_coord_surface tmp_s;
struct weston_coord_surface surf_pos;
tmp_g.c = weston_coord_from_fixed(x, y);
tmp_s = weston_coord_global_to_surface(view, tmp_g);
surf_pos = weston_coord_global_to_surface(view, pos);
weston_drag_set_focus(drag, seat, view,
wl_fixed_from_double(tmp_s.c.x),
wl_fixed_from_double(tmp_s.c.y));
wl_fixed_from_double(surf_pos.c.x),
wl_fixed_from_double(surf_pos.c.y));
} else
weston_drag_clear_focus(drag);
}

View File

@ -95,9 +95,10 @@ 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;
view = weston_compositor_pick_view(pointer->seat->compositor,
pointer->x, pointer->y);
pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
view = weston_compositor_pick_view(pointer->seat->compositor, pos);
/* Ignore views that don't belong to the grabbing client */
if (view != NULL &&

View File

@ -453,23 +453,22 @@ 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;
view = weston_compositor_pick_view(pointer->seat->compositor,
pointer->x, pointer->y);
pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
view = weston_compositor_pick_view(pointer->seat->compositor, pos);
if (view && view == pointer->focus) {
struct weston_coord_global tmp_g;
struct weston_coord_surface tmp_s;
struct weston_coord_surface surf_pos;
weston_view_update_transform(view);
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))
surf_pos = weston_coord_global_to_surface(view, 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;
}
if (pointer->focus != view || surface_jump)
@ -644,8 +643,10 @@ default_grab_pointer_button(struct weston_pointer_grab *grab,
if (pointer->button_count == 0 &&
state == WL_POINTER_BUTTON_STATE_RELEASED) {
view = weston_compositor_pick_view(compositor,
pointer->x, pointer->y);
struct weston_coord_global pos;
pos.c = weston_coord_from_fixed(pointer->x, pointer->y);
view = weston_compositor_pick_view(compositor, pos);
weston_pointer_set_focus(pointer, view);
}
@ -2444,7 +2445,7 @@ process_touch_normal(struct weston_touch_device *device,
* to that view for the remainder of the touch session i.e.
* until all touch points are up again. */
if (touch->num_tp == 1) {
ev = weston_compositor_pick_view(ec, x, y);
ev = weston_compositor_pick_view(ec, *pos);
weston_touch_set_focus(touch, ev);
} else if (!touch->focus) {
/* Unexpected condition: We have non-initial touch but