aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGeoff Voelker1996-01-21 00:20:52 +0000
committerGeoff Voelker1996-01-21 00:20:52 +0000
commitd484dc5552cd5124f194047e55b5cc17472daba8 (patch)
treec9ea894a045e3e81a05a40dcf1c95ae5ca47ae70 /src
parent7d6659459e84fb673beaba4dc727f81a409203b5 (diff)
downloademacs-d484dc5552cd5124f194047e55b5cc17472daba8.tar.gz
emacs-d484dc5552cd5124f194047e55b5cc17472daba8.zip
Include frame.h.
(critsect, h_input_available): New variables. (init_crit, delete_crit): Handle all three critical sections. (GetFrameDC, ReleaseFrameDC): New functions. (get_next_msg, post_msg): Use h_input_available. Use CRIT_MSG critical section.
Diffstat (limited to 'src')
-rw-r--r--src/w32xfns.c105
1 files changed, 73 insertions, 32 deletions
diff --git a/src/w32xfns.c b/src/w32xfns.c
index e478bc24537..9929248e92b 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"
@@ -29,38 +30,78 @@ Boston, MA 02111-1307, USA. */
29#define myalloc(cb) GlobalAllocPtr (GPTR, cb) 30#define myalloc(cb) GlobalAllocPtr (GPTR, cb)
30#define myfree(lp) GlobalFreePtr (lp) 31#define myfree(lp) GlobalFreePtr (lp)
31 32
32CRITICAL_SECTION critsect; 33CRITICAL_SECTION critsect[ CRIT_TOTAL ];
33extern HANDLE keyboard_handle; 34extern HANDLE keyboard_handle;
34HANDLE hEvent = NULL; 35HANDLE h_input_available = NULL;
35 36
36void 37void
37init_crit () 38init_crit ()
38{ 39{
39 InitializeCriticalSection (&critsect); 40 int i;
40 keyboard_handle = hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
41}
42 41
43void 42 for (i = 0; i < CRIT_TOTAL; i++)
44enter_crit () 43 InitializeCriticalSection (&critsect[i]);
45{ 44 /* For safety, h_input_available should only be reset by get_next_msg
46 EnterCriticalSection (&critsect); 45 when the input queue is empty, so make it a manual reset event. */
46 keyboard_handle = h_input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
47} 47}
48 48
49void 49void
50leave_crit () 50delete_crit ()
51{ 51{
52 LeaveCriticalSection (&critsect); 52 int i;
53
54 for (i = 0; i < CRIT_TOTAL; i++)
55 DeleteCriticalSection (&critsect[i]);
56 if (h_input_available)
57 {
58 CloseHandle (h_input_available);
59 h_input_available = NULL;
60 }
53} 61}
54 62
55void 63/* Get a DC for frame and select palette for drawing; force an update of
56delete_crit () 64 all frames if palette's mapping changes. */
65HDC
66GetFrameDC (FRAME_PTR f)
57{ 67{
58 DeleteCriticalSection (&critsect); 68 HDC hDC;
59 if (hEvent) 69
70 enter_crit (CRIT_GDI);
71
72 hDC = GetDC (f->output_data.win32->window_desc);
73
74 if (!NILP (Vwin32_enable_palette))
75 f->output_data.win32->h_old_palette =
76 SelectPalette (hDC, one_win32_display_info.h_palette, FALSE);
77 else
78 f->output_data.win32->h_old_palette = NULL;
79
80 if (RealizePalette (hDC))
60 { 81 {
61 CloseHandle (hEvent); 82 Lisp_Object frame, framelist;
62 hEvent = NULL; 83 FOR_EACH_FRAME (framelist, frame)
84 {
85 SET_FRAME_GARBAGED (XFRAME (frame));
86 }
63 } 87 }
88
89 return hDC;
90}
91
92int
93ReleaseFrameDC (FRAME_PTR f, HDC hDC)
94{
95 int ret;
96
97 if (f->output_data.win32->h_old_palette)
98 SelectPalette (hDC, f->output_data.win32->h_old_palette, FALSE);
99
100 ret = ReleaseDC (f->output_data.win32->window_desc, hDC);
101
102 leave_crit (CRIT_GDI);
103
104 return ret;
64} 105}
65 106
66typedef struct int_msg 107typedef struct int_msg
@@ -80,15 +121,15 @@ get_next_msg (lpmsg, bWait)
80{ 121{
81 BOOL bRet = FALSE; 122 BOOL bRet = FALSE;
82 123
83 enter_crit (); 124 enter_crit (CRIT_MSG);
84 125
85 /* The while loop takes care of multiple sets */ 126 /* The while loop takes care of multiple sets */
86 127
87 while (!nQueue && bWait) 128 while (!nQueue && bWait)
88 { 129 {
89 leave_crit (); 130 leave_crit (CRIT_MSG);
90 WaitForSingleObject (hEvent, INFINITE); 131 WaitForSingleObject (h_input_available, INFINITE);
91 enter_crit (); 132 enter_crit (CRIT_MSG);
92 } 133 }
93 134
94 if (nQueue) 135 if (nQueue)
@@ -107,8 +148,11 @@ get_next_msg (lpmsg, bWait)
107 148
108 bRet = TRUE; 149 bRet = TRUE;
109 } 150 }
151
152 if (nQueue == 0)
153 ResetEvent (h_input_available);
110 154
111 leave_crit (); 155 leave_crit (CRIT_MSG);
112 156
113 return (bRet); 157 return (bRet);
114} 158}
@@ -119,26 +163,23 @@ post_msg (lpmsg)
119{ 163{
120 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); 164 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg));
121 165
122 if (!lpNew) return (FALSE); 166 if (!lpNew)
167 return (FALSE);
123 168
124 bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg)); 169 bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg));
125 lpNew->lpNext = NULL; 170 lpNew->lpNext = NULL;
126 171
127 enter_crit (); 172 enter_crit (CRIT_MSG);
128 173
129 if (nQueue++) 174 if (nQueue++)
130 { 175 lpTail->lpNext = lpNew;
131 lpTail->lpNext = lpNew;
132 }
133 else 176 else
134 { 177 lpHead = lpNew;
135 lpHead = lpNew;
136 SetEvent (hEvent);
137 }
138 178
139 lpTail = lpNew; 179 lpTail = lpNew;
180 SetEvent (h_input_available);
140 181
141 leave_crit (); 182 leave_crit (CRIT_MSG);
142 183
143 return (TRUE); 184 return (TRUE);
144} 185}