zoom: use the new pointer motion signal to move the zoom frame.
This commit is contained in:
parent
6fcb378c01
commit
412b024be8
@ -155,6 +155,7 @@ struct weston_output_zoom {
|
||||
struct weston_fixed_point from;
|
||||
struct weston_fixed_point to;
|
||||
struct weston_fixed_point current;
|
||||
struct wl_listener motion_listener;
|
||||
};
|
||||
|
||||
/* bit compatible with drm definitions. */
|
||||
@ -1148,6 +1149,8 @@ weston_output_init_zoom(struct weston_output *output);
|
||||
void
|
||||
weston_output_update_zoom(struct weston_output *output);
|
||||
void
|
||||
weston_output_activate_zoom(struct weston_output *output);
|
||||
void
|
||||
weston_output_update_matrix(struct weston_output *output);
|
||||
void
|
||||
weston_output_move(struct weston_output *output, int x, int y);
|
||||
|
@ -712,9 +712,7 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t
|
||||
static void
|
||||
move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
struct weston_compositor *ec = seat->compositor;
|
||||
struct weston_pointer *pointer = seat->pointer;
|
||||
struct weston_output *output;
|
||||
int32_t ix, iy;
|
||||
|
||||
weston_pointer_clamp (pointer, &x, &y);
|
||||
@ -725,12 +723,6 @@ move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
|
||||
ix = wl_fixed_to_int(x);
|
||||
iy = wl_fixed_to_int(y);
|
||||
|
||||
wl_list_for_each(output, &ec->output_list, link)
|
||||
if (output->zoom.active &&
|
||||
pixman_region32_contains_point(&output->region,
|
||||
ix, iy, NULL))
|
||||
weston_output_update_zoom(output);
|
||||
|
||||
if (pointer->sprite) {
|
||||
weston_view_set_position(pointer->sprite,
|
||||
ix - pointer->hotspot_x,
|
||||
|
@ -3052,8 +3052,7 @@ do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis,
|
||||
else if (output->zoom.level > output->zoom.max_level)
|
||||
output->zoom.level = output->zoom.max_level;
|
||||
else if (!output->zoom.active) {
|
||||
output->zoom.active = 1;
|
||||
output->disable_planes++;
|
||||
weston_output_activate_zoom(output);
|
||||
}
|
||||
|
||||
output->zoom.spring_z.target = output->zoom.level;
|
||||
|
27
src/zoom.c
27
src/zoom.c
@ -45,6 +45,7 @@ weston_zoom_frame_z(struct weston_animation *animation,
|
||||
if (output->zoom.active && output->zoom.level <= 0.0) {
|
||||
output->zoom.active = 0;
|
||||
output->disable_planes--;
|
||||
wl_list_remove(&output->zoom.motion_listener.link);
|
||||
}
|
||||
output->zoom.spring_z.current = output->zoom.level;
|
||||
wl_list_remove(&animation->link);
|
||||
@ -236,6 +237,31 @@ weston_output_update_zoom(struct weston_output *output)
|
||||
weston_output_update_zoom_transform(output);
|
||||
}
|
||||
|
||||
static void
|
||||
motion(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct weston_output_zoom *zoom =
|
||||
container_of(listener, struct weston_output_zoom, motion_listener);
|
||||
struct weston_output *output =
|
||||
container_of(zoom, struct weston_output, zoom);
|
||||
|
||||
weston_output_update_zoom(output);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_output_activate_zoom(struct weston_output *output)
|
||||
{
|
||||
struct weston_seat *seat = weston_zoom_pick_seat(output->compositor);
|
||||
|
||||
if (output->zoom.active)
|
||||
return;
|
||||
|
||||
output->zoom.active = 1;
|
||||
output->disable_planes++;
|
||||
wl_signal_add(&seat->pointer->motion_signal,
|
||||
&output->zoom.motion_listener);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
weston_output_init_zoom(struct weston_output *output)
|
||||
{
|
||||
@ -253,4 +279,5 @@ weston_output_init_zoom(struct weston_output *output)
|
||||
output->zoom.spring_xy.friction = 1000;
|
||||
output->zoom.animation_xy.frame = weston_zoom_frame_xy;
|
||||
wl_list_init(&output->zoom.animation_xy.link);
|
||||
output->zoom.motion_listener.notify = motion;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user