aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGeoff Voelker1996-05-03 18:49:20 +0000
committerGeoff Voelker1996-05-03 18:49:20 +0000
commit97aab3a23baa2f8605bf006164173679e69d5802 (patch)
tree349719f5f7e1bb848224a633f0b640c52af6df27 /src
parentaba66c88ae39b8599525c2aaaca56e79e2fc0dcd (diff)
downloademacs-97aab3a23baa2f8605bf006164173679e69d5802.tar.gz
emacs-97aab3a23baa2f8605bf006164173679e69d5802.zip
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')
-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. */
22#include <config.h> 22#include <config.h>
23#include <stdio.h> 23#include <stdio.h>
24#include "lisp.h" 24#include "lisp.h"
25#include "frame.h"
25#include "blockinput.h" 26#include "blockinput.h"
26#include "w32term.h" 27#include "w32term.h"
27#include "windowsx.h" 28#include "windowsx.h"
@@ -31,36 +32,82 @@ Boston, MA 02111-1307, USA. */
31 32
32CRITICAL_SECTION critsect; 33CRITICAL_SECTION critsect;
33extern HANDLE keyboard_handle; 34extern HANDLE keyboard_handle;
34HANDLE hEvent = NULL; 35HANDLE input_available = NULL;
35 36
36void 37void
37init_crit () 38init_crit ()
38{ 39{
39 InitializeCriticalSection (&critsect); 40 InitializeCriticalSection (&critsect);
40 keyboard_handle = hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
41}
42 41
43void 42 /* For safety, input_available should only be reset by get_next_msg
44enter_crit () 43 when the input queue is empty, so make it a manual reset event. */
45{ 44 keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
46 EnterCriticalSection (&critsect);
47} 45}
48 46
49void 47void
50leave_crit () 48delete_crit ()
51{ 49{
52 LeaveCriticalSection (&critsect); 50 DeleteCriticalSection (&critsect);
51
52 if (input_available)
53 {
54 CloseHandle (input_available);
55 input_available = NULL;
56 }
53} 57}
54 58
55void 59void
56delete_crit () 60select_palette (FRAME_PTR f, HDC hdc)
57{ 61{
58 DeleteCriticalSection (&critsect); 62 if (!NILP (Vwin32_enable_palette))
59 if (hEvent) 63 f->output_data.win32->old_palette =
64 SelectPalette (hdc, one_win32_display_info.palette, FALSE);
65 else
66 f->output_data.win32->old_palette = NULL;
67
68 if (RealizePalette (hdc))
69 {
70 Lisp_Object frame, framelist;
71 FOR_EACH_FRAME (framelist, frame)
60 { 72 {
61 CloseHandle (hEvent); 73 SET_FRAME_GARBAGED (XFRAME (frame));
62 hEvent = NULL;
63 } 74 }
75 }
76}
77
78void
79deselect_palette (FRAME_PTR f, HDC hdc)
80{
81 if (f->output_data.win32->old_palette)
82 SelectPalette (hdc, f->output_data.win32->old_palette, FALSE);
83}
84
85/* Get a DC for frame and select palette for drawing; force an update of
86 all frames if palette's mapping changes. */
87HDC
88get_frame_dc (FRAME_PTR f)
89{
90 HDC hdc;
91
92 enter_crit ();
93
94 hdc = GetDC (f->output_data.win32->window_desc);
95 select_palette (f, hdc);
96
97 return hdc;
98}
99
100int
101release_frame_dc (FRAME_PTR f, HDC hdc)
102{
103 int ret;
104
105 deselect_palette (f, hdc);
106 ret = ReleaseDC (f->output_data.win32->window_desc, hdc);
107
108 leave_crit ();
109
110 return ret;
64} 111}
65 112
66typedef struct int_msg 113typedef struct int_msg
@@ -87,7 +134,7 @@ get_next_msg (lpmsg, bWait)
87 while (!nQueue && bWait) 134 while (!nQueue && bWait)
88 { 135 {
89 leave_crit (); 136 leave_crit ();
90 WaitForSingleObject (hEvent, INFINITE); 137 WaitForSingleObject (input_available, INFINITE);
91 enter_crit (); 138 enter_crit ();
92 } 139 }
93 140
@@ -107,6 +154,9 @@ get_next_msg (lpmsg, bWait)
107 154
108 bRet = TRUE; 155 bRet = TRUE;
109 } 156 }
157
158 if (nQueue == 0)
159 ResetEvent (input_available);
110 160
111 leave_crit (); 161 leave_crit ();
112 162
@@ -119,7 +169,8 @@ post_msg (lpmsg)
119{ 169{
120 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); 170 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg));
121 171
122 if (!lpNew) return (FALSE); 172 if (!lpNew)
173 return (FALSE);
123 174
124 bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg)); 175 bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg));
125 lpNew->lpNext = NULL; 176 lpNew->lpNext = NULL;
@@ -133,10 +184,10 @@ post_msg (lpmsg)
133 else 184 else
134 { 185 {
135 lpHead = lpNew; 186 lpHead = lpNew;
136 SetEvent (hEvent);
137 } 187 }
138 188
139 lpTail = lpNew; 189 lpTail = lpNew;
190 SetEvent (input_available);
140 191
141 leave_crit (); 192 leave_crit ();
142 193