213
|
1 /* Functions for the mswindows window system.
|
|
2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not synched with FSF. */
|
|
23
|
|
24 /* Authorship:
|
|
25
|
|
26 Ultimately based on FSF.
|
|
27 Substantially rewritten for XEmacs by Ben Wing.
|
272
|
28 Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0.
|
213
|
29 */
|
|
30
|
|
31 #include <config.h>
|
|
32 #include "lisp.h"
|
|
33
|
269
|
34 #include "buffer.h"
|
213
|
35 #include "console-msw.h"
|
272
|
36 #include "glyphs-msw.h"
|
269
|
37 #include "events.h"
|
231
|
38 #include "faces.h"
|
213
|
39 #include "frame.h"
|
269
|
40 #include "redisplay.h"
|
276
|
41 #include "window.h"
|
213
|
42
|
269
|
43 #define MSWINDOWS_FRAME_STYLE (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW)
|
|
44 #define MSWINDOWS_POPUP_STYLE (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP \
|
|
45 | WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX)
|
223
|
46
|
|
47 #define MSWINDOWS_FRAME_EXSTYLE WS_EX_OVERLAPPEDWINDOW
|
269
|
48 #define MSWINDOWS_POPUP_EXSTYLE WS_EX_PALETTEWINDOW
|
|
49
|
|
50 /* Default popup left top corner offset from the same
|
|
51 corner of the parent frame, in pixel */
|
|
52 #define POPUP_OFFSET 30
|
|
53
|
|
54 /* Default popup size, in characters */
|
|
55 #define POPUP_WIDTH 30
|
|
56 #define POPUP_HEIGHT 10
|
223
|
57
|
294
|
58 /* Default popup size, in characters */
|
|
59 #define DEFAULT_FRAME_WIDTH 80
|
|
60 #define DEFAULT_FRAME_HEIGHT 35
|
|
61
|
223
|
62 #ifdef HAVE_MENUBARS
|
|
63 #define ADJR_MENUFLAG TRUE
|
|
64 #else
|
|
65 #define ADJR_MENUFLAG FALSE
|
|
66 #endif
|
|
67
|
213
|
68 /* Default properties to use when creating frames. */
|
|
69 Lisp_Object Vdefault_mswindows_frame_plist;
|
294
|
70 Lisp_Object Vmswindows_use_system_frame_size_defaults;
|
269
|
71
|
213
|
72 /* Lisp_Object Qname, Qheight, Qwidth, Qinitially_unmapped, Qpopup, Qtop, Qleft; */
|
|
73 Lisp_Object Qinitially_unmapped, Qpopup;
|
|
74
|
269
|
75 /* This does not need to be GC protected, as it holds a
|
|
76 frame Lisp_Object already protected by Fmake_frame */
|
276
|
77 Lisp_Object Vmswindows_frame_being_created;
|
269
|
78
|
213
|
79 static void
|
|
80 mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
|
|
81 {
|
231
|
82 Lisp_Object initially_unmapped;
|
223
|
83 Lisp_Object name, height, width, popup, top, left;
|
269
|
84 Lisp_Object frame_obj = Qnil;
|
223
|
85 RECT rect;
|
269
|
86 XEMACS_RECT_WH rect_default;
|
223
|
87 DWORD style, exstyle;
|
269
|
88 HWND hwnd, hwnd_parent;
|
290
|
89 static BOOL first_frame = 1;
|
213
|
90
|
269
|
91 /* Pick up relevant properties */
|
223
|
92 initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
|
|
93 name = Fplist_get (props, Qname, Qnil);
|
269
|
94
|
223
|
95 popup = Fplist_get (props, Qpopup, Qnil);
|
269
|
96 if (EQ (popup, Qt))
|
|
97 popup = Fselected_frame (Qnil);
|
|
98
|
|
99 left = Fplist_get (props, Qleft, Qnil);
|
|
100 if (!NILP (left))
|
|
101 CHECK_INT (left);
|
|
102
|
223
|
103 top = Fplist_get (props, Qtop, Qnil);
|
269
|
104 if (!NILP (top))
|
|
105 CHECK_INT (top);
|
|
106
|
|
107 width = Fplist_get (props, Qwidth, Qnil);
|
|
108 if (!NILP (width))
|
|
109 CHECK_INT (width);
|
|
110
|
|
111 height = Fplist_get (props, Qheight, Qnil);
|
|
112 if (!NILP (height))
|
|
113 CHECK_INT (height);
|
|
114
|
294
|
115 f->frame_data = xnew_and_zero (struct mswindows_frame);
|
|
116 FRAME_MSWINDOWS_TARGET_RECT (f) = xnew_and_zero (XEMACS_RECT_WH);
|
213
|
117
|
294
|
118 FRAME_MSWINDOWS_TARGET_RECT (f)->left = NILP (left) ? -1 : abs (XINT (left));
|
|
119 FRAME_MSWINDOWS_TARGET_RECT (f)->top = NILP (top) ? -1 : abs (XINT (top));
|
|
120 FRAME_MSWINDOWS_TARGET_RECT (f)->width = NILP (width) ? -1 :
|
|
121 abs (XINT (width));
|
|
122 FRAME_MSWINDOWS_TARGET_RECT (f)->height = NILP (height) ? -1 :
|
|
123 abs (XINT (height));
|
|
124
|
269
|
125 /* Misc frame stuff */
|
223
|
126 FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0;
|
|
127 FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0;
|
|
128 FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0;
|
|
129 FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0;
|
|
130 FRAME_MSWINDOWS_DATA(f)->ignore_next_rbutton_up = 0;
|
|
131 FRAME_MSWINDOWS_DATA(f)->sizing = 0;
|
231
|
132 FRAME_MSWINDOWS_MENU_HASHTABLE(f) = Qnil;
|
276
|
133 #ifdef HAVE_TOOLBARS
|
|
134 FRAME_MSWINDOWS_TOOLBAR_HASHTABLE(f) = Fmake_hashtable (make_int (50),
|
|
135 Qequal);
|
|
136 #endif
|
231
|
137
|
269
|
138 /* Will initialize these in WM_SIZE handler. We cannot do it now,
|
|
139 because we do not know what is CW_USEDEFAULT height and width */
|
|
140 FRAME_WIDTH (f) = 0;
|
|
141 FRAME_HEIGHT (f) = 0;
|
|
142 FRAME_PIXWIDTH (f) = 0;
|
|
143 FRAME_PIXHEIGHT (f) = 0;
|
|
144
|
|
145 if (NILP (popup))
|
|
146 {
|
|
147 style = MSWINDOWS_FRAME_STYLE;
|
|
148 exstyle = MSWINDOWS_FRAME_EXSTYLE;
|
|
149 hwnd_parent = NULL;
|
|
150
|
290
|
151 if (first_frame)
|
|
152 {
|
|
153 style |= WS_VISIBLE;
|
|
154 first_frame = 0;
|
|
155 }
|
|
156
|
269
|
157 rect_default.left = rect_default.top = CW_USEDEFAULT;
|
|
158 rect_default.width = rect_default.height = CW_USEDEFAULT;
|
|
159 }
|
|
160 else
|
|
161 {
|
|
162 style = MSWINDOWS_POPUP_STYLE;
|
|
163 exstyle = MSWINDOWS_POPUP_EXSTYLE;
|
|
164
|
|
165 CHECK_MSWINDOWS_FRAME (popup);
|
|
166 hwnd_parent = FRAME_MSWINDOWS_HANDLE (XFRAME (popup));
|
|
167 assert (IsWindow (hwnd_parent));
|
|
168
|
|
169 /* We cannot use CW_USEDEFAULT when creating a popup window.
|
|
170 So by default, we offset the new popup 30 pixels right
|
|
171 and down from its parent, and give it size of 30x10 characters.
|
|
172 These dimensions look adequate on both high and low res monitors */
|
|
173 GetWindowRect (hwnd_parent, &rect);
|
|
174 rect_default.left = rect.left + POPUP_OFFSET;
|
|
175 rect_default.top = rect.top + POPUP_OFFSET;
|
|
176 char_to_real_pixel_size (f, POPUP_WIDTH, POPUP_HEIGHT,
|
|
177 &rect_default.width, &rect_default.height);
|
|
178 }
|
|
179
|
223
|
180 AdjustWindowRectEx(&rect, style, ADJR_MENUFLAG, exstyle);
|
|
181
|
|
182 XSETFRAME (frame_obj, f);
|
269
|
183
|
276
|
184 Vmswindows_frame_being_created = frame_obj;
|
269
|
185
|
|
186 hwnd = CreateWindowEx (exstyle,
|
|
187 XEMACS_CLASS,
|
|
188 STRINGP(f->name) ? XSTRING_DATA(f->name) :
|
278
|
189 (STRINGP(name) ? XSTRING_DATA(name) : XEMACS_CLASS),
|
269
|
190 style,
|
|
191 rect_default.left, rect_default.top,
|
|
192 rect_default.width, rect_default.height,
|
|
193 hwnd_parent, NULL, NULL, NULL);
|
|
194
|
276
|
195 Vmswindows_frame_being_created = Qnil;
|
269
|
196
|
|
197 if (hwnd == NULL)
|
|
198 error ("System call to create frame failed");
|
|
199
|
|
200 FRAME_MSWINDOWS_HANDLE(f) = hwnd;
|
|
201
|
|
202 SetWindowLong (hwnd, XWL_FRAMEOBJ, (LONG)LISP_TO_VOID(frame_obj));
|
|
203 FRAME_MSWINDOWS_DC(f) = GetDC (hwnd);
|
|
204 FRAME_MSWINDOWS_CDC(f) = CreateCompatibleDC (FRAME_MSWINDOWS_CDC(f));
|
|
205 SetTextAlign (FRAME_MSWINDOWS_DC(f), TA_BASELINE | TA_LEFT | TA_NOUPDATECP);
|
213
|
206 }
|
|
207
|
|
208 static void
|
|
209 mswindows_init_frame_2 (struct frame *f, Lisp_Object props)
|
|
210 {
|
294
|
211 if (NILP (Vmswindows_use_system_frame_size_defaults))
|
|
212 {
|
|
213 /* I don't think anything can set the frame size before this
|
|
214 since we don't have X resources. This may change if we look
|
|
215 at the registry. Even so these values can get overridden
|
|
216 later.*/
|
|
217 XEMACS_RECT_WH dest = { -1, -1, DEFAULT_FRAME_WIDTH,
|
|
218 DEFAULT_FRAME_HEIGHT };
|
|
219 mswindows_size_frame_internal (f, &dest);
|
|
220 }
|
213
|
221 }
|
|
222
|
|
223 /* Called after frame's properties are set */
|
|
224 static void
|
|
225 mswindows_init_frame_3 (struct frame *f)
|
|
226 {
|
269
|
227 /* Don't do this earlier or we get a WM_PAINT before the frame is ready */
|
219
|
228 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
|
229 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
249
|
230 DragAcceptFiles (FRAME_MSWINDOWS_HANDLE(f), TRUE);
|
219
|
231 }
|
|
232
|
|
233 static void
|
269
|
234 mswindows_after_init_frame (struct frame *f, int first_on_device,
|
|
235 int first_on_console)
|
|
236 {
|
|
237 /* Windows, unlike X, is very synchronous. After the initial
|
|
238 frame is created, it will never be displayed, except for
|
|
239 hollow border, unless we start pumping messages. Load progress
|
|
240 messages show in the bottom of the hollow frame, which is ugly.
|
|
241 We redipsplay the initial frame here, so modeline and root window
|
|
242 backgorund show.
|
|
243 */
|
|
244 if (first_on_console)
|
|
245 redisplay ();
|
|
246 }
|
|
247
|
|
248 static void
|
231
|
249 mswindows_mark_frame (struct frame *f, void (*markobj) (Lisp_Object))
|
|
250 {
|
|
251 ((markobj) (FRAME_MSWINDOWS_MENU_HASHTABLE (f)));
|
276
|
252 #ifdef HAVE_TOOLBARS
|
|
253 ((markobj) (FRAME_MSWINDOWS_TOOLBAR_HASHTABLE (f)));
|
|
254 #endif
|
231
|
255 }
|
|
256
|
|
257 static void
|
219
|
258 mswindows_focus_on_frame (struct frame *f)
|
|
259 {
|
269
|
260 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
213
|
261 }
|
|
262
|
|
263 static void
|
|
264 mswindows_delete_frame (struct frame *f)
|
|
265 {
|
|
266 if (f->frame_data)
|
|
267 {
|
269
|
268 DeleteDC(FRAME_MSWINDOWS_CDC(f));
|
223
|
269 ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
|
|
270 DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
|
269
|
271 xfree (f->frame_data);
|
213
|
272 }
|
269
|
273 f->frame_data = 0;
|
213
|
274 }
|
|
275
|
|
276 static void
|
294
|
277 mswindows_set_frame_size (struct frame *f, int width, int height)
|
213
|
278 {
|
269
|
279 RECT rect;
|
|
280 rect.left = rect.top = 0;
|
294
|
281 rect.right = width;
|
|
282 rect.bottom = height;
|
223
|
283
|
269
|
284 AdjustWindowRectEx (&rect,
|
223
|
285 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
286 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
287 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
269
|
288
|
|
289 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f)) || IsZoomed (FRAME_MSWINDOWS_HANDLE(f)))
|
|
290 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
|
291
|
|
292 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
|
|
293 0, 0, rect.right-rect.left, rect.bottom-rect.top,
|
|
294 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOMOVE);
|
213
|
295 }
|
|
296
|
|
297 static void
|
|
298 mswindows_set_frame_position (struct frame *f, int xoff, int yoff)
|
|
299 {
|
269
|
300 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
|
|
301 xoff, yoff, 0, 0,
|
|
302 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE);
|
219
|
303 }
|
|
304
|
|
305 static void
|
|
306 mswindows_make_frame_visible (struct frame *f)
|
|
307 {
|
|
308 if (f->iconified)
|
|
309 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
|
310 else
|
|
311 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
|
312 f->visible = 1;
|
|
313 f->iconified = 0;
|
|
314 }
|
|
315
|
|
316 static void
|
|
317 mswindows_make_frame_invisible (struct frame *f)
|
|
318 {
|
|
319 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_HIDE);
|
|
320 f->visible = -1;
|
|
321 }
|
|
322
|
|
323 static int
|
276
|
324 mswindows_frame_totally_visible_p (struct frame *f)
|
|
325 {
|
|
326 RECT rc_me, rc_other, rc_temp;
|
|
327 HWND hwnd = FRAME_MSWINDOWS_HANDLE(f);
|
|
328
|
|
329 /* We test against not a whole window rectangle, only agaist its
|
|
330 client part. So, if non-client are is covered and client area is
|
|
331 not, we return true. */
|
|
332 GetClientRect (hwnd, &rc_me);
|
|
333 MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rc_me, 2);
|
|
334
|
|
335 /* First see if we're off the desktop */
|
|
336 GetWindowRect (GetDesktopWindow(), &rc_other);
|
|
337 UnionRect(&rc_temp, &rc_me, &rc_other);
|
|
338 if (!EqualRect (&rc_temp, &rc_other))
|
|
339 return 0;
|
|
340
|
|
341 /* Then see if any window above us obscures us */
|
|
342 while ((hwnd = GetWindow (hwnd, GW_HWNDPREV)) != NULL)
|
|
343 if (IsWindowVisible (hwnd))
|
|
344 {
|
|
345 GetWindowRect (hwnd, &rc_other);
|
|
346 if (IntersectRect(&rc_temp, &rc_me, &rc_other))
|
|
347 return 0;
|
|
348 }
|
|
349
|
|
350 return 1;
|
|
351 }
|
|
352
|
|
353 static int
|
219
|
354 mswindows_frame_visible_p (struct frame *f)
|
|
355 {
|
|
356 return IsWindowVisible (FRAME_MSWINDOWS_HANDLE(f))
|
|
357 && !IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
358 }
|
|
359
|
|
360
|
|
361 static void
|
|
362 mswindows_iconify_frame (struct frame *f)
|
|
363 {
|
|
364 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_MINIMIZE);
|
|
365 f->visible = 0;
|
|
366 f->iconified = 1;
|
|
367 }
|
|
368
|
|
369 static int
|
|
370 mswindows_frame_iconified_p (struct frame *f)
|
|
371 {
|
|
372 return IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
373 }
|
|
374
|
|
375 static void
|
272
|
376 mswindows_set_frame_icon (struct frame *f)
|
|
377 {
|
|
378 if (IMAGE_INSTANCEP (f->icon)
|
|
379 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon)))
|
|
380 {
|
|
381 if (!XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon))
|
|
382 {
|
282
|
383 mswindows_initialize_image_instance_icon (XIMAGE_INSTANCE (f->icon),
|
|
384 FALSE);
|
272
|
385 }
|
|
386
|
|
387 SetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HICON,
|
|
388 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon));
|
|
389 }
|
|
390 }
|
|
391
|
|
392 static void
|
|
393 mswindows_set_frame_pointer (struct frame *f)
|
|
394 {
|
282
|
395 if (IMAGE_INSTANCEP (f->pointer)
|
|
396 && IMAGE_INSTANCE_TYPE (XIMAGE_INSTANCE (f->pointer)) == IMAGE_POINTER)
|
|
397 {
|
|
398 SetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HCURSOR,
|
|
399 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->pointer));
|
|
400 }
|
272
|
401 }
|
|
402
|
276
|
403 static void
|
|
404 mswindows_set_mouse_position (struct window *w, int x, int y)
|
|
405 {
|
|
406 struct frame *f = XFRAME (w->frame);
|
|
407 POINT pt;
|
|
408
|
|
409 pt.x = w->pixel_left + x;
|
|
410 pt.y = w->pixel_top + y;
|
|
411 ClientToScreen (FRAME_MSWINDOWS_HANDLE(f), &pt);
|
|
412 SetCursorPos (pt.x, pt.y);
|
|
413 }
|
|
414
|
|
415 static int
|
|
416 mswindows_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y)
|
|
417 {
|
|
418 POINT pt;
|
|
419 HWND hwnd;
|
|
420
|
|
421 GetCursorPos (&pt);
|
|
422
|
|
423 /* What's under cursor? */
|
|
424 hwnd = WindowFromPoint (pt);
|
|
425 if (hwnd == NULL)
|
|
426 return 0;
|
|
427
|
|
428 /* Get grandest parent of the window */
|
|
429 {
|
|
430 HWND hwnd_parent;
|
|
431 while ((hwnd_parent = GetParent (hwnd)) != NULL)
|
|
432 hwnd = hwnd_parent;
|
|
433 }
|
|
434
|
|
435 /* Make sure it belongs to us */
|
|
436 if (GetWindowThreadProcessId (hwnd, NULL) != GetCurrentThreadId ())
|
|
437 return 0;
|
|
438
|
|
439 /* And that the window is an XEmacs frame */
|
|
440 {
|
|
441 char class_name [sizeof(XEMACS_CLASS) + 1];
|
|
442 if (!GetClassName (hwnd, class_name, sizeof(XEMACS_CLASS))
|
|
443 || strcmp (class_name, XEMACS_CLASS) != 0)
|
|
444 return 0;
|
|
445 }
|
|
446
|
|
447 /* Yippie! */
|
|
448 ScreenToClient (hwnd, &pt);
|
|
449 VOID_TO_LISP (*frame, GetWindowLong (hwnd, XWL_FRAMEOBJ));
|
|
450 *x = pt.x;
|
|
451 *y = pt.y;
|
|
452 return 1;
|
|
453 }
|
|
454
|
272
|
455 static void
|
219
|
456 mswindows_raise_frame (struct frame *f)
|
|
457 {
|
|
458 BringWindowToTop (FRAME_MSWINDOWS_HANDLE(f));
|
|
459 /* XXX Should we do SetWindowForeground too ? */
|
|
460 }
|
|
461
|
|
462 static void
|
|
463 mswindows_lower_frame (struct frame *f)
|
|
464 {
|
269
|
465 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), HWND_BOTTOM, 0, 0, 0, 0,
|
|
466 SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING);
|
219
|
467 }
|
|
468
|
|
469 static void
|
|
470 mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title)
|
|
471 {
|
274
|
472 unsigned int new_checksum = hash_string (title, strlen (title));
|
|
473 if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM(f))
|
|
474 {
|
|
475 FRAME_MSWINDOWS_TITLE_CHECKSUM(f) = new_checksum;
|
|
476 SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title);
|
|
477 }
|
|
478 }
|
|
479
|
|
480 static Lisp_Object
|
|
481 mswindows_frame_property (struct frame *f, Lisp_Object property)
|
|
482 {
|
|
483 if (EQ (Qleft, property) || EQ (Qtop, property))
|
|
484 {
|
|
485 RECT rc;
|
|
486 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rc);
|
|
487 return make_int (EQ (Qtop, property) ? rc.top : rc.left);
|
|
488 }
|
|
489 return Qunbound;
|
|
490 }
|
|
491
|
|
492 static int
|
|
493 mswindows_internal_frame_property_p (struct frame *f, Lisp_Object property)
|
|
494 {
|
|
495 return EQ (property, Qleft)
|
|
496 || EQ (property, Qtop);
|
|
497 /* #### frame-x.c has also this. Why?
|
|
498 || STRINGP (property);
|
|
499 */
|
|
500 }
|
|
501
|
|
502 static Lisp_Object
|
|
503 mswindows_frame_properties (struct frame *f)
|
|
504 {
|
|
505 Lisp_Object props = Qnil;
|
|
506 RECT rc;
|
|
507 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rc);
|
|
508
|
|
509 props = cons3 (Qtop, make_int (rc.top), props);
|
|
510 props = cons3 (Qleft, make_int (rc.left), props);
|
|
511
|
|
512 return props;
|
213
|
513 }
|
|
514
|
|
515 static void
|
|
516 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
517 {
|
294
|
518 int x=-1, y=-1;
|
|
519 int width = -1, height = -1;
|
213
|
520 BOOL width_specified_p = FALSE;
|
|
521 BOOL height_specified_p = FALSE;
|
|
522 BOOL x_specified_p = FALSE;
|
|
523 BOOL y_specified_p = FALSE;
|
|
524 Lisp_Object tail;
|
|
525
|
|
526 /* Extract the properties from plist */
|
|
527 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
528 {
|
|
529 Lisp_Object prop = Fcar (tail);
|
|
530 Lisp_Object val = Fcar (Fcdr (tail));
|
|
531
|
|
532 if (SYMBOLP (prop))
|
|
533 {
|
|
534 /* Kludge to handle the font property. */
|
|
535 if (EQ (prop, Qfont))
|
|
536 {
|
|
537 /* If the value is not a string we silently ignore it. */
|
|
538 if (STRINGP (val))
|
|
539 {
|
|
540 Lisp_Object frm, font_spec;
|
|
541
|
|
542 XSETFRAME (frm, f);
|
|
543 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil);
|
|
544
|
|
545 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil);
|
|
546 update_frame_face_values (f);
|
|
547 }
|
|
548 }
|
|
549 else if (EQ (prop, Qwidth))
|
|
550 {
|
|
551 CHECK_INT (val);
|
|
552 width = XINT (val);
|
|
553 width_specified_p = TRUE;
|
|
554 }
|
|
555 else if (EQ (prop, Qheight))
|
|
556 {
|
|
557 CHECK_INT (val);
|
|
558 height = XINT (val);
|
|
559 height_specified_p = TRUE;
|
|
560 }
|
|
561 else if (EQ (prop, Qleft))
|
|
562 {
|
|
563 CHECK_INT (val);
|
|
564 x = XINT (val);
|
|
565 x_specified_p = TRUE;
|
|
566 }
|
|
567 else if (EQ (prop, Qtop))
|
|
568 {
|
|
569 CHECK_INT (val);
|
|
570 y = XINT (val);
|
|
571 y_specified_p = TRUE;
|
|
572 }
|
|
573 }
|
|
574 }
|
|
575
|
269
|
576 /* Now we've extracted the properties, apply them.
|
|
577 Do not apply geometric properties during frame creation. This
|
|
578 is excessive anyways, and this loses becuase WM_SIZE has not
|
294
|
579 been sent yet, so frame width and height fields are not initialized.
|
|
580
|
|
581 unfortunately WM_SIZE loses as well since the resize is only
|
|
582 applied once and the first time WM_SIZE is applied not everything
|
|
583 is initialised in the frame (toolbars for instance). enabling
|
|
584 this always makes no visible difference and fixes a whole host of
|
|
585 bugs (and is more consistent with X) so I am going to reenable it.
|
|
586 --andyp */
|
|
587 if ( FRAME_PIXWIDTH (f) && FRAME_PIXHEIGHT (f)
|
|
588 && (width_specified_p || height_specified_p || x_specified_p || y_specified_p))
|
213
|
589 {
|
294
|
590 XEMACS_RECT_WH dest = { x, y, width, height };
|
|
591
|
|
592 mswindows_size_frame_internal (f, &dest);
|
|
593 }
|
|
594 }
|
213
|
595
|
294
|
596 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest)
|
|
597 {
|
|
598 RECT rect;
|
|
599 int pixel_width, pixel_height;
|
|
600 int size_p = (dest->width >=0 || dest->height >=0);
|
|
601 int move_p = (dest->top >=0 || dest->left >=0);
|
213
|
602
|
294
|
603 char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, &pixel_height);
|
|
604
|
|
605 if (dest->width < 0)
|
|
606 pixel_width = FRAME_PIXWIDTH (f);
|
|
607 if (dest->height < 0)
|
|
608 pixel_height = FRAME_PIXHEIGHT (f);
|
|
609
|
|
610 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
611 if (dest->left < 0)
|
|
612 dest->left = rect.left;
|
|
613 if (dest->top < 0)
|
|
614 dest->top = rect.top;
|
219
|
615
|
294
|
616 rect.left = rect.top = 0;
|
|
617 rect.right = pixel_width;
|
|
618 rect.bottom = pixel_height;
|
|
619
|
|
620 AdjustWindowRectEx (&rect,
|
|
621 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
622 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
623 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
223
|
624
|
294
|
625 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f))
|
|
626 || IsZoomed (FRAME_MSWINDOWS_HANDLE(f)))
|
|
627 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
269
|
628
|
294
|
629 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
|
|
630 dest->left, dest->top, rect.right - rect.left, rect.bottom - rect.top,
|
|
631 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING
|
|
632 | (size_p ? 0 : SWP_NOSIZE)
|
|
633 | (move_p ? 0 : SWP_NOMOVE));
|
213
|
634 }
|
|
635
|
269
|
636 static Lisp_Object
|
|
637 mswindows_get_frame_parent (struct frame *f)
|
|
638 {
|
|
639 HWND hwnd = FRAME_MSWINDOWS_HANDLE(f);
|
|
640 hwnd = GetParent (hwnd);
|
|
641 if (hwnd)
|
|
642 {
|
|
643 Lisp_Object parent;
|
|
644 VOID_TO_LISP (parent, GetWindowLong (hwnd, XWL_FRAMEOBJ));
|
|
645 assert (FRAME_MSWINDOWS_P (XFRAME (parent)));
|
|
646 return parent;
|
|
647 }
|
|
648 else
|
|
649 return Qnil;
|
|
650 }
|
|
651
|
|
652 static void
|
|
653 mswindows_update_frame_external_traits (struct frame* frm, Lisp_Object name)
|
|
654 {
|
282
|
655 }
|
269
|
656
|
282
|
657 static int
|
|
658 mswindows_frame_size_fixed_p (struct frame *f)
|
|
659 {
|
|
660 /* Frame size cannot change if the frame is maximized */
|
|
661 return IsZoomed (FRAME_MSWINDOWS_HANDLE (f));
|
269
|
662 }
|
213
|
663
|
|
664 void
|
|
665 console_type_create_frame_mswindows (void)
|
|
666 {
|
|
667 /* frame methods */
|
|
668 CONSOLE_HAS_METHOD (mswindows, init_frame_1);
|
294
|
669 CONSOLE_HAS_METHOD (mswindows, init_frame_2);
|
213
|
670 CONSOLE_HAS_METHOD (mswindows, init_frame_3);
|
269
|
671 CONSOLE_HAS_METHOD (mswindows, after_init_frame);
|
231
|
672 CONSOLE_HAS_METHOD (mswindows, mark_frame);
|
219
|
673 CONSOLE_HAS_METHOD (mswindows, focus_on_frame);
|
213
|
674 CONSOLE_HAS_METHOD (mswindows, delete_frame);
|
276
|
675 CONSOLE_HAS_METHOD (mswindows, get_mouse_position);
|
|
676 CONSOLE_HAS_METHOD (mswindows, set_mouse_position);
|
219
|
677 CONSOLE_HAS_METHOD (mswindows, raise_frame);
|
|
678 CONSOLE_HAS_METHOD (mswindows, lower_frame);
|
|
679 CONSOLE_HAS_METHOD (mswindows, make_frame_visible);
|
|
680 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible);
|
|
681 CONSOLE_HAS_METHOD (mswindows, iconify_frame);
|
213
|
682 CONSOLE_HAS_METHOD (mswindows, set_frame_size);
|
|
683 CONSOLE_HAS_METHOD (mswindows, set_frame_position);
|
274
|
684 CONSOLE_HAS_METHOD (mswindows, frame_property);
|
|
685 CONSOLE_HAS_METHOD (mswindows, internal_frame_property_p);
|
|
686 CONSOLE_HAS_METHOD (mswindows, frame_properties);
|
213
|
687 CONSOLE_HAS_METHOD (mswindows, set_frame_properties);
|
219
|
688 CONSOLE_HAS_METHOD (mswindows, set_title_from_bufbyte);
|
213
|
689 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_bufbyte); */
|
219
|
690 CONSOLE_HAS_METHOD (mswindows, frame_visible_p);
|
276
|
691 CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p);
|
219
|
692 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p);
|
272
|
693 CONSOLE_HAS_METHOD (mswindows, set_frame_pointer);
|
|
694 CONSOLE_HAS_METHOD (mswindows, set_frame_icon);
|
269
|
695 CONSOLE_HAS_METHOD (mswindows, get_frame_parent);
|
|
696 CONSOLE_HAS_METHOD (mswindows, update_frame_external_traits);
|
282
|
697 CONSOLE_HAS_METHOD (mswindows, frame_size_fixed_p);
|
213
|
698 }
|
|
699
|
|
700 void
|
|
701 syms_of_frame_mswindows (void)
|
|
702 {
|
|
703 }
|
|
704
|
|
705 void
|
|
706 vars_of_frame_mswindows (void)
|
|
707 {
|
276
|
708 /* Needn't staticpro -- see comment above. */
|
|
709 Vmswindows_frame_being_created = Qnil;
|
269
|
710
|
294
|
711 DEFVAR_LISP ("mswindows-use-system-frame-size-defaults", &Vmswindows_use_system_frame_size_defaults /*
|
|
712 Controls whether to use system or XEmacs defaults for frame size.
|
|
713 If nil then reasonable defaults are used for intial frame sizes. If t
|
|
714 then the system will choose default sizes for the frame.
|
|
715 */ );
|
|
716 Vmswindows_use_system_frame_size_defaults = Qnil;
|
|
717
|
213
|
718 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /*
|
|
719 Plist of default frame-creation properties for mswindows frames.
|
|
720 These override what is specified in `default-frame-plist', but are
|
|
721 overridden by the arguments to the particular call to `make-frame'.
|
|
722
|
|
723 Note: In many cases, properties of a frame are available as specifiers
|
|
724 instead of through the frame-properties mechanism.
|
|
725
|
|
726 Here is a list of recognized frame properties, other than those
|
|
727 documented in `set-frame-properties' (they can be queried and
|
|
728 set at any time, except as otherwise noted):
|
|
729
|
|
730 initially-unmapped If non-nil, the frame will not be visible
|
|
731 when it is created. In this case, you
|
|
732 need to call `make-frame-visible' to make
|
|
733 the frame appear.
|
|
734 popup If non-nil, it should be a frame, and this
|
|
735 frame will be created as a "popup" frame
|
|
736 whose parent is the given frame. This
|
|
737 will make the window manager treat the
|
|
738 frame as a dialog box, which may entail
|
|
739 doing different things (e.g. not asking
|
|
740 for positioning, and not iconifying
|
|
741 separate from its parent).
|
|
742 top Y position (in pixels) of the upper-left
|
|
743 outermost corner of the frame (i.e. the
|
|
744 upper-left of the window-manager
|
|
745 decorations).
|
|
746 left X position (in pixels) of the upper-left
|
|
747 outermost corner of the frame (i.e. the
|
|
748 upper-left of the window-manager
|
|
749 decorations).
|
|
750
|
|
751 See also `default-frame-plist', which specifies properties which apply
|
|
752 to all frames, not just mswindows frames.
|
|
753 */ );
|
|
754 Vdefault_mswindows_frame_plist = Qnil;
|
|
755
|
|
756 mswindows_console_methods->device_specific_frame_props =
|
|
757 &Vdefault_mswindows_frame_plist;
|
|
758 }
|