diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-11 15:07:53 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-11 15:07:53 +0000 |
commit | 69d9bff2319d5e1952a988c38a44b5ef5562a027 (patch) | |
tree | 6981af521abb09a2498298179756e5d51c58105f | |
parent | [w3m-dev 03558] long title is displayed over tab region (diff) | |
download | w3m-69d9bff2319d5e1952a988c38a44b5ef5562a027.tar.gz w3m-69d9bff2319d5e1952a988c38a44b5ef5562a027.zip |
[w3m-dev 03559] Re: use select instead of signal for loading images
* fm.h (Buffer): add image_loaded
* image.c (W3M_SIGIMG): deleted
(image_lock): deleted
(need_load_image): deleted
(load_image_handler): deleted
(load_image_next): deleted
(getAllImage): check image_loaded
(loadImage): delete image_lock
delete IMG_FLAG_NEXT
* main.c (main): check image_loaded
* proto.h (sleep_till_anykey): return int
* terms.c (sleep_till_anykey): return int
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | fm.h | 3 | ||||
-rw-r--r-- | image.c | 79 | ||||
-rw-r--r-- | main.c | 14 | ||||
-rw-r--r-- | proto.h | 4 | ||||
-rw-r--r-- | terms.c | 10 |
6 files changed, 51 insertions, 77 deletions
@@ -1,5 +1,21 @@ 2002-12-12 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03559] Re: use select instead of signal for loading images + * fm.h (Buffer): add image_loaded + * image.c (W3M_SIGIMG): deleted + (image_lock): deleted + (need_load_image): deleted + (load_image_handler): deleted + (load_image_next): deleted + (getAllImage): check image_loaded + (loadImage): delete image_lock + delete IMG_FLAG_NEXT + * main.c (main): check image_loaded + * proto.h (sleep_till_anykey): return int + * terms.c (sleep_till_anykey): return int + +2002-12-12 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03558] long title is displayed over tab region * display.c (redrawNLine): check l < 0 use addnstr @@ -5721,4 +5737,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.612 2002/12/11 15:03:06 ukai Exp $ +$Id: ChangeLog,v 1.613 2002/12/11 15:07:53 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.95 2002/12/10 15:51:14 ukai Exp $ */ +/* $Id: fm.h,v 1.96 2002/12/11 15:07:53 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -458,6 +458,7 @@ typedef struct _Buffer { char *ssl_certificate; #endif char image_flag; + char image_loaded; char need_reshape; Anchor *submit; struct _BufferPos *undo; @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.21 2002/11/27 16:46:34 ukai Exp $ */ +/* $Id: image.c,v 1.22 2002/12/11 15:07:53 ukai Exp $ */ #include "fm.h" #include <sys/types.h> @@ -12,10 +12,6 @@ #ifdef USE_IMAGE -#ifndef W3M_SIGIMG -#define W3M_SIGIMG (SIGUSR1) -#endif - static int image_index = 0; /* display image */ @@ -276,25 +272,6 @@ static Hash_sv *image_hash = NULL; static Hash_sv *image_file = NULL; static GeneralList *image_list = NULL; static ImageCache **image_cache = NULL; -static char *image_lock = NULL; -static int need_load_image = FALSE; - -static MySignalHandler -load_image_handler(SIGNAL_ARG) -{ - need_load_image = TRUE; - signal(W3M_SIGIMG, load_image_handler); - SIGNAL_RETURN; -} - -static MySignalHandler -load_image_next(SIGNAL_ARG) -{ - need_load_image = TRUE; - signal(W3M_SIGIMG, load_image_handler); - loadImage(IMG_FLAG_NEXT); - SIGNAL_RETURN; -} void deleteImage(Buffer *buf) @@ -328,13 +305,18 @@ getAllImage(Buffer *buf) if (!buf) return; + buf->image_loaded = TRUE; al = buf->img; if (!al) return; current = baseURL(buf); for (i = 0, a = al->anchors; i < al->nanchor; i++, a++) { - if (a->image) + if (a->image) { a->image->cache = getImage(a->image, current, buf->image_flag); + if (a->image->cache && + a->image->cache->loaded == IMG_FLAG_UNLOADED) + buf->image_loaded = FALSE; + } } } @@ -401,14 +383,11 @@ loadImage(int flag) } image_list = NULL; image_file = NULL; - if (image_lock) - unlink(image_lock); - need_load_image = FALSE; n_load_image = maxLoadImage; return; } - if (need_load_image) { + { int draw = FALSE; for (i = 0; i < n_load_image; i++) { cache = image_cache[i]; @@ -432,7 +411,7 @@ loadImage(int flag) if (!stat(cache->file, &st)) { cache->loaded = IMG_FLAG_LOADED; if (getImageSize(cache)) { - if (flag == IMG_FLAG_NEXT && CurrentTab && Currentbuf) + if (CurrentTab && Currentbuf) Currentbuf->need_reshape = TRUE; } draw = TRUE; @@ -442,17 +421,12 @@ loadImage(int flag) unlink(cache->touch); image_cache[i] = NULL; } - if (flag == IMG_FLAG_NEXT && draw) + if (draw && CurrentTab && Currentbuf) { drawImage(); - if (CurrentTab && Currentbuf) showImageProgress(Currentbuf); + } } - if (image_lock) - unlink(image_lock); - need_load_image = FALSE; - signal(W3M_SIGIMG, load_image_handler); - if (!image_list) return; for (i = 0; i < n_load_image; i++) { @@ -463,7 +437,7 @@ loadImage(int flag) if (!cache) { for (i = 0; i < n_load_image; i++) { if (image_cache[i]) - goto load_image_end; + return; } image_list = NULL; image_file = NULL; @@ -476,17 +450,9 @@ loadImage(int flag) } image_cache[i] = cache; - if (!image_lock) { - image_lock = tmpfname(TMPF_DFL, ".lock")->ptr; - pushText(fileToDelete, image_lock); - } - flush_tty(); if ((cache->pid = fork()) == 0) { Buffer *b; -#if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)) - FILE *f; -#endif reset_signals(); signal(SIGINT, SIG_IGN); close_tty(); @@ -498,21 +464,13 @@ loadImage(int flag) unlink(cache->file); #if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT) symlink(cache->file, cache->touch); - if (lstat(image_lock, &st)) { - if (symlink(cache->file, image_lock)) - exit(0); #else - f = fopen(cache->touch, "w"); - if (f) - fclose(f); - if (stat(image_lock, &st)) { - f = fopen(image_lock, "w"); - if (!f) - exit(0); - fclose(f); -#endif - kill(getppid(), W3M_SIGIMG); + { + FILE *f = fopen(cache->touch, "w"); + if (f) + fclose(f); } +#endif exit(0); } else if (cache->pid < 0) { @@ -520,9 +478,6 @@ loadImage(int flag) return; } } - load_image_end: - if (flag == IMG_FLAG_NEXT) - signal(W3M_SIGIMG, load_image_next); } ImageCache * @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.166 2002/12/10 15:53:03 ukai Exp $ */ +/* $Id: main.c,v 1.167 2002/12/11 15:07:53 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -1039,14 +1039,14 @@ main(int argc, char **argv, char **envp) signal(SIGWINCH, resize_handler); #endif #ifdef USE_IMAGE - if (activeImage && displayImage) - loadImage(IMG_FLAG_NEXT); + if (activeImage && displayImage && Currentbuf->img && + !Currentbuf->image_loaded) { + do { + loadImage(IMG_FLAG_NEXT); + } while (sleep_till_anykey(1, 0) <= 0); + } #endif c = getch(); -#ifdef USE_IMAGE - if (activeImage && displayImage) - loadImage(IMG_FLAG_START); -#endif #ifdef SIGWINCH signal(SIGWINCH, resize_hook); #endif @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.68 2002/12/10 15:51:15 ukai Exp $ */ +/* $Id: proto.h,v 1.69 2002/12/11 15:07:53 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -472,7 +472,7 @@ extern void flush_tty(void); extern void toggle_stand(void); extern char getch(void); extern void bell(void); -extern void sleep_till_anykey(int sec, int purge); +extern int sleep_till_anykey(int sec, int purge); #ifdef USE_IMAGE extern void touch_cursor(); #endif @@ -1,4 +1,4 @@ -/* $Id: terms.c,v 1.40 2002/12/04 16:38:54 ukai Exp $ */ +/* $Id: terms.c,v 1.41 2002/12/11 15:07:53 ukai Exp $ */ /* * An original curses library for EUC-kanji by Akinori ITO, December 1989 * revised by Akinori ITO, January 1995 @@ -1962,12 +1962,12 @@ skip_escseq(void) } } -void +int sleep_till_anykey(int sec, int purge) { fd_set rfd; struct timeval tim; - int er, c; + int er, c, ret; TerminalMode ioval; TerminalGet(tty, &ioval); @@ -1979,7 +1979,8 @@ sleep_till_anykey(int sec, int purge) FD_ZERO(&rfd); FD_SET(tty, &rfd); - if (select(tty + 1, &rfd, 0, 0, &tim) > 0 && purge) { + ret = select(tty + 1, &rfd, 0, 0, &tim); + if (ret > 0 && purge) { c = getch(); if (c == ESC_CODE) skip_escseq(); @@ -1989,6 +1990,7 @@ sleep_till_anykey(int sec, int purge) printf("Error occured: errno=%d\n", errno); reset_exit(SIGNAL_ARGLIST); } + return ret; } #ifdef USE_MOUSE |