X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/acfa068f4a1a4652b784af1d7aaac92929399249..aad3612f9eb7280bd4db8ee697186e75b1e82765:/src/w32xfns.c
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 018dd14cb8..07f7547786 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -1,5 +1,6 @@
/* Functions taken directly from X sources for use with the Microsoft Windows API.
- Copyright (C) 1989, 1992-1995, 1999, 2001-2012 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1992-1995, 1999, 2001-2013 Free Software
+ Foundation, Inc.
This file is part of GNU Emacs.
@@ -19,6 +20,7 @@ along with GNU Emacs. If not, see . */
#include
#include
#include
+
#include "lisp.h"
#include "keyboard.h"
#include "frame.h"
@@ -32,7 +34,11 @@ along with GNU Emacs. If not, see . */
#define myfree(lp) GlobalFreePtr (lp)
CRITICAL_SECTION critsect;
+
+#ifdef WINDOWSNT
extern HANDLE keyboard_handle;
+#endif /* WINDOWSNT */
+
HANDLE input_available = NULL;
HANDLE interrupt_handle = NULL;
@@ -43,7 +49,11 @@ init_crit (void)
/* 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);
+ input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
+
+#ifdef WINDOWSNT
+ keyboard_handle = input_available;
+#endif /* WINDOWSNT */
/* interrupt_handle is signaled when quit (C-g) is detected, so that
blocking system calls can be interrupted. We make it a manual
@@ -80,9 +90,9 @@ signal_quit (void)
}
void
-select_palette (FRAME_PTR f, HDC hdc)
+select_palette (struct frame *f, HDC hdc)
{
- struct w32_display_info *display_info = FRAME_W32_DISPLAY_INFO (f);
+ struct w32_display_info *display_info = FRAME_DISPLAY_INFO (f);
if (!display_info->has_palette)
return;
@@ -107,7 +117,7 @@ select_palette (FRAME_PTR f, HDC hdc)
}
void
-deselect_palette (FRAME_PTR f, HDC hdc)
+deselect_palette (struct frame *f, HDC hdc)
{
if (f->output_data.w32->old_palette)
SelectPalette (hdc, f->output_data.w32->old_palette, FALSE);
@@ -116,7 +126,7 @@ deselect_palette (FRAME_PTR f, HDC hdc)
/* Get a DC for frame and select palette for drawing; force an update of
all frames if palette's mapping changes. */
HDC
-get_frame_dc (FRAME_PTR f)
+get_frame_dc (struct frame *f)
{
HDC hdc;
@@ -136,7 +146,7 @@ get_frame_dc (FRAME_PTR f)
}
int
-release_frame_dc (FRAME_PTR f, HDC hdc)
+release_frame_dc (struct frame *f, HDC hdc)
{
int ret;
@@ -240,6 +250,22 @@ get_next_msg (W32Msg * lpmsg, BOOL bWait)
return (bRet);
}
+extern char * w32_strerror (int error_no);
+
+/* Tell the main thread that we have input available; if the main
+ thread is blocked in select(), we wake it up here. */
+static void
+notify_msg_ready (void)
+{
+ SetEvent (input_available);
+
+#ifdef CYGWIN
+ /* Wakes up the main thread, which is blocked select()ing for /dev/windows,
+ among other files. */
+ (void) PostThreadMessage (dwMainThreadId, WM_EMACS_INPUT_READY, 0, 0);
+#endif /* CYGWIN */
+}
+
BOOL
post_msg (W32Msg * lpmsg)
{
@@ -263,8 +289,7 @@ post_msg (W32Msg * lpmsg)
}
lpTail = lpNew;
- SetEvent (input_available);
-
+ notify_msg_ready ();
leave_crit ();
return (TRUE);
@@ -285,26 +310,26 @@ prepend_msg (W32Msg *lpmsg)
nQueue++;
lpNew->lpNext = lpHead;
lpHead = lpNew;
-
+ notify_msg_ready ();
leave_crit ();
return (TRUE);
}
-/* Process all messages in the current thread's queue. */
-void
+/* Process all messages in the current thread's queue. Value is 1 if
+ one of these messages was WM_EMACS_FILENOTIFY, zero otherwise. */
+int
drain_message_queue (void)
{
MSG msg;
+ int retval = 0;
+
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
+ if (msg.message == WM_EMACS_FILENOTIFY)
+ retval = 1;
TranslateMessage (&msg);
DispatchMessage (&msg);
}
-}
-
-/* x_sync is a no-op on W32. */
-void
-x_sync (struct frame *f)
-{
+ return retval;
}