diff -brcN xglk-virgin/Makefile xglk/Makefile *** xglk-virgin/Makefile Sat Apr 15 14:13:28 2000 --- xglk/Makefile Tue Sep 11 18:40:11 2001 *************** *** 37,44 **** # definitions for SGI / Irix #SYSTEMFLAGS = ! # definitions for Linux ! #SYSTEMFLAGS = # -------------------- --- 37,44 ---- # definitions for SGI / Irix #SYSTEMFLAGS = ! # definitions for Linux. _BSD_SOURCE may be necessary for struct timezone. ! SYSTEMFLAGS = -D_BSD_SOURCE # -------------------- *************** *** 58,65 **** #XLIB = -L/usr/X11R6/lib -lX11 # for Red Hat Linux ! XINCLUDE = -I/usr/X11R6/include/X11 ! XLIB = -L/usr/X11R6/lib -lX11 # for SparcStation / Solaris #XINCLUDE = -I/usr/openwin/include --- 58,65 ---- #XLIB = -L/usr/X11R6/lib -lX11 # for Red Hat Linux ! XINCLUDE = -I/usr/local/include -I/usr/X11R6/include/X11 ! XLIB = -L/usr/local/lib -L/usr/X11R6/lib -lX11 # for SparcStation / Solaris #XINCLUDE = -I/usr/openwin/include *************** *** 78,92 **** # If there is no JPEG lib available, uncomment this line. # JPEGFLAG = -DNO_JPEG_AVAILABLE # -------------------- # Pick a C compiler. #CC = cc CC = gcc ! CFLAGS = -O -ansi $(PNGFLAG) $(JPEGFLAG) $(PNGINCLUDE) $(JPEGINCLUDE) -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-unused -Wbad-function-cast $(SYSTEMFLAGS) $(XINCLUDE) LDFLAGS = ! LIBS = $(XLIB) $(PNGLIB) $(JPEGLIB) $(SYSTEMLIBS) OBJS = main.o xglk.o xglk_vars.o xglk_prefs.o xglk_loop.o xglk_init.o \ xglk_scrap.o xglk_msg.o xglk_key.o xglk_weggie.o xglk_pict.o \ --- 78,97 ---- # If there is no JPEG lib available, uncomment this line. # JPEGFLAG = -DNO_JPEG_AVAILABLE + # definitions for the MikMod library. + SDLINCLUDE = $(shell sdl-config --cflags) + SDLCFLAGS = \$$\(shell sdl-config --cflags\) + SDLLIB = \$$\(shell sdl-config --libs\) -lSDL_mixer + # -------------------- # Pick a C compiler. #CC = cc CC = gcc ! CFLAGS = -O -ansi $(PNGFLAG) $(JPEGFLAG) $(PNGINCLUDE) $(JPEGINCLUDE) $(SDLINCLUDE) -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-unused -Wbad-function-cast $(SYSTEMFLAGS) $(XINCLUDE) LDFLAGS = ! LIBS = $(XLIB) $(PNGLIB) $(JPEGLIB) $(SDLLIB) $(SYSTEMLIBS) OBJS = main.o xglk.o xglk_vars.o xglk_prefs.o xglk_loop.o xglk_init.o \ xglk_scrap.o xglk_msg.o xglk_key.o xglk_weggie.o xglk_pict.o \ diff -brcN xglk-virgin/xg_gestalt.c xglk/xg_gestalt.c *** xglk-virgin/xg_gestalt.c Mon Jul 10 21:04:16 2000 --- xglk/xg_gestalt.c Tue Sep 11 18:37:18 2001 *************** *** 91,97 **** case gestalt_SoundVolume: case gestalt_SoundNotify: case gestalt_SoundMusic: ! return FALSE; case gestalt_Hyperlinks: { return TRUE; --- 91,97 ---- case gestalt_SoundVolume: case gestalt_SoundNotify: case gestalt_SoundMusic: ! return TRUE; case gestalt_Hyperlinks: { return TRUE; diff -brcN xglk-virgin/xg_internal.h xglk/xg_internal.h *** xglk-virgin/xg_internal.h Wed Apr 12 19:51:23 2000 --- xglk/xg_internal.h Tue Sep 11 18:37:18 2001 *************** *** 1,7 **** --- 1,14 ---- #ifndef _XG_INTERNAL_H #define _XG_INTERNAL_H + #include #include + + #ifdef GLK_MODULE_SOUND + #include + #include + #endif + #include "gi_dispa.h" /* --- General declarations --- */ *************** *** 12,17 **** --- 19,25 ---- typedef struct glk_window_struct window_t; typedef struct glk_stream_struct stream_t; typedef struct glk_fileref_struct fileref_t; + typedef struct glk_schannel_struct channel_t; typedef struct stylehints_struct stylehints_t; extern int gli_special_typable_table[keycode_MAXVAL+1]; *************** *** 130,135 **** --- 138,173 ---- }; extern int init_gli_filerefs(void); + + /* --- Sound channels --- */ + + struct glk_schannel_struct { + glui32 rock; + + glui32 snd; + glui32 vol; + glui32 notify; + int channel; + + enum { + SCHANNEL_MUSIC, + SCHANNEL_SAMPLE + } type; + + union { + Mix_Music *music; + Mix_Chunk *sample; + } data; + + char filename[L_tmpnam]; + + gidispatch_rock_t disprock; + channel_t *chain_next, *chain_prev; + }; + + extern int init_gli_schannels(void); + extern void exit_gli_schannels(void); + extern Bool gli_eventloop_schannels(void); /* --- Styles --- */ diff -brcN xglk-virgin/xg_misc.c xglk/xg_misc.c *** xglk-virgin/xg_misc.c Sun Jun 6 11:07:45 1999 --- xglk/xg_misc.c Tue Sep 11 18:37:18 2001 *************** *** 123,128 **** --- 123,130 ---- (*func)(); } + exit_gli_schannels(); + exit(1); } *************** *** 133,138 **** --- 135,141 ---- window_t *win; stream_t *str; fileref_t *fref; + channel_t *chan; gli_register_obj = reg; gli_unregister_obj = unreg; *************** *** 155,160 **** --- 158,168 ---- fref = glk_fileref_iterate(fref, NULL)) { fref->disprock = (*gli_register_obj)(fref, gidisp_Class_Fileref); } + for (chan = glk_schannel_iterate(NULL, NULL); + chan; + chan = glk_schannel_iterate(chan, NULL)) { + chan->disprock = (*gli_register_obj)(chan, gidisp_Class_Schannel); + } } } *************** *** 176,181 **** --- 184,191 ---- return ((stream_t *)obj)->disprock; case gidisp_Class_Fileref: return ((fileref_t *)obj)->disprock; + case gidisp_Class_Schannel: + return ((channel_t *)obj)->disprock; default: { gidispatch_rock_t dummy; dummy.num = 0; diff -brcN xglk-virgin/xg_schan.c xglk/xg_schan.c *** xglk-virgin/xg_schan.c Wed Jul 21 17:49:01 1999 --- xglk/xg_schan.c Tue Sep 11 18:37:18 2001 *************** *** 1,61 **** #include #include #include "xglk.h" #include "xg_internal.h" ! /* The whole sound-channel situation is very simple for us; ! we don't support it. */ #ifdef GLK_MODULE_SOUND schanid_t glk_schannel_create(glui32 rock) { return NULL; } void glk_schannel_destroy(schanid_t chan) { } ! schanid_t glk_schannel_iterate(schanid_t chan, glui32 *rockptr) { ! if (rockptr) ! *rockptr = 0; return NULL; } ! glui32 glk_schannel_get_rock(schanid_t chan) { gli_strict_warning("schannel_get_rock: invalid id."); return 0; } glui32 glk_schannel_play(schanid_t chan, glui32 snd) { ! gli_strict_warning("schannel_play: invalid id."); ! return 0; } glui32 glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) { gli_strict_warning("schannel_play_ext: invalid id."); return 0; } void glk_schannel_stop(schanid_t chan) { gli_strict_warning("schannel_stop: invalid id."); } void glk_schannel_set_volume(schanid_t chan, glui32 vol) { gli_strict_warning("schannel_set_volume: invalid id."); } void glk_sound_load_hint(glui32 snd, glui32 flag) { ! gli_strict_warning("schannel_sound_load_hint: invalid id."); } #endif /* GLK_MODULE_SOUND */ --- 1,404 ---- #include #include + #include #include "xglk.h" #include "xg_internal.h" ! /* Sound support using SDL_mixer. AIFF support in SDL_mixer 1.2.0 does not ! * work, so we're going to need something more recent than that. Even then ! * samples may come out at slightly the wrong speed because SDL needs to ! * convert all sound data to a common frequency and it does so favoring speed ! * over accuracy. ! */ #ifdef GLK_MODULE_SOUND + #define DEBUG_MODULE_SOUND 1 + + #include "gi_blorb.h" + + void music_finished_hook(void); + + #define giblorb_ID_MOD (giblorb_make_id('M', 'O', 'D', ' ')) + #define giblorb_ID_FORM (giblorb_make_id('F', 'O', 'R', 'M')) + #define giblorb_ID_SONG (giblorb_make_id('S', 'O', 'N', 'G')) + + static channel_t *gli_channellist = NULL; + static Bool music_playing = FALSE; + + static void clear_channel(schanid_t chan) + { + if (!chan) + return; + + if (chan->filename[0] != '\0') { + unlink(chan->filename); + chan->filename[0] = '\0'; + } + + if (chan->type == SCHANNEL_MUSIC && chan->data.music != NULL) { + if (Mix_PlayingMusic()) + Mix_HaltMusic(); + Mix_FreeMusic(chan->data.music); + chan->data.music = NULL; + music_playing = FALSE; + } + + if (chan->type == SCHANNEL_SAMPLE && chan->data.sample != NULL) { + if (Mix_Playing(chan->channel)) + Mix_HaltChannel(chan->channel); + Mix_FreeChunk(chan->data.sample); + chan->data.sample = NULL; + } + } + + static void set_channel_volume(schanid_t chan, glui32 vol) + { + if (!chan) + return; + + if (chan->type == SCHANNEL_MUSIC && chan->data.music) + Mix_VolumeMusic((MIX_MAX_VOLUME * vol) / 0x10000); + + if (chan->type == SCHANNEL_SAMPLE && chan->data.sample) + Mix_Volume(chan->channel, (MIX_MAX_VOLUME * vol) / 0x10000); + } + + void music_finished_hook() + { + music_playing = FALSE; + #ifdef DEBUG_MODULE_SOUND + fprintf(stderr, "music_finished_hook()\n"); + #endif + } + + Bool gli_eventloop_schannels() + { + channel_t *chan = gli_channellist; + + while (chan) { + switch (chan->type) { + case SCHANNEL_MUSIC: + /* We cannot use Mix_PlayingMusic() to see if the music is playing + * because that will break repeating music. + */ + if (chan->data.music != NULL && !music_playing) { + #if DEBUG_MODULE_SOUND + fprintf(stderr, "Sound %ld (music) has stopped: notify %ld\n", + chan->snd, chan->notify); + #endif + clear_channel(chan); + if (chan->notify != 0) { + eventloop_setevent(evtype_SoundNotify, NULL, chan->snd, chan->notify); + chan->notify = 0; + return TRUE; + } + } + break; + + case SCHANNEL_SAMPLE: + if (chan->data.sample != NULL && !Mix_Playing(chan->channel)) { + #if DEBUG_MODULE_SOUND + fprintf(stderr, "Sound %ld (sample) has stopped: notify %ld\n", + chan->snd, chan->notify); + #endif + clear_channel(chan); + if (chan->notify != 0) { + eventloop_setevent(evtype_SoundNotify, NULL, chan->snd, chan->notify); + chan->notify = 0; + return TRUE; + } + } + break; + + default: + break; + } + chan = chan->chain_next; + } + return FALSE; + } + + int init_gli_schannels() + { + int audio_rate = 22050; + Uint16 audio_format = AUDIO_S16; + int audio_channels = 2; + int audio_buffers = 4096; + + if (SDL_Init(SDL_INIT_AUDIO) < 0) { + fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + return FALSE; + } + + if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, + audio_buffers) < 0) { + fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + return FALSE; + } + + /* As far as I understand, we will get one music channels and eight AIFF + * channels. We can't do anything about the number of music channels, but + * we could allocate more AIFF channels with Mix_AllocateChannels() + */ + + #if DEBUG_MODULE_SOUND + Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); + fprintf(stderr, "Opened audio at %d Hz %d bit %s\n", audio_rate, + (audio_format & 0xff), + (audio_channels > 1) ? "stereo" : "mono"); + #endif + + /* Notify when the music has stopped playing */ + Mix_HookMusicFinished(music_finished_hook); + + /* Set the external music player, if any */ + Mix_SetMusicCMD(getenv("MUSIC_CMD")); + + return TRUE; + } + + void exit_gli_schannels() + { + channel_t *chan = gli_channellist; + + while (chan) { + clear_channel(chan); + chan = chan->chain_next; + } + + Mix_CloseAudio(); + } + schanid_t glk_schannel_create(glui32 rock) { + channel_t *chan = (channel_t *)malloc(sizeof(channel_t)); + + if (!chan) return NULL; + + chan->rock = rock; + chan->vol = 0x10000; + + chan->chain_prev = NULL; + chan->chain_next = gli_channellist; + gli_channellist = chan; + if (chan->chain_next) { + chan->chain_next->chain_prev = chan; + } + + if (gli_register_obj) + chan->disprock = (*gli_register_obj)(chan, gidisp_Class_Schannel); + else + chan->disprock.ptr = NULL; + + return chan; } void glk_schannel_destroy(schanid_t chan) { + channel_t *prev, *next; + + if (!chan) { + gli_strict_warning("schannel_destroy: invalid id."); + return; + } + + if (gli_unregister_obj) + (*gli_unregister_obj)(chan, gidisp_Class_Schannel, chan->disprock); + + prev = chan->chain_prev; + next = chan->chain_next; + chan->chain_prev = NULL; + chan->chain_next = NULL; + + if (prev) + prev->chain_next = next; + else + gli_channellist = next; + if (next) + next->chain_prev = prev; + + clear_channel(chan); + free(chan); } ! channel_t *glk_schannel_iterate(schanid_t chan, glui32 *rock) { ! if (!chan) { ! chan = gli_channellist; ! } else { ! chan = chan->chain_next; ! } ! ! if (chan) { ! if (rock) ! *rock = chan->rock; ! return chan; ! } ! ! if (rock) ! *rock = 0; return NULL; } ! glui32 glk_schannel_get_rock(channel_t *chan) { + if (!chan) { gli_strict_warning("schannel_get_rock: invalid id."); return 0; + } + return chan->rock; } glui32 glk_schannel_play(schanid_t chan, glui32 snd) { ! /* Error messages will be slightly wrong, but I'm lazy... */ ! return glk_schannel_play_ext(chan, snd, 1, 0); } glui32 glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) { + FILE *fl, *tmpfl; + long pos, remaining, expected, read_len; + glui32 chunktype; + unsigned char filebuf[BUFSIZ]; + + #if DEBUG_MODULE_SOUND + fprintf(stderr, "play snd %ld (notify %ld, loop %ld)\n", + snd, notify, repeats); + #endif + + if (!chan) { gli_strict_warning("schannel_play_ext: invalid id."); return 0; + } + + clear_channel(chan); + + if (repeats == 0) + return 1; + + /* TODO: Allow picture_find()-style reading (and caching?) */ + if (!xres_is_resource_map()) { + gli_strict_warning("schannel_play_ext: no resource map."); + return 0; + } + + xres_get_resource(giblorb_ID_Snd, snd, &fl, &pos, &remaining, &chunktype); + + if (!fl) { + gli_strict_warning("schannel_play_ext: internal error - no file pointer."); + return 0; + } + + fseek(fl, pos, 0); + + /* TODO: Better temp-file handling. This is supposedly not quite secure. */ + if (tmpnam(chan->filename) == NULL) { + gli_strict_warning("schannel_play_ext: tmpnam failed."); + return 0; + } + + tmpfl = fopen(chan->filename, "wb"); + if (tmpfl == NULL) { + gli_strict_warning("schannel_play_ext: could not create temporary file."); + return 0; + } + + while (remaining > 0) { + expected = (remaining < BUFSIZ) ? remaining : BUFSIZ; + read_len = fread(filebuf, 1, expected, fl); + + if (read_len != expected) { + gli_strict_warning("schannel_play_ext: unexpected end-of-file."); + remaining = 0; + } + + fwrite(filebuf, 1, read_len, tmpfl); + remaining -= read_len; + } + + fclose(tmpfl); + + chan->snd = snd; + chan->notify = notify; + + switch (chunktype) { + case giblorb_ID_MOD: + if (Mix_PlayingMusic()) { + gli_strict_warning("schannel_play_ext: music is already playing."); + unlink(chan->filename); + return 0; + } + + chan->type = SCHANNEL_MUSIC; + chan->data.music = Mix_LoadMUS(chan->filename); + if (chan->data.music == NULL) { + gli_strict_warning("schannel_play_ext: Mix_LoadMUS() failure."); + return 0; + } + if (Mix_PlayMusic(chan->data.music, repeats) == -1) { + gli_strict_warning("schannel_play_ext: Mix_PlayMusic() failure."); + Mix_FreeMusic(chan->data.music); + chan->data.music = NULL; + return 0; + } + music_playing = TRUE; + break; + + case giblorb_ID_FORM: + chan->type = SCHANNEL_SAMPLE; + chan->data.sample = Mix_LoadWAV(chan->filename); + if (chan->data.sample == NULL) { + gli_strict_warning("schannel_play_ext: Mix_LoadWAV() failure."); + return 0; + } + chan->channel = Mix_PlayChannel(-1, chan->data.sample, + (repeats == -1) ? -1 : repeats - 1); + if (chan->channel == -1) { + gli_strict_warning("schannel_play_ext: Mix_PlayChannel() failure."); + Mix_FreeChunk(chan->data.sample); + chan->data.sample = NULL; + return 0; + } + break; + + case giblorb_ID_SONG: + gli_strict_warning("schannel_play_ext: sound type 'SONG' is not supported."); + unlink(chan->filename); + return 0; + } + + set_channel_volume(chan, chan->vol); + return 1; } void glk_schannel_stop(schanid_t chan) { + if (!chan) { gli_strict_warning("schannel_stop: invalid id."); + return; + } + + clear_channel(chan); } void glk_schannel_set_volume(schanid_t chan, glui32 vol) { + if (!chan) { gli_strict_warning("schannel_set_volume: invalid id."); + return; + } + + chan->vol = vol; + set_channel_volume(chan, vol); } void glk_sound_load_hint(glui32 snd, glui32 flag) { ! /* I doubt this will make much difference, so make it a no-op for now. */ } #endif /* GLK_MODULE_SOUND */ diff -brcN xglk-virgin/xg_win_textbuf.c xglk/xg_win_textbuf.c *** xglk-virgin/xg_win_textbuf.c Sat Apr 15 15:00:49 2000 --- xglk/xg_win_textbuf.c Wed Sep 19 09:36:39 2001 *************** *** 1580,1585 **** --- 1580,1591 ---- { window_textbuffer_t *dwin = win->data; + /* If a zero-line window is paging, we'll never get to the end of it. */ + if (dwin->linesonpage <= 1) { + gli_strict_warning("win_textbuffer_is_paging: would have scrolled zero lines"); + return FALSE; + } + if (dwin->lastseenline < dwin->numlines - dwin->linesonpage) { /* this is wrong -- linesonpage doesn't correctly measure lines at the end. */ diff -brcN xglk-virgin/xglk.c xglk/xglk.c *** xglk-virgin/xglk.c Wed Apr 12 22:00:50 2000 --- xglk/xglk.c Tue Sep 11 18:37:18 2001 *************** *** 58,63 **** --- 58,65 ---- return FALSE; if (!init_gli_filerefs()) return FALSE; + if (!init_gli_schannels()) + return FALSE; if (!init_gli_windows()) return FALSE; diff -brcN xglk-virgin/xglk_loop.c xglk/xglk_loop.c *** xglk-virgin/xglk_loop.c Sun Jun 6 11:07:45 1999 --- xglk/xglk_loop.c Tue Sep 11 18:37:18 2001 *************** *** 1,4 **** --- 1,5 ---- #include + #include #include #include #include *************** *** 17,30 **** void xglk_event_poll(event_t *ev, glui32 millisec) { struct timeval tv, curtime, outtime; - struct timezone tz; /* just check for a timer event, nothing else. */ eventloop_event = ev; if (millisec) { if (lasttime.tv_sec == 0) ! gettimeofday(&lasttime, &tz); outtime.tv_sec = lasttime.tv_sec + (millisec/1000); outtime.tv_usec = lasttime.tv_usec + ((millisec%1000)*1000); if (outtime.tv_usec >= 1000000) { --- 18,30 ---- void xglk_event_poll(event_t *ev, glui32 millisec) { struct timeval tv, curtime, outtime; /* just check for a timer event, nothing else. */ eventloop_event = ev; if (millisec) { if (lasttime.tv_sec == 0) ! gettimeofday(&lasttime, NULL); outtime.tv_sec = lasttime.tv_sec + (millisec/1000); outtime.tv_usec = lasttime.tv_usec + ((millisec%1000)*1000); if (outtime.tv_usec >= 1000000) { *************** *** 34,40 **** } if (millisec) { ! gettimeofday(&curtime, &tz); if (curtime.tv_sec > outtime.tv_sec || (curtime.tv_sec == outtime.tv_sec && curtime.tv_usec > outtime.tv_usec)) { --- 34,40 ---- } if (millisec) { ! gettimeofday(&curtime, NULL); if (curtime.tv_sec > outtime.tv_sec || (curtime.tv_sec == outtime.tv_sec && curtime.tv_usec > outtime.tv_usec)) { *************** *** 61,74 **** int eventp; int firsttime = TRUE; struct timeval tv, curtime, outtime; - struct timezone tz; eventloop_event = ev; xglk_perform_click(mouse_Reset, NULL, 0, 0); if (millisec) { if (lasttime.tv_sec == 0) ! gettimeofday(&lasttime, &tz); outtime.tv_sec = lasttime.tv_sec + (millisec/1000); outtime.tv_usec = lasttime.tv_usec + ((millisec%1000)*1000); if (outtime.tv_usec >= 1000000) { --- 61,73 ---- int eventp; int firsttime = TRUE; struct timeval tv, curtime, outtime; eventloop_event = ev; xglk_perform_click(mouse_Reset, NULL, 0, 0); if (millisec) { if (lasttime.tv_sec == 0) ! gettimeofday(&lasttime, NULL); outtime.tv_sec = lasttime.tv_sec + (millisec/1000); outtime.tv_usec = lasttime.tv_usec + ((millisec%1000)*1000); if (outtime.tv_usec >= 1000000) { *************** *** 79,90 **** while (ev->type == evtype_None) { if (xio_any_invalid) { xglk_redraw(); } if (millisec && !firsttime) { ! gettimeofday(&curtime, &tz); if (curtime.tv_sec > outtime.tv_sec || (curtime.tv_sec == outtime.tv_sec && curtime.tv_usec > outtime.tv_usec)) { --- 78,92 ---- while (ev->type == evtype_None) { + if (gli_eventloop_schannels()) + continue; + if (xio_any_invalid) { xglk_redraw(); } if (millisec && !firsttime) { ! gettimeofday(&curtime, NULL); if (curtime.tv_sec > outtime.tv_sec || (curtime.tv_sec == outtime.tv_sec && curtime.tv_usec > outtime.tv_usec)) { diff -brcN xglk-virgin/xglk_msg.c xglk/xglk_msg.c *** xglk-virgin/xglk_msg.c Wed Apr 12 20:31:54 2000 --- xglk/xglk_msg.c Tue Sep 11 18:36:39 2001 *************** *** 25,32 **** int init_xmsg() { - struct timezone tz; - message_size = 80; message = (char *)malloc(message_size * sizeof(char)); if (!message) --- 25,30 ---- *************** *** 36,42 **** LIBRARYNAME, LIBRARYVERSION); messagelen = strlen(message); messagesticky = FALSE; ! gettimeofday(&messagetime, &tz); messagetime.tv_sec += TIMEOUT; return TRUE; --- 34,40 ---- LIBRARYNAME, LIBRARYVERSION); messagelen = strlen(message); messagesticky = FALSE; ! gettimeofday(&messagetime, NULL); messagetime.tv_sec += TIMEOUT; return TRUE; *************** *** 104,111 **** void xmsg_set_message(char *str, int sticky) { - struct timezone tz; - if (!message) return; if (!str) --- 102,107 ---- *************** *** 121,139 **** xmsg_redraw(); messagesticky = sticky; ! gettimeofday(&messagetime, &tz); messagetime.tv_sec += TIMEOUT; } void xmsg_check_timeout() { - struct timezone tz; struct timeval tv; if (messagesticky) return; ! gettimeofday(&tv, &tz); if (tv.tv_sec > messagetime.tv_sec || (tv.tv_sec == messagetime.tv_sec && tv.tv_usec > messagetime.tv_usec)) { xmsg_set_message(NULL, TRUE); --- 117,134 ---- xmsg_redraw(); messagesticky = sticky; ! gettimeofday(&messagetime, NULL); messagetime.tv_sec += TIMEOUT; } void xmsg_check_timeout() { struct timeval tv; if (messagesticky) return; ! gettimeofday(&tv, NULL); if (tv.tv_sec > messagetime.tv_sec || (tv.tv_sec == messagetime.tv_sec && tv.tv_usec > messagetime.tv_usec)) { xmsg_set_message(NULL, TRUE); diff -brcN xglk-virgin/xglk_pict.c xglk/xglk_pict.c *** xglk-virgin/xglk_pict.c Thu Aug 26 13:42:12 1999 --- xglk/xglk_pict.c Tue Sep 11 18:36:50 2001 *************** *** 305,311 **** channels = cinfo.output_components; destdepth = xiodepth; ! destrowbytes = (width * destdepth + 7) / 8; if (destrowbytes & 31) destrowbytes = (destrowbytes | 31) + 1; destdata = malloc(destrowbytes * height); --- 305,311 ---- channels = cinfo.output_components; destdepth = xiodepth; ! destrowbytes = (width * ((destdepth==24)?32:destdepth) + 7) / 8; if (destrowbytes & 31) destrowbytes = (destrowbytes | 31) + 1; destdata = malloc(destrowbytes * height); *************** *** 406,412 **** channels = png_get_channels(png_ptr, info_ptr); destdepth = xiodepth; ! destrowbytes = (width * destdepth + 7) / 8; if (destrowbytes & 31) destrowbytes = (destrowbytes | 31) + 1; destdata = malloc(destrowbytes * height); --- 406,412 ---- channels = png_get_channels(png_ptr, info_ptr); destdepth = xiodepth; ! destrowbytes = (width * ((destdepth==24)?32:destdepth) + 7) / 8; if (destrowbytes & 31) destrowbytes = (destrowbytes | 31) + 1; destdata = malloc(destrowbytes * height); *************** *** 712,718 **** destptr[gsb] = srcptr[0]; destptr[bsb] = srcptr[0]; srcptr += channels; ! destptr += 3; } srcrowptr += srcrowbytes; destrowptr += destrowbytes; --- 712,718 ---- destptr[gsb] = srcptr[0]; destptr[bsb] = srcptr[0]; srcptr += channels; ! destptr += 4; } srcrowptr += srcrowbytes; destrowptr += destrowbytes; *************** *** 727,733 **** destptr[gsb] = srcptr[1]; destptr[bsb] = srcptr[2]; srcptr += channels; ! destptr += 3; } srcrowptr += srcrowbytes; destrowptr += destrowbytes; --- 727,733 ---- destptr[gsb] = srcptr[1]; destptr[bsb] = srcptr[2]; srcptr += channels; ! destptr += 4; } srcrowptr += srcrowbytes; destrowptr += destrowbytes; *************** *** 896,902 **** int destiptr, srciptr; int *rowmap; ! destrowbytes = (destwidth * depth + 7) / 8; if (destrowbytes & 31) destrowbytes = (destrowbytes | 31) + 1; destdata = (unsigned char *)malloc(destrowbytes * destheight); --- 896,902 ---- int destiptr, srciptr; int *rowmap; ! destrowbytes = (destwidth * ((depth==24)?32:depth) + 7) / 8; if (destrowbytes & 31) destrowbytes = (destrowbytes | 31) + 1; destdata = (unsigned char *)malloc(destrowbytes * destheight); *************** *** 938,944 **** destiptr += 2; } } ! else if (depth == 32) { for (ix=0; ix