summaryrefslogtreecommitdiff
path: root/src/winwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/winwidget.c')
-rw-r--r--src/winwidget.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/winwidget.c b/src/winwidget.c
index 26a43e2..a39e8ef 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -1,6 +1,7 @@
/* winwidget.c
Copyright (C) 1999-2003 Tom Gilbert.
+Copyright (C) 2010-2011 Daniel Friesel.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
@@ -57,6 +58,7 @@ static winwidget winwidget_allocate(void)
ret->type = WIN_TYPE_UNSET;
ret->visible = 0;
ret->caption_entry = 0;
+ ret->force_aliasing = opt.force_aliasing;
/* Zoom stuff */
ret->mode = MODE_NORMAL;
@@ -98,7 +100,7 @@ winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type)
if (opt.full_screen && (type != WIN_TYPE_THUMBNAIL))
ret->full_screen = True;
winwidget_create_window(ret, ret->w, ret->h);
- winwidget_render_image(ret, 1, 1);
+ winwidget_render_image(ret, 1, 0);
return(ret);
}
@@ -131,7 +133,7 @@ winwidget winwidget_create_from_file(gib_list * list, char *name, char type)
if (opt.full_screen)
ret->full_screen = True;
winwidget_create_window(ret, ret->w, ret->h);
- winwidget_render_image(ret, 1, 1);
+ winwidget_render_image(ret, 1, 0);
}
return(ret);
@@ -361,10 +363,11 @@ void winwidget_setup_pixmaps(winwidget winwid)
return;
}
-void winwidget_render_image(winwidget winwid, int resize, int alias)
+void winwidget_render_image(winwidget winwid, int resize, int force_alias)
{
int sx, sy, sw, sh, dx, dy, dw, dh;
int calc_w, calc_h;
+ int antialias = 0;
if (!winwid->full_screen && resize) {
winwidget_resize(winwid, winwid->im_w, winwid->im_h);
@@ -377,13 +380,14 @@ void winwidget_render_image(winwidget winwid, int resize, int alias)
if (winwid->im_y > winwid->h)
winwid->im_y = winwid->h;
- D(("winwidget_render_image resize %d alias %d im %dx%d\n",
- resize, alias, winwid->im_w, winwid->im_h));
+ D(("winwidget_render_image resize %d force_alias %d im %dx%d\n",
+ resize, force_alias, winwid->im_w, winwid->im_h));
winwidget_setup_pixmaps(winwid);
if (!winwid->full_screen && opt.scale_down && ((winwid->w < winwid->im_w)
- || (winwid->h < winwid->im_h))) {
+ || (winwid->h < winwid->im_h)) &&
+ (winwid->old_zoom == 1.0)) {
D(("scaling down image %dx%d\n", winwid->w, winwid->h));
feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
@@ -424,7 +428,7 @@ void winwidget_render_image(winwidget winwid, int resize, int alias)
smaller = ((winwid->im_w < max_w)
&& (winwid->im_h < max_h));
- if (!smaller || opt.auto_zoom) {
+ if (!smaller || opt.zoom_mode) {
double ratio = 0.0;
/* Image is larger than the screen (so wants shrinking), or it's
@@ -522,17 +526,22 @@ void winwidget_render_image(winwidget winwid, int resize, int alias)
D(("sx: %d sy: %d sw: %d sh: %d dx: %d dy: %d dw: %d dh: %d zoom: %f\n",
sx, sy, sw, sh, dx, dy, dw, dh, winwid->zoom));
+ if ((winwid->zoom != 1.0) && !force_alias && !winwid->force_aliasing)
+ antialias = 1;
+
D(("winwidget_render(): winwid->im_angle = %f\n", winwid->im_angle));
if (winwid->has_rotated)
gib_imlib_render_image_part_on_drawable_at_size_with_rotation
- (winwid->bg_pmap, winwid->im, sx, sy, sw, sh, dx, dy, dw, dh, winwid->im_angle, 1, 1, alias);
+ (winwid->bg_pmap, winwid->im, sx, sy, sw, sh, dx, dy, dw, dh,
+ winwid->im_angle, 1, 1, antialias);
else
gib_imlib_render_image_part_on_drawable_at_size(winwid->bg_pmap,
winwid->im,
sx, sy, sw,
sh, dx, dy,
dw, dh, 1,
- gib_imlib_image_has_alpha(winwid->im), alias);
+ gib_imlib_image_has_alpha(winwid->im),
+ antialias);
if (opt.mode == MODE_NORMAL) {
if (opt.caption_path)
@@ -543,7 +552,7 @@ void winwidget_render_image(winwidget winwid, int resize, int alias)
feh_draw_actions(winwid);
if (opt.info_cmd)
feh_draw_info(winwid);
- } else if ((opt.mode == MODE_ZOOM) && !alias)
+ } else if ((opt.mode == MODE_ZOOM) && !antialias)
feh_draw_zoom(winwid);
XSetWindowBackgroundPixmap(disp, winwid->win, winwid->bg_pmap);
@@ -578,6 +587,9 @@ double feh_calc_needed_zoom(double *zoom, int orig_w, int orig_h, int dest_w, in
ratio = ((double) orig_w / orig_h) / ((double) dest_w / dest_h);
+ if (opt.zoom_mode == ZOOM_MODE_FILL)
+ ratio = 1.0 / ratio;
+
if (ratio > 1.0)
*zoom = ((double) dest_w / orig_w);
else
@@ -686,13 +698,13 @@ void winwidget_destroy_all(void)
return;
}
-void winwidget_rerender_all(int resize, int alias)
+void winwidget_rerender_all(int resize)
{
int i;
/* Have to DESCEND the list here, 'cos of the way _unregister works */
for (i = window_num - 1; i >= 0; i--)
- winwidget_render_image(windows[i], resize, alias);
+ winwidget_render_image(windows[i], resize, 0);
return;
}
@@ -908,6 +920,7 @@ void feh_debug_print_winwid(winwidget w)
void winwidget_reset_image(winwidget winwid)
{
winwid->zoom = 1.0;
+ winwid->old_zoom = 1.0;
winwid->im_x = 0;
winwid->im_y = 0;
winwid->im_angle = 0.0;
@@ -982,7 +995,7 @@ void winwidget_size_to_image(winwidget winwid)
{
winwidget_resize(winwid, winwid->im_w * winwid->zoom, winwid->im_h * winwid->zoom);
winwid->im_x = winwid->im_y = 0;
- winwidget_render_image(winwid, 0, 1);
+ winwidget_render_image(winwid, 0, 0);
return;
}