1 /* Functions taken directly from X sources
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation.
4 This file is part of GNU Emacs.
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)
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.
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
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24 #include "blockinput.h"
28 #define myalloc(cb) GlobalAllocPtr (GPTR, cb)
29 #define myfree(lp) GlobalFreePtr (lp)
31 CRITICAL_SECTION critsect
;
32 extern HANDLE keyboard_handle
;
38 InitializeCriticalSection (&critsect
);
39 keyboard_handle
= hEvent
= CreateEvent (NULL
, FALSE
, FALSE
, NULL
);
45 EnterCriticalSection (&critsect
);
51 LeaveCriticalSection (&critsect
);
57 DeleteCriticalSection (&critsect
);
65 typedef struct int_msg
68 struct int_msg
*lpNext
;
71 int_msg
*lpHead
= NULL
;
72 int_msg
*lpTail
= NULL
;
76 get_next_msg (lpmsg
, bWait
)
84 /* The while loop takes care of multiple sets */
86 while (!nQueue
&& bWait
)
89 WaitForSingleObject (hEvent
, INFINITE
);
95 bcopy (&(lpHead
->w32msg
), lpmsg
, sizeof (Win32Msg
));
98 int_msg
* lpCur
= lpHead
;
100 lpHead
= lpHead
->lpNext
;
119 int_msg
* lpNew
= (int_msg
*) myalloc (sizeof (int_msg
));
121 if (!lpNew
) return (FALSE
);
123 bcopy (lpmsg
, &(lpNew
->w32msg
), sizeof (Win32Msg
));
124 lpNew
->lpNext
= NULL
;
130 lpTail
->lpNext
= lpNew
;
146 * XParseGeometry parses strings of the form
147 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
148 * width, height, xoffset, and yoffset are unsigned integers.
149 * Example: "=80x24+300-49"
150 * The equal sign is optional.
151 * It returns a bitmask that indicates which of the four values
152 * were actually found in the string. For each value found,
153 * the corresponding argument is updated; for each value
154 * not found, the corresponding argument is left unchanged.
158 read_integer (string
, NextString
)
159 register char *string
;
162 register int Result
= 0;
167 else if (*string
== '-')
172 for (; (*string
>= '0') && (*string
<= '9'); string
++)
174 Result
= (Result
* 10) + (*string
- '0');
176 *NextString
= string
;
184 XParseGeometry (string
, x
, y
, width
, height
)
187 unsigned int *width
, *height
; /* RETURN */
190 register char *strind
;
191 unsigned int tempWidth
, tempHeight
;
195 if ((string
== NULL
) || (*string
== '\0')) return (mask
);
197 string
++; /* ignore possible '=' at beg of geometry spec */
199 strind
= (char *)string
;
200 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
202 tempWidth
= read_integer (strind
, &nextCharacter
);
203 if (strind
== nextCharacter
)
205 strind
= nextCharacter
;
209 if (*strind
== 'x' || *strind
== 'X')
212 tempHeight
= read_integer (strind
, &nextCharacter
);
213 if (strind
== nextCharacter
)
215 strind
= nextCharacter
;
219 if ((*strind
== '+') || (*strind
== '-'))
224 tempX
= -read_integer (strind
, &nextCharacter
);
225 if (strind
== nextCharacter
)
227 strind
= nextCharacter
;
234 tempX
= read_integer (strind
, &nextCharacter
);
235 if (strind
== nextCharacter
)
237 strind
= nextCharacter
;
240 if ((*strind
== '+') || (*strind
== '-'))
245 tempY
= -read_integer (strind
, &nextCharacter
);
246 if (strind
== nextCharacter
)
248 strind
= nextCharacter
;
255 tempY
= read_integer (strind
, &nextCharacter
);
256 if (strind
== nextCharacter
)
258 strind
= nextCharacter
;
264 /* If strind isn't at the end of the string the it's an invalid
265 geometry specification. */
267 if (*strind
!= '\0') return (0);
273 if (mask
& WidthValue
)
275 if (mask
& HeightValue
)
276 *height
= tempHeight
;
280 /* We can use mouse menus when we wish. */
287 /* x_sync is a no-op on Win32. */