diff options
author | Dennis Real <github@tildepipe.org> | 2013-02-14 17:02:16 +0100 |
---|---|---|
committer | Dennis Real <github@tildepipe.org> | 2013-02-14 17:02:16 +0100 |
commit | 08faff479023efff6380061d81362073f679cd34 (patch) | |
tree | a462195afe9a6e2e2249f070c12ff6d1ff60d65c /src/events.c | |
parent | 353578ebc130f53547996ab87f5b3795c1360f3f (diff) | |
parent | 43a7d315ae6952e096ae3a0351273c5639377870 (diff) |
Merge branch 'master' of git://github.com/derf/feh
Diffstat (limited to 'src/events.c')
-rw-r--r-- | src/events.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/events.c b/src/events.c index dcd1aa1..fadae9b 100644 --- a/src/events.c +++ b/src/events.c @@ -152,6 +152,10 @@ void init_buttonbindings(void) cur_bb = &buttons.blur; else if (!strcmp(action, "rotate")) cur_bb = &buttons.rotate; + else if (!strcmp(action, "zoom_in")) + cur_bb = &buttons.zoom_in; + else if (!strcmp(action, "zoom_out")) + cur_bb = &buttons.zoom_out; else weprintf("buttons: Invalid action: %s", action); @@ -246,6 +250,62 @@ static void feh_event_handle_ButtonPress(XEvent * ev) winwid->im_click_offset_y = (winwid->click_offset_y - winwid->im_y) / winwid->old_zoom; + } else if (feh_is_bb(&buttons.zoom_in, button, state)) { + D(("Zoom_In Button Press event\n")); + D(("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y)); + winwid->click_offset_x = ev->xbutton.x; + winwid->click_offset_y = ev->xbutton.y; + winwid->old_zoom = winwid->zoom; + + /* required to adjust the image position in zoom mode */ + winwid->im_click_offset_x = (winwid->click_offset_x + - winwid->im_x) / winwid->old_zoom; + winwid->im_click_offset_y = (winwid->click_offset_y + - winwid->im_y) / winwid->old_zoom; + + /* copied from zoom_in, keyevents.c */ + winwid->zoom = winwid->zoom * 1.25; + + if (winwid->zoom > ZOOM_MAX) + winwid->zoom = ZOOM_MAX; + + /* copied from below (ZOOM, feh_event_handle_MotionNotify) */ + winwid->im_x = winwid->click_offset_x + - (winwid->im_click_offset_x * winwid->zoom); + winwid->im_y = winwid->click_offset_y + - (winwid->im_click_offset_y * winwid->zoom); + + winwidget_sanitise_offsets(winwid); + winwidget_render_image(winwid, 0, 0); + + } else if (feh_is_bb(&buttons.zoom_out, button, state)) { + D(("Zoom_Out Button Press event\n")); + D(("click offset is %d,%d\n", ev->xbutton.x, ev->xbutton.y)); + winwid->click_offset_x = ev->xbutton.x; + winwid->click_offset_y = ev->xbutton.y; + winwid->old_zoom = winwid->zoom; + + /* required to adjust the image position in zoom mode */ + winwid->im_click_offset_x = (winwid->click_offset_x + - winwid->im_x) / winwid->old_zoom; + winwid->im_click_offset_y = (winwid->click_offset_y + - winwid->im_y) / winwid->old_zoom; + + /* copied from zoom_out, keyevents.c */ + winwid->zoom = winwid->zoom * 0.80; + + if (winwid->zoom < ZOOM_MIN) + winwid->zoom = ZOOM_MIN; + + /* copied from below (ZOOM, feh_event_handle_MotionNotify) */ + winwid->im_x = winwid->click_offset_x + - (winwid->im_click_offset_x * winwid->zoom); + winwid->im_y = winwid->click_offset_y + - (winwid->im_click_offset_y * winwid->zoom); + + winwidget_sanitise_offsets(winwid); + winwidget_render_image(winwid, 0, 0); + } else if (feh_is_bb(&buttons.reload, button, state)) { D(("Reload Button Press event\n")); feh_reload_image(winwid, 0, 1); |