From ca01b1ff8daf005e93d6c7ef3a7b6854ea140f54 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Wed, 10 Apr 2024 23:37:20 -0300 Subject: clients/image: move a few functions on the file Cosmetic changes. Move the image_widget handlers closer to each other. Signed-off-by: Leandro Ribeiro --- clients/image.c | 58 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/clients/image.c b/clients/image.c index f1c28099..dd54ff1d 100644 --- a/clients/image.c +++ b/clients/image.c @@ -193,15 +193,6 @@ image_resize_handler(struct widget *widget, allocation.width, allocation.height); } -static void -keyboard_focus_handler(struct window *window, - struct input *device, void *data) -{ - struct image *image = data; - - window_schedule_redraw(image->window); -} - static int image_enter_handler(struct widget *widget, struct input *input, @@ -299,6 +290,35 @@ zoom(struct image *image, double scale) clamp_view(image); } +static void +image_axis_handler(struct widget *widget, struct input *input, uint32_t time, + uint32_t axis, wl_fixed_t value, void *data) +{ + struct image *image = data; + + if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL && + input_get_modifiers(input) == MOD_CONTROL_MASK) { + /* set zoom level to 2% per 10 axis units */ + zoom(image, (1.0 - wl_fixed_to_double(value) / 500.0)); + + window_schedule_redraw(image->window); + } else if (input_get_modifiers(input) == 0) { + if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) + move_viewport(image, 0, wl_fixed_to_double(value)); + else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) + move_viewport(image, wl_fixed_to_double(value), 0); + } +} + +static void +keyboard_focus_handler(struct window *window, + struct input *device, void *data) +{ + struct image *image = data; + + window_schedule_redraw(image->window); +} + static void key_handler(struct window *window, struct input *input, uint32_t time, uint32_t key, uint32_t sym, enum wl_keyboard_key_state state, @@ -330,26 +350,6 @@ key_handler(struct window *window, struct input *input, uint32_t time, } } -static void -image_axis_handler(struct widget *widget, struct input *input, uint32_t time, - uint32_t axis, wl_fixed_t value, void *data) -{ - struct image *image = data; - - if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL && - input_get_modifiers(input) == MOD_CONTROL_MASK) { - /* set zoom level to 2% per 10 axis units */ - zoom(image, (1.0 - wl_fixed_to_double(value) / 500.0)); - - window_schedule_redraw(image->window); - } else if (input_get_modifiers(input) == 0) { - if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - move_viewport(image, 0, wl_fixed_to_double(value)); - else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) - move_viewport(image, wl_fixed_to_double(value), 0); - } -} - static void fullscreen_handler(struct window *window, void *data) { -- cgit v1.2.3