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.
|
321
|
29 Graphics features added and frame resizing fiddled with by Andy Piper.
|
213
|
30 */
|
|
31
|
|
32 #include <config.h>
|
|
33 #include "lisp.h"
|
|
34
|
269
|
35 #include "buffer.h"
|
213
|
36 #include "console-msw.h"
|
272
|
37 #include "glyphs-msw.h"
|
269
|
38 #include "events.h"
|
231
|
39 #include "faces.h"
|
213
|
40 #include "frame.h"
|
269
|
41 #include "redisplay.h"
|
276
|
42 #include "window.h"
|
213
|
43
|
269
|
44 #define MSWINDOWS_FRAME_STYLE (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW)
|
|
45 #define MSWINDOWS_POPUP_STYLE (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP \
|
|
46 | WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX)
|
223
|
47
|
|
48 #define MSWINDOWS_FRAME_EXSTYLE WS_EX_OVERLAPPEDWINDOW
|
269
|
49 #define MSWINDOWS_POPUP_EXSTYLE WS_EX_PALETTEWINDOW
|
|
50
|
|
51 /* Default popup left top corner offset from the same
|
|
52 corner of the parent frame, in pixel */
|
|
53 #define POPUP_OFFSET 30
|
|
54
|
|
55 /* Default popup size, in characters */
|
|
56 #define POPUP_WIDTH 30
|
|
57 #define POPUP_HEIGHT 10
|
223
|
58
|
294
|
59 /* Default popup size, in characters */
|
|
60 #define DEFAULT_FRAME_WIDTH 80
|
|
61 #define DEFAULT_FRAME_HEIGHT 35
|
|
62
|
223
|
63 #ifdef HAVE_MENUBARS
|
|
64 #define ADJR_MENUFLAG TRUE
|
|
65 #else
|
|
66 #define ADJR_MENUFLAG FALSE
|
|
67 #endif
|
|
68
|
213
|
69 /* Default properties to use when creating frames. */
|
|
70 Lisp_Object Vdefault_mswindows_frame_plist;
|
294
|
71 Lisp_Object Vmswindows_use_system_frame_size_defaults;
|
269
|
72
|
|
73 /* This does not need to be GC protected, as it holds a
|
|
74 frame Lisp_Object already protected by Fmake_frame */
|
276
|
75 Lisp_Object Vmswindows_frame_being_created;
|
269
|
76
|
213
|
77 static void
|
|
78 mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
|
|
79 {
|
231
|
80 Lisp_Object initially_unmapped;
|
223
|
81 Lisp_Object name, height, width, popup, top, left;
|
269
|
82 Lisp_Object frame_obj = Qnil;
|
223
|
83 RECT rect;
|
269
|
84 XEMACS_RECT_WH rect_default;
|
223
|
85 DWORD style, exstyle;
|
269
|
86 HWND hwnd, hwnd_parent;
|
213
|
87
|
269
|
88 /* Pick up relevant properties */
|
223
|
89 initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
|
|
90 name = Fplist_get (props, Qname, Qnil);
|
269
|
91
|
223
|
92 popup = Fplist_get (props, Qpopup, Qnil);
|
269
|
93 if (EQ (popup, Qt))
|
|
94 popup = Fselected_frame (Qnil);
|
|
95
|
|
96 left = Fplist_get (props, Qleft, Qnil);
|
|
97 if (!NILP (left))
|
|
98 CHECK_INT (left);
|
|
99
|
223
|
100 top = Fplist_get (props, Qtop, Qnil);
|
269
|
101 if (!NILP (top))
|
|
102 CHECK_INT (top);
|
|
103
|
|
104 width = Fplist_get (props, Qwidth, Qnil);
|
|
105 if (!NILP (width))
|
|
106 CHECK_INT (width);
|
|
107
|
|
108 height = Fplist_get (props, Qheight, Qnil);
|
|
109 if (!NILP (height))
|
|
110 CHECK_INT (height);
|
|
111
|
294
|
112 f->frame_data = xnew_and_zero (struct mswindows_frame);
|
|
113 FRAME_MSWINDOWS_TARGET_RECT (f) = xnew_and_zero (XEMACS_RECT_WH);
|
213
|
114
|
294
|
115 FRAME_MSWINDOWS_TARGET_RECT (f)->left = NILP (left) ? -1 : abs (XINT (left));
|
|
116 FRAME_MSWINDOWS_TARGET_RECT (f)->top = NILP (top) ? -1 : abs (XINT (top));
|
|
117 FRAME_MSWINDOWS_TARGET_RECT (f)->width = NILP (width) ? -1 :
|
|
118 abs (XINT (width));
|
|
119 FRAME_MSWINDOWS_TARGET_RECT (f)->height = NILP (height) ? -1 :
|
|
120 abs (XINT (height));
|
|
121
|
269
|
122 /* Misc frame stuff */
|
223
|
123 FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0;
|
|
124 FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0;
|
|
125 FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0;
|
|
126 FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0;
|
|
127 FRAME_MSWINDOWS_DATA(f)->ignore_next_rbutton_up = 0;
|
|
128 FRAME_MSWINDOWS_DATA(f)->sizing = 0;
|
231
|
129 FRAME_MSWINDOWS_MENU_HASHTABLE(f) = Qnil;
|
276
|
130 #ifdef HAVE_TOOLBARS
|
|
131 FRAME_MSWINDOWS_TOOLBAR_HASHTABLE(f) = Fmake_hashtable (make_int (50),
|
|
132 Qequal);
|
|
133 #endif
|
231
|
134
|
269
|
135 /* Will initialize these in WM_SIZE handler. We cannot do it now,
|
|
136 because we do not know what is CW_USEDEFAULT height and width */
|
|
137 FRAME_WIDTH (f) = 0;
|
|
138 FRAME_HEIGHT (f) = 0;
|
|
139 FRAME_PIXWIDTH (f) = 0;
|
|
140 FRAME_PIXHEIGHT (f) = 0;
|
|
141
|
|
142 if (NILP (popup))
|
|
143 {
|
|
144 style = MSWINDOWS_FRAME_STYLE;
|
|
145 exstyle = MSWINDOWS_FRAME_EXSTYLE;
|
|
146 hwnd_parent = NULL;
|
|
147
|
|
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
|
|
199 static void
|
|
200 mswindows_init_frame_2 (struct frame *f, Lisp_Object props)
|
|
201 {
|
294
|
202 if (NILP (Vmswindows_use_system_frame_size_defaults))
|
|
203 {
|
|
204 /* I don't think anything can set the frame size before this
|
|
205 since we don't have X resources. This may change if we look
|
|
206 at the registry. Even so these values can get overridden
|
|
207 later.*/
|
|
208 XEMACS_RECT_WH dest = { -1, -1, DEFAULT_FRAME_WIDTH,
|
|
209 DEFAULT_FRAME_HEIGHT };
|
|
210 mswindows_size_frame_internal (f, &dest);
|
|
211 }
|
213
|
212 }
|
|
213
|
|
214 /* Called after frame's properties are set */
|
|
215 static void
|
|
216 mswindows_init_frame_3 (struct frame *f)
|
|
217 {
|
298
|
218 /* Don't do this earlier or we get a WM_PAINT before the frame is ready.
|
|
219 * The SW_x parameter in the first call that an app makes to ShowWindow is
|
|
220 * ignored, and the parameter specified in the caller's STARTUPINFO is
|
|
221 * substituted instead. That parameter is SW_HIDE if we were started by
|
|
222 * runemacs, so call this twice. #### runemacs is evil */
|
|
223 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
219
|
224 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
|
225 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
249
|
226 DragAcceptFiles (FRAME_MSWINDOWS_HANDLE(f), TRUE);
|
219
|
227 }
|
|
228
|
|
229 static void
|
269
|
230 mswindows_after_init_frame (struct frame *f, int first_on_device,
|
|
231 int first_on_console)
|
|
232 {
|
|
233 /* Windows, unlike X, is very synchronous. After the initial
|
|
234 frame is created, it will never be displayed, except for
|
|
235 hollow border, unless we start pumping messages. Load progress
|
|
236 messages show in the bottom of the hollow frame, which is ugly.
|
|
237 We redipsplay the initial frame here, so modeline and root window
|
|
238 backgorund show.
|
|
239 */
|
|
240 if (first_on_console)
|
|
241 redisplay ();
|
|
242 }
|
|
243
|
|
244 static void
|
231
|
245 mswindows_mark_frame (struct frame *f, void (*markobj) (Lisp_Object))
|
|
246 {
|
|
247 ((markobj) (FRAME_MSWINDOWS_MENU_HASHTABLE (f)));
|
276
|
248 #ifdef HAVE_TOOLBARS
|
|
249 ((markobj) (FRAME_MSWINDOWS_TOOLBAR_HASHTABLE (f)));
|
|
250 #endif
|
231
|
251 }
|
|
252
|
|
253 static void
|
219
|
254 mswindows_focus_on_frame (struct frame *f)
|
|
255 {
|
269
|
256 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
213
|
257 }
|
|
258
|
|
259 static void
|
|
260 mswindows_delete_frame (struct frame *f)
|
|
261 {
|
|
262 if (f->frame_data)
|
|
263 {
|
269
|
264 DeleteDC(FRAME_MSWINDOWS_CDC(f));
|
223
|
265 ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
|
|
266 DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
|
269
|
267 xfree (f->frame_data);
|
213
|
268 }
|
269
|
269 f->frame_data = 0;
|
213
|
270 }
|
|
271
|
|
272 static void
|
294
|
273 mswindows_set_frame_size (struct frame *f, int width, int height)
|
213
|
274 {
|
269
|
275 RECT rect;
|
|
276 rect.left = rect.top = 0;
|
294
|
277 rect.right = width;
|
|
278 rect.bottom = height;
|
223
|
279
|
269
|
280 AdjustWindowRectEx (&rect,
|
223
|
281 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
282 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
283 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
269
|
284
|
|
285 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f)) || IsZoomed (FRAME_MSWINDOWS_HANDLE(f)))
|
|
286 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
|
287
|
|
288 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
|
|
289 0, 0, rect.right-rect.left, rect.bottom-rect.top,
|
|
290 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOMOVE);
|
213
|
291 }
|
|
292
|
|
293 static void
|
|
294 mswindows_set_frame_position (struct frame *f, int xoff, int yoff)
|
|
295 {
|
269
|
296 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
|
|
297 xoff, yoff, 0, 0,
|
|
298 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | SWP_NOSIZE);
|
219
|
299 }
|
|
300
|
|
301 static void
|
|
302 mswindows_make_frame_visible (struct frame *f)
|
|
303 {
|
|
304 if (f->iconified)
|
|
305 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
|
306 else
|
333
|
307 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOW);
|
219
|
308 f->visible = 1;
|
|
309 f->iconified = 0;
|
|
310 }
|
|
311
|
|
312 static void
|
|
313 mswindows_make_frame_invisible (struct frame *f)
|
|
314 {
|
|
315 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_HIDE);
|
|
316 f->visible = -1;
|
|
317 }
|
|
318
|
|
319 static int
|
276
|
320 mswindows_frame_totally_visible_p (struct frame *f)
|
|
321 {
|
|
322 RECT rc_me, rc_other, rc_temp;
|
|
323 HWND hwnd = FRAME_MSWINDOWS_HANDLE(f);
|
|
324
|
|
325 /* We test against not a whole window rectangle, only agaist its
|
|
326 client part. So, if non-client are is covered and client area is
|
|
327 not, we return true. */
|
|
328 GetClientRect (hwnd, &rc_me);
|
|
329 MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rc_me, 2);
|
|
330
|
|
331 /* First see if we're off the desktop */
|
|
332 GetWindowRect (GetDesktopWindow(), &rc_other);
|
|
333 UnionRect(&rc_temp, &rc_me, &rc_other);
|
|
334 if (!EqualRect (&rc_temp, &rc_other))
|
|
335 return 0;
|
|
336
|
|
337 /* Then see if any window above us obscures us */
|
|
338 while ((hwnd = GetWindow (hwnd, GW_HWNDPREV)) != NULL)
|
|
339 if (IsWindowVisible (hwnd))
|
|
340 {
|
|
341 GetWindowRect (hwnd, &rc_other);
|
|
342 if (IntersectRect(&rc_temp, &rc_me, &rc_other))
|
|
343 return 0;
|
|
344 }
|
|
345
|
|
346 return 1;
|
|
347 }
|
|
348
|
|
349 static int
|
219
|
350 mswindows_frame_visible_p (struct frame *f)
|
|
351 {
|
|
352 return IsWindowVisible (FRAME_MSWINDOWS_HANDLE(f))
|
|
353 && !IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
354 }
|
|
355
|
|
356
|
|
357 static void
|
|
358 mswindows_iconify_frame (struct frame *f)
|
|
359 {
|
|
360 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_MINIMIZE);
|
|
361 f->visible = 0;
|
|
362 f->iconified = 1;
|
|
363 }
|
|
364
|
|
365 static int
|
|
366 mswindows_frame_iconified_p (struct frame *f)
|
|
367 {
|
|
368 return IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
369 }
|
|
370
|
|
371 static void
|
272
|
372 mswindows_set_frame_icon (struct frame *f)
|
|
373 {
|
|
374 if (IMAGE_INSTANCEP (f->icon)
|
|
375 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon)))
|
|
376 {
|
|
377 if (!XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon))
|
|
378 {
|
282
|
379 mswindows_initialize_image_instance_icon (XIMAGE_INSTANCE (f->icon),
|
|
380 FALSE);
|
272
|
381 }
|
|
382
|
|
383 SetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HICON,
|
|
384 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->icon));
|
|
385 }
|
|
386 }
|
|
387
|
|
388 static void
|
|
389 mswindows_set_frame_pointer (struct frame *f)
|
|
390 {
|
282
|
391 if (IMAGE_INSTANCEP (f->pointer)
|
|
392 && IMAGE_INSTANCE_TYPE (XIMAGE_INSTANCE (f->pointer)) == IMAGE_POINTER)
|
|
393 {
|
|
394 SetClassLong (FRAME_MSWINDOWS_HANDLE (f), GCL_HCURSOR,
|
|
395 (LONG) XIMAGE_INSTANCE_MSWINDOWS_ICON (f->pointer));
|
327
|
396 /* we only have to do this because GC doesn't cause a mouse
|
|
397 event and doesn't give time to event processing even if it
|
|
398 did. */
|
|
399 SetCursor (XIMAGE_INSTANCE_MSWINDOWS_ICON (f->pointer));
|
282
|
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 }
|
|
460
|
|
461 static void
|
|
462 mswindows_lower_frame (struct frame *f)
|
|
463 {
|
269
|
464 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), HWND_BOTTOM, 0, 0, 0, 0,
|
|
465 SWP_NOSIZE | SWP_NOMOVE | SWP_NOSENDCHANGING);
|
219
|
466 }
|
|
467
|
|
468 static void
|
|
469 mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title)
|
|
470 {
|
274
|
471 unsigned int new_checksum = hash_string (title, strlen (title));
|
|
472 if (new_checksum != FRAME_MSWINDOWS_TITLE_CHECKSUM(f))
|
|
473 {
|
|
474 FRAME_MSWINDOWS_TITLE_CHECKSUM(f) = new_checksum;
|
|
475 SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title);
|
|
476 }
|
|
477 }
|
|
478
|
|
479 static Lisp_Object
|
|
480 mswindows_frame_property (struct frame *f, Lisp_Object property)
|
|
481 {
|
|
482 if (EQ (Qleft, property) || EQ (Qtop, property))
|
|
483 {
|
|
484 RECT rc;
|
|
485 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rc);
|
|
486 return make_int (EQ (Qtop, property) ? rc.top : rc.left);
|
|
487 }
|
|
488 return Qunbound;
|
|
489 }
|
|
490
|
|
491 static int
|
|
492 mswindows_internal_frame_property_p (struct frame *f, Lisp_Object property)
|
|
493 {
|
|
494 return EQ (property, Qleft)
|
|
495 || EQ (property, Qtop);
|
|
496 /* #### frame-x.c has also this. Why?
|
|
497 || STRINGP (property);
|
|
498 */
|
|
499 }
|
|
500
|
|
501 static Lisp_Object
|
|
502 mswindows_frame_properties (struct frame *f)
|
|
503 {
|
|
504 Lisp_Object props = Qnil;
|
|
505 RECT rc;
|
|
506 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rc);
|
|
507
|
|
508 props = cons3 (Qtop, make_int (rc.top), props);
|
|
509 props = cons3 (Qleft, make_int (rc.left), props);
|
|
510
|
|
511 return props;
|
213
|
512 }
|
|
513
|
|
514 static void
|
|
515 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
516 {
|
294
|
517 int x=-1, y=-1;
|
|
518 int width = -1, height = -1;
|
213
|
519 BOOL width_specified_p = FALSE;
|
|
520 BOOL height_specified_p = FALSE;
|
|
521 BOOL x_specified_p = FALSE;
|
|
522 BOOL y_specified_p = FALSE;
|
|
523 Lisp_Object tail;
|
|
524
|
|
525 /* Extract the properties from plist */
|
|
526 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
527 {
|
|
528 Lisp_Object prop = Fcar (tail);
|
|
529 Lisp_Object val = Fcar (Fcdr (tail));
|
|
530
|
|
531 if (SYMBOLP (prop))
|
|
532 {
|
|
533 /* Kludge to handle the font property. */
|
|
534 if (EQ (prop, Qfont))
|
|
535 {
|
|
536 /* If the value is not a string we silently ignore it. */
|
|
537 if (STRINGP (val))
|
|
538 {
|
|
539 Lisp_Object frm, font_spec;
|
|
540
|
|
541 XSETFRAME (frm, f);
|
|
542 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil);
|
|
543
|
|
544 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil);
|
|
545 update_frame_face_values (f);
|
|
546 }
|
|
547 }
|
|
548 else if (EQ (prop, Qwidth))
|
|
549 {
|
|
550 CHECK_INT (val);
|
|
551 width = XINT (val);
|
|
552 width_specified_p = TRUE;
|
|
553 }
|
|
554 else if (EQ (prop, Qheight))
|
|
555 {
|
|
556 CHECK_INT (val);
|
|
557 height = XINT (val);
|
|
558 height_specified_p = TRUE;
|
|
559 }
|
|
560 else if (EQ (prop, Qleft))
|
|
561 {
|
|
562 CHECK_INT (val);
|
|
563 x = XINT (val);
|
|
564 x_specified_p = TRUE;
|
|
565 }
|
|
566 else if (EQ (prop, Qtop))
|
|
567 {
|
|
568 CHECK_INT (val);
|
|
569 y = XINT (val);
|
|
570 y_specified_p = TRUE;
|
|
571 }
|
|
572 }
|
|
573 }
|
|
574
|
269
|
575 /* Now we've extracted the properties, apply them.
|
|
576 Do not apply geometric properties during frame creation. This
|
|
577 is excessive anyways, and this loses becuase WM_SIZE has not
|
294
|
578 been sent yet, so frame width and height fields are not initialized.
|
|
579
|
|
580 unfortunately WM_SIZE loses as well since the resize is only
|
|
581 applied once and the first time WM_SIZE is applied not everything
|
|
582 is initialised in the frame (toolbars for instance). enabling
|
|
583 this always makes no visible difference and fixes a whole host of
|
|
584 bugs (and is more consistent with X) so I am going to reenable it.
|
|
585 --andyp */
|
|
586 if ( FRAME_PIXWIDTH (f) && FRAME_PIXHEIGHT (f)
|
|
587 && (width_specified_p || height_specified_p || x_specified_p || y_specified_p))
|
213
|
588 {
|
294
|
589 XEMACS_RECT_WH dest = { x, y, width, height };
|
|
590
|
|
591 mswindows_size_frame_internal (f, &dest);
|
|
592 }
|
|
593 }
|
213
|
594
|
294
|
595 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest)
|
|
596 {
|
|
597 RECT rect;
|
|
598 int pixel_width, pixel_height;
|
|
599 int size_p = (dest->width >=0 || dest->height >=0);
|
|
600 int move_p = (dest->top >=0 || dest->left >=0);
|
321
|
601 struct device* d = XDEVICE (FRAME_DEVICE (f));
|
294
|
602 char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, &pixel_height);
|
|
603
|
|
604 if (dest->width < 0)
|
|
605 pixel_width = FRAME_PIXWIDTH (f);
|
|
606 if (dest->height < 0)
|
|
607 pixel_height = FRAME_PIXHEIGHT (f);
|
|
608
|
|
609 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
610 if (dest->left < 0)
|
|
611 dest->left = rect.left;
|
|
612 if (dest->top < 0)
|
|
613 dest->top = rect.top;
|
321
|
614
|
294
|
615 rect.left = rect.top = 0;
|
|
616 rect.right = pixel_width;
|
|
617 rect.bottom = pixel_height;
|
|
618
|
|
619 AdjustWindowRectEx (&rect,
|
|
620 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
621 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
622 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
223
|
623
|
321
|
624 /* resize and move the window so that it fits on the screen. This is
|
|
625 not restrictive since this will happen later anyway in WM_SIZE. We
|
|
626 have to do this after adjusting the rect to account for menubar
|
|
627 etc. */
|
|
628 pixel_width = rect.right - rect.left;
|
|
629 pixel_height = rect.bottom - rect.top;
|
|
630 if (pixel_width > DEVICE_MSWINDOWS_HORZRES(d))
|
|
631 {
|
|
632 pixel_width = DEVICE_MSWINDOWS_HORZRES(d);
|
|
633 size_p=1;
|
|
634 }
|
|
635 if (pixel_height > DEVICE_MSWINDOWS_VERTRES(d))
|
|
636 {
|
|
637 pixel_height = DEVICE_MSWINDOWS_VERTRES(d);
|
|
638 size_p=1;
|
|
639 }
|
|
640
|
|
641 /* adjust position so window is on screen */
|
|
642 if (dest->left + pixel_width > DEVICE_MSWINDOWS_HORZRES(d))
|
|
643 {
|
|
644 dest->left = DEVICE_MSWINDOWS_HORZRES(d) - pixel_width;
|
|
645 move_p=1;
|
|
646 }
|
|
647 if (dest->top + pixel_height > DEVICE_MSWINDOWS_VERTRES(d))
|
|
648 {
|
|
649 dest->top = DEVICE_MSWINDOWS_VERTRES(d) - pixel_height;
|
|
650 move_p=1;
|
|
651 }
|
|
652
|
294
|
653 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f))
|
|
654 || IsZoomed (FRAME_MSWINDOWS_HANDLE(f)))
|
|
655 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
269
|
656
|
294
|
657 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL,
|
321
|
658 dest->left, dest->top, pixel_width, pixel_height,
|
294
|
659 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING
|
|
660 | (size_p ? 0 : SWP_NOSIZE)
|
|
661 | (move_p ? 0 : SWP_NOMOVE));
|
213
|
662 }
|
|
663
|
269
|
664 static Lisp_Object
|
|
665 mswindows_get_frame_parent (struct frame *f)
|
|
666 {
|
|
667 HWND hwnd = FRAME_MSWINDOWS_HANDLE(f);
|
|
668 hwnd = GetParent (hwnd);
|
|
669 if (hwnd)
|
|
670 {
|
|
671 Lisp_Object parent;
|
|
672 VOID_TO_LISP (parent, GetWindowLong (hwnd, XWL_FRAMEOBJ));
|
|
673 assert (FRAME_MSWINDOWS_P (XFRAME (parent)));
|
|
674 return parent;
|
|
675 }
|
|
676 else
|
|
677 return Qnil;
|
|
678 }
|
|
679
|
|
680 static void
|
|
681 mswindows_update_frame_external_traits (struct frame* frm, Lisp_Object name)
|
|
682 {
|
282
|
683 }
|
269
|
684
|
282
|
685 static int
|
|
686 mswindows_frame_size_fixed_p (struct frame *f)
|
|
687 {
|
|
688 /* Frame size cannot change if the frame is maximized */
|
|
689 return IsZoomed (FRAME_MSWINDOWS_HANDLE (f));
|
269
|
690 }
|
213
|
691
|
|
692 void
|
|
693 console_type_create_frame_mswindows (void)
|
|
694 {
|
|
695 /* frame methods */
|
|
696 CONSOLE_HAS_METHOD (mswindows, init_frame_1);
|
294
|
697 CONSOLE_HAS_METHOD (mswindows, init_frame_2);
|
213
|
698 CONSOLE_HAS_METHOD (mswindows, init_frame_3);
|
269
|
699 CONSOLE_HAS_METHOD (mswindows, after_init_frame);
|
231
|
700 CONSOLE_HAS_METHOD (mswindows, mark_frame);
|
219
|
701 CONSOLE_HAS_METHOD (mswindows, focus_on_frame);
|
213
|
702 CONSOLE_HAS_METHOD (mswindows, delete_frame);
|
276
|
703 CONSOLE_HAS_METHOD (mswindows, get_mouse_position);
|
|
704 CONSOLE_HAS_METHOD (mswindows, set_mouse_position);
|
219
|
705 CONSOLE_HAS_METHOD (mswindows, raise_frame);
|
|
706 CONSOLE_HAS_METHOD (mswindows, lower_frame);
|
|
707 CONSOLE_HAS_METHOD (mswindows, make_frame_visible);
|
|
708 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible);
|
|
709 CONSOLE_HAS_METHOD (mswindows, iconify_frame);
|
213
|
710 CONSOLE_HAS_METHOD (mswindows, set_frame_size);
|
|
711 CONSOLE_HAS_METHOD (mswindows, set_frame_position);
|
274
|
712 CONSOLE_HAS_METHOD (mswindows, frame_property);
|
|
713 CONSOLE_HAS_METHOD (mswindows, internal_frame_property_p);
|
|
714 CONSOLE_HAS_METHOD (mswindows, frame_properties);
|
213
|
715 CONSOLE_HAS_METHOD (mswindows, set_frame_properties);
|
219
|
716 CONSOLE_HAS_METHOD (mswindows, set_title_from_bufbyte);
|
213
|
717 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_bufbyte); */
|
219
|
718 CONSOLE_HAS_METHOD (mswindows, frame_visible_p);
|
276
|
719 CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p);
|
219
|
720 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p);
|
272
|
721 CONSOLE_HAS_METHOD (mswindows, set_frame_pointer);
|
|
722 CONSOLE_HAS_METHOD (mswindows, set_frame_icon);
|
269
|
723 CONSOLE_HAS_METHOD (mswindows, get_frame_parent);
|
|
724 CONSOLE_HAS_METHOD (mswindows, update_frame_external_traits);
|
282
|
725 CONSOLE_HAS_METHOD (mswindows, frame_size_fixed_p);
|
213
|
726 }
|
|
727
|
|
728 void
|
|
729 syms_of_frame_mswindows (void)
|
|
730 {
|
|
731 }
|
|
732
|
|
733 void
|
|
734 vars_of_frame_mswindows (void)
|
|
735 {
|
276
|
736 /* Needn't staticpro -- see comment above. */
|
|
737 Vmswindows_frame_being_created = Qnil;
|
269
|
738
|
294
|
739 DEFVAR_LISP ("mswindows-use-system-frame-size-defaults", &Vmswindows_use_system_frame_size_defaults /*
|
|
740 Controls whether to use system or XEmacs defaults for frame size.
|
|
741 If nil then reasonable defaults are used for intial frame sizes. If t
|
|
742 then the system will choose default sizes for the frame.
|
|
743 */ );
|
|
744 Vmswindows_use_system_frame_size_defaults = Qnil;
|
|
745
|
213
|
746 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /*
|
|
747 Plist of default frame-creation properties for mswindows frames.
|
|
748 These override what is specified in `default-frame-plist', but are
|
|
749 overridden by the arguments to the particular call to `make-frame'.
|
|
750
|
|
751 Note: In many cases, properties of a frame are available as specifiers
|
|
752 instead of through the frame-properties mechanism.
|
|
753
|
|
754 Here is a list of recognized frame properties, other than those
|
|
755 documented in `set-frame-properties' (they can be queried and
|
|
756 set at any time, except as otherwise noted):
|
|
757
|
|
758 initially-unmapped If non-nil, the frame will not be visible
|
|
759 when it is created. In this case, you
|
|
760 need to call `make-frame-visible' to make
|
|
761 the frame appear.
|
|
762 popup If non-nil, it should be a frame, and this
|
|
763 frame will be created as a "popup" frame
|
|
764 whose parent is the given frame. This
|
|
765 will make the window manager treat the
|
|
766 frame as a dialog box, which may entail
|
|
767 doing different things (e.g. not asking
|
|
768 for positioning, and not iconifying
|
|
769 separate from its parent).
|
|
770 top Y position (in pixels) of the upper-left
|
|
771 outermost corner of the frame (i.e. the
|
|
772 upper-left of the window-manager
|
|
773 decorations).
|
|
774 left X position (in pixels) of the upper-left
|
|
775 outermost corner of the frame (i.e. the
|
|
776 upper-left of the window-manager
|
|
777 decorations).
|
|
778
|
|
779 See also `default-frame-plist', which specifies properties which apply
|
|
780 to all frames, not just mswindows frames.
|
|
781 */ );
|
|
782 Vdefault_mswindows_frame_plist = Qnil;
|
|
783
|
|
784 mswindows_console_methods->device_specific_frame_props =
|
|
785 &Vdefault_mswindows_frame_plist;
|
|
786 }
|