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