summaryrefslogtreecommitdiff
path: root/src/winwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/winwidget.c')
-rw-r--r--src/winwidget.c76
1 files changed, 43 insertions, 33 deletions
diff --git a/src/winwidget.c b/src/winwidget.c
index 65cefca..f249694 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "filelist.h"
#include "winwidget.h"
#include "options.h"
+#include "events.h"
static void winwidget_unregister(winwidget win);
static void winwidget_register(winwidget win);
@@ -297,6 +298,13 @@ void winwidget_create_window(winwidget ret, int w, int h)
XSetCommand(disp, ret->win, cmdargv, cmdargc);
winwidget_register(ret);
+
+ /* do not scale down a thumbnail list window, only those created from it */
+ if (opt.scale_down && (ret->type != WIN_TYPE_THUMBNAIL)) {
+ opt.geom_w = w;
+ opt.geom_h = h;
+ opt.geom_flags |= WidthValue | HeightValue;
+ }
return;
}
@@ -393,7 +401,7 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
int need_center = winwid->had_resize;
if (!winwid->full_screen && resize) {
- winwidget_resize(winwid, winwid->im_w, winwid->im_h);
+ winwidget_resize(winwid, winwid->im_w, winwid->im_h, 0);
winwidget_reset_image(winwid);
}
@@ -408,28 +416,6 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
winwidget_setup_pixmaps(winwid);
- if (!winwid->full_screen && opt.scale_down &&
- (winwid->type != WIN_TYPE_THUMBNAIL) &&
- (winwid->old_zoom == 1.0)) {
- int max_w = winwid->w, max_h = winwid->h;
- if (opt.geom_flags & WidthValue) {
- max_w = opt.geom_w;
- }
- if (opt.geom_flags & HeightValue) {
- max_h = opt.geom_h;
- }
- D(("max: %dx%d, size: %dx%d\n", max_w, max_h, winwid->im_w, winwid->im_h));
- if (max_w < winwid->im_w || max_h < winwid->im_h) {
- D(("scaling down image %dx%d\n", max_w, max_h));
-
- feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h,
- max_w, max_h);
- if (resize)
- winwidget_resize(winwid, winwid->im_w * winwid->zoom, winwid->im_h * winwid->zoom);
- D(("after scaling down image %dx%d\n", winwid->w, winwid->h));
- }
- }
-
if (!winwid->full_screen && ((gib_imlib_image_has_alpha(winwid->im))
|| (opt.geom_flags & (WidthValue | HeightValue))
|| (winwid->im_x || winwid->im_y) || (winwid->zoom != 1.0)
@@ -438,13 +424,22 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
feh_draw_checks(winwid);
if (!winwid->full_screen && opt.zoom_mode
- && (winwid->zoom == 1.0) && ! (opt.geom_flags & (WidthValue | HeightValue))
- && (winwid->w > winwid->im_w) && (winwid->h > winwid->im_h))
+ && (winwid->zoom == 1.0) && ! (opt.geom_flags & (WidthValue | HeightValue))
+ && (winwid->w > winwid->im_w) && (winwid->h > winwid->im_h))
+ feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
+
+ /*
+ * In case of a resize, the geomflags (and im_w, im_h) get updated by
+ * the ConfigureNotify handler.
+ */
+ if (need_center && !winwid->full_screen
+ && (opt.geom_flags & (WidthValue | HeightValue))
+ && ((winwid->w < winwid->im_w) || (winwid->h < winwid->im_h)))
feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
if (resize && (winwid->full_screen
- || (!opt.scale_down && (opt.geom_flags & (WidthValue | HeightValue))))) {
+ || (opt.geom_flags & (WidthValue | HeightValue)))) {
int smaller; /* Is the image smaller than screen? */
int max_w = 0, max_h = 0;
@@ -532,8 +527,8 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
winwid->im_y = (int) (max_h - (winwid->im_h * winwid->zoom)) >> 1;
}
}
- else if (need_center && !winwid->full_screen && opt.scale_down
- && (winwid->type != WIN_TYPE_THUMBNAIL)) {
+ else if (need_center && !winwid->full_screen
+ && (winwid->type != WIN_TYPE_THUMBNAIL) && !opt.keep_zoom_vp) {
winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1;
winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1;
}
@@ -776,6 +771,15 @@ void winwidget_show(winwidget winwid)
/* wait for the window to map */
D(("Waiting for window to map\n"));
XMaskEvent(disp, StructureNotifyMask, &ev);
+ /* Unfortunately, StructureNotifyMask does not only mask
+ * the events of type MapNotify (which we want to mask here)
+ * but also such of type ConfigureNotify (and others, see
+ * https://tronche.com/gui/x/xlib/events/processing-overview.html),
+ * which should be handled, especially on tiling wm's. To
+ * remedy this, the handler is executed explicitly:
+ */
+ if (ev.type == ConfigureNotify)
+ feh_event_handle_ConfigureNotify(&ev);
D(("Window mapped\n"));
winwid->visible = 1;
}
@@ -797,7 +801,7 @@ void winwidget_move(winwidget winwid, int x, int y)
return;
}
-void winwidget_resize(winwidget winwid, int w, int h)
+void winwidget_resize(winwidget winwid, int w, int h, int force_resize)
{
XWindowAttributes attributes;
int tc_x, tc_y, px, py;
@@ -826,8 +830,8 @@ void winwidget_resize(winwidget winwid, int w, int h)
}
}
- if (getenv("XINERAMA_SCREEN"))
- xinerama_screen = atoi(getenv("XINERAMA_SCREEN"));
+ if (opt.xinerama_index >= 0)
+ xinerama_screen = opt.xinerama_index;
scr_width = xinerama_screens[xinerama_screen].width;
scr_height = xinerama_screens[xinerama_screen].height;
@@ -838,7 +842,7 @@ void winwidget_resize(winwidget winwid, int w, int h)
D((" x %d y %d w %d h %d\n", attributes.x, attributes.y, winwid->w,
winwid->h));
- if (!opt.scale_down && opt.geom_flags & (WidthValue | HeightValue)) {
+ if ((opt.geom_flags & (WidthValue | HeightValue)) && !force_resize) {
winwid->had_resize = 1;
return;
}
@@ -862,6 +866,12 @@ void winwidget_resize(winwidget winwid, int w, int h)
winwid->had_resize = 1;
XFlush(disp);
+ if (force_resize && (opt.geom_flags & (WidthValue | HeightValue))
+ && (winwid->type != WIN_TYPE_THUMBNAIL)) {
+ opt.geom_w = winwid->w;
+ opt.geom_h = winwid->h;
+ }
+
D(("-> x %d y %d w %d h %d\n", winwid->x, winwid->y, winwid->w,
winwid->h));
@@ -1051,7 +1061,7 @@ void winwidget_sanitise_offsets(winwidget winwid)
void winwidget_size_to_image(winwidget winwid)
{
- winwidget_resize(winwid, winwid->im_w * winwid->zoom, winwid->im_h * winwid->zoom);
+ winwidget_resize(winwid, winwid->im_w * winwid->zoom, winwid->im_h * winwid->zoom, 1);
winwid->im_x = winwid->im_y = 0;
winwidget_render_image(winwid, 0, 0);
return;