From 0084d755618c8a5a55f36bbdd2c17952dfae68f0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 8 Feb 2013 18:04:21 +0100 Subject: handle stdin when loading filelist so it also works with --list, rotation, etc. --- src/imlib.c | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index bdf54ac..98a91be 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -61,7 +61,6 @@ int num_xinerama_screens; int childpid = 0; -static char *feh_stdin_load_image(); static char *feh_http_load_image(char *url); static char *feh_magick_load_image(char *filename); @@ -210,7 +209,7 @@ void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err) int feh_load_image(Imlib_Image * im, feh_file * file) { Imlib_Load_Error err; - enum { SRC_IMLIB, SRC_HTTP, SRC_MAGICK, SRC_STDIN } image_source = + enum { SRC_IMLIB, SRC_HTTP, SRC_MAGICK } image_source = SRC_IMLIB; char *tmpname = NULL; char *real_filename = NULL; @@ -227,10 +226,6 @@ int feh_load_image(Imlib_Image * im, feh_file * file) tmpname = feh_http_load_image(file->filename); } - if ((strlen(file->filename) == 1) && (file->filename[0] == '-')) { - image_source = SRC_STDIN; - tmpname = feh_stdin_load_image(); - } else *im = imlib_load_image_with_error_return(file->filename, &err); @@ -275,38 +270,6 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return(1); } -static char *feh_stdin_load_image() -{ - char buf[1024]; - size_t readsize; - char *sfn = estrjoin("_", "/tmp/feh_stdin", "XXXXXX", NULL); - int fd = mkstemp(sfn); - FILE *outfile; - - if (fd == -1) { - free(sfn); - return NULL; - } - - outfile = fdopen(fd, "w"); - - if (outfile == NULL) { - free(sfn); - return NULL; - } - - while ((readsize = fread(buf, sizeof(char), sizeof(buf), stdin)) > 0) { - if (fwrite(buf, sizeof(char), readsize, outfile) < readsize) { - free(sfn); - return NULL; - } - } - - fclose(outfile); - - return sfn; -} - static char *feh_magick_load_image(char *filename) { char argv_fd[12]; -- cgit v1.2.3 From a889a9f9a866f5dea241773f04d52fafd3ab0175 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 8 Feb 2013 22:31:29 +0100 Subject: fix imlib2 and x11 warnings when opening a URL that returned an HTTP error --- ChangeLog | 2 ++ src/imlib.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/imlib.c') diff --git a/ChangeLog b/ChangeLog index 561abfd..f4abf3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ git HEAD * Add --sort mtime option (patch by guns) * Add a desktop file (installed to share/applications/feh.desktop) * Use "feh -" to read image from stdin + * Fix Imlib2 and X11 warnings when opening a URL that returned an HTTP + error Mon, 24 Dec 2012 15:45:54 +0100 Daniel Friesel diff --git a/src/imlib.c b/src/imlib.c index 98a91be..2425050 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -224,7 +224,8 @@ int feh_load_image(Imlib_Image * im, feh_file * file) || (!strncmp(file->filename, "ftp://", 6))) { image_source = SRC_HTTP; - tmpname = feh_http_load_image(file->filename); + if ((tmpname = feh_http_load_image(file->filename)) == NULL) + err = IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST; } else *im = imlib_load_image_with_error_return(file->filename, &err); -- cgit v1.2.3 From 5dfdc0bc15e49f7c091aad123cf1b03f55d936cb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 14 Feb 2013 12:12:56 +0100 Subject: Determine active Xinerama screen by pointer position --- ChangeLog | 5 +++++ src/imlib.c | 27 +++++++++++++++++++++++---- src/winwidget.c | 17 +++++++++++------ 3 files changed, 39 insertions(+), 10 deletions(-) (limited to 'src/imlib.c') diff --git a/ChangeLog b/ChangeLog index 842c208..bd69368 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +git HEAD + + * Set correct window dimensions on any Xinerama screen, not just the + first one (active screen is determined by current pointer location) + Wed, 13 Feb 2013 01:46:56 +0100 Daniel Friesel * Release v2.9 diff --git a/src/imlib.c b/src/imlib.c index 2425050..5514a34 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -68,13 +68,32 @@ static char *feh_magick_load_image(char *filename); void init_xinerama(void) { if (opt.xinerama && XineramaIsActive(disp)) { - int major, minor; + int major, minor, px, py, i; + + /* discarded */ + Window dw; + int di; + unsigned int du; + + XineramaQueryVersion(disp, &major, &minor); + xinerama_screens = XineramaQueryScreens(disp, &num_xinerama_screens); + if (getenv("XINERAMA_SCREEN")) xinerama_screen = atoi(getenv("XINERAMA_SCREEN")); - else + else { xinerama_screen = 0; - XineramaQueryVersion(disp, &major, &minor); - xinerama_screens = XineramaQueryScreens(disp, &num_xinerama_screens); + XQueryPointer(disp, root, &dw, &dw, &px, &py, &di, &di, &du); + for (i = 0; i < num_xinerama_screens; i++) { + if (XY_IN_RECT(px, py, + xinerama_screens[i].x_org, + xinerama_screens[i].y_org, + xinerama_screens[i].width, + xinerama_screens[i].height)) { + xinerama_screen = i; + break; + } + } + } } } #endif /* HAVE_LIBXINERAMA */ diff --git a/src/winwidget.c b/src/winwidget.c index 2f543df..ada4c02 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -780,23 +780,28 @@ void winwidget_move(winwidget winwid, int x, int y) void winwidget_resize(winwidget winwid, int w, int h) { - Window ignored_window; XWindowAttributes attributes; - int tc_x, tc_y; + int tc_x, tc_y, px, py; int scr_width = scr->width; int scr_height = scr->height; + /* discarded */ + Window dw; + int di, i; + unsigned int du; + XGetWindowAttributes(disp, winwid->win, &attributes); #ifdef HAVE_LIBXINERAMA if (opt.xinerama && xinerama_screens) { - int i; xinerama_screen = 0; + XQueryPointer(disp, root, &dw, &dw, &px, &py, &di, &di, &du); for (i = 0; i < num_xinerama_screens; i++) { - if (XY_IN_RECT(attributes.x, attributes.y, + if (XY_IN_RECT(px, py, xinerama_screens[i].x_org, xinerama_screens[i].y_org, - xinerama_screens[i].width, xinerama_screens[i].height)) { + xinerama_screens[i].width, + xinerama_screens[i].height)) { xinerama_screen = i; break; } @@ -828,7 +833,7 @@ void winwidget_resize(winwidget winwid, int w, int h) XTranslateCoordinates(disp, winwid->win, attributes.root, -attributes.border_width - attributes.x, - -attributes.border_width - attributes.y, &tc_x, &tc_y, &ignored_window); + -attributes.border_width - attributes.y, &tc_x, &tc_y, &dw); winwid->x = tc_x; winwid->y = tc_y; XMoveResizeWindow(disp, winwid->win, tc_x, tc_y, winwid->w, winwid->h); -- cgit v1.2.3