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, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 #include "blockinput.h"
29 #define myalloc(cb) GlobalAllocPtr (GPTR, cb)
30 #define myfree(lp) GlobalFreePtr (lp)
32 CRITICAL_SECTION critsect
;
33 extern HANDLE keyboard_handle
;
39 InitializeCriticalSection (&critsect
);
40 keyboard_handle
= hEvent
= CreateEvent (NULL
, FALSE
, FALSE
, NULL
);
46 EnterCriticalSection (&critsect
);
52 LeaveCriticalSection (&critsect
);
58 DeleteCriticalSection (&critsect
);
66 typedef struct int_msg
69 struct int_msg
*lpNext
;
72 int_msg
*lpHead
= NULL
;
73 int_msg
*lpTail
= NULL
;
77 get_next_msg (lpmsg
, bWait
)
85 /* The while loop takes care of multiple sets */
87 while (!nQueue
&& bWait
)
90 WaitForSingleObject (hEvent
, INFINITE
);
96 bcopy (&(lpHead
->w32msg
), lpmsg
, sizeof (Win32Msg
));
99 int_msg
* lpCur
= lpHead
;
101 lpHead
= lpHead
->lpNext
;
120 int_msg
* lpNew
= (int_msg
*) myalloc (sizeof (int_msg
));
122 if (!lpNew
) return (FALSE
);
124 bcopy (lpmsg
, &(lpNew
->w32msg
), sizeof (Win32Msg
));
125 lpNew
->lpNext
= NULL
;
131 lpTail
->lpNext
= lpNew
;
147 prepend_msg (Win32Msg
*lpmsg
)
149 int_msg
* lpNew
= (int_msg
*) myalloc (sizeof (int_msg
));
154 bcopy (lpmsg
, &(lpNew
->w32msg
), sizeof (Win32Msg
));
159 lpNew
->lpNext
= lpHead
;
168 * XParseGeometry parses strings of the form
169 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
170 * width, height, xoffset, and yoffset are unsigned integers.
171 * Example: "=80x24+300-49"
172 * The equal sign is optional.
173 * It returns a bitmask that indicates which of the four values
174 * were actually found in the string. For each value found,
175 * the corresponding argument is updated; for each value
176 * not found, the corresponding argument is left unchanged.
180 read_integer (string
, NextString
)
181 register char *string
;
184 register int Result
= 0;
189 else if (*string
== '-')
194 for (; (*string
>= '0') && (*string
<= '9'); string
++)
196 Result
= (Result
* 10) + (*string
- '0');
198 *NextString
= string
;
206 XParseGeometry (string
, x
, y
, width
, height
)
209 unsigned int *width
, *height
; /* RETURN */
212 register char *strind
;
213 unsigned int tempWidth
, tempHeight
;
217 if ((string
== NULL
) || (*string
== '\0')) return (mask
);
219 string
++; /* ignore possible '=' at beg of geometry spec */
221 strind
= (char *)string
;
222 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
224 tempWidth
= read_integer (strind
, &nextCharacter
);
225 if (strind
== nextCharacter
)
227 strind
= nextCharacter
;
231 if (*strind
== 'x' || *strind
== 'X')
234 tempHeight
= read_integer (strind
, &nextCharacter
);
235 if (strind
== nextCharacter
)
237 strind
= nextCharacter
;
241 if ((*strind
== '+') || (*strind
== '-'))
246 tempX
= -read_integer (strind
, &nextCharacter
);
247 if (strind
== nextCharacter
)
249 strind
= nextCharacter
;
256 tempX
= read_integer (strind
, &nextCharacter
);
257 if (strind
== nextCharacter
)
259 strind
= nextCharacter
;
262 if ((*strind
== '+') || (*strind
== '-'))
267 tempY
= -read_integer (strind
, &nextCharacter
);
268 if (strind
== nextCharacter
)
270 strind
= nextCharacter
;
277 tempY
= read_integer (strind
, &nextCharacter
);
278 if (strind
== nextCharacter
)
280 strind
= nextCharacter
;
286 /* If strind isn't at the end of the string the it's an invalid
287 geometry specification. */
289 if (*strind
!= '\0') return (0);
295 if (mask
& WidthValue
)
297 if (mask
& HeightValue
)
298 *height
= tempHeight
;
302 /* We can use mouse menus when we wish. */
309 /* x_sync is a no-op on Win32. */