diff options
| author | Daniel Friesel <derf@derf.homelinux.org> | 2010-06-19 20:53:38 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-06-19 20:53:38 +0200 | 
| commit | e2ebaaa2cd997b553c772bafd082b5b2e69efeec (patch) | |
| tree | 36712442f46497a6d0a8cfc5078d7e4c725b8646 /src | |
| parent | add9cfa1ae859e5f728a2ec3fd1d02586008dfe0 (diff) | |
Make <keypad /> and <keypad *> actually useful
Diffstat (limited to 'src')
| -rw-r--r-- | src/events.c | 28 | ||||
| -rw-r--r-- | src/keyevents.c | 2 | ||||
| -rw-r--r-- | src/winwidget.c | 29 | ||||
| -rw-r--r-- | src/winwidget.h | 1 | 
4 files changed, 33 insertions, 27 deletions
| diff --git a/src/events.c b/src/events.c index 7caa4d2..de2e3c0 100644 --- a/src/events.c +++ b/src/events.c @@ -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) { diff --git a/src/keyevents.c b/src/keyevents.c index 67f5389..aa18d02 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -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: diff --git a/src/winwidget.c b/src/winwidget.c index e57be89..3172086 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -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; diff --git a/src/winwidget.h b/src/winwidget.h index 37e0624..a856475 100644 --- a/src/winwidget.h +++ b/src/winwidget.h @@ -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); | 
