Commit 701cf137 authored by ulteq's avatar ulteq
Browse files

Adapt the new --offset option

parent 0235156b
Loading
Loading
Loading
Loading
+6 −16
Original line number Diff line number Diff line
@@ -450,33 +450,23 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
				&& (!opt.default_zoom || required_zoom < winwid->zoom))
			winwid->zoom = required_zoom;

		winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1;
		winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1;
	}

	/*
	 * Adjust X/Y offset if the image is larger than the window and
	 * --inner-geometry is set. This will cause odd behaviour when
	 * zooming an already large image in --inner-geometry mode, but in most
	 * cases this should be what the user wants. Plus, it doesn't require
	 * fiddling around in two or three places above, so it's the best
	 * solution considering a future refactoring of this function.
	 */

	if (had_resize) {
		if ((opt.offset_flags & XValue) && (winwid->im_w * winwid->zoom) > winwid->w) {
		if (opt.offset_flags & XValue) {
			if (opt.offset_flags & XNegative) {
				winwid->im_x = winwid->w - (winwid->im_w * winwid->zoom) - opt.offset_x;
			} else {
				winwid->im_x = - opt.offset_x * winwid->zoom;
			}
		} else {
			winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1;
		}
		if ((opt.offset_flags & YValue) && (winwid->im_h * winwid->zoom) > winwid->h) {
		if (opt.offset_flags & YValue) {
			if (opt.offset_flags & YNegative) {
				winwid->im_y = winwid->h - (winwid->im_h * winwid->zoom) - opt.offset_y;
			} else {
				winwid->im_y = - opt.offset_y * winwid->zoom;
			}
		} else {
			winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1;
		}
	}