Commit e2ebaaa2 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Make <keypad /> and <keypad *> actually useful

parent add9cfa1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ git HEAD
    * --font now sets the global default font (for action/filename display etc.)
    * Rename --screen-clip 0 to --no-screen-clip
    * Allow multiline theme definitions (via backslash, like in the shell)
    * Center the image after pressing <keypad /> or <keypad *>

Thu Jun 10 12:12:04 CEST 2010

+1 −27
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ void feh_event_init(void)
static void feh_event_handle_ButtonPress(XEvent * ev)
{
	winwidget winwid = NULL;
	int scr_width, scr_height;

	/* get the heck out if it's a mouse-click on the
	   cover, we'll hide the menus on release */
@@ -69,15 +68,6 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
		return;
	}

	scr_width = scr->width;
	scr_height = scr->height;
#ifdef HAVE_LIBXINERAMA
	if (opt.xinerama && xinerama_screens) {
		scr_width = xinerama_screens[xinerama_screen].width;
		scr_height = xinerama_screens[xinerama_screen].height;
	}
#endif				/* HAVE_LIBXINERAMA */

	winwid = winwidget_get_from_window(ev->xbutton.window);
	if (winwid && winwid->caption_entry) {
		return;
@@ -132,23 +122,7 @@ static void feh_event_handle_ButtonPress(XEvent * ev)
			winwid->im_click_offset_y = (winwid->click_offset_y
					- winwid->im_y) / winwid->old_zoom;

			/* center the image */
			if (winwid->full_screen) {
				winwid->im_x = (scr_width - winwid->im_w) >> 1;
				winwid->im_y = (scr_height - winwid->im_h) >> 1;
			} else {
				if (opt.geom_flags & WidthValue) {
					winwid->im_x = (opt.geom_w - winwid->im_w) >> 1;
				} else {
					winwid->im_x = 0;
				}
				if (opt.geom_flags & HeightValue) {
					winwid->im_y = (opt.geom_h - winwid->im_h) >> 1;
				} else {
					winwid->im_y = 0;
				}
			}

			winwidget_center_image(winwid);
			winwidget_render_image(winwid, 0, 0);
		}
	} else if (ev->xbutton.button == opt.reload_button) {
+2 −0
Original line number Diff line number Diff line
@@ -271,11 +271,13 @@ void feh_event_handle_keypress(XEvent * ev)
	case XK_KP_Multiply:
		len = 0;
		winwid->zoom = 1;
		winwidget_center_image(winwid);
		winwidget_render_image(winwid, 0, 0);
		break;
	case XK_KP_Divide:
		len = 0;
		feh_calc_needed_zoom(&winwid->zoom, winwid->im_w, winwid->im_h, winwid->w, winwid->h);
		winwidget_center_image(winwid);
		winwidget_render_image(winwid, 0, 1);
		break;
	case XK_KP_Begin:
+29 −0
Original line number Diff line number Diff line
@@ -886,6 +886,35 @@ void winwidget_reset_image(winwidget winwid)
	return;
}

void winwidget_center_image(winwidget winwid)
{
	int scr_width, scr_height;

	scr_width = scr->width;
	scr_height = scr->height;

#ifdef HAVE_LIBXINERAMA
	if (opt.xinerama && xinerama_screens) {
		scr_width = xinerama_screens[xinerama_screen].width;
		scr_height = xinerama_screens[xinerama_screen].height;
	}
#endif				/* HAVE_LIBXINERAMA */

	if (winwid->full_screen) {
		winwid->im_x = (scr_width - lround(winwid->im_w * winwid->zoom)) >> 1;
		winwid->im_y = (scr_height - lround(winwid->im_h * winwid->zoom)) >> 1;
	} else {
		if (opt.geom_flags & WidthValue)
			winwid->im_x = (opt.geom_w - lround(winwid->im_w * winwid->zoom)) >> 1;
		else
			winwid->im_x = 0;
		if (opt.geom_flags & HeightValue)
			winwid->im_y = (opt.geom_h - lround(winwid->im_h * winwid->zoom)) >> 1;
		else
			winwid->im_y = 0;
	}
}

void winwidget_sanitise_offsets(winwidget winwid)
{
	int far_left, far_top;
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ void winwidget_show_menu(winwidget winwid);
void winwidget_hide(winwidget winwid);
void winwidget_destroy_all(void);
void winwidget_free_image(winwidget w);
void winwidget_center_image(winwidget w);
void winwidget_render_image(winwidget winwid, int resize, int alias);
void winwidget_rotate_image(winwidget winid, double angle);
void winwidget_move(winwidget winwid, int x, int y);