Mercurial > emacs
annotate src/w32xfns.c @ 23258:2f8585bcea90
(code_convert_region): Update beg_unchanged and
end_unchanged after we delete the source text.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 16 Sep 1998 07:21:31 +0000 |
parents | ae5e3b23c7e2 |
children | afcb561b535d |
rev | line source |
---|---|
16884
36babc489b0c
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
1 /* Functions taken directly from X sources for use with the Microsoft W32 API. |
13434 | 2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation. |
3 | |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13866
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13866
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
13434 | 20 |
21 #include <signal.h> | |
22 #include <config.h> | |
23 #include <stdio.h> | |
24 #include "lisp.h" | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
25 #include "frame.h" |
13434 | 26 #include "blockinput.h" |
27 #include "w32term.h" | |
28 #include "windowsx.h" | |
29 | |
30 #define myalloc(cb) GlobalAllocPtr (GPTR, cb) | |
31 #define myfree(lp) GlobalFreePtr (lp) | |
32 | |
14352 | 33 CRITICAL_SECTION critsect; |
13434 | 34 extern HANDLE keyboard_handle; |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
35 HANDLE input_available = NULL; |
22077
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
36 HANDLE interrupt_handle = NULL; |
13434 | 37 |
38 void | |
39 init_crit () | |
40 { | |
14352 | 41 InitializeCriticalSection (&critsect); |
13434 | 42 |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
43 /* For safety, input_available should only be reset by get_next_msg |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
44 when the input queue is empty, so make it a manual reset event. */ |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
45 keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL); |
22077
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
46 |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
47 /* interrupt_handle is signalled when quit (C-g) is detected, so that |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
48 blocking system calls can be interrupted. We make it a manual |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
49 reset event, so that if we should ever have multiple threads |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
50 performing system calls, they will all be interrupted (I'm guessing |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
51 that would the right response). Note that we use PulseEvent to |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
52 signal this event, so that it never remains signalled. */ |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
53 interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL); |
13434 | 54 } |
55 | |
56 void | |
57 delete_crit () | |
58 { | |
14352 | 59 DeleteCriticalSection (&critsect); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
60 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
61 if (input_available) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
62 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
63 CloseHandle (input_available); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
64 input_available = NULL; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
65 } |
22077
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
66 if (interrupt_handle) |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
67 { |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
68 CloseHandle (interrupt_handle); |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
69 interrupt_handle = NULL; |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
70 } |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
71 } |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
72 |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
73 void |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
74 signal_quit () |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
75 { |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
76 /* Make sure this event never remains signalled; if the main thread |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
77 isn't in a blocking call, then this should do nothing. */ |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
78 PulseEvent (interrupt_handle); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
79 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
80 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
81 void |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
82 select_palette (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
83 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
84 if (!NILP (Vw32_enable_palette)) |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
85 f->output_data.w32->old_palette = |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
86 SelectPalette (hdc, one_w32_display_info.palette, FALSE); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
87 else |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
88 f->output_data.w32->old_palette = NULL; |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
89 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
90 if (RealizePalette (hdc)) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
91 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
92 Lisp_Object frame, framelist; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
93 FOR_EACH_FRAME (framelist, frame) |
13434 | 94 { |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
95 SET_FRAME_GARBAGED (XFRAME (frame)); |
13434 | 96 } |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
97 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
98 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
99 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
100 void |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
101 deselect_palette (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
102 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
103 if (f->output_data.w32->old_palette) |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
104 SelectPalette (hdc, f->output_data.w32->old_palette, FALSE); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
105 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
106 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
107 /* Get a DC for frame and select palette for drawing; force an update of |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
108 all frames if palette's mapping changes. */ |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
109 HDC |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
110 get_frame_dc (FRAME_PTR f) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
111 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
112 HDC hdc; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
113 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
114 enter_crit (); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
115 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
116 hdc = GetDC (f->output_data.w32->window_desc); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
117 select_palette (f, hdc); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
118 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
119 return hdc; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
120 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
121 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
122 int |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
123 release_frame_dc (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
124 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
125 int ret; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
126 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
127 deselect_palette (f, hdc); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
128 ret = ReleaseDC (f->output_data.w32->window_desc, hdc); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
129 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
130 leave_crit (); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
131 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
132 return ret; |
13434 | 133 } |
134 | |
135 typedef struct int_msg | |
136 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
137 W32Msg w32msg; |
13434 | 138 struct int_msg *lpNext; |
139 } int_msg; | |
140 | |
141 int_msg *lpHead = NULL; | |
142 int_msg *lpTail = NULL; | |
143 int nQueue = 0; | |
144 | |
145 BOOL | |
146 get_next_msg (lpmsg, bWait) | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
147 W32Msg * lpmsg; |
13434 | 148 BOOL bWait; |
149 { | |
150 BOOL bRet = FALSE; | |
151 | |
14352 | 152 enter_crit (); |
13434 | 153 |
154 /* The while loop takes care of multiple sets */ | |
155 | |
156 while (!nQueue && bWait) | |
157 { | |
14352 | 158 leave_crit (); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
159 WaitForSingleObject (input_available, INFINITE); |
14352 | 160 enter_crit (); |
13434 | 161 } |
162 | |
163 if (nQueue) | |
164 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
165 bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg)); |
13434 | 166 |
167 { | |
168 int_msg * lpCur = lpHead; | |
169 | |
170 lpHead = lpHead->lpNext; | |
171 | |
172 myfree (lpCur); | |
173 } | |
174 | |
175 nQueue--; | |
176 | |
177 bRet = TRUE; | |
178 } | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
179 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
180 if (nQueue == 0) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
181 ResetEvent (input_available); |
13434 | 182 |
14352 | 183 leave_crit (); |
13434 | 184 |
185 return (bRet); | |
186 } | |
187 | |
188 BOOL | |
189 post_msg (lpmsg) | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
190 W32Msg * lpmsg; |
13434 | 191 { |
192 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); | |
193 | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
194 if (!lpNew) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
195 return (FALSE); |
13434 | 196 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
197 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); |
13434 | 198 lpNew->lpNext = NULL; |
199 | |
14352 | 200 enter_crit (); |
13434 | 201 |
202 if (nQueue++) | |
14352 | 203 { |
204 lpTail->lpNext = lpNew; | |
205 } | |
13434 | 206 else |
14352 | 207 { |
208 lpHead = lpNew; | |
209 } | |
13434 | 210 |
211 lpTail = lpNew; | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
212 SetEvent (input_available); |
13434 | 213 |
14352 | 214 leave_crit (); |
13434 | 215 |
216 return (TRUE); | |
217 } | |
218 | |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
219 BOOL |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
220 prepend_msg (W32Msg *lpmsg) |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
221 { |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
222 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
223 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
224 if (!lpNew) |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
225 return (FALSE); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
226 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
227 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
228 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
229 enter_crit (); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
230 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
231 nQueue++; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
232 lpNew->lpNext = lpHead; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
233 lpHead = lpNew; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
234 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
235 leave_crit (); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
236 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
237 return (TRUE); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
238 } |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
239 |
13434 | 240 /* |
241 * XParseGeometry parses strings of the form | |
242 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where | |
243 * width, height, xoffset, and yoffset are unsigned integers. | |
244 * Example: "=80x24+300-49" | |
245 * The equal sign is optional. | |
246 * It returns a bitmask that indicates which of the four values | |
247 * were actually found in the string. For each value found, | |
248 * the corresponding argument is updated; for each value | |
249 * not found, the corresponding argument is left unchanged. | |
250 */ | |
251 | |
252 static int | |
253 read_integer (string, NextString) | |
254 register char *string; | |
255 char **NextString; | |
256 { | |
257 register int Result = 0; | |
258 int Sign = 1; | |
259 | |
260 if (*string == '+') | |
261 string++; | |
262 else if (*string == '-') | |
263 { | |
264 string++; | |
265 Sign = -1; | |
266 } | |
267 for (; (*string >= '0') && (*string <= '9'); string++) | |
268 { | |
269 Result = (Result * 10) + (*string - '0'); | |
270 } | |
271 *NextString = string; | |
272 if (Sign >= 0) | |
273 return (Result); | |
274 else | |
275 return (-Result); | |
276 } | |
277 | |
278 int | |
279 XParseGeometry (string, x, y, width, height) | |
280 char *string; | |
281 int *x, *y; | |
282 unsigned int *width, *height; /* RETURN */ | |
283 { | |
284 int mask = NoValue; | |
285 register char *strind; | |
286 unsigned int tempWidth, tempHeight; | |
287 int tempX, tempY; | |
288 char *nextCharacter; | |
289 | |
290 if ((string == NULL) || (*string == '\0')) return (mask); | |
291 if (*string == '=') | |
292 string++; /* ignore possible '=' at beg of geometry spec */ | |
293 | |
294 strind = (char *)string; | |
295 if (*strind != '+' && *strind != '-' && *strind != 'x') | |
296 { | |
297 tempWidth = read_integer (strind, &nextCharacter); | |
298 if (strind == nextCharacter) | |
299 return (0); | |
300 strind = nextCharacter; | |
301 mask |= WidthValue; | |
302 } | |
303 | |
304 if (*strind == 'x' || *strind == 'X') | |
305 { | |
306 strind++; | |
307 tempHeight = read_integer (strind, &nextCharacter); | |
308 if (strind == nextCharacter) | |
309 return (0); | |
310 strind = nextCharacter; | |
311 mask |= HeightValue; | |
312 } | |
313 | |
314 if ((*strind == '+') || (*strind == '-')) | |
315 { | |
316 if (*strind == '-') | |
317 { | |
318 strind++; | |
319 tempX = -read_integer (strind, &nextCharacter); | |
320 if (strind == nextCharacter) | |
321 return (0); | |
322 strind = nextCharacter; | |
323 mask |= XNegative; | |
324 | |
325 } | |
326 else | |
327 { | |
328 strind++; | |
329 tempX = read_integer (strind, &nextCharacter); | |
330 if (strind == nextCharacter) | |
331 return (0); | |
332 strind = nextCharacter; | |
333 } | |
334 mask |= XValue; | |
335 if ((*strind == '+') || (*strind == '-')) | |
336 { | |
337 if (*strind == '-') | |
338 { | |
339 strind++; | |
340 tempY = -read_integer (strind, &nextCharacter); | |
341 if (strind == nextCharacter) | |
342 return (0); | |
343 strind = nextCharacter; | |
344 mask |= YNegative; | |
345 | |
346 } | |
347 else | |
348 { | |
349 strind++; | |
350 tempY = read_integer (strind, &nextCharacter); | |
351 if (strind == nextCharacter) | |
352 return (0); | |
353 strind = nextCharacter; | |
354 } | |
355 mask |= YValue; | |
356 } | |
357 } | |
358 | |
359 /* If strind isn't at the end of the string the it's an invalid | |
360 geometry specification. */ | |
361 | |
362 if (*strind != '\0') return (0); | |
363 | |
364 if (mask & XValue) | |
365 *x = tempX; | |
366 if (mask & YValue) | |
367 *y = tempY; | |
368 if (mask & WidthValue) | |
369 *width = tempWidth; | |
370 if (mask & HeightValue) | |
371 *height = tempHeight; | |
372 return (mask); | |
373 } | |
374 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
375 /* x_sync is a no-op on W32. */ |
13434 | 376 void |
377 x_sync (f) | |
378 void *f; | |
379 { | |
380 } | |
381 |