/* -*-C-*-
-$Id: ntgui.c,v 1.8 1993/09/03 17:56:44 gjr Exp $
+$Id: ntgui.c,v 1.9 1993/09/04 07:03:43 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
promotional, or sales literature without prior written consent from
MIT in each case. */
+#include <string.h>
+#include <stdarg.h>
#include "scheme.h"
#include "prims.h"
-#include "nt.h"
#include "os.h"
+#include "nt.h"
+#include "ntdialog.h"
#include "ntgui.h"
#include "ntscreen.h"
-#include "ntdialog.h"
-#include <string.h>
-#include <stdarg.h>
\f
extern /*static*/ HANDLE ghInstance = 0;
}
\f
extern HANDLE master_tty_window;
+extern void catatonia_trigger (void);
+
+void
+catatonia_trigger (void)
+{
+ if ((MessageBox (master_tty_window,
+ "Scheme appears to have become catatonic.\n"
+ "OK to kill it?",
+ "MIT Scheme",
+ (MB_ICONSTOP | MB_OKCANCEL)))
+ == IDOK)
+ {
+ extern void termination_normal (int);
+ termination_normal (0);
+ }
+ else
+ {
+ Registers[REGBLOCK_CATATONIA_COUNTER] = 0;
+ return;
+ }
+}
static void
nt_gui_high_priority_poll (void)
{
MSG close_msg;
- if (PeekMessage (&close_msg,
- master_tty_window,
-#if 0
- WM_HOTKEY,
- (WM_HOTKEY + 1),
-#else
- WM_CLOSE,
- (WM_CLOSE + 1),
-#endif
+ if (PeekMessage (&close_msg, master_tty_window,
+ WM_CATATONIC, (WM_CATATONIC + 1),
PM_REMOVE))
{
MIT_TranslateMessage (&close_msg);
}
return;
}
-
+\f
DEFINE_PRIMITIVE ("MICROCODE-POLL-INTERRUPT-HANDLER",
Prim_microcode_poll_interrupt_handler, 2, 2,
"NT High-priority timer interrupt handler for Windows I/O.")
}
else
{
+ Registers[REGBLOCK_CATATONIA_COUNTER] = 0;
nt_gui_default_poll ();
#ifndef USE_WM_TIMER
low_level_timer_tick ();
}
}
+extern void EXFUN (NT_gui_init, (void));
+
void
DEFUN_VOID (NT_gui_init)
{
/* -*-C-*-
-$Id: ntgui.h,v 1.3 1993/06/24 02:14:39 gjr Exp $
+$Id: ntgui.h,v 1.4 1993/09/04 07:04:23 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
#ifndef SCM_NTGUI_H
#define SCM_NTGUI_H
\f
-void EXFUN (NT_gui_init, (void));
-
#define IDM_NEW 100
#define IDM_OPEN 101
#define IDM_SAVE 102
#define IDM_ABOUT 303
#define IDM_EMERGENCYKILL 400
+#ifndef REGBLOCK_CATATONIA_COUNTER
+/* They must be contiguous, with counter being lower. */
+# define REGBLOCK_CATATONIA_COUNTER REGBLOCK_MINIMUM_LENGTH
+# define REGBLOCK_CATATONIA_LIMIT (REGBLOCK_MINIMUM_LENGTH + 1)
+#endif
+
+#define WM_CATATONIC (WM_USER)
+
#endif /* SCM_NTGUI_H */
/* -*-C-*-
-$Id: ntscmlib.h,v 1.2 1993/08/21 03:38:52 gjr Exp $
+$Id: ntscmlib.h,v 1.3 1993/09/04 07:01:36 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
unsigned long); /* size */
extern UINT
- win32_install_async_timer (unsigned long *, /* regs */
+ win32_install_async_timer (void **, /* timer state */
+ unsigned long *, /* regs */
unsigned long, /* memtop off */
unsigned long, /* int_code off */
unsigned long, /* int_mask off */
unsigned long, /* mask */
- void **); /* timer state */
+ unsigned long, /* ctr_off */
+ unsigned long, /* message */
+ HWND); /* window */
+
extern void
win32_flush_async_timer (void *);
#define NTW32LIB_INSTALL_TIMER 3
struct ntw32lib_itimer_s
{
+ SCM_ULONG handle; /* ->32 */
SCM_ULPTR base; /* ->16 */
SCM_ULONG memtop_off; /* ->16 */
SCM_ULONG int_code_off; /* ->16 */
SCM_ULONG int_mask_off; /* ->16 */
SCM_ULONG bit_mask; /* ->16 */
- SCM_ULONG handle; /* ->32 */
+ SCM_ULONG ctr_off; /* ->16 */
+ SCM_ULONG message; /* ->16 */
+ SCM_ULONG window; /* ->16 */
};
#define NTW32LIB_FLUSH_TIMER 4
/* -*-C-*-
-$Id: ntscreen.c,v 1.14 1993/09/03 18:01:28 gjr Exp $
+$Id: ntscreen.c,v 1.15 1993/09/04 07:06:52 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
#include <stdlib.h>
#include "ntscreen.h"
+#include "ntgui.h"
//#include "screen.rh"
/* Allow conditionalization for underlying OS. */
extern BOOL win32_under_win32s_p (void);
DestroyScreenInfo (hWnd);
break ;
+ case WM_CATATONIC:
+ {
+ extern void catatonia_trigger (void);
+ catatonia_trigger ();
+ break;
+ }
+
case WM_CLOSE:
{
extern HANDLE master_tty_window;
/* -*-C-*-
-$Id: ntscreen.h,v 1.7 1993/09/03 17:57:40 gjr Exp $
+$Id: ntscreen.h,v 1.8 1993/09/04 07:06:11 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
//---------------------------------------------------------------------------
#ifndef SCREEN_COMMAND_FIRST
-#define SCREEN_COMMAND_FIRST WM_USER
+#define SCREEN_COMMAND_FIRST (WM_USER + 10)
#endif
#define SCREEN_WRITE (SCREEN_COMMAND_FIRST+0)
/* -*-C-*-
-$Id: ntsig.c,v 1.9 1993/09/03 18:02:29 gjr Exp $
+$Id: ntsig.c,v 1.10 1993/09/04 07:08:22 gjr Exp $
Copyright (c) 1992-1993 Massachusetts Institute of Technology
*/
#include "scheme.h"
-#include "nt.h"
-#include <signal.h>
+#include "critsec.h"
#include "ossig.h"
#include "osctty.h"
#include "ostty.h"
-#include "critsec.h"
-#include "ntsys.h"
+#include "nt.h"
+#include "ntgui.h"
#include "ntio.h"
-#include "extern.h"
-#include "ntscreen.h"
#include "ntscmlib.h"
+#include "ntscreen.h"
+#include "ntsys.h"
+
+extern HANDLE master_tty_window;
\f
/* Signal mask manipulation */
static void
DEFUN_VOID (update_interrupt_characters)
{
- extern HANDLE master_tty_window;
int i;
for (i = 0; i < KB_INT_TABLE_SIZE; i++)
return;
}
\f
-/* Timer interrupt */
+/* System-level timer interrupt */
-/* Why does this raise INT_Timer as well?
- We could request an synchronous Windows timer that would trigger
- the timer interrupt bit. -- This does not seem to work!
-
- INT_Global_GC: High-priority Windows polling interrupt.
+/* INT_Global_GC: High-priority Windows polling interrupt.
INT_Global_1: Windows polling interrupt.
- INT_Timer: Thread-switch timer interrupt.
*/
+#define CATATONIA_PERIOD 60000 /* msec */
+#define ASYNC_TIMER_PERIOD 50 /* msec */
+
static void * timer_state = ((void *) NULL);
static char *
DEFUN_VOID (install_timer)
{
- switch (win32_install_async_timer (&Registers[0],
+ Registers[REGBLOCK_CATATONIA_COUNTER] = 0;
+ Registers[REGBLOCK_CATATONIA_LIMIT]
+ = (CATATONIA_PERIOD / ASYNC_TIMER_PERIOD);
+ switch (win32_install_async_timer (&timer_state,
+ &Registers[0],
REGBLOCK_MEMTOP,
REGBLOCK_INT_CODE,
REGBLOCK_INT_MASK,
- (INT_Global_GC
- | INT_Global_1),
- &timer_state))
+ (INT_Global_GC | INT_Global_1),
+ REGBLOCK_CATATONIA_COUNTER,
+ WM_CATATONIC,
+ master_tty_window))
{
case WIN32_ASYNC_TIMER_OK:
return (NULL);
/* -*-C-*-
-$Id: nttop.c,v 1.9 1993/09/03 18:04:32 gjr Exp $
+$Id: nttop.c,v 1.10 1993/09/04 07:08:54 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
MIT in each case. */
#include "nt.h"
-#include "ntgui.h"
#include "nttop.h"
#include "osctty.h"
#include "prims.h"
extern void EXFUN (execute_reload_cleanups, (void));
+extern void EXFUN (NT_gui_init, (void));
extern void EXFUN (NT_initialize_channels, (void));
extern void EXFUN (NT_initialize_directory_reader, (void));
extern void EXFUN (NT_initialize_signals, (void));
### -*- Fundamental -*-
###
-### $Id: makefile,v 1.11 1993/09/03 17:50:09 gjr Exp $
+### $Id: makefile,v 1.12 1993/09/04 06:59:05 gjr Exp $
###
### Copyright (c) 1992-1993 Massachusetts Institute of Technology
###
ntenv.obj : scheme.tch osenv.h ntscreen.h $(NT_DEPENDENCIES)
ntfile.obj : osfile.h osio.h ntio.h $(NT_DEPENDENCIES)
ntfs.obj : osfs.h $(NT_DEPENDENCIES)
-ntio.obj : osio.h ntio.h $(NT_DEPENDENCIES)
+ntio.obj : osio.h ntio.h ntscreen.h $(NT_DEPENDENCIES)
nttop.obj : ostop.h nttop.h osctty.h errors.h option.h $(NT_DEPENDENCIES)
nttty.obj : ostty.h osenv.h osio.h ntio.h osterm.h ntterm.h $(NT_DEPENDENCIES)
-ntsig.obj : ossig.h osctty.h ostty.h critsec.h $(NT_DEPENDENCIES) ntscmlib.h
+ntsig.obj : ossig.h osctty.h ostty.h critsec.h \
+ $(NT_DEPENDENCIES) ntgui.h ntio.h ntscmlib.h ntscreen.h
nttrap.obj: nttrap.h ntscmlib.h $(GC_HEAD_FILES) $(NT_DEPENDENCIES)
ntsys.obj: ntsys.h
-ntgui.obj : ntgui.c ntdialog.h ntscreen.h $(NT_DEPENDENCIES) scheme.tch
+ntgui.obj : ntgui.c ntdialog.h ntgui.h ntscreen.h $(NT_DEPENDENCIES) scheme.tch
ntasutl.obj : ntasutl.asm
ntkbutl.obj : ntkbutl.asm
-ntscreen.obj : ntscreen.c ntscreen.h
+ntscreen.obj : ntscreen.c ntgui.h ntscreen.h
prntenv.obj : $(NT_DEPENDENCIES)
prntfs.obj : $(NT_DEPENDENCIES) scheme.tch prims.h osfs.h
prntio.obj : $(NT_DEPENDENCIES) scheme.tch prims.h ntio.h osio.h syscall.h
/* -*-C-*-
-$Id: scheme16.c,v 1.4 1993/08/24 04:53:32 gjr Exp $
+$Id: scheme16.c,v 1.5 1993/09/04 06:59:59 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
static WORD htimer = 0;
static unsigned long timer_index = 0;
-
static WORD (FAR PASCAL * KillSystemTimer) (WORD htimer);
static struct ntw16lib_itimer_s
{
struct ntw16lib_itimer_s FAR * next;
+ unsigned long index;
unsigned long FAR * base;
unsigned long memtop_off;
unsigned long int_code_off;
unsigned long int_mask_off;
unsigned long bit_mask;
- unsigned long index;
+ unsigned long ctr_off;
+ UINT message;
+ HWND window;
UINT selector;
HGLOBAL ghan;
} FAR * async_timers = ((struct ntw16lib_itimer_s FAR *) NULL);
& scm_timer->bit_mask)
!= 0)
scm_timer->base[scm_timer->memtop_off] = ((unsigned long) -1L);
+ scm_timer->base[scm_timer->ctr_off] += 1L;
+ if ((scm_timer->base[scm_timer->ctr_off]
+ > scm_timer->base[scm_timer->ctr_off + 1])
+ && (scm_timer->base[scm_timer->ctr_off + 1] != 0))
+ {
+ PostMessage (scm_timer->window,
+ scm_timer->message,
+ ((WPARAM) 0),
+ ((LPARAM) 0));
+ scm_timer->base[scm_timer->ctr_off] = 0L;
+ }
scm_timer = scm_timer->next;
}
return;
}
-
+\f
static void
scheme_asynctimer_end (void)
{
return;
}
-\f
+
static void
possibly_uninstall_async_handler (void)
{
return (WIN32_ASYNC_TIMER_NOLDT);
}
- scm_timer->ghan = ghan;
+ scm_timer->next = async_timers;
+ scm_timer->index = timer_index++;
scm_timer->base = (MK_FP (scm_timer->selector, (FP_OFF (buf->base))));
scm_timer->memtop_off = buf->memtop_off;
scm_timer->int_code_off = buf->int_code_off;
scm_timer->int_mask_off = buf->int_mask_off;
scm_timer->bit_mask = buf->bit_mask;
- scm_timer->index = timer_index++;
- scm_timer->next = async_timers;
+ scm_timer->ctr_off = buf->ctr_off;
+ scm_timer->message = ((UINT) buf->message);
+ scm_timer->window = ((HWND) buf->window);
+ scm_timer->ghan = ghan;
buf->handle = scm_timer->index;
async_timers = scm_timer;
/* -*-C-*-
-$Id: scheme31.c,v 1.3 1993/08/24 04:51:20 gjr Exp $
+$Id: scheme31.c,v 1.4 1993/09/04 07:00:37 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
}
\f
UINT
-win32_install_async_timer (unsigned long * base,
+win32_install_async_timer (void ** state_ptr,
+ unsigned long * base,
unsigned long memtop_off,
unsigned long int_code_off,
unsigned long int_mask_off,
unsigned long bit_mask,
- void ** state_ptr)
+ unsigned long ctr_off,
+ unsigned long message,
+ HWND window)
{
struct ntw32lib_itimer_s param;
LPVOID translation[2];
param.int_code_off = ((SCM_ULONG) int_code_off);
param.int_mask_off = ((SCM_ULONG) int_mask_off);
param.bit_mask = ((SCM_ULONG) bit_mask);
+ param.ctr_off = ((SCM_ULONG) ctr_off);
+ param.message = ((SCM_ULONG) message);
+ param.window = ((SCM_ULONG) window);
translation[0] = ((LPVOID) & param.base);
translation[1] = ((LPVOID) NULL);
/* -*-C-*-
-$Id: scheme32.c,v 1.4 1993/09/03 17:50:59 gjr Exp $
+$Id: scheme32.c,v 1.5 1993/09/04 07:01:12 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
unsigned long int_code_off;
unsigned long int_mask_off;
unsigned long bit_mask;
+ unsigned long ctr_off;
+ unsigned long message;
+ HWND window;
};
static void _stdcall
& timer_closure->bit_mask)
!= 0)
timer_closure->block[timer_closure->memtop_off] = ((unsigned long) -1);
+ timer_closure->block[timer_closure->ctr_off] += 1;
+ if ((timer_closure->block[timer_closure->ctr_off]
+ > timer_closure->block[timer_closure->ctr_off + 1])
+ && (timer_closure->block[timer_closure->ctr_off + 1] != 0))
+ {
+ PostMessage (timer_closure->window,
+ timer_closure->message,
+ ((WPARAM) 0),
+ ((LPARAM) 0));
+ timer_closure->block[timer_closure->ctr_off] = 0;
+ }
return;
}
}
\f
UINT
-win32_install_async_timer (unsigned long * block,
+win32_install_async_timer (void ** state_ptr,
+ unsigned long * block,
unsigned long memtop_off,
unsigned long int_code_off,
unsigned long int_mask_off,
unsigned long bit_mask,
- void ** state_ptr)
+ unsigned long ctr_off,
+ unsigned long message,
+ HWND window)
{
TIMECAPS tc;
UINT wTimerRes;
if (timer_closure == ((struct win32_timer_closure_s *) NULL))
return (WIN32_ASYNC_TIMER_NOMEM);
+ timer_closure->timer_id = 0;
timer_closure->block = block;
timer_closure->memtop_off = memtop_off;
timer_closure->int_code_off = int_code_off;
timer_closure->int_mask_off = int_mask_off;
timer_closure->bit_mask = bit_mask;
- timer_closure->timer_id = 0;
+ timer_closure->ctr_off = ctr_off;
+ timer_closure->message = message;
+ timer_closure->window = window;
if ((! (VirtualLock (((void *) timer_closure),
(sizeof (struct win32_timer_closure_s)))))