[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>
This commit is contained in:
@@ -1,3 +1,19 @@
|
|||||||
|
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>
|
2002-12-12 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||||
|
|
||||||
* [w3m-dev 03558] long title is displayed over tab region
|
* [w3m-dev 03558] long title is displayed over tab region
|
||||||
@@ -5721,4 +5737,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-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
|
* w3m: WWW wo Miru utility
|
||||||
*
|
*
|
||||||
@@ -458,6 +458,7 @@ typedef struct _Buffer {
|
|||||||
char *ssl_certificate;
|
char *ssl_certificate;
|
||||||
#endif
|
#endif
|
||||||
char image_flag;
|
char image_flag;
|
||||||
|
char image_loaded;
|
||||||
char need_reshape;
|
char need_reshape;
|
||||||
Anchor *submit;
|
Anchor *submit;
|
||||||
struct _BufferPos *undo;
|
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 "fm.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -12,10 +12,6 @@
|
|||||||
|
|
||||||
#ifdef USE_IMAGE
|
#ifdef USE_IMAGE
|
||||||
|
|
||||||
#ifndef W3M_SIGIMG
|
|
||||||
#define W3M_SIGIMG (SIGUSR1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int image_index = 0;
|
static int image_index = 0;
|
||||||
|
|
||||||
/* display image */
|
/* display image */
|
||||||
@@ -276,25 +272,6 @@ static Hash_sv *image_hash = NULL;
|
|||||||
static Hash_sv *image_file = NULL;
|
static Hash_sv *image_file = NULL;
|
||||||
static GeneralList *image_list = NULL;
|
static GeneralList *image_list = NULL;
|
||||||
static ImageCache **image_cache = 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
|
void
|
||||||
deleteImage(Buffer *buf)
|
deleteImage(Buffer *buf)
|
||||||
@@ -328,13 +305,18 @@ getAllImage(Buffer *buf)
|
|||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return;
|
return;
|
||||||
|
buf->image_loaded = TRUE;
|
||||||
al = buf->img;
|
al = buf->img;
|
||||||
if (!al)
|
if (!al)
|
||||||
return;
|
return;
|
||||||
current = baseURL(buf);
|
current = baseURL(buf);
|
||||||
for (i = 0, a = al->anchors; i < al->nanchor; i++, a++) {
|
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);
|
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_list = NULL;
|
||||||
image_file = NULL;
|
image_file = NULL;
|
||||||
if (image_lock)
|
|
||||||
unlink(image_lock);
|
|
||||||
need_load_image = FALSE;
|
|
||||||
n_load_image = maxLoadImage;
|
n_load_image = maxLoadImage;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_load_image) {
|
{
|
||||||
int draw = FALSE;
|
int draw = FALSE;
|
||||||
for (i = 0; i < n_load_image; i++) {
|
for (i = 0; i < n_load_image; i++) {
|
||||||
cache = image_cache[i];
|
cache = image_cache[i];
|
||||||
@@ -432,7 +411,7 @@ loadImage(int flag)
|
|||||||
if (!stat(cache->file, &st)) {
|
if (!stat(cache->file, &st)) {
|
||||||
cache->loaded = IMG_FLAG_LOADED;
|
cache->loaded = IMG_FLAG_LOADED;
|
||||||
if (getImageSize(cache)) {
|
if (getImageSize(cache)) {
|
||||||
if (flag == IMG_FLAG_NEXT && CurrentTab && Currentbuf)
|
if (CurrentTab && Currentbuf)
|
||||||
Currentbuf->need_reshape = TRUE;
|
Currentbuf->need_reshape = TRUE;
|
||||||
}
|
}
|
||||||
draw = TRUE;
|
draw = TRUE;
|
||||||
@@ -442,17 +421,12 @@ loadImage(int flag)
|
|||||||
unlink(cache->touch);
|
unlink(cache->touch);
|
||||||
image_cache[i] = NULL;
|
image_cache[i] = NULL;
|
||||||
}
|
}
|
||||||
if (flag == IMG_FLAG_NEXT && draw)
|
if (draw && CurrentTab && Currentbuf) {
|
||||||
drawImage();
|
drawImage();
|
||||||
if (CurrentTab && Currentbuf)
|
|
||||||
showImageProgress(Currentbuf);
|
showImageProgress(Currentbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image_lock)
|
|
||||||
unlink(image_lock);
|
|
||||||
need_load_image = FALSE;
|
|
||||||
signal(W3M_SIGIMG, load_image_handler);
|
|
||||||
|
|
||||||
if (!image_list)
|
if (!image_list)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < n_load_image; i++) {
|
for (i = 0; i < n_load_image; i++) {
|
||||||
@@ -463,7 +437,7 @@ loadImage(int flag)
|
|||||||
if (!cache) {
|
if (!cache) {
|
||||||
for (i = 0; i < n_load_image; i++) {
|
for (i = 0; i < n_load_image; i++) {
|
||||||
if (image_cache[i])
|
if (image_cache[i])
|
||||||
goto load_image_end;
|
return;
|
||||||
}
|
}
|
||||||
image_list = NULL;
|
image_list = NULL;
|
||||||
image_file = NULL;
|
image_file = NULL;
|
||||||
@@ -476,17 +450,9 @@ loadImage(int flag)
|
|||||||
}
|
}
|
||||||
image_cache[i] = cache;
|
image_cache[i] = cache;
|
||||||
|
|
||||||
if (!image_lock) {
|
|
||||||
image_lock = tmpfname(TMPF_DFL, ".lock")->ptr;
|
|
||||||
pushText(fileToDelete, image_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
flush_tty();
|
flush_tty();
|
||||||
if ((cache->pid = fork()) == 0) {
|
if ((cache->pid = fork()) == 0) {
|
||||||
Buffer *b;
|
Buffer *b;
|
||||||
#if !(defined(HAVE_SYMLINK) && defined(HAVE_LSTAT))
|
|
||||||
FILE *f;
|
|
||||||
#endif
|
|
||||||
reset_signals();
|
reset_signals();
|
||||||
signal(SIGINT, SIG_IGN);
|
signal(SIGINT, SIG_IGN);
|
||||||
close_tty();
|
close_tty();
|
||||||
@@ -498,21 +464,13 @@ loadImage(int flag)
|
|||||||
unlink(cache->file);
|
unlink(cache->file);
|
||||||
#if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)
|
#if defined(HAVE_SYMLINK) && defined(HAVE_LSTAT)
|
||||||
symlink(cache->file, cache->touch);
|
symlink(cache->file, cache->touch);
|
||||||
if (lstat(image_lock, &st)) {
|
|
||||||
if (symlink(cache->file, image_lock))
|
|
||||||
exit(0);
|
|
||||||
#else
|
#else
|
||||||
f = fopen(cache->touch, "w");
|
{
|
||||||
if (f)
|
FILE *f = fopen(cache->touch, "w");
|
||||||
fclose(f);
|
if (f)
|
||||||
if (stat(image_lock, &st)) {
|
fclose(f);
|
||||||
f = fopen(image_lock, "w");
|
|
||||||
if (!f)
|
|
||||||
exit(0);
|
|
||||||
fclose(f);
|
|
||||||
#endif
|
|
||||||
kill(getppid(), W3M_SIGIMG);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (cache->pid < 0) {
|
else if (cache->pid < 0) {
|
||||||
@@ -520,9 +478,6 @@ loadImage(int flag)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
load_image_end:
|
|
||||||
if (flag == IMG_FLAG_NEXT)
|
|
||||||
signal(W3M_SIGIMG, load_image_next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageCache *
|
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
|
#define MAINPROGRAM
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -1039,14 +1039,14 @@ main(int argc, char **argv, char **envp)
|
|||||||
signal(SIGWINCH, resize_handler);
|
signal(SIGWINCH, resize_handler);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_IMAGE
|
#ifdef USE_IMAGE
|
||||||
if (activeImage && displayImage)
|
if (activeImage && displayImage && Currentbuf->img &&
|
||||||
loadImage(IMG_FLAG_NEXT);
|
!Currentbuf->image_loaded) {
|
||||||
|
do {
|
||||||
|
loadImage(IMG_FLAG_NEXT);
|
||||||
|
} while (sleep_till_anykey(1, 0) <= 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
c = getch();
|
c = getch();
|
||||||
#ifdef USE_IMAGE
|
|
||||||
if (activeImage && displayImage)
|
|
||||||
loadImage(IMG_FLAG_START);
|
|
||||||
#endif
|
|
||||||
#ifdef SIGWINCH
|
#ifdef SIGWINCH
|
||||||
signal(SIGWINCH, resize_hook);
|
signal(SIGWINCH, resize_hook);
|
||||||
#endif
|
#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.
|
* This file was automatically generated by version 1.7 of cextract.
|
||||||
* Manual editing not recommended.
|
* Manual editing not recommended.
|
||||||
@@ -472,7 +472,7 @@ extern void flush_tty(void);
|
|||||||
extern void toggle_stand(void);
|
extern void toggle_stand(void);
|
||||||
extern char getch(void);
|
extern char getch(void);
|
||||||
extern void bell(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
|
#ifdef USE_IMAGE
|
||||||
extern void touch_cursor();
|
extern void touch_cursor();
|
||||||
#endif
|
#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
|
* An original curses library for EUC-kanji by Akinori ITO, December 1989
|
||||||
* revised by Akinori ITO, January 1995
|
* revised by Akinori ITO, January 1995
|
||||||
@@ -1962,12 +1962,12 @@ skip_escseq(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
sleep_till_anykey(int sec, int purge)
|
sleep_till_anykey(int sec, int purge)
|
||||||
{
|
{
|
||||||
fd_set rfd;
|
fd_set rfd;
|
||||||
struct timeval tim;
|
struct timeval tim;
|
||||||
int er, c;
|
int er, c, ret;
|
||||||
TerminalMode ioval;
|
TerminalMode ioval;
|
||||||
|
|
||||||
TerminalGet(tty, &ioval);
|
TerminalGet(tty, &ioval);
|
||||||
@@ -1979,7 +1979,8 @@ sleep_till_anykey(int sec, int purge)
|
|||||||
FD_ZERO(&rfd);
|
FD_ZERO(&rfd);
|
||||||
FD_SET(tty, &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();
|
c = getch();
|
||||||
if (c == ESC_CODE)
|
if (c == ESC_CODE)
|
||||||
skip_escseq();
|
skip_escseq();
|
||||||
@@ -1989,6 +1990,7 @@ sleep_till_anykey(int sec, int purge)
|
|||||||
printf("Error occured: errno=%d\n", errno);
|
printf("Error occured: errno=%d\n", errno);
|
||||||
reset_exit(SIGNAL_ARGLIST);
|
reset_exit(SIGNAL_ARGLIST);
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_MOUSE
|
#ifdef USE_MOUSE
|
||||||
|
|||||||
Reference in New Issue
Block a user