Mercurial > emacs
annotate src/w32xfns.c @ 81960:5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
makes only the minimum changes needed to get the old vc.el logic
working with the new back ends.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Wed, 18 Jul 2007 16:31:56 +0000 |
parents | e90d04cd455a |
children | 922696f363b0 95d0cdf160ea |
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. |
75227
e90d04cd455a
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
68651
diff
changeset
|
2 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1999, 2001, 2002, 2003, |
e90d04cd455a
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
68651
diff
changeset
|
3 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
13434 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 2, or (at your option) | |
10 any later version. | |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. */ | |
13434 | 21 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
24917
diff
changeset
|
22 #include <config.h> |
13434 | 23 #include <signal.h> |
24 #include <stdio.h> | |
25 #include "lisp.h" | |
31117
f390b90e3495
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
26088
diff
changeset
|
26 #include "keyboard.h" |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
27 #include "frame.h" |
23509
afcb561b535d
Include charset.h and fontset.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22077
diff
changeset
|
28 #include "charset.h" |
afcb561b535d
Include charset.h and fontset.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22077
diff
changeset
|
29 #include "fontset.h" |
13434 | 30 #include "blockinput.h" |
31 #include "w32term.h" | |
32 #include "windowsx.h" | |
33 | |
34 #define myalloc(cb) GlobalAllocPtr (GPTR, cb) | |
35 #define myfree(lp) GlobalFreePtr (lp) | |
36 | |
14352 | 37 CRITICAL_SECTION critsect; |
13434 | 38 extern HANDLE keyboard_handle; |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
39 HANDLE input_available = NULL; |
22077
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
40 HANDLE interrupt_handle = NULL; |
13434 | 41 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
42 void |
13434 | 43 init_crit () |
44 { | |
14352 | 45 InitializeCriticalSection (&critsect); |
13434 | 46 |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
47 /* 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
|
48 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
|
49 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
|
50 |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
51 /* 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 signal this event, so that it never remains signalled. */ |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
57 interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL); |
13434 | 58 } |
59 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
60 void |
13434 | 61 delete_crit () |
62 { | |
14352 | 63 DeleteCriticalSection (&critsect); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
64 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
65 if (input_available) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
66 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
67 CloseHandle (input_available); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
68 input_available = NULL; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
69 } |
22077
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
70 if (interrupt_handle) |
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 CloseHandle (interrupt_handle); |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
73 interrupt_handle = NULL; |
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 |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
77 void |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
78 signal_quit () |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
79 { |
ae5e3b23c7e2
(interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
19715
diff
changeset
|
80 /* 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
|
81 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
|
82 PulseEvent (interrupt_handle); |
15153
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 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
85 void |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
86 select_palette (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
87 { |
34783
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
88 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
|
89 |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
90 if (!display_info->has_palette) |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
91 return; |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
92 |
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
93 if (display_info->palette == 0) |
35943
7a9bc23b91e7
(select_palette): Do nothing if palette hasn't yet
Andrew Innes <andrewi@gnu.org>
parents:
34999
diff
changeset
|
94 return; |
34783
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
95 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
96 if (!NILP (Vw32_enable_palette)) |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
97 f->output_data.w32->old_palette = |
34783
9c0d7d896682
(select_palette): Avoid calling SelectPalette if
Andrew Innes <andrewi@gnu.org>
parents:
34094
diff
changeset
|
98 SelectPalette (hdc, display_info->palette, FALSE); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
99 else |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
100 f->output_data.w32->old_palette = NULL; |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
101 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
102 if (RealizePalette (hdc)) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
103 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
104 Lisp_Object frame, framelist; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
105 FOR_EACH_FRAME (framelist, frame) |
13434 | 106 { |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
107 SET_FRAME_GARBAGED (XFRAME (frame)); |
13434 | 108 } |
15153
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 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
112 void |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
113 deselect_palette (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
114 { |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
115 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
|
116 SelectPalette (hdc, f->output_data.w32->old_palette, FALSE); |
15153
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 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
119 /* 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
|
120 all frames if palette's mapping changes. */ |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
121 HDC |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
122 get_frame_dc (FRAME_PTR f) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
123 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
124 HDC hdc; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
125 |
34999
549bbda5364a
(get_frame_dc): Abort if called on a non-w32 frame.
Andrew Innes <andrewi@gnu.org>
parents:
34783
diff
changeset
|
126 if (f->output_method != output_w32) |
549bbda5364a
(get_frame_dc): Abort if called on a non-w32 frame.
Andrew Innes <andrewi@gnu.org>
parents:
34783
diff
changeset
|
127 abort (); |
549bbda5364a
(get_frame_dc): Abort if called on a non-w32 frame.
Andrew Innes <andrewi@gnu.org>
parents:
34783
diff
changeset
|
128 |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
129 enter_crit (); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
130 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
131 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
|
132 |
59adbaee3092
(get_frame_dc): Avoid changing the palette on an invalid frame.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
133 /* 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
|
134 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
|
135 if (hdc) |
59adbaee3092
(get_frame_dc): Avoid changing the palette on an invalid frame.
Jason Rumney <jasonr@gnu.org>
parents:
31117
diff
changeset
|
136 select_palette (f, hdc); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
137 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
138 return 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 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
141 int |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
142 release_frame_dc (FRAME_PTR f, HDC hdc) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
143 { |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
144 int ret; |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
145 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
146 deselect_palette (f, hdc); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
147 ret = ReleaseDC (f->output_data.w32->window_desc, hdc); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
148 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
149 leave_crit (); |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
150 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
151 return ret; |
13434 | 152 } |
153 | |
154 typedef struct int_msg | |
155 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
156 W32Msg w32msg; |
13434 | 157 struct int_msg *lpNext; |
158 } int_msg; | |
159 | |
160 int_msg *lpHead = NULL; | |
161 int_msg *lpTail = NULL; | |
162 int nQueue = 0; | |
163 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
164 BOOL |
13434 | 165 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
|
166 W32Msg * lpmsg; |
13434 | 167 BOOL bWait; |
168 { | |
169 BOOL bRet = FALSE; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
170 |
14352 | 171 enter_crit (); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
172 |
13434 | 173 /* The while loop takes care of multiple sets */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
174 |
13434 | 175 while (!nQueue && bWait) |
176 { | |
14352 | 177 leave_crit (); |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
178 WaitForSingleObject (input_available, INFINITE); |
14352 | 179 enter_crit (); |
13434 | 180 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
181 |
13434 | 182 if (nQueue) |
183 { | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
184 bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg)); |
13434 | 185 |
186 { | |
187 int_msg * lpCur = lpHead; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
188 |
13434 | 189 lpHead = lpHead->lpNext; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
190 |
13434 | 191 myfree (lpCur); |
192 } | |
193 | |
194 nQueue--; | |
195 | |
196 bRet = TRUE; | |
197 } | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
198 |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
199 if (nQueue == 0) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
200 ResetEvent (input_available); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
201 |
14352 | 202 leave_crit (); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
203 |
13434 | 204 return (bRet); |
205 } | |
206 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
207 BOOL |
13434 | 208 post_msg (lpmsg) |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
209 W32Msg * lpmsg; |
13434 | 210 { |
211 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); | |
212 | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
213 if (!lpNew) |
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
214 return (FALSE); |
13434 | 215 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
216 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); |
13434 | 217 lpNew->lpNext = NULL; |
218 | |
14352 | 219 enter_crit (); |
13434 | 220 |
221 if (nQueue++) | |
14352 | 222 { |
223 lpTail->lpNext = lpNew; | |
224 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
225 else |
14352 | 226 { |
227 lpHead = lpNew; | |
228 } | |
13434 | 229 |
230 lpTail = lpNew; | |
15153
c1494aa589e8
Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14460
diff
changeset
|
231 SetEvent (input_available); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
232 |
14352 | 233 leave_crit (); |
13434 | 234 |
235 return (TRUE); | |
236 } | |
237 | |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
238 BOOL |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
239 prepend_msg (W32Msg *lpmsg) |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
240 { |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
241 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
242 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
243 if (!lpNew) |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
244 return (FALSE); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
245 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
246 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg)); |
14460
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
247 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
248 enter_crit (); |
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 nQueue++; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
251 lpNew->lpNext = lpHead; |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
252 lpHead = lpNew; |
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 leave_crit (); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
255 |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
256 return (TRUE); |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
257 } |
61fc696a0c6a
(prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14352
diff
changeset
|
258 |
24917
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
259 /* Process all messages in the current thread's queue. */ |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
260 void |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
261 drain_message_queue () |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
262 { |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
263 MSG msg; |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
264 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) |
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 TranslateMessage (&msg); |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
267 DispatchMessage (&msg); |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
268 } |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
269 } |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
270 |
600578f35004
(drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents:
23509
diff
changeset
|
271 |
13434 | 272 /* |
273 * XParseGeometry parses strings of the form | |
274 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where | |
275 * width, height, xoffset, and yoffset are unsigned integers. | |
276 * Example: "=80x24+300-49" | |
277 * The equal sign is optional. | |
278 * It returns a bitmask that indicates which of the four values | |
279 * were actually found in the string. For each value found, | |
280 * the corresponding argument is updated; for each value | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
281 * not found, the corresponding argument is left unchanged. |
13434 | 282 */ |
283 | |
284 static int | |
285 read_integer (string, NextString) | |
286 register char *string; | |
287 char **NextString; | |
288 { | |
289 register int Result = 0; | |
290 int Sign = 1; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
291 |
13434 | 292 if (*string == '+') |
293 string++; | |
294 else if (*string == '-') | |
295 { | |
296 string++; | |
297 Sign = -1; | |
298 } | |
299 for (; (*string >= '0') && (*string <= '9'); string++) | |
300 { | |
301 Result = (Result * 10) + (*string - '0'); | |
302 } | |
303 *NextString = string; | |
304 if (Sign >= 0) | |
305 return (Result); | |
306 else | |
307 return (-Result); | |
308 } | |
309 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
310 int |
13434 | 311 XParseGeometry (string, x, y, width, height) |
312 char *string; | |
313 int *x, *y; | |
314 unsigned int *width, *height; /* RETURN */ | |
315 { | |
316 int mask = NoValue; | |
317 register char *strind; | |
318 unsigned int tempWidth, tempHeight; | |
319 int tempX, tempY; | |
320 char *nextCharacter; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
321 |
13434 | 322 if ((string == NULL) || (*string == '\0')) return (mask); |
323 if (*string == '=') | |
324 string++; /* ignore possible '=' at beg of geometry spec */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
325 |
13434 | 326 strind = (char *)string; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
327 if (*strind != '+' && *strind != '-' && *strind != 'x') |
13434 | 328 { |
329 tempWidth = read_integer (strind, &nextCharacter); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
330 if (strind == nextCharacter) |
13434 | 331 return (0); |
332 strind = nextCharacter; | |
333 mask |= WidthValue; | |
334 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
335 |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
336 if (*strind == 'x' || *strind == 'X') |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
337 { |
13434 | 338 strind++; |
339 tempHeight = read_integer (strind, &nextCharacter); | |
340 if (strind == nextCharacter) | |
341 return (0); | |
342 strind = nextCharacter; | |
343 mask |= HeightValue; | |
344 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
345 |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
346 if ((*strind == '+') || (*strind == '-')) |
13434 | 347 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
348 if (*strind == '-') |
13434 | 349 { |
350 strind++; | |
351 tempX = -read_integer (strind, &nextCharacter); | |
352 if (strind == nextCharacter) | |
353 return (0); | |
354 strind = nextCharacter; | |
355 mask |= XNegative; | |
356 | |
357 } | |
358 else | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
359 { |
13434 | 360 strind++; |
361 tempX = read_integer (strind, &nextCharacter); | |
362 if (strind == nextCharacter) | |
363 return (0); | |
364 strind = nextCharacter; | |
365 } | |
366 mask |= XValue; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
367 if ((*strind == '+') || (*strind == '-')) |
13434 | 368 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
369 if (*strind == '-') |
13434 | 370 { |
371 strind++; | |
372 tempY = -read_integer (strind, &nextCharacter); | |
373 if (strind == nextCharacter) | |
374 return (0); | |
375 strind = nextCharacter; | |
376 mask |= YNegative; | |
377 | |
378 } | |
379 else | |
380 { | |
381 strind++; | |
382 tempY = read_integer (strind, &nextCharacter); | |
383 if (strind == nextCharacter) | |
384 return (0); | |
385 strind = nextCharacter; | |
386 } | |
387 mask |= YValue; | |
388 } | |
389 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
390 |
13434 | 391 /* If strind isn't at the end of the string the it's an invalid |
392 geometry specification. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
393 |
13434 | 394 if (*strind != '\0') return (0); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
35943
diff
changeset
|
395 |
13434 | 396 if (mask & XValue) |
397 *x = tempX; | |
398 if (mask & YValue) | |
399 *y = tempY; | |
400 if (mask & WidthValue) | |
401 *width = tempWidth; | |
402 if (mask & HeightValue) | |
403 *height = tempHeight; | |
404 return (mask); | |
405 } | |
406 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
15153
diff
changeset
|
407 /* x_sync is a no-op on W32. */ |
13434 | 408 void |
409 x_sync (f) | |
410 void *f; | |
411 { | |
412 } | |
52401 | 413 |
414 /* arch-tag: 4fab3695-4ad3-4cc6-a2b1-fd2c67dc46be | |
415 (do not change this comment) */ |