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