summaryrefslogtreecommitdiff
path: root/src/w32xfns.c
diff options
context:
space:
mode:
authorGeoff Voelker <voelker@cs.washington.edu>1996-05-03 18:49:20 +0000
committerGeoff Voelker <voelker@cs.washington.edu>1996-05-03 18:49:20 +0000
commit97aab3a23baa2f8605bf006164173679e69d5802 (patch)
tree349719f5f7e1bb848224a633f0b640c52af6df27 /src/w32xfns.c
parentaba66c88ae39b8599525c2aaaca56e79e2fc0dcd (diff)
downloademacs-97aab3a23baa2f8605bf006164173679e69d5802.tar.gz
Include frame.h.
(hEvent): Renamed to h_input_available. (init_crit, delete_crit, get_next_msg, post_msg): Use h_input_available. (GetFrameDC, ReleaseFrameDC): New functions. (leave_crit): Function removed.
Diffstat (limited to 'src/w32xfns.c')
-rw-r--r--src/w32xfns.c87
1 files changed, 69 insertions, 18 deletions
diff --git a/src/w32xfns.c b/src/w32xfns.c
index 3898ff00d8f..24bbf6c7df4 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -22,6 +22,7 @@ Boston, MA 02111-1307, USA. */
#include <config.h>
#include <stdio.h>
#include "lisp.h"
+#include "frame.h"
#include "blockinput.h"
#include "w32term.h"
#include "windowsx.h"
@@ -31,36 +32,82 @@ Boston, MA 02111-1307, USA. */
CRITICAL_SECTION critsect;
extern HANDLE keyboard_handle;
-HANDLE hEvent = NULL;
+HANDLE input_available = NULL;
void
init_crit ()
{
InitializeCriticalSection (&critsect);
- keyboard_handle = hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-}
-void
-enter_crit ()
-{
- EnterCriticalSection (&critsect);
+ /* 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);
}
void
-leave_crit ()
+delete_crit ()
{
- LeaveCriticalSection (&critsect);
+ DeleteCriticalSection (&critsect);
+
+ if (input_available)
+ {
+ CloseHandle (input_available);
+ input_available = NULL;
+ }
}
-void
-delete_crit ()
+void
+select_palette (FRAME_PTR f, HDC hdc)
{
- DeleteCriticalSection (&critsect);
- if (hEvent)
+ if (!NILP (Vwin32_enable_palette))
+ f->output_data.win32->old_palette =
+ SelectPalette (hdc, one_win32_display_info.palette, FALSE);
+ else
+ f->output_data.win32->old_palette = NULL;
+
+ if (RealizePalette (hdc))
+ {
+ Lisp_Object frame, framelist;
+ FOR_EACH_FRAME (framelist, frame)
{
- CloseHandle (hEvent);
- hEvent = NULL;
+ SET_FRAME_GARBAGED (XFRAME (frame));
}
+ }
+}
+
+void
+deselect_palette (FRAME_PTR f, HDC hdc)
+{
+ if (f->output_data.win32->old_palette)
+ SelectPalette (hdc, f->output_data.win32->old_palette, FALSE);
+}
+
+/* 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)
+{
+ HDC hdc;
+
+ enter_crit ();
+
+ hdc = GetDC (f->output_data.win32->window_desc);
+ select_palette (f, hdc);
+
+ return hdc;
+}
+
+int
+release_frame_dc (FRAME_PTR f, HDC hdc)
+{
+ int ret;
+
+ deselect_palette (f, hdc);
+ ret = ReleaseDC (f->output_data.win32->window_desc, hdc);
+
+ leave_crit ();
+
+ return ret;
}
typedef struct int_msg
@@ -87,7 +134,7 @@ get_next_msg (lpmsg, bWait)
while (!nQueue && bWait)
{
leave_crit ();
- WaitForSingleObject (hEvent, INFINITE);
+ WaitForSingleObject (input_available, INFINITE);
enter_crit ();
}
@@ -107,6 +154,9 @@ get_next_msg (lpmsg, bWait)
bRet = TRUE;
}
+
+ if (nQueue == 0)
+ ResetEvent (input_available);
leave_crit ();
@@ -119,7 +169,8 @@ post_msg (lpmsg)
{
int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg));
- if (!lpNew) return (FALSE);
+ if (!lpNew)
+ return (FALSE);
bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg));
lpNew->lpNext = NULL;
@@ -133,10 +184,10 @@ post_msg (lpmsg)
else
{
lpHead = lpNew;
- SetEvent (hEvent);
}
lpTail = lpNew;
+ SetEvent (input_available);
leave_crit ();