static void drag_grab_touch_motion(struct weston_touch_grab *grab, uint32_t time, int touch_id, wl_fixed_t sx, wl_fixed_t sy) { 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; if (touch_id != touch->grab_touch_id) return; drag_grab_touch_focus(touch_drag); if (touch_drag->base.icon) { fx = wl_fixed_to_double(touch->grab_x) + touch_drag->base.dx; fy = wl_fixed_to_double(touch->grab_y) + touch_drag->base.dy; weston_view_set_position(touch_drag->base.icon, fx, fy); weston_view_schedule_repaint(touch_drag->base.icon); } if (touch_drag->base.focus_resource) { weston_view_from_global_fixed(touch_drag->base.focus, touch->grab_x, touch->grab_y, &view_x, &view_y); wl_data_device_send_motion(touch_drag->base.focus_resource, time, view_x, view_y); } }
static void drag_grab_motion(struct weston_pointer_grab *grab, uint32_t time, wl_fixed_t x, wl_fixed_t y) { struct weston_pointer_drag *drag = container_of(grab, struct weston_pointer_drag, grab); struct weston_pointer *pointer = drag->grab.pointer; float fx, fy; wl_fixed_t sx, sy; weston_pointer_move(pointer, x, y); if (drag->base.icon) { fx = wl_fixed_to_double(pointer->x) + drag->base.dx; fy = wl_fixed_to_double(pointer->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) { weston_view_from_global_fixed(drag->base.focus, pointer->x, pointer->y, &sx, &sy); wl_data_device_send_motion(drag->base.focus_resource, time, sx, sy); } }
void Shell::defaultPointerGrabMotion(weston_pointer_grab *grab, uint32_t time, wl_fixed_t x, wl_fixed_t y) { weston_pointer *pointer = grab->pointer; movePointer(pointer, time, x, y); wl_list *resource_list = &pointer->focus_resource_list; wl_resource *resource; wl_resource_for_each(resource, resource_list) { wl_fixed_t sx, sy; weston_view_from_global_fixed(pointer->focus, pointer->x, pointer->y, &sx, &sy); wl_pointer_send_motion(resource, time, sx, sy); }
static void surface_to_from_global(void *data) { struct weston_compositor *compositor = data; struct weston_surface *surface; struct weston_view *view; float x, y; wl_fixed_t fx, fy; int32_t ix, iy; surface = weston_surface_create(compositor); assert(surface); view = weston_view_create(surface); assert(view); surface->width = 50; surface->height = 50; 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); weston_view_to_global_float(view, -8, -2, &x, &y); assert(x == -3 && 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)); weston_view_from_global_float(view, 38, 32, &x, &y); assert(x == 33 && y == 22); weston_view_from_global_float(view, 42, 5, &x, &y); assert(x == 37 && 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)); weston_view_from_global(view, 0, 0, &ix, &iy); assert(ix == -5 && iy == -10); weston_view_from_global(view, 5, 10, &ix, &iy); assert(ix == 0 && iy == 0); wl_display_terminate(compositor->wl_display); }