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.
|
|
28 Rewritten for mswindows by Jonathan Harris, November 1997 for 20.4.
|
|
29 */
|
|
30
|
|
31 #include <config.h>
|
|
32 #include "lisp.h"
|
|
33
|
|
34 #include "console-msw.h"
|
|
35 #include "event-msw.h"
|
|
36
|
|
37 #include "buffer.h"
|
|
38 #include "frame.h"
|
|
39 #include "events.h"
|
|
40
|
223
|
41 #define MSWINDOWS_FRAME_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_OVERLAPPEDWINDOW
|
|
42 #define MSWINDOWS_POPUP_STYLE WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_CAPTION|WS_POPUP
|
|
43
|
|
44 #define MSWINDOWS_FRAME_EXSTYLE WS_EX_OVERLAPPEDWINDOW
|
|
45 #define MSWINDOWS_POPUP_EXSTYLE WS_EX_OVERLAPPEDWINDOW
|
|
46
|
|
47 #ifdef HAVE_MENUBARS
|
|
48 #define ADJR_MENUFLAG TRUE
|
|
49 #else
|
|
50 #define ADJR_MENUFLAG FALSE
|
|
51 #endif
|
|
52
|
213
|
53 /* Default properties to use when creating frames. */
|
|
54 Lisp_Object Vdefault_mswindows_frame_plist;
|
|
55 /* Lisp_Object Qname, Qheight, Qwidth, Qinitially_unmapped, Qpopup, Qtop, Qleft; */
|
|
56 Lisp_Object Qinitially_unmapped, Qpopup;
|
|
57
|
|
58 static void
|
|
59 mswindows_init_frame_1 (struct frame *f, Lisp_Object props)
|
|
60 {
|
|
61 Lisp_Object device = FRAME_DEVICE (f);
|
|
62 struct device *d = XDEVICE (device);
|
|
63 Lisp_Object lisp_window_id, initially_unmapped;
|
223
|
64 Lisp_Object name, height, width, popup, top, left;
|
|
65 Lisp_Object frame_obj;
|
|
66 int pixel_width, pixel_height;
|
|
67 RECT rect;
|
|
68 DWORD style, exstyle;
|
|
69 HWND hwnd;
|
213
|
70
|
223
|
71 initially_unmapped = Fplist_get (props, Qinitially_unmapped, Qnil);
|
|
72 name = Fplist_get (props, Qname, Qnil);
|
|
73 height = Fplist_get (props, Qheight, Qnil);
|
|
74 width = Fplist_get (props, Qwidth, Qnil);
|
|
75 popup = Fplist_get (props, Qpopup, Qnil);
|
|
76 top = Fplist_get (props, Qtop, Qnil);
|
|
77 left = Fplist_get (props, Qleft, Qnil);
|
213
|
78
|
|
79 f->frame_data = xnew_and_zero (struct mswindows_frame);
|
223
|
80 FRAME_WIDTH (f) = INTP(width) ? XINT(width) : 80;
|
|
81 FRAME_HEIGHT (f) = INTP(height) ? XINT(height) : 30;
|
|
82 char_to_pixel_size (f, FRAME_WIDTH(f), FRAME_HEIGHT (f),
|
|
83 &FRAME_PIXWIDTH (f), &FRAME_PIXHEIGHT (f));
|
|
84
|
|
85 style = (NILP(popup)) ? MSWINDOWS_FRAME_STYLE : MSWINDOWS_POPUP_STYLE;
|
|
86 exstyle = (NILP(popup)) ? MSWINDOWS_FRAME_EXSTYLE : MSWINDOWS_POPUP_EXSTYLE;
|
|
87 rect.left = rect.top = 0;
|
|
88 rect.right = FRAME_PIXWIDTH (f);
|
|
89 rect.bottom = FRAME_PIXHEIGHT (f);
|
|
90
|
|
91 FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0;
|
|
92 FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0;
|
|
93 FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0;
|
|
94 FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0;
|
|
95 FRAME_MSWINDOWS_DATA(f)->ignore_next_rbutton_up = 0;
|
|
96 FRAME_MSWINDOWS_DATA(f)->sizing = 0;
|
|
97
|
|
98 AdjustWindowRectEx(&rect, style, ADJR_MENUFLAG, exstyle);
|
|
99
|
|
100 FRAME_MSWINDOWS_HANDLE(f) =
|
|
101 CreateWindowEx (exstyle,
|
|
102 XEMACS_CLASS,
|
|
103 STRINGP(f->name) ? XSTRING_DATA(f->name) :
|
|
104 (STRINGP(name) ? XSTRING_DATA(name) : XEMACS_CLASS),
|
|
105 style,
|
|
106 INTP(left) ? XINT(left) : CW_USEDEFAULT,
|
|
107 INTP(top) ? XINT(top) : CW_USEDEFAULT,
|
|
108 rect.right-rect.left, rect.bottom-rect.top,
|
|
109 NULL, NULL, NULL, NULL);
|
|
110 XSETFRAME (frame_obj, f);
|
|
111 SetWindowLong (FRAME_MSWINDOWS_HANDLE(f), XWL_FRAMEOBJ, (LONG)frame_obj);
|
213
|
112 FRAME_MSWINDOWS_DC(f) = GetDC(FRAME_MSWINDOWS_HANDLE(f));
|
|
113 SetTextAlign(FRAME_MSWINDOWS_DC(f), TA_BASELINE|TA_LEFT|TA_NOUPDATECP);
|
|
114 }
|
|
115
|
215
|
116 /* Called just before frame's properties are set, size is 10x10 or something */
|
213
|
117 static void
|
|
118 mswindows_init_frame_2 (struct frame *f, Lisp_Object props)
|
|
119 {
|
|
120 }
|
|
121
|
|
122 /* Called after frame's properties are set */
|
|
123 static void
|
|
124 mswindows_init_frame_3 (struct frame *f)
|
|
125 {
|
|
126 /* Don't do this earlier or we get a WM_PAINT before the frame is ready*/
|
219
|
127 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
|
128 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
|
129 }
|
|
130
|
|
131 static void
|
|
132 mswindows_focus_on_frame (struct frame *f)
|
|
133 {
|
|
134 SetForegroundWindow (FRAME_MSWINDOWS_HANDLE(f));
|
213
|
135 }
|
|
136
|
|
137 static void
|
|
138 mswindows_delete_frame (struct frame *f)
|
|
139 {
|
|
140 if (f->frame_data)
|
|
141 {
|
223
|
142 ReleaseDC(FRAME_MSWINDOWS_HANDLE(f), FRAME_MSWINDOWS_DC(f));
|
|
143 DestroyWindow(FRAME_MSWINDOWS_HANDLE(f));
|
213
|
144 }
|
|
145 }
|
|
146
|
|
147 static void
|
|
148 mswindows_set_frame_size (struct frame *f, int cols, int rows)
|
|
149 {
|
219
|
150 RECT rect1, rect2;
|
|
151
|
|
152 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect1);
|
|
153 rect2.left = rect2.top = 0;
|
|
154 char_to_pixel_size (f, cols, rows, &rect2.right, &rect2.bottom);
|
223
|
155
|
|
156 AdjustWindowRectEx (&rect2,
|
|
157 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
158 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
159 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
|
160
|
219
|
161 MoveWindow (FRAME_MSWINDOWS_HANDLE(f), rect1.left, rect1.top,
|
|
162 rect2.right-rect2.left, rect2.bottom-rect2.top, TRUE);
|
213
|
163 }
|
|
164
|
|
165
|
|
166 static void
|
|
167 mswindows_set_frame_position (struct frame *f, int xoff, int yoff)
|
|
168 {
|
219
|
169 RECT rect;
|
|
170
|
|
171 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
172 MoveWindow (FRAME_MSWINDOWS_HANDLE(f), xoff, yoff,
|
|
173 rect.right-rect.left, rect.bottom-rect.top, TRUE);
|
|
174 }
|
|
175
|
|
176 static void
|
|
177 mswindows_make_frame_visible (struct frame *f)
|
|
178 {
|
|
179 if (f->iconified)
|
|
180 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE);
|
|
181 else
|
|
182 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_SHOWNORMAL);
|
|
183 f->visible = 1;
|
|
184 f->iconified = 0;
|
|
185 }
|
|
186
|
|
187 static void
|
|
188 mswindows_make_frame_invisible (struct frame *f)
|
|
189 {
|
|
190 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_HIDE);
|
|
191 f->visible = -1;
|
|
192 }
|
|
193
|
|
194 static int
|
|
195 mswindows_frame_visible_p (struct frame *f)
|
|
196 {
|
|
197 return IsWindowVisible (FRAME_MSWINDOWS_HANDLE(f))
|
|
198 && !IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
199 }
|
|
200
|
|
201
|
|
202 static void
|
|
203 mswindows_iconify_frame (struct frame *f)
|
|
204 {
|
|
205 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_MINIMIZE);
|
|
206 f->visible = 0;
|
|
207 f->iconified = 1;
|
|
208 }
|
|
209
|
|
210 static int
|
|
211 mswindows_frame_iconified_p (struct frame *f)
|
|
212 {
|
|
213 return IsIconic (FRAME_MSWINDOWS_HANDLE(f));
|
|
214 }
|
|
215
|
|
216 static void
|
|
217 mswindows_raise_frame (struct frame *f)
|
|
218 {
|
|
219 BringWindowToTop (FRAME_MSWINDOWS_HANDLE(f));
|
|
220 /* XXX Should we do SetWindowForeground too ? */
|
|
221 }
|
|
222
|
|
223 static void
|
|
224 mswindows_lower_frame (struct frame *f)
|
|
225 {
|
|
226 RECT rect;
|
|
227
|
|
228 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
229 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), HWND_BOTTOM, rect.top, rect.left,
|
|
230 rect.right-rect.left, rect.bottom-rect.top, 0);
|
|
231 }
|
|
232
|
|
233 static void
|
|
234 mswindows_set_title_from_bufbyte (struct frame *f, Bufbyte *title)
|
|
235 {
|
|
236 SetWindowText (FRAME_MSWINDOWS_HANDLE(f), title);
|
213
|
237 }
|
|
238
|
|
239 static void
|
|
240 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist)
|
|
241 {
|
|
242 int x, y;
|
|
243 int width = 0, height = 0;
|
|
244 BOOL width_specified_p = FALSE;
|
|
245 BOOL height_specified_p = FALSE;
|
|
246 BOOL x_specified_p = FALSE;
|
|
247 BOOL y_specified_p = FALSE;
|
|
248 Lisp_Object tail;
|
|
249
|
|
250 /* Extract the properties from plist */
|
|
251 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
|
|
252 {
|
|
253 Lisp_Object prop = Fcar (tail);
|
|
254 Lisp_Object val = Fcar (Fcdr (tail));
|
|
255
|
|
256 if (SYMBOLP (prop))
|
|
257 {
|
|
258 /* Kludge to handle the font property. */
|
|
259 if (EQ (prop, Qfont))
|
|
260 {
|
|
261 /* If the value is not a string we silently ignore it. */
|
|
262 if (STRINGP (val))
|
|
263 {
|
|
264 Lisp_Object frm, font_spec;
|
|
265
|
|
266 XSETFRAME (frm, f);
|
|
267 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil);
|
|
268
|
|
269 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil);
|
|
270 update_frame_face_values (f);
|
|
271 }
|
|
272 }
|
|
273 else if (EQ (prop, Qwidth))
|
|
274 {
|
|
275 CHECK_INT (val);
|
|
276 width = XINT (val);
|
|
277 width_specified_p = TRUE;
|
|
278 }
|
|
279 else if (EQ (prop, Qheight))
|
|
280 {
|
|
281 CHECK_INT (val);
|
|
282 height = XINT (val);
|
|
283 height_specified_p = TRUE;
|
|
284 }
|
|
285 else if (EQ (prop, Qleft))
|
|
286 {
|
|
287 CHECK_INT (val);
|
|
288 x = XINT (val);
|
|
289 x_specified_p = TRUE;
|
|
290 }
|
|
291 else if (EQ (prop, Qtop))
|
|
292 {
|
|
293 CHECK_INT (val);
|
|
294 y = XINT (val);
|
|
295 y_specified_p = TRUE;
|
|
296 }
|
|
297 }
|
|
298 }
|
|
299
|
|
300 /* Now we've extracted the properties, apply them */
|
|
301 if (width_specified_p || height_specified_p || x_specified_p || y_specified_p)
|
|
302 {
|
|
303 Lisp_Object frame;
|
|
304 RECT rect;
|
|
305 int pixel_width, pixel_height;
|
|
306 XSETFRAME (frame, f);
|
|
307
|
|
308 if (!width_specified_p)
|
|
309 width = FRAME_WIDTH (f);
|
|
310 if (!height_specified_p)
|
|
311 height = FRAME_HEIGHT (f);
|
|
312 char_to_pixel_size (f, width, height, &pixel_width, &pixel_height);
|
|
313
|
|
314 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect);
|
|
315 if (!x_specified_p)
|
|
316 x = rect.left;
|
|
317 if (!y_specified_p)
|
|
318 y = rect.top;
|
219
|
319
|
223
|
320 AdjustWindowRectEx (&rect,
|
|
321 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE),
|
|
322 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL,
|
|
323 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE));
|
|
324
|
213
|
325 MoveWindow (FRAME_MSWINDOWS_HANDLE(f), x, y, pixel_width, pixel_height,
|
|
326 (width_specified_p || height_specified_p));
|
|
327 }
|
|
328 }
|
|
329
|
|
330
|
|
331 void
|
|
332 console_type_create_frame_mswindows (void)
|
|
333 {
|
|
334 /* frame methods */
|
|
335 CONSOLE_HAS_METHOD (mswindows, init_frame_1);
|
|
336 CONSOLE_HAS_METHOD (mswindows, init_frame_2);
|
|
337 CONSOLE_HAS_METHOD (mswindows, init_frame_3);
|
|
338 /* CONSOLE_HAS_METHOD (mswindows, mark_frame); */
|
219
|
339 CONSOLE_HAS_METHOD (mswindows, focus_on_frame);
|
213
|
340 CONSOLE_HAS_METHOD (mswindows, delete_frame);
|
|
341 /* CONSOLE_HAS_METHOD (mswindows, get_mouse_position); */
|
|
342 /* CONSOLE_HAS_METHOD (mswindows, set_mouse_position); */
|
219
|
343 CONSOLE_HAS_METHOD (mswindows, raise_frame);
|
|
344 CONSOLE_HAS_METHOD (mswindows, lower_frame);
|
|
345 CONSOLE_HAS_METHOD (mswindows, make_frame_visible);
|
|
346 CONSOLE_HAS_METHOD (mswindows, make_frame_invisible);
|
|
347 CONSOLE_HAS_METHOD (mswindows, iconify_frame);
|
213
|
348 CONSOLE_HAS_METHOD (mswindows, set_frame_size);
|
|
349 CONSOLE_HAS_METHOD (mswindows, set_frame_position);
|
|
350 /* CONSOLE_HAS_METHOD (mswindows, frame_property); */
|
|
351 /* CONSOLE_HAS_METHOD (mswindows, internal_frame_property_p); */
|
|
352 /* CONSOLE_HAS_METHOD (mswindows, frame_properties); */
|
|
353 CONSOLE_HAS_METHOD (mswindows, set_frame_properties);
|
219
|
354 CONSOLE_HAS_METHOD (mswindows, set_title_from_bufbyte);
|
213
|
355 /* CONSOLE_HAS_METHOD (mswindows, set_icon_name_from_bufbyte); */
|
219
|
356 CONSOLE_HAS_METHOD (mswindows, frame_visible_p);
|
213
|
357 /* CONSOLE_HAS_METHOD (mswindows, frame_totally_visible_p); */
|
219
|
358 CONSOLE_HAS_METHOD (mswindows, frame_iconified_p);
|
213
|
359 /* CONSOLE_HAS_METHOD (mswindows, set_frame_pointer); */
|
|
360 /* CONSOLE_HAS_METHOD (mswindows, set_frame_icon); */
|
|
361 /* CONSOLE_HAS_METHOD (mswindows, get_frame_parent); */
|
|
362 }
|
|
363
|
|
364 void
|
|
365 syms_of_frame_mswindows (void)
|
|
366 {
|
|
367 #if 0 /* XXX these are in general.c */
|
|
368 defsymbol (&Qname, "name");
|
|
369 defsymbol (&Qheight, "height");
|
|
370 defsymbol (&Qwidth, "width");
|
|
371 defsymbol (&Qtop, "top");
|
|
372 defsymbol (&Qleft, "left");
|
|
373 #endif
|
|
374 defsymbol (&Qinitially_unmapped, "initially-unmapped");
|
|
375 defsymbol (&Qpopup, "popup");
|
|
376 }
|
|
377
|
|
378 void
|
|
379 vars_of_frame_mswindows (void)
|
|
380 {
|
|
381 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /*
|
|
382 Plist of default frame-creation properties for mswindows frames.
|
|
383 These override what is specified in `default-frame-plist', but are
|
|
384 overridden by the arguments to the particular call to `make-frame'.
|
|
385
|
|
386 Note: In many cases, properties of a frame are available as specifiers
|
|
387 instead of through the frame-properties mechanism.
|
|
388
|
|
389 Here is a list of recognized frame properties, other than those
|
|
390 documented in `set-frame-properties' (they can be queried and
|
|
391 set at any time, except as otherwise noted):
|
|
392
|
|
393 initially-unmapped If non-nil, the frame will not be visible
|
|
394 when it is created. In this case, you
|
|
395 need to call `make-frame-visible' to make
|
|
396 the frame appear.
|
|
397 popup If non-nil, it should be a frame, and this
|
|
398 frame will be created as a "popup" frame
|
|
399 whose parent is the given frame. This
|
|
400 will make the window manager treat the
|
|
401 frame as a dialog box, which may entail
|
|
402 doing different things (e.g. not asking
|
|
403 for positioning, and not iconifying
|
|
404 separate from its parent).
|
|
405 top Y position (in pixels) of the upper-left
|
|
406 outermost corner of the frame (i.e. the
|
|
407 upper-left of the window-manager
|
|
408 decorations).
|
|
409 left X position (in pixels) of the upper-left
|
|
410 outermost corner of the frame (i.e. the
|
|
411 upper-left of the window-manager
|
|
412 decorations).
|
|
413
|
|
414 See also `default-frame-plist', which specifies properties which apply
|
|
415 to all frames, not just mswindows frames.
|
|
416 */ );
|
|
417 Vdefault_mswindows_frame_plist = Qnil;
|
|
418
|
|
419 mswindows_console_methods->device_specific_frame_props =
|
|
420 &Vdefault_mswindows_frame_plist;
|
|
421 }
|