preserve image center over short periods when the "broken image" icon is
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 30 May 2009 20:18:22 +0000 (20:18 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 30 May 2009 20:18:22 +0000 (20:18 +0000)
displayed
http://sourceforge.net/tracker/?func=detail&aid=2793057&group_id=222125&atid=1054680

src/pixbuf-renderer.c

index 703b181..8e99b3c 100644 (file)
@@ -3172,11 +3172,23 @@ static void pixbuf_renderer_sync_scroll_center(PixbufRenderer *pr)
        gint src_x, src_y;
        if (!pr->width || !pr->height) return;
 
-       src_x = pr->x_scroll + pr->vis_width / 2;
-       src_y = pr->y_scroll + pr->vis_height / 2;
+       /* 
+        * Update norm_center only if the image is bigger than the window.
+        * With this condition the stored center survives also a temporary display
+        * of the "broken image" icon.
+       */
 
-       pr->norm_center_x = (gdouble)src_x / pr->width;
-       pr->norm_center_y = (gdouble)src_y / pr->height;
+       if (pr->width > pr->window_width)
+               {
+               src_x = pr->x_scroll + pr->vis_width / 2;
+               pr->norm_center_x = (gdouble)src_x / pr->width;
+               }
+       
+       if (pr->height > pr->window_height)
+               {
+               src_y = pr->y_scroll + pr->vis_height / 2;
+               pr->norm_center_y = (gdouble)src_y / pr->height;
+               }
 }