diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 4ca789794..4bf4eabaa 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -3421,71 +3421,6 @@ surface_opacity_binding(struct weston_pointer *pointer, weston_surface_damage(surface); } -static void -do_zoom(struct weston_seat *seat, const struct timespec *time, uint32_t key, - uint32_t axis, double value) -{ - struct weston_compositor *compositor = seat->compositor; - struct weston_pointer *pointer = weston_seat_get_pointer(seat); - struct weston_output *output; - float increment; - - if (!pointer) { - weston_log("Zoom hotkey pressed but seat '%s' contains no pointer.\n", seat->seat_name); - return; - } - - wl_list_for_each(output, &compositor->output_list, link) { - if (pixman_region32_contains_point(&output->region, - wl_fixed_to_double(pointer->x), - wl_fixed_to_double(pointer->y), - NULL)) { - if (key == KEY_PAGEUP) - increment = output->zoom.increment; - else if (key == KEY_PAGEDOWN) - increment = -output->zoom.increment; - else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - /* For every pixel zoom 20th of a step */ - increment = output->zoom.increment * - -value / 20.0; - else - increment = 0; - - output->zoom.level += increment; - - if (output->zoom.level < 0.0) - output->zoom.level = 0.0; - else if (output->zoom.level > output->zoom.max_level) - output->zoom.level = output->zoom.max_level; - - if (!output->zoom.active) { - if (output->zoom.level <= 0.0) - continue; - weston_output_activate_zoom(output, seat); - } - - output->zoom.spring_z.target = output->zoom.level; - - weston_output_update_zoom(output); - } - } -} - -static void -zoom_axis_binding(struct weston_pointer *pointer, const struct timespec *time, - struct weston_pointer_axis_event *event, - void *data) -{ - do_zoom(pointer->seat, time, 0, event->axis, event->value); -} - -static void -zoom_key_binding(struct weston_keyboard *keyboard, const struct timespec *time, - uint32_t key, void *data) -{ - do_zoom(keyboard->seat, time, key, 0, 0); -} - static void terminate_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) @@ -5022,14 +4957,6 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell) MODIFIER_SUPER | MODIFIER_ALT, surface_opacity_binding, NULL); - weston_compositor_add_axis_binding(ec, WL_POINTER_AXIS_VERTICAL_SCROLL, - mod, zoom_axis_binding, - NULL); - - weston_compositor_add_key_binding(ec, KEY_PAGEUP, mod, - zoom_key_binding, NULL); - weston_compositor_add_key_binding(ec, KEY_PAGEDOWN, mod, - zoom_key_binding, NULL); weston_compositor_add_key_binding(ec, KEY_M, mod | MODIFIER_SHIFT, maximize_binding, NULL); weston_compositor_add_key_binding(ec, KEY_F, mod | MODIFIER_SHIFT, diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h index d99dc763a..90350c9e6 100644 --- a/include/libweston/libweston.h +++ b/include/libweston/libweston.h @@ -150,21 +150,6 @@ struct weston_spring { uint32_t clip; }; -struct weston_output_zoom { - bool active; - float increment; - float level; - float max_level; - float trans_x, trans_y; - struct { - double x, y; - } current; - struct weston_seat *seat; - struct weston_animation animation_z; - struct weston_spring spring_z; - struct wl_listener motion_listener; -}; - /* bit compatible with drm definitions. */ enum dpms_enum { WESTON_DPMS_ON, @@ -324,7 +309,6 @@ struct weston_output { /** For cancelling the idle_repaint callback on output destruction. */ struct wl_event_source *idle_repaint_source; - struct weston_output_zoom zoom; int dirty; struct wl_signal frame_signal; struct wl_signal destroy_signal; /**< sent when disabled */ @@ -1876,11 +1860,6 @@ void weston_compositor_exit_with_code(struct weston_compositor *compositor, int exit_code); void -weston_output_update_zoom(struct weston_output *output); -void -weston_output_activate_zoom(struct weston_output *output, - struct weston_seat *seat); -void weston_output_add_destroy_listener(struct weston_output *output, struct wl_listener *listener); struct wl_listener * diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 203b8a4e7..be647deb4 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -414,27 +414,14 @@ drm_output_render(struct drm_output_state *state, pixman_region32_t *damage) pixman_region32_init(&scanout_damage); pixman_region32_copy(&scanout_damage, damage); - if (output->base.zoom.active) { - pixman_region32_t clip; - - weston_matrix_transform_region(&scanout_damage, - &output->base.matrix, - &scanout_damage); - pixman_region32_init_rect(&clip, 0, 0, - output->base.width, - output->base.height); - pixman_region32_intersect(&scanout_damage, &scanout_damage, &clip); - pixman_region32_fini(&clip); - } else { - pixman_region32_translate(&scanout_damage, - -output->base.x, -output->base.y); - weston_transformed_region(output->base.width, - output->base.height, - output->base.transform, - output->base.current_scale, - &scanout_damage, - &scanout_damage); - } + pixman_region32_translate(&scanout_damage, + -output->base.x, -output->base.y); + weston_transformed_region(output->base.width, + output->base.height, + output->base.transform, + output->base.current_scale, + &scanout_damage, + &scanout_damage); assert(scanout_state->damage_blob_id == 0); diff --git a/libweston/backend.h b/libweston/backend.h index 3ae59a6c7..af0d6671e 100644 --- a/libweston/backend.h +++ b/libweston/backend.h @@ -154,9 +154,6 @@ weston_output_damage(struct weston_output *output); void weston_output_release(struct weston_output *output); -void -weston_output_init_zoom(struct weston_output *output); - void weston_output_finish_frame(struct weston_output *output, const struct timespec *stamp, diff --git a/libweston/compositor.c b/libweston/compositor.c index 452d32f73..bb2aa62d3 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -6064,11 +6064,8 @@ weston_compositor_reflow_outputs(struct weston_compositor *compositor, * \param region The region to be transformed in-place. * * This takes a region in the global coordinate system, and takes into account - * output position, transform and scale, and the zoom, and converts the region - * into output pixel coordinates in the framebuffer. - * - * Uses floating-point operations if zoom is active, which may round to expand - * the region. + * output position, transform and scale, and converts the region into output + * pixel coordinates in the framebuffer. * * \internal * \ingroup output @@ -6077,34 +6074,19 @@ WL_EXPORT void weston_output_region_from_global(struct weston_output *output, pixman_region32_t *region) { - if (output->zoom.active) { - weston_matrix_transform_region(region, &output->matrix, region); - } else { - pixman_region32_translate(region, -output->x, -output->y); - weston_transformed_region(output->width, output->height, - output->transform, - output->current_scale, - region, region); - } + pixman_region32_translate(region, -output->x, -output->y); + weston_transformed_region(output->width, output->height, + output->transform, + output->current_scale, + region, region); } static void weston_output_update_matrix(struct weston_output *output) { - float magnification; - weston_matrix_init(&output->matrix); weston_matrix_translate(&output->matrix, -output->x, -output->y, 0); - if (output->zoom.active) { - magnification = 1 / (1 - output->zoom.spring_z.current); - weston_output_update_zoom(output); - weston_matrix_translate(&output->matrix, -output->zoom.trans_x, - -output->zoom.trans_y, 0); - weston_matrix_scale(&output->matrix, magnification, - magnification, 1.0); - } - switch (output->transform) { case WL_OUTPUT_TRANSFORM_FLIPPED: case WL_OUTPUT_TRANSFORM_FLIPPED_90: @@ -6682,8 +6664,8 @@ weston_output_create_heads_string(struct weston_output *output) * Output coordinates are calculated and each new output is by default * assigned to the right of previous one. * - * Sets up the transformation, zoom, and geometry of the output using - * the properties that need to be configured by the compositor. + * Sets up the transformation, and geometry of the output using the + * properties that need to be configured by the compositor. * * Establishes a repaint timer for the output with the relevant display * object's event loop. See output_repaint_timer_handler(). @@ -6762,7 +6744,6 @@ weston_output_enable(struct weston_output *output) wl_signal_init(&output->destroy_signal); weston_output_transform_scale_init(output, output->transform, output->scale); - weston_output_init_zoom(output); weston_output_init_geometry(output, x, y); weston_output_damage(output); diff --git a/libweston/meson.build b/libweston/meson.build index 257d69501..186ae4a52 100644 --- a/libweston/meson.build +++ b/libweston/meson.build @@ -35,7 +35,6 @@ srcs_libweston = [ 'weston-log-flight-rec.c', 'weston-log.c', 'weston-direct-display.c', - 'zoom.c', linux_dmabuf_unstable_v1_protocol_c, linux_dmabuf_unstable_v1_server_protocol_h, linux_explicit_synchronization_unstable_v1_protocol_c, diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 8cc7a7c2c..501a68025 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -1068,7 +1068,7 @@ draw_paint_node(struct weston_paint_node *pnode, glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - if (pnode->view->transform.enabled || pnode->output->zoom.active || + if (pnode->view->transform.enabled || pnode->output->current_scale != pnode->surface->buffer_viewport.buffer.scale) filter = GL_LINEAR; else diff --git a/libweston/zoom.c b/libweston/zoom.c deleted file mode 100644 index 064d6a849..000000000 --- a/libweston/zoom.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright © 2012 Scott Moreau - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "config.h" - -#include -#include -#include -#include - -#include -#include "backend.h" -#include "libweston-internal.h" -#include "text-cursor-position-server-protocol.h" -#include "shared/helpers.h" - -static void -weston_zoom_frame_z(struct weston_animation *animation, - struct weston_output *output, - const struct timespec *time) -{ - if (animation->frame_counter <= 1) - output->zoom.spring_z.timestamp = *time; - - weston_spring_update(&output->zoom.spring_z, time); - - if (output->zoom.spring_z.current > output->zoom.max_level) - output->zoom.spring_z.current = output->zoom.max_level; - else if (output->zoom.spring_z.current < 0.0) - output->zoom.spring_z.current = 0.0; - - if (weston_spring_done(&output->zoom.spring_z)) { - if (output->zoom.active && output->zoom.level <= 0.0) { - output->zoom.active = false; - output->zoom.seat = NULL; - weston_output_disable_planes_decr(output); - wl_list_remove(&output->zoom.motion_listener.link); - } - output->zoom.spring_z.current = output->zoom.level; - wl_list_remove(&animation->link); - wl_list_init(&animation->link); - } - - output->dirty = 1; - weston_output_damage(output); -} - -static void -zoom_area_center_from_point(struct weston_output *output, - double *x, double *y) -{ - float level = output->zoom.spring_z.current; - - *x = (*x - output->x) * level + output->width / 2.; - *y = (*y - output->y) * level + output->height / 2.; -} - -static void -weston_output_update_zoom_transform(struct weston_output *output) -{ - double x = output->zoom.current.x; /* global pointer coords */ - double y = output->zoom.current.y; - float level; - - level = output->zoom.spring_z.current; - - if (!output->zoom.active || level > output->zoom.max_level || - level == 0.0f) - return; - - zoom_area_center_from_point(output, &x, &y); - - output->zoom.trans_x = x - output->width / 2; - output->zoom.trans_y = y - output->height / 2; - - if (output->zoom.trans_x < 0) - output->zoom.trans_x = 0; - if (output->zoom.trans_y < 0) - output->zoom.trans_y = 0; - if (output->zoom.trans_x > level * output->width) - output->zoom.trans_x = level * output->width; - if (output->zoom.trans_y > level * output->height) - output->zoom.trans_y = level * output->height; -} - -static void -weston_zoom_transition(struct weston_output *output) -{ - if (output->zoom.level != output->zoom.spring_z.current) { - output->zoom.spring_z.target = output->zoom.level; - if (wl_list_empty(&output->zoom.animation_z.link)) { - output->zoom.animation_z.frame_counter = 0; - wl_list_insert(output->animation_list.prev, - &output->zoom.animation_z.link); - } - } - - output->dirty = 1; - weston_output_damage(output); -} - -WL_EXPORT void -weston_output_update_zoom(struct weston_output *output) -{ - struct weston_seat *seat = output->zoom.seat; - struct weston_pointer *pointer = weston_seat_get_pointer(seat); - - if (!pointer) - return; - - assert(output->zoom.active); - - output->zoom.current.x = wl_fixed_to_double(pointer->x); - output->zoom.current.y = wl_fixed_to_double(pointer->y); - - weston_zoom_transition(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) -{ - struct weston_pointer *pointer = weston_seat_get_pointer(seat); - - if (!pointer || output->zoom.active) - return; - - output->zoom.active = true; - output->zoom.seat = seat; - weston_output_disable_planes_incr(output); - wl_signal_add(&pointer->motion_signal, - &output->zoom.motion_listener); -} - -WL_EXPORT void -weston_output_init_zoom(struct weston_output *output) -{ - output->zoom.active = false; - output->zoom.seat = NULL; - output->zoom.increment = 0.07; - output->zoom.max_level = 0.95; - output->zoom.level = 0.0; - output->zoom.trans_x = 0.0; - output->zoom.trans_y = 0.0; - weston_spring_init(&output->zoom.spring_z, 250.0, 0.0, 0.0); - output->zoom.spring_z.friction = 1000; - output->zoom.animation_z.frame = weston_zoom_frame_z; - wl_list_init(&output->zoom.animation_z.link); - output->zoom.motion_listener.notify = motion; -}