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 * XParseGeometry parses strings of the form
148 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
149 * width, height, xoffset, and yoffset are unsigned integers.
150 * Example: "=80x24+300-49"
151 * The equal sign is optional.
152 * It returns a bitmask that indicates which of the four values
153 * were actually found in the string. For each value found,
154 * the corresponding argument is updated; for each value
155 * not found, the corresponding argument is left unchanged.
159 read_integer (string
, NextString
)
160 register char *string
;
163 register int Result
= 0;
168 else if (*string
== '-')
173 for (; (*string
>= '0') && (*string
<= '9'); string
++)
175 Result
= (Result
* 10) + (*string
- '0');
177 *NextString
= string
;
185 XParseGeometry (string
, x
, y
, width
, height
)
188 unsigned int *width
, *height
; /* RETURN */
191 register char *strind
;
192 unsigned int tempWidth
, tempHeight
;
196 if ((string
== NULL
) || (*string
== '\0')) return (mask
);
198 string
++; /* ignore possible '=' at beg of geometry spec */
200 strind
= (char *)string
;
201 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x')
203 tempWidth
= read_integer (strind
, &nextCharacter
);
204 if (strind
== nextCharacter
)
206 strind
= nextCharacter
;
210 if (*strind
== 'x' || *strind
== 'X')
213 tempHeight
= read_integer (strind
, &nextCharacter
);
214 if (strind
== nextCharacter
)
216 strind
= nextCharacter
;
220 if ((*strind
== '+') || (*strind
== '-'))
225 tempX
= -read_integer (strind
, &nextCharacter
);
226 if (strind
== nextCharacter
)
228 strind
= nextCharacter
;
235 tempX
= read_integer (strind
, &nextCharacter
);
236 if (strind
== nextCharacter
)
238 strind
= nextCharacter
;
241 if ((*strind
== '+') || (*strind
== '-'))
246 tempY
= -read_integer (strind
, &nextCharacter
);
247 if (strind
== nextCharacter
)
249 strind
= nextCharacter
;
256 tempY
= read_integer (strind
, &nextCharacter
);
257 if (strind
== nextCharacter
)
259 strind
= nextCharacter
;
265 /* If strind isn't at the end of the string the it's an invalid
266 geometry specification. */
268 if (*strind
!= '\0') return (0);
274 if (mask
& WidthValue
)
276 if (mask
& HeightValue
)
277 *height
= tempHeight
;
281 /* We can use mouse menus when we wish. */
288 /* x_sync is a no-op on Win32. */