Mercurial > emacs
annotate src/w32xfns.c @ 34917:989f2f0c8a7e
(x-complement-fontset-spec): Resolve
ASCII font name so that the same family name is used for fonts
registered in x-font-name-charset-alist.
(create-fontset-from-fontset-spec): Adjusted for the above change.
The name of fontset alias should be a unresolved ASCII font name.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 29 Dec 2000 06:14:42 +0000 |
parents | 9c0d7d896682 |
children | 549bbda5364a |
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. |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
24917
diff
changeset
|
2 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1999 Free Software Foundation. |
13434 | 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 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
24917
diff
changeset
|
21 #include <config.h> |
13434 | 22 #include <signal.h> |
23 #include <stdio.h> | |
24 #include "lisp.h" | |
31117
f390b90e3495
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
26088
diff
changeset
|
25 #include "keyboard.h" |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
26 #include "frame.h" |
23509
afcb561b535d
Include charset.h and fontset.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22077
diff
changeset
|
27 #include "charset.h" |
afcb561b535d
Include charset.h and fontset.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22077
diff
changeset
|
28 #include "fontset.h" |
13434 | 29 #include "blockinput.h" |
30 #include "w32term.h" | |
31 #include "windowsx.h" | |
32 | |
33 #define myalloc(cb) GlobalAllocPtr (GPTR, cb) | |
34 #define myfree(lp) GlobalFreePtr (lp) | |
35 | |
14352 | 36 CRITICAL_SECTION critsect; |
13434 | 37 extern HANDLE keyboard_handle; |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
38 HANDLE input_available = NULL; |
22077
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
39 HANDLE interrupt_handle = NULL; |
13434 | 40 |
41 void | |
42 init_crit () | |
43 { | |
14352 | 44 InitializeCriticalSection (&critsect); |
13434 | 45 |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
46 /* 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
|
47 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
|
48 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
|
49 |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
50 /* 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 signal this event, so that it never remains signalled. */ |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
56 interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL); |
13434 | 57 } |
58 | |
59 void | |
60 delete_crit () | |
61 { | |
14352 | 62 DeleteCriticalSection (&critsect); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
63 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
64 if (input_available) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
65 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
66 CloseHandle (input_available); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
67 input_available = NULL; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
68 } |
22077
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
69 if (interrupt_handle) |
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 CloseHandle (interrupt_handle); |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
72 interrupt_handle = NULL; |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
73 } |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
74 } |
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 void |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
77 signal_quit () |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
78 { |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
79 /* 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
|
80 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
|
81 PulseEvent (interrupt_handle); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
82 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
83 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
84 void |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
85 select_palette (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
86 { |
34783
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
87 struct w32_display_info *display_info = FRAME_W32_DISPLAY_INFO (f); |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
88 |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
89 if (!display_info->has_palette) |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
90 return; |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
91 |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
92 if (display_info->palette == 0) |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
93 abort (); |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
94 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
95 if (!NILP (Vw32_enable_palette)) |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
96 f->output_data.w32->old_palette = |
34783
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
97 SelectPalette (hdc, display_info->palette, FALSE); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
98 else |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
99 f->output_data.w32->old_palette = NULL; |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
100 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
101 if (RealizePalette (hdc)) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
102 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
103 Lisp_Object frame, framelist; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
104 FOR_EACH_FRAME (framelist, frame) |
13434 | 105 { |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
106 SET_FRAME_GARBAGED (XFRAME (frame)); |
13434 | 107 } |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
108 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
109 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
110 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
111 void |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
112 deselect_palette (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
113 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
114 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
|
115 SelectPalette (hdc, f->output_data.w32->old_palette, FALSE); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
116 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
117 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
118 /* 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
|
119 all frames if palette's mapping changes. */ |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
120 HDC |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
121 get_frame_dc (FRAME_PTR f) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
122 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
123 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 enter_crit (); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
126 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
127 hdc = GetDC (f->output_data.w32->window_desc); |
34094
59adbaee3092
(get_frame_dc): Avoid changing the palette on an invalid frame.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
128 |
59adbaee3092
(get_frame_dc): Avoid changing the palette on an invalid frame.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
129 /* If this gets called during startup before the frame is valid, |
59adbaee3092
(get_frame_dc): Avoid changing the palette on an invalid frame.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
130 there is a chance of corrupting random data or crashing. */ |
59adbaee3092
(get_frame_dc): Avoid changing the palette on an invalid frame.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
131 if (hdc) |
59adbaee3092
(get_frame_dc): Avoid changing the palette on an invalid frame.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
132 select_palette (f, hdc); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
133 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
134 return hdc; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
135 } |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
136 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
137 int |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
138 release_frame_dc (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
139 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
140 int ret; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
141 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
142 deselect_palette (f, hdc); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
143 ret = ReleaseDC (f->output_data.w32->window_desc, hdc); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
144 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
145 leave_crit (); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
146 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
147 return ret; |
13434 | 148 } |
149 | |
150 typedef struct int_msg | |
151 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
152 W32Msg w32msg; |
13434 | 153 struct int_msg *lpNext; |
154 } int_msg; | |
155 | |
156 int_msg *lpHead = NULL; | |
157 int_msg *lpTail = NULL; | |
158 int nQueue = 0; | |
159 | |
160 BOOL | |
161 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
|
162 W32Msg * lpmsg; |
13434 | 163 BOOL bWait; |
164 { | |
165 BOOL bRet = FALSE; | |
166 | |
14352 | 167 enter_crit (); |
13434 | 168 |
169 /* The while loop takes care of multiple sets */ | |
170 | |
171 while (!nQueue && bWait) | |
172 { | |
14352 | 173 leave_crit (); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
174 WaitForSingleObject (input_available, INFINITE); |
14352 | 175 enter_crit (); |
13434 | 176 } |
177 | |
178 if (nQueue) | |
179 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
180 bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg)); |
13434 | 181 |
182 { | |
183 int_msg * lpCur = lpHead; | |
184 | |
185 lpHead = lpHead->lpNext; | |
186 | |
187 myfree (lpCur); | |
188 } | |
189 | |
190 nQueue--; | |
191 | |
192 bRet = TRUE; | |
193 } | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
194 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
195 if (nQueue == 0) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
196 ResetEvent (input_available); |
13434 | 197 |
14352 | 198 leave_crit (); |
13434 | 199 |
200 return (bRet); | |
201 } | |
202 | |
203 BOOL | |
204 post_msg (lpmsg) | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
205 W32Msg * lpmsg; |
13434 | 206 { |
207 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); | |
208 | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
209 if (!lpNew) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
210 return (FALSE); |
13434 | 211 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
212 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); |
13434 | 213 lpNew->lpNext = NULL; |
214 | |
14352 | 215 enter_crit (); |
13434 | 216 |
217 if (nQueue++) | |
14352 | 218 { |
219 lpTail->lpNext = lpNew; | |
220 } | |
13434 | 221 else |
14352 | 222 { |
223 lpHead = lpNew; | |
224 } | |
13434 | 225 |
226 lpTail = lpNew; | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
227 SetEvent (input_available); |
13434 | 228 |
14352 | 229 leave_crit (); |
13434 | 230 |
231 return (TRUE); | |
232 } | |
233 | |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
234 BOOL |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
235 prepend_msg (W32Msg *lpmsg) |
14460
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 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); |
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 if (!lpNew) |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
240 return (FALSE); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
241 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
242 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
243 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
244 enter_crit (); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
245 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
246 nQueue++; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
247 lpNew->lpNext = lpHead; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
248 lpHead = lpNew; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
249 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
250 leave_crit (); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
251 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
252 return (TRUE); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
253 } |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
254 |
24917
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
255 /* Process all messages in the current thread's queue. */ |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
256 void |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
257 drain_message_queue () |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
258 { |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
259 MSG msg; |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
260 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
261 { |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
262 TranslateMessage (&msg); |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
263 DispatchMessage (&msg); |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
264 } |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
265 } |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
266 |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
267 |
13434 | 268 /* |
269 * XParseGeometry parses strings of the form | |
270 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where | |
271 * width, height, xoffset, and yoffset are unsigned integers. | |
272 * Example: "=80x24+300-49" | |
273 * The equal sign is optional. | |
274 * It returns a bitmask that indicates which of the four values | |
275 * were actually found in the string. For each value found, | |
276 * the corresponding argument is updated; for each value | |
277 * not found, the corresponding argument is left unchanged. | |
278 */ | |
279 | |
280 static int | |
281 read_integer (string, NextString) | |
282 register char *string; | |
283 char **NextString; | |
284 { | |
285 register int Result = 0; | |
286 int Sign = 1; | |
287 | |
288 if (*string == '+') | |
289 string++; | |
290 else if (*string == '-') | |
291 { | |
292 string++; | |
293 Sign = -1; | |
294 } | |
295 for (; (*string >= '0') && (*string <= '9'); string++) | |
296 { | |
297 Result = (Result * 10) + (*string - '0'); | |
298 } | |
299 *NextString = string; | |
300 if (Sign >= 0) | |
301 return (Result); | |
302 else | |
303 return (-Result); | |
304 } | |
305 | |
306 int | |
307 XParseGeometry (string, x, y, width, height) | |
308 char *string; | |
309 int *x, *y; | |
310 unsigned int *width, *height; /* RETURN */ | |
311 { | |
312 int mask = NoValue; | |
313 register char *strind; | |
314 unsigned int tempWidth, tempHeight; | |
315 int tempX, tempY; | |
316 char *nextCharacter; | |
317 | |
318 if ((string == NULL) || (*string == '\0')) return (mask); | |
319 if (*string == '=') | |
320 string++; /* ignore possible '=' at beg of geometry spec */ | |
321 | |
322 strind = (char *)string; | |
323 if (*strind != '+' && *strind != '-' && *strind != 'x') | |
324 { | |
325 tempWidth = read_integer (strind, &nextCharacter); | |
326 if (strind == nextCharacter) | |
327 return (0); | |
328 strind = nextCharacter; | |
329 mask |= WidthValue; | |
330 } | |
331 | |
332 if (*strind == 'x' || *strind == 'X') | |
333 { | |
334 strind++; | |
335 tempHeight = read_integer (strind, &nextCharacter); | |
336 if (strind == nextCharacter) | |
337 return (0); | |
338 strind = nextCharacter; | |
339 mask |= HeightValue; | |
340 } | |
341 | |
342 if ((*strind == '+') || (*strind == '-')) | |
343 { | |
344 if (*strind == '-') | |
345 { | |
346 strind++; | |
347 tempX = -read_integer (strind, &nextCharacter); | |
348 if (strind == nextCharacter) | |
349 return (0); | |
350 strind = nextCharacter; | |
351 mask |= XNegative; | |
352 | |
353 } | |
354 else | |
355 { | |
356 strind++; | |
357 tempX = read_integer (strind, &nextCharacter); | |
358 if (strind == nextCharacter) | |
359 return (0); | |
360 strind = nextCharacter; | |
361 } | |
362 mask |= XValue; | |
363 if ((*strind == '+') || (*strind == '-')) | |
364 { | |
365 if (*strind == '-') | |
366 { | |
367 strind++; | |
368 tempY = -read_integer (strind, &nextCharacter); | |
369 if (strind == nextCharacter) | |
370 return (0); | |
371 strind = nextCharacter; | |
372 mask |= YNegative; | |
373 | |
374 } | |
375 else | |
376 { | |
377 strind++; | |
378 tempY = read_integer (strind, &nextCharacter); | |
379 if (strind == nextCharacter) | |
380 return (0); | |
381 strind = nextCharacter; | |
382 } | |
383 mask |= YValue; | |
384 } | |
385 } | |
386 | |
387 /* If strind isn't at the end of the string the it's an invalid | |
388 geometry specification. */ | |
389 | |
390 if (*strind != '\0') return (0); | |
391 | |
392 if (mask & XValue) | |
393 *x = tempX; | |
394 if (mask & YValue) | |
395 *y = tempY; | |
396 if (mask & WidthValue) | |
397 *width = tempWidth; | |
398 if (mask & HeightValue) | |
399 *height = tempHeight; | |
400 return (mask); | |
401 } | |
402 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
403 /* x_sync is a no-op on W32. */ |
13434 | 404 void |
405 x_sync (f) | |
406 void *f; | |
407 { | |
408 } |