]> code.delx.au - gnu-emacs/blobdiff - src/w32xfns.c
(interrupt_handle): New variable.
[gnu-emacs] / src / w32xfns.c
index 24bbf6c7df43e9f408ec88a34d9a2a69263576a2..c2b1d705c9aac7410182be792a5890e5c21c73af 100644 (file)
@@ -1,4 +1,4 @@
-/* Functions taken directly from X sources
+/* Functions taken directly from X sources for use with the Microsoft W32 API.
    Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation.
 
 This file is part of GNU Emacs.
@@ -33,6 +33,7 @@ Boston, MA 02111-1307, USA.  */
 CRITICAL_SECTION critsect;
 extern HANDLE keyboard_handle;
 HANDLE input_available = NULL;
+HANDLE interrupt_handle = NULL;
 
 void 
 init_crit ()
@@ -42,6 +43,14 @@ init_crit ()
   /* For safety, input_available should only be reset by get_next_msg
      when the input queue is empty, so make it a manual reset event. */
   keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
+
+  /* interrupt_handle is signalled when quit (C-g) is detected, so that
+     blocking system calls can be interrupted.  We make it a manual
+     reset event, so that if we should ever have multiple threads
+     performing system calls, they will all be interrupted (I'm guessing
+     that would the right response).  Note that we use PulseEvent to
+     signal this event, so that it never remains signalled.  */
+  interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL);
 }
 
 void 
@@ -54,16 +63,29 @@ delete_crit ()
       CloseHandle (input_available);
       input_available = NULL;
     }
+  if (interrupt_handle)
+    {
+      CloseHandle (interrupt_handle);
+      interrupt_handle = NULL;
+    }
+}
+
+void
+signal_quit ()
+{
+  /* Make sure this event never remains signalled; if the main thread
+     isn't in a blocking call, then this should do nothing.  */
+  PulseEvent (interrupt_handle);
 }
 
 void
 select_palette (FRAME_PTR f, HDC hdc)
 {
-  if (!NILP (Vwin32_enable_palette))
-    f->output_data.win32->old_palette =
-      SelectPalette (hdc, one_win32_display_info.palette, FALSE);
+  if (!NILP (Vw32_enable_palette))
+    f->output_data.w32->old_palette =
+      SelectPalette (hdc, one_w32_display_info.palette, FALSE);
   else
-    f->output_data.win32->old_palette = NULL;
+    f->output_data.w32->old_palette = NULL;
 
   if (RealizePalette (hdc))
   {
@@ -78,8 +100,8 @@ select_palette (FRAME_PTR f, HDC hdc)
 void
 deselect_palette (FRAME_PTR f, HDC hdc)
 {
-  if (f->output_data.win32->old_palette)
-    SelectPalette (hdc, f->output_data.win32->old_palette, FALSE);
+  if (f->output_data.w32->old_palette)
+    SelectPalette (hdc, f->output_data.w32->old_palette, FALSE);
 }
 
 /* Get a DC for frame and select palette for drawing; force an update of
@@ -91,7 +113,7 @@ get_frame_dc (FRAME_PTR f)
 
   enter_crit ();
 
-  hdc = GetDC (f->output_data.win32->window_desc);
+  hdc = GetDC (f->output_data.w32->window_desc);
   select_palette (f, hdc);
 
   return hdc;
@@ -103,7 +125,7 @@ release_frame_dc (FRAME_PTR f, HDC hdc)
   int ret;
 
   deselect_palette (f, hdc);
-  ret = ReleaseDC (f->output_data.win32->window_desc, hdc);
+  ret = ReleaseDC (f->output_data.w32->window_desc, hdc);
 
   leave_crit ();
 
@@ -112,7 +134,7 @@ release_frame_dc (FRAME_PTR f, HDC hdc)
 
 typedef struct int_msg
 {
-  Win32Msg w32msg;
+  W32Msg w32msg;
   struct int_msg *lpNext;
 } int_msg;
 
@@ -122,7 +144,7 @@ int nQueue = 0;
 
 BOOL 
 get_next_msg (lpmsg, bWait)
-     Win32Msg * lpmsg;
+     W32Msg * lpmsg;
      BOOL bWait;
 {
   BOOL bRet = FALSE;
@@ -140,7 +162,7 @@ get_next_msg (lpmsg, bWait)
   
   if (nQueue)
     {
-      bcopy (&(lpHead->w32msg), lpmsg, sizeof (Win32Msg));
+      bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg));
 
       {
        int_msg * lpCur = lpHead;
@@ -165,14 +187,14 @@ get_next_msg (lpmsg, bWait)
 
 BOOL 
 post_msg (lpmsg)
-     Win32Msg * lpmsg;
+     W32Msg * lpmsg;
 {
   int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg));
 
   if (!lpNew)
     return (FALSE);
 
-  bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg));
+  bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg));
   lpNew->lpNext = NULL;
 
   enter_crit ();
@@ -195,14 +217,14 @@ post_msg (lpmsg)
 }
 
 BOOL
-prepend_msg (Win32Msg *lpmsg)
+prepend_msg (W32Msg *lpmsg)
 {
   int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg));
 
   if (!lpNew)
     return (FALSE);
 
-  bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg));
+  bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg));
 
   enter_crit ();
 
@@ -350,14 +372,7 @@ XParseGeometry (string, x, y, width, height)
   return (mask);
 }
 
-/* We can use mouse menus when we wish.  */
-int
-have_menus_p (void)
-{
-  return 1;
-}
-
-/* x_sync is a no-op on Win32.  */
+/* x_sync is a no-op on W32.  */
 void
 x_sync (f)
      void *f;