libweston: Don't return coordinates from weston_compositor_pick_view
Sometimes callers don't want them, and sometimes (when view is NULL) the coordinate is invalid. Waste a tiny bit of time calculating them as needed in the callers instead. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
9409ce7024
commit
4d141a7881
|
@ -1291,11 +1291,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;
|
||||
wl_fixed_t sx, sy;
|
||||
|
||||
view = weston_compositor_pick_view(pointer->seat->compositor,
|
||||
pointer->x, pointer->y,
|
||||
&sx, &sy);
|
||||
pointer->x, pointer->y);
|
||||
desktop_surface = weston_surface_get_desktop_surface(view->surface);
|
||||
|
||||
if (!grab->shsurf || grab->shsurf->desktop_surface != desktop_surface) {
|
||||
|
|
|
@ -1847,9 +1847,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,
|
||||
wl_fixed_t *sx, wl_fixed_t *sy);
|
||||
|
||||
wl_fixed_t x, wl_fixed_t y);
|
||||
|
||||
struct weston_binding;
|
||||
typedef void (*weston_key_binding_handler_t)(struct weston_keyboard *keyboard,
|
||||
|
|
|
@ -1945,8 +1945,7 @@ 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,
|
||||
wl_fixed_t *vx, wl_fixed_t *vy)
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_view *view;
|
||||
wl_fixed_t view_x, view_y;
|
||||
|
@ -1967,13 +1966,9 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
|
|||
if (!weston_view_takes_input_at_point(view, view_ix, view_iy))
|
||||
continue;
|
||||
|
||||
*vx = view_x;
|
||||
*vy = view_y;
|
||||
return view;
|
||||
}
|
||||
|
||||
*vx = wl_fixed_from_int(-1000000);
|
||||
*vy = wl_fixed_from_int(-1000000);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -582,13 +582,14 @@ drag_grab_focus_internal(struct weston_drag *drag, struct weston_seat *seat,
|
|||
struct weston_view *view;
|
||||
wl_fixed_t sx, sy;
|
||||
|
||||
view = weston_compositor_pick_view(seat->compositor, x, y, &sx, &sy);
|
||||
view = weston_compositor_pick_view(seat->compositor, x, y);
|
||||
if (drag->focus == view)
|
||||
return;
|
||||
|
||||
if (view)
|
||||
if (view) {
|
||||
weston_view_to_global_fixed(view, x, y, &sx, &sy);
|
||||
weston_drag_set_focus(drag, seat, view, sx, sy);
|
||||
else
|
||||
} else
|
||||
weston_drag_clear_focus(drag);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
wl_fixed_t sx, sy;
|
||||
|
||||
view = weston_compositor_pick_view(pointer->seat->compositor,
|
||||
pointer->x, pointer->y, &sx, &sy);
|
||||
pointer->x, pointer->y);
|
||||
|
||||
if (view != NULL &&
|
||||
view->surface->resource != NULL &&
|
||||
|
|
|
@ -462,13 +462,13 @@ default_grab_pointer_focus(struct weston_pointer_grab *grab)
|
|||
return;
|
||||
|
||||
view = weston_compositor_pick_view(pointer->seat->compositor,
|
||||
pointer->x, pointer->y,
|
||||
&sx, &sy);
|
||||
pointer->x, pointer->y);
|
||||
if (view) {
|
||||
weston_view_to_global_fixed(view, pointer->x, pointer->y,
|
||||
&sx, &sy);
|
||||
if (pointer->sx != sx || pointer->sy != sy)
|
||||
surface_jump = true;
|
||||
}
|
||||
|
||||
if (pointer->focus != view || surface_jump)
|
||||
weston_pointer_set_focus(pointer, view);
|
||||
}
|
||||
|
@ -628,15 +628,13 @@ default_grab_pointer_button(struct weston_pointer_grab *grab,
|
|||
struct weston_pointer *pointer = grab->pointer;
|
||||
struct weston_compositor *compositor = pointer->seat->compositor;
|
||||
struct weston_view *view;
|
||||
wl_fixed_t sx, sy;
|
||||
|
||||
weston_pointer_send_button(pointer, time, button, state);
|
||||
|
||||
if (pointer->button_count == 0 &&
|
||||
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||
view = weston_compositor_pick_view(compositor,
|
||||
pointer->x, pointer->y,
|
||||
&sx, &sy);
|
||||
pointer->x, pointer->y);
|
||||
|
||||
weston_pointer_set_focus(pointer, view);
|
||||
}
|
||||
|
@ -1420,9 +1418,8 @@ seat_send_updated_caps(struct weston_seat *seat)
|
|||
* This can be used to unset pointer focus and set the co-ordinates to the
|
||||
* arbitrary values we use for the no focus case.
|
||||
*
|
||||
* There's no requirement to use this function. For example, passing the
|
||||
* results of a weston_compositor_pick_view() directly to
|
||||
* weston_pointer_set_focus() will do the right thing when no view is found.
|
||||
* There's no requirement to use this function. Passing NULL directly to
|
||||
* weston_pointer_set_focus() will do the right thing.
|
||||
*/
|
||||
WL_EXPORT void
|
||||
weston_pointer_clear_focus(struct weston_pointer *pointer)
|
||||
|
@ -2408,7 +2405,6 @@ process_touch_normal(struct weston_touch_device *device,
|
|||
struct weston_touch_grab *grab = device->aggregate->grab;
|
||||
struct weston_compositor *ec = device->aggregate->seat->compositor;
|
||||
struct weston_view *ev;
|
||||
wl_fixed_t sx, sy;
|
||||
wl_fixed_t x = wl_fixed_from_double(double_x);
|
||||
wl_fixed_t y = wl_fixed_from_double(double_y);
|
||||
|
||||
|
@ -2424,7 +2420,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, &sx, &sy);
|
||||
ev = weston_compositor_pick_view(ec, x, y);
|
||||
weston_touch_set_focus(touch, ev);
|
||||
} else if (!touch->focus) {
|
||||
/* Unexpected condition: We have non-initial touch but
|
||||
|
|
Loading…
Reference in New Issue