Mercurial > hg > xemacs-beta
annotate src/frame-x.c @ 5927:b58b74274fa2 cygwin
changes from long ago, never committed...
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Wed, 15 Dec 2021 19:02:33 +0000 |
parents | 56144c8593a8 |
children |
rev | line source |
---|---|
428 | 1 /* Functions for the X window system. |
2 Copyright (C) 1989, 1992-5, 1997 Free Software Foundation, Inc. | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
3 Copyright (C) 1995, 1996, 2001, 2002, 2004, 2010 Ben Wing. |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
4 Copyright (C) 2010 Didier Verna |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5239
diff
changeset
|
8 XEmacs is free software: you can redistribute it and/or modify it |
428 | 9 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5239
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5239
diff
changeset
|
11 option) any later version. |
428 | 12 |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5239
diff
changeset
|
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 20 |
21 /* Synched up with: Not synched with FSF. */ | |
22 | |
2367 | 23 /* This file has been Mule-ized, Ben Wing, 10-14-04. */ |
24 | |
428 | 25 /* Substantially rewritten for XEmacs. */ |
26 | |
27 #include <config.h> | |
28 #include "lisp.h" | |
29 | |
800 | 30 #include "buffer.h" |
872 | 31 #include "device-impl.h" |
800 | 32 #include "events.h" |
33 #include "extents.h" | |
34 #include "faces.h" | |
872 | 35 #include "frame-impl.h" |
800 | 36 #include "gutter.h" |
872 | 37 #include "window.h" |
38 | |
39 #include "console-x-impl.h" | |
800 | 40 #include "glyphs-x.h" |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5050
diff
changeset
|
41 #include "fontcolor-x-impl.h" |
800 | 42 #include "scrollbar-x.h" |
43 | |
428 | 44 #include "xintrinsicp.h" /* CoreP.h needs this */ |
45 #include <X11/CoreP.h> /* Numerous places access the fields of | |
46 a core widget directly. We could | |
47 use XtGetValues(), but ... */ | |
48 #include <X11/Shell.h> | |
49 #include <X11/ShellP.h> | |
4769
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
4706
diff
changeset
|
50 #include <X11/Xmu/Editres.h> |
428 | 51 #include "EmacsManager.h" |
52 #include "EmacsFrameP.h" | |
53 #include "EmacsShell.h" | |
54 #ifdef EXTERNAL_WIDGET | |
55 #include "ExternalShell.h" | |
56 #endif | |
57 | |
58 #ifdef HAVE_DRAGNDROP | |
59 #include "dragdrop.h" | |
60 #endif | |
61 | |
62 /* Default properties to use when creating frames. */ | |
63 Lisp_Object Vdefault_x_frame_plist; | |
64 | |
2747 | 65 Lisp_Object Qoverride_redirect; |
428 | 66 Lisp_Object Qx_resource_name; |
67 | |
1204 | 68 static const struct memory_description x_frame_data_description_1 [] = { |
1346 | 69 { XD_LISP_OBJECT, offsetof (struct x_frame, last_menubar_buffer) }, |
1204 | 70 { XD_LISP_OBJECT, offsetof (struct x_frame, icon_pixmap) }, |
71 { XD_LISP_OBJECT, offsetof (struct x_frame, icon_pixmap_mask) }, | |
72 { XD_END } | |
73 }; | |
74 | |
3092 | 75 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
76 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("x-frame", x_frame, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
77 0, x_frame_data_description_1, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
78 Lisp_X_Frame); |
3092 | 79 #else /* not NEW_GC */ |
1204 | 80 extern const struct sized_memory_description x_frame_data_description; |
81 | |
82 const struct sized_memory_description x_frame_data_description = { | |
83 sizeof (struct x_frame), x_frame_data_description_1 | |
84 }; | |
3092 | 85 #endif /* not NEW_GC */ |
1204 | 86 |
428 | 87 EXFUN (Fx_window_id, 1); |
88 | |
89 | |
90 /************************************************************************/ | |
91 /* helper functions */ | |
92 /************************************************************************/ | |
93 | |
94 /* Return the Emacs frame-object corresponding to an X window */ | |
95 struct frame * | |
96 x_window_to_frame (struct device *d, Window wdesc) | |
97 { | |
98 Lisp_Object tail, frame; | |
99 struct frame *f; | |
100 | |
101 /* This function was previously written to accept only a window argument | |
102 (and to loop over all devices looking for a matching window), but | |
103 that is incorrect because window ID's are not unique across displays. */ | |
104 | |
105 for (tail = DEVICE_FRAME_LIST (d); CONSP (tail); tail = XCDR (tail)) | |
106 { | |
107 frame = XCAR (tail); | |
108 if (!FRAMEP (frame)) | |
109 continue; | |
110 f = XFRAME (frame); | |
111 if (FRAME_X_P (f) && XtWindow (FRAME_X_TEXT_WIDGET (f)) == wdesc) | |
112 return f; | |
113 } | |
114 return 0; | |
115 } | |
116 | |
117 /* Like x_window_to_frame but also compares the window with the widget's | |
118 windows */ | |
119 struct frame * | |
120 x_any_window_to_frame (struct device *d, Window wdesc) | |
121 { | |
122 Widget w; | |
123 assert (DEVICE_X_P (d)); | |
124 | |
125 w = XtWindowToWidget (DEVICE_X_DISPLAY (d), wdesc); | |
126 | |
127 if (!w) | |
128 return 0; | |
129 | |
130 /* We used to map over all frames here and then map over all widgets | |
131 belonging to that frame. However it turns out that this was very fragile | |
442 | 132 as it requires our display structures to be in sync _and_ that the |
428 | 133 loop is told about every new widget somebody adds. Therefore we |
134 now let Xt find it for us (which does a bottom-up search which | |
135 could even be faster) */ | |
136 return x_any_widget_or_parent_to_frame (d, w); | |
137 } | |
138 | |
139 static struct frame * | |
140 x_find_frame_for_window (struct device *d, Window wdesc) | |
141 { | |
142 Lisp_Object tail, frame; | |
143 struct frame *f; | |
144 /* This function was previously written to accept only a window argument | |
145 (and to loop over all devices looking for a matching window), but | |
146 that is incorrect because window ID's are not unique across displays. */ | |
147 | |
148 for (tail = DEVICE_FRAME_LIST (d); CONSP (tail); tail = XCDR (tail)) | |
149 { | |
150 frame = XCAR (tail); | |
151 f = XFRAME (frame); | |
152 /* This frame matches if the window is any of its widgets. */ | |
153 if (wdesc == XtWindow (FRAME_X_SHELL_WIDGET (f)) || | |
154 wdesc == XtWindow (FRAME_X_CONTAINER_WIDGET (f)) || | |
155 wdesc == XtWindow (FRAME_X_TEXT_WIDGET (f))) | |
156 return f; | |
157 | |
158 /* Match if the window is one of the widgets at the top of the frame | |
159 (menubar, Energize psheets). */ | |
160 | |
161 /* Note: Jamie once said | |
162 | |
163 "Do *not* match if the window is this frame's psheet." | |
164 | |
165 But this is wrong and will screw up some functions that expect | |
166 x_any_window_to_frame() to work as advertised. I think the reason | |
167 for this statement is that, in the old (broken) event loop, where | |
168 not all events went through XtDispatchEvent(), psheet events | |
169 would incorrectly get sucked away by Emacs if this function matched | |
170 on psheet widgets. */ | |
171 | |
172 /* Note: that this called only from | |
173 x_any_widget_or_parent_to_frame it is unnecessary to iterate | |
174 over the top level widgets. */ | |
175 | |
176 /* Note: we use to special case scrollbars but this turns out to be a bad idea | |
177 because | |
178 1. We sometimes get events for _unmapped_ scrollbars and our | |
179 callers don't want us to fail. | |
180 2. Starting with the 21.2 widget stuff there are now loads of | |
181 widgets to check and it is easy to forget adding them in a loop here. | |
182 See x_any_window_to_frame | |
183 3. We pick up all widgets now anyway. */ | |
184 } | |
185 | |
186 return 0; | |
187 } | |
188 | |
189 struct frame * | |
190 x_any_widget_or_parent_to_frame (struct device *d, Widget widget) | |
191 { | |
192 while (widget) | |
193 { | |
194 struct frame *f = x_find_frame_for_window (d, XtWindow (widget)); | |
195 if (f) | |
196 return f; | |
197 widget = XtParent (widget); | |
198 } | |
199 | |
200 return 0; | |
201 } | |
202 | |
203 struct frame * | |
204 decode_x_frame (Lisp_Object frame) | |
205 { | |
206 if (NILP (frame)) | |
793 | 207 frame = wrap_frame (selected_frame ()); |
428 | 208 CHECK_LIVE_FRAME (frame); |
209 /* this will also catch dead frames, but putting in the above check | |
210 results in a more useful error */ | |
211 CHECK_X_FRAME (frame); | |
212 return XFRAME (frame); | |
213 } | |
214 | |
215 | |
216 /************************************************************************/ | |
217 /* window-manager interactions */ | |
218 /************************************************************************/ | |
219 | |
220 #if 0 | |
221 /* Not currently used. */ | |
222 | |
223 void | |
224 x_wm_mark_shell_size_user_specified (Widget wmshell) | |
225 { | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
226 assert (XtIsWMShell (wmshell)); |
428 | 227 EmacsShellSetSizeUserSpecified (wmshell); |
228 } | |
229 | |
230 void | |
231 x_wm_mark_shell_position_user_specified (Widget wmshell) | |
232 { | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
233 assert (XtIsWMShell (wmshell)); |
428 | 234 EmacsShellSetPositionUserSpecified (wmshell); |
235 } | |
236 | |
237 #endif | |
238 | |
239 void | |
240 x_wm_set_shell_iconic_p (Widget shell, int iconic_p) | |
241 { | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
242 assert (XtIsWMShell (shell)); |
428 | 243 |
244 /* Because of questionable logic in Shell.c, this sequence can't work: | |
245 | |
246 w = XtCreatePopupShell (...); | |
247 Xt_SET_VALUE (w, XtNiconic, True); | |
248 XtRealizeWidget (w); | |
249 | |
250 The iconic resource is only consulted at initialization time (when | |
251 XtCreatePopupShell is called) instead of at realization time (just | |
252 before the window gets created, which would be more sensible) or | |
253 at management-time (just before the window gets mapped, which would | |
254 be most sensible of all). | |
255 | |
256 The bug is that Shell's SetValues method doesn't do anything to | |
257 w->wm.wm_hints.initial_state until after the widget has been realized. | |
258 Calls to XtSetValues are ignored in the window between creation and | |
259 realization. This is true of MIT X11R5 patch level 25, at least. | |
260 (Apparently some other versions of Xt don't have this bug?) | |
261 */ | |
262 Xt_SET_VALUE (shell, XtNiconic, iconic_p); | |
263 EmacsShellSmashIconicHint (shell, iconic_p); | |
264 } | |
265 | |
266 void | |
267 x_wm_set_cell_size (Widget wmshell, int cw, int ch) | |
268 { | |
269 Arg al [2]; | |
270 | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
271 assert (XtIsWMShell (wmshell)); |
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
272 assert (cw > 0 && ch > 0); |
428 | 273 |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
274 Xt_SET_ARG (al[0], XtNwidthInc, cw); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
275 Xt_SET_ARG (al[1], XtNheightInc, ch); |
428 | 276 XtSetValues (wmshell, al, 2); |
277 } | |
278 | |
279 void | |
280 x_wm_set_variable_size (Widget wmshell, int width, int height) | |
281 { | |
282 Arg al [2]; | |
283 | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
284 assert (XtIsWMShell (wmshell)); |
428 | 285 #ifdef DEBUG_GEOMETRY_MANAGEMENT |
286 /* See comment in EmacsShell.c */ | |
287 printf ("x_wm_set_variable_size: %d %d\n", width, height); | |
288 fflush (stdout); | |
289 #endif | |
290 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
291 Xt_SET_ARG (al[0], XtNwidthCells, width); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
292 Xt_SET_ARG (al[1], XtNheightCells, height); |
428 | 293 XtSetValues (wmshell, al, 2); |
294 } | |
295 | |
296 /* If the WM_PROTOCOLS property does not already contain WM_TAKE_FOCUS | |
297 and WM_DELETE_WINDOW, then add them. (They may already be present | |
298 because of the toolkit (Motif adds them, for example, but Xt doesn't). | |
299 */ | |
300 static void | |
301 x_wm_hack_wm_protocols (Widget widget) | |
302 { | |
303 Display *dpy = XtDisplay (widget); | |
304 struct device *d = get_device_from_display (dpy); | |
305 Window w = XtWindow (widget); | |
306 int need_delete = 1; | |
307 int need_focus = 1; | |
308 | |
309 assert (XtIsWMShell (widget)); | |
310 | |
311 { | |
1885 | 312 Atom type; |
428 | 313 int format = 0; |
314 unsigned long nitems = 0; | |
315 unsigned long bytes_after; | |
2367 | 316 Rawbyte *prop_return = 0; /* semantically a void* */ |
428 | 317 |
318 if (Success == XGetWindowProperty (dpy, w, DEVICE_XATOM_WM_PROTOCOLS (d), | |
319 0, 100, False, XA_ATOM, | |
320 &type, &format, &nitems, &bytes_after, | |
1885 | 321 &prop_return) |
428 | 322 && format == 32 && type == XA_ATOM) |
323 while (nitems > 0) | |
324 { | |
1885 | 325 Atom *atoms = (Atom *) prop_return; |
428 | 326 nitems--; |
1885 | 327 if (atoms[nitems] == DEVICE_XATOM_WM_DELETE_WINDOW (d)) |
428 | 328 need_delete = 0; |
1885 | 329 else if (atoms[nitems] == DEVICE_XATOM_WM_TAKE_FOCUS (d)) |
428 | 330 need_focus = 0; |
331 } | |
2367 | 332 if (prop_return) XFree ((CRawbyte *) prop_return); |
428 | 333 } |
334 { | |
335 Atom props [10]; | |
336 int count = 0; | |
337 if (need_delete) props[count++] = DEVICE_XATOM_WM_DELETE_WINDOW (d); | |
338 if (need_focus) props[count++] = DEVICE_XATOM_WM_TAKE_FOCUS (d); | |
339 if (count) | |
340 XChangeProperty (dpy, w, DEVICE_XATOM_WM_PROTOCOLS (d), XA_ATOM, 32, | |
2367 | 341 PropModeAppend, (Rawbyte *) props, count); |
428 | 342 } |
343 } | |
344 | |
345 static void | |
2367 | 346 x_wm_store_class_hints (Widget shell, Extbyte *frame_name) |
428 | 347 { |
348 Display *dpy = XtDisplay (shell); | |
2367 | 349 Extbyte *app_name, *app_class; |
428 | 350 XClassHint classhint; |
351 | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
352 assert (XtIsWMShell (shell)); |
428 | 353 |
354 XtGetApplicationNameAndClass (dpy, &app_name, &app_class); | |
355 classhint.res_name = frame_name; | |
356 classhint.res_class = app_class; | |
357 XSetClassHint (dpy, XtWindow (shell), &classhint); | |
358 } | |
359 | |
360 #ifndef HAVE_WMCOMMAND | |
2367 | 361 |
428 | 362 static void |
363 x_wm_maybe_store_wm_command (struct frame *f) | |
364 { | |
365 Widget w = FRAME_X_SHELL_WIDGET (f); | |
366 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
367 | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
368 assert (XtIsWMShell (w)); |
428 | 369 |
370 if (NILP (DEVICE_X_WM_COMMAND_FRAME (d))) | |
371 { | |
372 int argc; | |
2367 | 373 Wexttext **argv; |
428 | 374 make_argc_argv (Vcommand_line_args, &argc, &argv); |
375 XSetCommand (XtDisplay (w), XtWindow (w), argv, argc); | |
376 free_argc_argv (argv); | |
793 | 377 DEVICE_X_WM_COMMAND_FRAME (d) = wrap_frame (f); |
428 | 378 } |
379 } | |
380 | |
381 /* If we're deleting the frame on which the WM_COMMAND property has been | |
382 set, then move that property to another frame so that there is exactly | |
383 one frame that has that property set. | |
384 */ | |
385 static void | |
386 x_wm_maybe_move_wm_command (struct frame *f) | |
387 { | |
388 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
389 | |
390 /* There may not be a frame in DEVICE_X_WM_COMMAND_FRAME() | |
391 if we C-c'ed at startup at the right time. */ | |
392 if (FRAMEP (DEVICE_X_WM_COMMAND_FRAME (d)) | |
393 && f == XFRAME (DEVICE_X_WM_COMMAND_FRAME (d))) | |
394 { | |
395 Lisp_Object rest = DEVICE_FRAME_LIST (d); | |
396 DEVICE_X_WM_COMMAND_FRAME (d) = Qnil; | |
397 /* find some random other X frame that is not this one, or give up */ | |
398 /* skip non-top-level (ExternalClient) frames */ | |
399 while (!NILP (rest) && | |
400 (f == XFRAME (XCAR (rest)) || | |
401 !FRAME_X_TOP_LEVEL_FRAME_P (XFRAME (XCAR (rest))))) | |
402 rest = XCDR (rest); | |
403 if (NILP (rest)) | |
404 return; | |
405 f = XFRAME (XCAR (rest)); | |
406 | |
407 x_wm_maybe_store_wm_command (f); | |
408 | |
409 } | |
410 } | |
2367 | 411 |
428 | 412 #endif /* !HAVE_WMCOMMAND */ |
413 | |
593 | 414 int |
415 x_frame_window_state (struct frame *f) | |
428 | 416 { |
417 Atom actual_type; | |
418 int actual_format; | |
419 unsigned long nitems, bytesafter; | |
2367 | 420 Rawbyte *datap = 0; |
428 | 421 Widget widget; |
593 | 422 int result = -1; |
428 | 423 struct device *d = XDEVICE (FRAME_DEVICE (f)); |
424 | |
425 widget = FRAME_X_SHELL_WIDGET (f); | |
426 if (Success == XGetWindowProperty (XtDisplay (widget), XtWindow (widget), | |
427 DEVICE_XATOM_WM_STATE (d), 0, 2, False, | |
428 DEVICE_XATOM_WM_STATE (d), &actual_type, | |
429 &actual_format, &nitems, &bytesafter, | |
1885 | 430 &datap) |
428 | 431 && datap) |
432 { | |
1885 | 433 unsigned long *ul_result_ptr = (unsigned long *) datap; |
593 | 434 if (nitems <= 2) /* "suggested" by ICCCM version 1 */ |
1885 | 435 result = (int) ul_result_ptr[0]; |
2367 | 436 XFree ((CRawbyte *) datap); |
428 | 437 } |
593 | 438 |
428 | 439 return result; |
440 } | |
441 | |
593 | 442 static int |
443 x_frame_iconified_p (struct frame *f) | |
444 { | |
445 return x_frame_window_state (f) == IconicState; | |
446 } | |
447 | |
428 | 448 |
449 /************************************************************************/ | |
450 /* frame properties */ | |
451 /************************************************************************/ | |
452 | |
453 /* Connect the frame-property names (symbols) to the corresponding | |
454 X Resource Manager names. The name of a property, as a Lisp symbol, | |
793 | 455 has an `x-resource-name' property which is a Lisp string. */ |
428 | 456 |
457 static void | |
458 init_x_prop_symbols (void) | |
459 { | |
460 #define def(sym, rsrc) \ | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
461 Fput (sym, Qx_resource_name, build_ascstring (rsrc)) |
428 | 462 #define defi(sym,rsrc) \ |
463 def (sym, rsrc); Fput (sym, Qintegerp, Qt) | |
464 | |
465 #if 0 /* this interferes with things. #### fix this right */ | |
466 def (Qminibuffer, XtNminibuffer); | |
467 def (Qunsplittable, XtNunsplittable); | |
468 #endif | |
469 defi(Qinternal_border_width, XtNinternalBorderWidth); | |
470 def (Qscrollbar_placement, XtNscrollBarPlacement); | |
471 defi(Qinter_line_space, XtNinterline); | |
472 /* font, foreground */ | |
473 def (Qiconic, XtNiconic); | |
474 def (Qbar_cursor, XtNbarCursor); | |
475 def (Qvisual_bell, XtNvisualBell); | |
476 defi(Qbell_volume, XtNbellVolume); | |
477 def (Qpointer_background, XtNpointerBackground); | |
478 def (Qpointer_color, XtNpointerColor); | |
479 def (Qtext_pointer, XtNtextPointer); | |
480 def (Qspace_pointer, XtNspacePointer); | |
481 def (Qmodeline_pointer, XtNmodeLinePointer); | |
482 def (Qgc_pointer, XtNgcPointer); | |
483 /* geometry, initial_geometry */ | |
484 def (Qinitially_unmapped, XtNinitiallyUnmapped); | |
485 /* preferred_width, preferred_height */ | |
486 def (Quse_backing_store, XtNuseBackingStore); | |
487 | |
488 /* inherited: */ | |
489 | |
490 def (Qborder_color, XtNborderColor); | |
491 defi(Qborder_width, XtNborderWidth); | |
492 defi(Qwidth, XtNwidth); | |
493 defi(Qheight, XtNheight); | |
494 defi(Qleft, XtNx); | |
495 defi(Qtop, XtNy); | |
496 | |
497 #undef def | |
3381 | 498 #undef defi |
428 | 499 } |
500 | |
501 static Lisp_Object | |
502 color_to_string (Widget w, unsigned long pixel) | |
503 { | |
867 | 504 Ibyte buf[255]; |
428 | 505 |
506 XColor color; | |
507 color.pixel = pixel; | |
508 XQueryColor (XtDisplay (w), w->core.colormap, &color); | |
771 | 509 qxesprintf (buf, "#%04x%04x%04x", color.red, color.green, color.blue); |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
510 return build_istring (buf); |
428 | 511 } |
512 | |
513 static void | |
514 x_get_top_level_position (Display *d, Window w, Position *x, Position *y) | |
515 { | |
516 Window root, parent = w, *children; | |
517 unsigned int nchildren; | |
518 XWindowAttributes xwa; | |
519 | |
520 do | |
521 { | |
522 w = parent; | |
523 if (!XQueryTree (d, w, &root, &parent, &children, &nchildren)) | |
524 { | |
525 *x = 0; | |
526 *y = 0; | |
527 return; | |
528 } | |
529 XFree (children); | |
530 } | |
531 while (root != parent); | |
532 XGetWindowAttributes (d, w, &xwa); | |
533 *x = xwa.x; | |
534 *y = xwa.y; | |
535 } | |
536 | |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
537 void x_get_frame_text_position (struct frame *f) |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
538 { |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
539 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (FRAME_DEVICE (f))); |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
540 Window window = XtWindow (FRAME_X_TEXT_WIDGET (f)); |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
541 Window root, child; |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
542 int x, y; |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
543 unsigned int width, height, border_width; |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
544 unsigned int depth; |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
545 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
546 XGetGeometry (dpy, window, &root, &x, &y, &width, &height, &border_width, |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
547 &depth); |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
548 XTranslateCoordinates (dpy, window, root, 0, 0, &x, &y, &child); |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
549 |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
550 FRAME_X_X (f) = x; |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
551 FRAME_X_Y (f) = y; |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
552 } |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
553 |
428 | 554 #if 0 |
555 static void | |
556 x_smash_bastardly_shell_position (Widget shell) | |
557 { | |
558 /* Naturally those bastards who wrote Xt couldn't be bothered | |
559 to learn about race conditions and such. We can't trust | |
560 the X and Y values to have any semblance of correctness, | |
561 so we smash the right values in place. */ | |
562 | |
563 /* We might be called before we've actually realized the window (if | |
564 we're checking for the minibuffer resource). This will bomb in | |
565 that case so we don't bother calling it. */ | |
566 if (XtWindow (shell)) | |
567 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), | |
568 &shell->core.x, &shell->core.y); | |
569 } | |
570 #endif /* 0 */ | |
571 | |
572 static Lisp_Object | |
573 x_frame_property (struct frame *f, Lisp_Object property) | |
574 { | |
575 Widget shell = FRAME_X_SHELL_WIDGET (f); | |
576 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); | |
577 Widget gw = (Widget) w; | |
578 | |
579 if (EQ (Qleft, property) || EQ (Qtop, property)) | |
580 { | |
581 Position x, y; | |
582 if (!XtWindow(shell)) | |
583 return Qzero; | |
584 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), &x, &y); | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
585 if (EQ (Qleft, property)) return make_fixnum (x); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
586 if (EQ (Qtop, property)) return make_fixnum (y); |
428 | 587 } |
588 if (EQ (Qborder_width, property)) | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
589 return make_fixnum (w->core.border_width); |
428 | 590 if (EQ (Qinternal_border_width, property)) |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
591 return make_fixnum (w->emacs_frame.internal_border_width); |
428 | 592 if (EQ (Qborder_color, property)) |
593 return color_to_string (gw, w->core.border_pixel); | |
594 if (EQ (Qinter_line_space, property)) | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
595 return make_fixnum (w->emacs_frame.interline); |
428 | 596 if (EQ (Qwindow_id, property)) |
771 | 597 return Fx_window_id (wrap_frame (f)); |
428 | 598 |
599 return Qunbound; | |
600 } | |
601 | |
602 static int | |
2286 | 603 x_internal_frame_property_p (struct frame *UNUSED (f), Lisp_Object property) |
428 | 604 { |
605 return EQ (property, Qleft) | |
606 || EQ (property, Qtop) | |
607 || EQ (property, Qborder_width) | |
608 || EQ (property, Qinternal_border_width) | |
609 || EQ (property, Qborder_color) | |
610 || EQ (property, Qinter_line_space) | |
611 || EQ (property, Qwindow_id) | |
612 || STRINGP (property); | |
613 } | |
614 | |
615 static Lisp_Object | |
616 x_frame_properties (struct frame *f) | |
617 { | |
618 Lisp_Object props = Qnil; | |
619 Widget shell = FRAME_X_SHELL_WIDGET (f); | |
620 EmacsFrame w = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); | |
621 Widget gw = (Widget) w; | |
622 Position x, y; | |
623 | |
771 | 624 props = cons3 (Qwindow_id, Fx_window_id (wrap_frame (f)), props); |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
625 props = cons3 (Qinter_line_space, make_fixnum (w->emacs_frame.interline), props); |
428 | 626 |
627 props = cons3 (Qborder_color, | |
628 color_to_string (gw, w->core.border_pixel), props); | |
629 props = cons3 (Qinternal_border_width, | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
630 make_fixnum (w->emacs_frame.internal_border_width), props); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
631 props = cons3 (Qborder_width, make_fixnum (w->core.border_width), props); |
428 | 632 |
633 if (!XtWindow(shell)) | |
634 x = y = 0; | |
635 else | |
636 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), &x, &y); | |
637 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
638 props = cons3 (Qtop, make_fixnum (y), props); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
639 props = cons3 (Qleft, make_fixnum (x), props); |
428 | 640 |
641 return props; | |
642 } | |
643 | |
644 | |
645 /* Functions called only from `x_set_frame_properties' to set | |
646 individual properties. */ | |
647 | |
648 static void | |
867 | 649 x_set_frame_text_value (struct frame *f, Ibyte *value, |
428 | 650 String Xt_resource_name, |
651 String Xt_resource_encoding_name) | |
652 { | |
653 Atom encoding = XA_STRING; | |
654 String new_XtValue = (String) value; | |
655 String old_XtValue = NULL; | |
656 | |
657 #ifdef MULE | |
867 | 658 Ibyte *ptr; |
428 | 659 /* Optimize for common ASCII case */ |
660 for (ptr = value; *ptr; ptr++) | |
826 | 661 if (!byte_ascii_p (*ptr)) |
428 | 662 { |
663 encoding = DEVICE_XATOM_COMPOUND_TEXT (XDEVICE (FRAME_DEVICE (f))); | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
664 new_XtValue = (String) ITEXT_TO_EXTERNAL (value, Qctext); |
428 | 665 break; |
666 } | |
667 #endif /* MULE */ | |
668 | |
440 | 669 /* #### Caching is device-independent - belongs in update_frame_title. */ |
428 | 670 Xt_GET_VALUE (FRAME_X_SHELL_WIDGET (f), Xt_resource_name, &old_XtValue); |
671 if (!old_XtValue || strcmp (new_XtValue, old_XtValue)) | |
672 { | |
673 Arg al[2]; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
674 Xt_SET_ARG (al[0], Xt_resource_name, new_XtValue); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
675 Xt_SET_ARG (al[1], Xt_resource_encoding_name, encoding); |
428 | 676 XtSetValues (FRAME_X_SHELL_WIDGET (f), al, 2); |
677 } | |
678 } | |
679 | |
680 static void | |
867 | 681 x_set_title_from_ibyte (struct frame *f, Ibyte *name) |
428 | 682 { |
683 x_set_frame_text_value (f, name, XtNtitle, XtNtitleEncoding); | |
684 } | |
685 | |
686 static void | |
867 | 687 x_set_icon_name_from_ibyte (struct frame *f, Ibyte *name) |
428 | 688 { |
689 x_set_frame_text_value (f, name, XtNiconName, XtNiconNameEncoding); | |
690 } | |
691 | |
692 /* Set the initial frame size as specified. This function is used | |
693 when the frame's widgets have not yet been realized. In this | |
694 case, it is not sufficient just to set the width and height of | |
695 the EmacsFrame widget, because they will be ignored when the | |
696 widget is realized (instead, the shell's geometry resource is | |
697 used). */ | |
698 | |
699 static void | |
700 x_set_initial_frame_size (struct frame *f, int flags, int x, int y, | |
647 | 701 int w, int h) |
428 | 702 { |
2367 | 703 Ascbyte shell_geom[255]; |
428 | 704 int xval, yval; |
2367 | 705 Ascbyte xsign, ysign; |
706 Boolbyte uspos = !!(flags & (XValue | YValue)); | |
707 Boolbyte ussize = !!(flags & (WidthValue | HeightValue)); | |
708 Ascbyte *temp; | |
428 | 709 |
710 /* assign the correct size to the EmacsFrame widget ... */ | |
711 EmacsFrameSetCharSize (FRAME_X_TEXT_WIDGET (f), w, h); | |
712 | |
713 /* and also set the WMShell's geometry */ | |
714 (flags & XNegative) ? (xval = -x, xsign = '-') : (xval = x, xsign = '+'); | |
715 (flags & YNegative) ? (yval = -y, ysign = '-') : (yval = y, ysign = '+'); | |
716 | |
717 if (uspos && ussize) | |
718 sprintf (shell_geom, "=%dx%d%c%d%c%d", w, h, xsign, xval, ysign, yval); | |
719 else if (uspos) | |
720 sprintf (shell_geom, "=%c%d%c%d", xsign, xval, ysign, yval); | |
721 else if (ussize) | |
722 sprintf (shell_geom, "=%dx%d", w, h); | |
723 | |
724 if (uspos || ussize) | |
725 { | |
2367 | 726 temp = xnew_ascbytes (1 + strlen (shell_geom)); |
428 | 727 strcpy (temp, shell_geom); |
728 FRAME_X_GEOM_FREE_ME_PLEASE (f) = temp; | |
729 } | |
730 else | |
731 temp = NULL; | |
732 | |
733 Xt_SET_VALUE (FRAME_X_SHELL_WIDGET (f), XtNgeometry, temp); | |
734 } | |
735 | |
736 /* Report to X that a frame property of frame S is being set or changed. | |
737 If the property is not specially recognized, do nothing. | |
738 */ | |
739 | |
740 static void | |
741 x_set_frame_properties (struct frame *f, Lisp_Object plist) | |
742 { | |
743 Position x, y; | |
744 Dimension width = 0, height = 0; | |
745 Bool width_specified_p = False; | |
746 Bool height_specified_p = False; | |
747 Bool x_position_specified_p = False; | |
748 Bool y_position_specified_p = False; | |
749 Bool internal_border_width_specified = False; | |
750 Lisp_Object tail; | |
3415 | 751 Widget w; |
752 | |
753 /* We can be called after the X IO error handler has seen a broken pipe on | |
754 the relevant display. Don't do anything in that case. */ | |
755 if (!FRAME_LIVE_P (f) || DEVICE_X_BEING_DELETED (XDEVICE (FRAME_DEVICE (f)))) | |
756 return; | |
757 | |
758 w = FRAME_X_TEXT_WIDGET (f); | |
428 | 759 |
760 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) | |
761 { | |
762 Lisp_Object prop = Fcar (tail); | |
763 Lisp_Object val = Fcar (Fcdr (tail)); | |
764 | |
765 if (STRINGP (prop)) | |
766 { | |
2367 | 767 const Extbyte *extprop; |
428 | 768 |
769 if (XSTRING_LENGTH (prop) == 0) | |
770 continue; | |
771 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
772 extprop = LISP_STRING_TO_EXTERNAL (prop, Qxt_widget_arg_encoding); |
428 | 773 if (STRINGP (val)) |
774 { | |
442 | 775 const Extbyte *extval; |
665 | 776 Bytecount extvallen; |
428 | 777 |
2367 | 778 /* !!#### I seriously doubt there is a single external format |
779 for the value of a widget argument; it depends on the | |
780 semantics of the argument. So use of | |
781 Qxt_widget_arg_encoding is totally bogus. --ben */ | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
782 LISP_STRING_TO_SIZED_EXTERNAL (val, extval, extvallen, |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
783 Qxt_widget_arg_encoding); |
428 | 784 XtVaSetValues (w, XtVaTypedArg, extprop, |
2367 | 785 /* !!#### Verify this + 1 and document |
786 as zero-termination */ | |
428 | 787 XtRString, extval, extvallen + 1, |
3463 | 788 NULL); |
428 | 789 } |
790 else | |
791 XtVaSetValues (w, XtVaTypedArg, extprop, XtRInt, | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
792 XFIXNUM (val), sizeof (int), |
3463 | 793 NULL); |
428 | 794 } |
795 else if (SYMBOLP (prop)) | |
796 { | |
797 Lisp_Object str = Fget (prop, Qx_resource_name, Qnil); | |
798 int int_p = !NILP (Fget (prop, Qintegerp, Qnil)); | |
2367 | 799 Extbyte *strext; |
428 | 800 |
801 if (NILP (prop) || NILP (str)) | |
802 { | |
803 /* Kludge to handle the font property. */ | |
804 if (EQ (prop, Qfont)) | |
805 { | |
806 /* If the value is not a string we silently ignore it. */ | |
807 if (STRINGP (val)) | |
808 { | |
809 Lisp_Object frm, font_spec; | |
810 | |
793 | 811 frm = wrap_frame (f); |
428 | 812 font_spec = Fget (Fget_face (Qdefault), Qfont, Qnil); |
813 | |
814 Fadd_spec_to_specifier (font_spec, val, frm, Qnil, Qnil); | |
815 update_frame_face_values (f); | |
816 } | |
817 | |
818 continue; | |
819 } | |
820 else | |
821 continue; | |
822 } | |
823 CHECK_STRING (str); | |
824 | |
825 /* Kludge the width/height so that we interpret them in characters | |
826 instead of pixels. Yuck yuck yuck. */ | |
2367 | 827 if (!qxestrcmp_ascii (XSTRING_DATA (str), "width")) |
428 | 828 { |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
829 CHECK_FIXNUM (val); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
830 width = XFIXNUM (val); |
428 | 831 width_specified_p = True; |
832 continue; | |
833 } | |
2367 | 834 if (!qxestrcmp_ascii (XSTRING_DATA (str), "height")) |
428 | 835 { |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
836 CHECK_FIXNUM (val); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
837 height = XFIXNUM (val); |
428 | 838 height_specified_p = True; |
839 continue; | |
840 } | |
841 /* Further kludge the x/y. */ | |
2367 | 842 if (!qxestrcmp_ascii (XSTRING_DATA (str), "x")) |
428 | 843 { |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
844 CHECK_FIXNUM (val); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
845 x = (Position) XFIXNUM (val); |
428 | 846 x_position_specified_p = True; |
847 continue; | |
848 } | |
2367 | 849 if (!qxestrcmp_ascii (XSTRING_DATA (str), "y")) |
428 | 850 { |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
851 CHECK_FIXNUM (val); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
852 y = (Position) XFIXNUM (val); |
428 | 853 y_position_specified_p = True; |
854 continue; | |
855 } | |
856 /* Have you figured out by now that this entire function is | |
857 one gigantic kludge? */ | |
2367 | 858 if (!qxestrcmp_ascii (XSTRING_DATA (str), "internalBorderWidth")) |
428 | 859 { |
860 internal_border_width_specified = True; | |
861 } | |
862 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
863 strext = LISP_STRING_TO_EXTERNAL (str, Qxt_widget_arg_encoding); |
428 | 864 if (int_p) |
865 { | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
866 CHECK_FIXNUM (val); |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
867 Xt_SET_VALUE (w, strext, XFIXNUM (val)); |
428 | 868 } |
869 else if (EQ (val, Qt)) | |
870 { | |
2367 | 871 Xt_SET_VALUE (w, strext, True); /* XtN...*/ |
428 | 872 } |
873 else if (EQ (val, Qnil)) | |
874 { | |
2367 | 875 Xt_SET_VALUE (w, strext, False); /* XtN...*/ |
428 | 876 } |
877 else | |
878 { | |
2367 | 879 const Extbyte *extval; |
880 Bytecount extvallen; | |
2372 | 881 CHECK_STRING (val); |
2367 | 882 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
883 LISP_STRING_TO_SIZED_EXTERNAL (val, extval, extvallen, |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
884 Qxt_widget_arg_encoding); |
428 | 885 XtVaSetValues (w, XtVaTypedArg, |
886 /* XtN... */ | |
2367 | 887 strext, |
888 /* !!#### Verify this + 1 and document | |
889 as zero-termination */ | |
890 XtRString, extval, extvallen + 1, | |
3463 | 891 NULL); |
428 | 892 } |
893 | |
894 #ifdef HAVE_SCROLLBARS | |
2367 | 895 if (!qxestrcmp_ascii (XSTRING_DATA (str), "scrollBarWidth") |
896 || !qxestrcmp_ascii (XSTRING_DATA (str), "scrollBarHeight")) | |
428 | 897 { |
898 x_update_frame_scrollbars (f); | |
899 } | |
900 #endif /* HAVE_SCROLLBARS */ | |
901 } | |
902 } | |
903 | |
904 /* Kludge kludge kludge. We need to deal with the size and position | |
905 specially. */ | |
906 { | |
907 int size_specified_p = width_specified_p || height_specified_p; | |
908 int position_specified_p = x_position_specified_p || | |
909 y_position_specified_p; | |
910 | |
911 if (!width_specified_p) | |
912 width = FRAME_WIDTH (f); | |
913 if (!height_specified_p) | |
914 height = FRAME_HEIGHT (f); | |
915 | |
916 /* Kludge kludge kludge kludge. */ | |
917 if (position_specified_p && | |
918 (!x_position_specified_p || !y_position_specified_p)) | |
919 { | |
920 Position dummy; | |
921 Widget shell = FRAME_X_SHELL_WIDGET (f); | |
922 x_get_top_level_position (XtDisplay (shell), XtWindow (shell), | |
923 (x_position_specified_p ? &dummy : &x), | |
924 (y_position_specified_p ? &dummy : &y)); | |
925 #if 0 | |
926 x = (int) (FRAME_X_SHELL_WIDGET (f)->core.x); | |
927 y = (int) (FRAME_X_SHELL_WIDGET (f)->core.y); | |
928 #endif | |
929 } | |
930 | |
931 if (!f->init_finished) | |
932 { | |
933 int flags = (size_specified_p ? WidthValue | HeightValue : 0) | | |
934 (position_specified_p ? | |
935 XValue | YValue | (x < 0 ? XNegative : 0) | (y < 0 ? YNegative : 0) | |
936 : 0); | |
937 if (size_specified_p | |
938 || position_specified_p | |
939 || internal_border_width_specified) | |
940 x_set_initial_frame_size (f, flags, x, y, width, height); | |
941 } | |
942 else | |
943 { | |
944 if (size_specified_p || internal_border_width_specified) | |
945 { | |
793 | 946 Lisp_Object frame = wrap_frame (f); |
947 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
948 Fset_frame_size (frame, make_fixnum (width), |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
949 make_fixnum (height), Qnil); |
428 | 950 } |
951 if (position_specified_p) | |
952 { | |
793 | 953 Lisp_Object frame = wrap_frame (f); |
954 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
955 Fset_frame_position (frame, make_fixnum (x), make_fixnum (y)); |
428 | 956 } |
957 } | |
958 } | |
959 } | |
960 | |
961 static int frame_title_format_already_set; | |
962 | |
963 static void | |
964 maybe_set_frame_title_format (Widget shell) | |
965 { | |
966 | |
967 /* Only do this if this is the first X frame we're creating. | |
968 | |
969 If the *title resource (or -title option) was specified, then | |
970 set frame-title-format to its value. | |
971 */ | |
972 | |
973 if (!frame_title_format_already_set) | |
974 { | |
975 /* No doubt there's a less stupid way to do this. */ | |
2367 | 976 Extbyte *results[2]; |
977 XtResource resources[2]; | |
978 results[0] = results[1] = 0; | |
979 resources[0].resource_name = XtNtitle; | |
980 resources[0].resource_class = XtCTitle; | |
981 resources[0].resource_type = XtRString; | |
982 resources[0].resource_size = sizeof (String); | |
983 resources[0].resource_offset = 0; | |
984 resources[0].default_type = XtRString; | |
985 resources[0].default_addr = 0; | |
986 resources[1].resource_name = XtNiconName; | |
987 resources[1].resource_class = XtCIconName; | |
988 resources[1].resource_type = XtRString; | |
989 resources[1].resource_size = sizeof (String); | |
990 resources[1].resource_offset = sizeof (Extbyte *); | |
991 resources[1].default_type = XtRString; | |
992 resources[1].default_addr = 0; | |
428 | 993 XtGetSubresources (XtParent (shell), (XtPointer) results, |
994 shell->core.name, | |
995 shell->core.widget_class->core_class.class_name, | |
996 resources, XtNumber (resources), 0, 0); | |
997 if (results[0]) | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
998 Vframe_title_format = build_extstring (results[0], Qctext); |
428 | 999 if (results[1]) |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1000 Vframe_icon_title_format = build_extstring (results[1], Qctext); |
428 | 1001 } |
1002 | |
1003 frame_title_format_already_set = 1; | |
1004 } | |
1005 | |
4790
bc4f2511bbea
Remove support for the OffiX drag-and-drop protocol. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
4769
diff
changeset
|
1006 #if defined (HAVE_CDE) |
2367 | 1007 |
1008 static Extbyte * | |
1009 start_drag_internal_1 (Lisp_Object event, Lisp_Object data, | |
1010 Lisp_Object encoding, XEvent *x_event, int listp, | |
1011 Widget *wid_out, Bytecount *len_out, | |
1012 int *num_items_out) | |
1013 { | |
1014 struct frame *f; | |
1015 Widget wid; | |
1016 struct device *d; | |
1017 struct x_device *xd; | |
1018 XWindowAttributes win_attrib; | |
1019 int modifier = 0, state = 0; | |
1020 Extbyte *dnd_data; | |
1021 Lisp_Event *lisp_event; | |
1022 | |
1023 CHECK_EVENT (event); | |
1024 lisp_event = XEVENT (event); | |
1025 if (EVENT_TYPE (lisp_event) != button_press_event) | |
1026 invalid_argument ("Need button-press event for drag", event); | |
1027 f = decode_x_frame (FW_FRAME (EVENT_CHANNEL (lisp_event))); | |
1028 wid = FRAME_X_TEXT_WIDGET (f); | |
1029 d = XDEVICE (FRAME_DEVICE (f)); | |
1030 xd = DEVICE_X_DATA (d); | |
1031 *num_items_out = 0; | |
1032 | |
1033 if (listp) | |
1034 { | |
1035 DECLARE_EISTRING (ei); | |
1036 | |
1037 EXTERNAL_LIST_LOOP_2 (elt, data) | |
1038 { | |
1039 CHECK_STRING (elt); | |
1040 eicat_lstr (ei, elt); | |
1041 eicat_ch (ei, '\0'); | |
1042 (*num_items_out)++; | |
1043 } | |
1044 eicat_ch (ei, '\0'); | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1045 TO_EXTERNAL_FORMAT (DATA, (eidata (ei), eilen (ei)), |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1046 MALLOC, (dnd_data, *len_out), |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1047 encoding); |
2367 | 1048 } |
1049 else | |
1050 { | |
1051 CHECK_STRING (data); | |
1052 LISP_STRING_TO_SIZED_EXTERNAL_MALLOC (data, dnd_data, *len_out, | |
1053 encoding); | |
1054 *len_out += EXTTEXT_ZTERM_SIZE; | |
1055 (*num_items_out)++; | |
1056 } | |
1057 | |
1058 /* not so gross hack that converts an emacs event back to a XEvent */ | |
1059 | |
1060 x_event->xbutton.type = ButtonPress; | |
1061 x_event->xbutton.send_event = False; | |
1062 x_event->xbutton.display = XtDisplayOfObject (wid); | |
1063 x_event->xbutton.window = XtWindowOfObject (wid); | |
1064 x_event->xbutton.root = XRootWindow (x_event->xbutton.display, 0); | |
1065 x_event->xbutton.subwindow = 0; | |
1066 x_event->xbutton.time = lisp_event->timestamp; | |
1067 x_event->xbutton.x = EVENT_BUTTON_X (lisp_event); | |
1068 x_event->xbutton.y = EVENT_BUTTON_Y (lisp_event); | |
1069 if (Success == XGetWindowAttributes (x_event->xbutton.display, | |
1070 x_event->xbutton.window, | |
1071 &win_attrib)) | |
1072 { | |
1073 x_event->xbutton.x_root = win_attrib.x + EVENT_BUTTON_X (lisp_event); | |
1074 x_event->xbutton.y_root = win_attrib.y + EVENT_BUTTON_Y (lisp_event); | |
1075 } | |
1076 else | |
1077 { | |
1078 x_event->xbutton.x_root = EVENT_BUTTON_X (lisp_event); /* this is wrong */ | |
1079 x_event->xbutton.y_root = EVENT_BUTTON_Y (lisp_event); | |
1080 } | |
1081 | |
1082 modifier = EVENT_BUTTON_MODIFIERS (lisp_event); | |
1083 if (modifier & XEMACS_MOD_SHIFT) state |= ShiftMask; | |
1084 if (modifier & XEMACS_MOD_CONTROL) state |= ControlMask; | |
1085 if (modifier & XEMACS_MOD_META) state |= xd->MetaMask; | |
1086 if (modifier & XEMACS_MOD_SUPER) state |= xd->SuperMask; | |
1087 if (modifier & XEMACS_MOD_HYPER) state |= xd->HyperMask; | |
1088 if (modifier & XEMACS_MOD_ALT) state |= xd->AltMask; | |
1089 state |= Button1Mask << (EVENT_BUTTON_BUTTON (lisp_event) - 1); | |
1090 | |
1091 x_event->xbutton.state = state; | |
1092 x_event->xbutton.button = EVENT_BUTTON_BUTTON (lisp_event); | |
1093 x_event->xbutton.same_screen = True; | |
1094 | |
1095 *wid_out = wid; | |
1096 return dnd_data; | |
1097 } | |
1098 | |
4790
bc4f2511bbea
Remove support for the OffiX drag-and-drop protocol. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
4769
diff
changeset
|
1099 #endif /* defined (HAVE_CDE) */ |
2367 | 1100 |
428 | 1101 #ifdef HAVE_CDE |
1102 #include <Dt/Dt.h> | |
1103 #include <Dt/Dnd.h> | |
1104 | |
1105 static Widget CurrentDragWidget = NULL; | |
1106 static XtCallbackRec dnd_convert_cb_rec[2]; | |
1107 static XtCallbackRec dnd_destroy_cb_rec[2]; | |
1108 static int drag_not_done = 0; | |
1109 | |
1110 static void | |
1111 x_cde_destroy_callback (Widget widget, XtPointer clientData, | |
1112 XtPointer callData) | |
1113 { | |
1114 DtDndDragFinishCallbackStruct *dragFinishInfo = | |
2367 | 1115 (DtDndDragFinishCallbackStruct *) callData; |
428 | 1116 DtDndContext *dragData = dragFinishInfo->dragData; |
1117 int i; | |
1118 | |
1119 /* free the items */ | |
1120 if (callData != NULL && dragData != NULL) | |
1121 { | |
1122 if (dragData->protocol == DtDND_BUFFER_TRANSFER) | |
1123 { | |
1124 for (i = 0; i < dragData->numItems; i++) | |
1125 { | |
2367 | 1126 XtFree ((CRawbyte *) dragData->data.buffers[i].bp); |
428 | 1127 if (dragData->data.buffers[i].name) |
1128 XtFree(dragData->data.buffers[i].name); | |
1129 } | |
1130 } | |
1131 else | |
1132 { | |
1133 for (i = 0; i < dragData->numItems; i++) | |
1134 XtFree(dragData->data.files[i]); | |
1135 } | |
1136 } | |
1137 | |
1138 /* free the data string */ | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1139 xfree (clientData); |
428 | 1140 |
1141 CurrentDragWidget = NULL; | |
1142 } | |
1143 | |
1144 static void | |
1145 x_cde_convert_callback (Widget widget, XtPointer clientData, | |
1146 XtPointer callData) | |
1147 { | |
1148 DtDndConvertCallbackStruct *convertInfo = | |
1149 (DtDndConvertCallbackStruct *) callData; | |
2367 | 1150 Extbyte *textdata = (Extbyte *) clientData; |
1151 Extbyte *textptr = NULL; | |
428 | 1152 int i; |
1153 | |
1154 if (convertInfo == NULL) | |
1155 { | |
1156 return; | |
1157 } | |
1158 | |
1159 if ((convertInfo->dragData->protocol != DtDND_BUFFER_TRANSFER | |
1160 && convertInfo->dragData->protocol != DtDND_FILENAME_TRANSFER) || | |
1161 (convertInfo->reason != DtCR_DND_CONVERT_DATA)) | |
1162 { | |
1163 return; | |
1164 } | |
1165 | |
2367 | 1166 for (textptr = textdata, i = 0; |
1167 i < convertInfo->dragData->numItems; | |
1168 textptr += strlen (textptr) + 1, i++) | |
428 | 1169 { |
1170 if (convertInfo->dragData->protocol == DtDND_BUFFER_TRANSFER) | |
1171 { | |
2367 | 1172 convertInfo->dragData->data.buffers[i].bp = XtNewString (textptr); |
1173 convertInfo->dragData->data.buffers[i].size = strlen (textptr); | |
428 | 1174 convertInfo->dragData->data.buffers[i].name = NULL; |
1175 } | |
1176 else | |
1177 { | |
2367 | 1178 convertInfo->dragData->data.files[i] = XtNewString (textptr); |
428 | 1179 } |
1180 } | |
1181 | |
1182 convertInfo->status = DtDND_SUCCESS; | |
1183 } | |
1184 | |
1185 static Lisp_Object | |
2367 | 1186 abort_current_drag (Lisp_Object arg) |
428 | 1187 { |
1188 if (CurrentDragWidget && drag_not_done) | |
1189 { | |
1190 XmDragCancel(CurrentDragWidget); | |
1191 CurrentDragWidget = NULL; | |
1192 } | |
1193 return arg; | |
1194 } | |
1195 | |
1196 DEFUN ("cde-start-drag-internal", Fcde_start_drag_internal, 3, 3, 0, /* | |
1197 Start a CDE drag from a buffer. | |
1198 First argument is the event that started the drag (must be a | |
1199 button-press-event), | |
1200 second arg defines if the data should be treated as a buffer or | |
1201 a filename transfer (set to nil for buffer transfer), | |
1202 and the third argument is a list of data strings. | |
1203 WARNING: can only handle plain/text and file: transfers! | |
1204 */ | |
1205 (event, dragtype, dragdata)) | |
1206 { | |
2367 | 1207 Extbyte *dnd_data; |
1208 XEvent x_event; | |
1209 Bytecount dnd_len; | |
1210 Widget wid; | |
1211 int num_items; | |
1212 | |
1213 dnd_data = start_drag_internal_1 (event, dragdata, Qdt_dnd_encoding, | |
1214 &x_event, 1, | |
1215 &wid, &dnd_len, &num_items); | |
1216 | |
1217 dnd_convert_cb_rec[0].callback = x_cde_convert_callback; | |
1218 dnd_convert_cb_rec[0].closure = (XtPointer) dnd_data; | |
1219 dnd_convert_cb_rec[1].callback = NULL; | |
1220 dnd_convert_cb_rec[1].closure = NULL; | |
1221 | |
1222 dnd_destroy_cb_rec[0].callback = x_cde_destroy_callback; | |
1223 dnd_destroy_cb_rec[0].closure = (XtPointer) dnd_data; | |
1224 dnd_destroy_cb_rec[1].callback = NULL; | |
1225 dnd_destroy_cb_rec[1].closure = NULL; | |
1226 | |
1227 CurrentDragWidget = | |
1228 DtDndDragStart (wid, &x_event, | |
1229 (NILP (dragtype) ? DtDND_BUFFER_TRANSFER : | |
1230 DtDND_FILENAME_TRANSFER), | |
1231 num_items, | |
1232 XmDROP_COPY, | |
1233 dnd_convert_cb_rec, | |
1234 dnd_destroy_cb_rec, | |
1235 NULL, 0); | |
1236 | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1237 xfree (dnd_data); |
2367 | 1238 |
1239 return num_items ? Qt : Qnil; | |
428 | 1240 } |
1241 | |
1242 static void | |
1243 x_cde_transfer_callback (Widget widget, XtPointer clientData, | |
1244 XtPointer callData) | |
1245 { | |
2367 | 1246 int ii, enqueue = 1; |
428 | 1247 Lisp_Object frame = Qnil; |
1248 Lisp_Object l_type = Qnil; | |
1249 Lisp_Object l_data = Qnil; | |
1250 DtDndTransferCallbackStruct *transferInfo = NULL; | |
1251 struct gcpro gcpro1, gcpro2, gcpro3; | |
1252 | |
1253 /* | |
1254 this needs to be changed to the new protocol: | |
1255 - we need the button, modifier and pointer states to create a | |
1256 correct misc_user_event | |
1257 - the data must be converted to the new format (URL/MIME) | |
1258 */ | |
1259 /* return; */ | |
1260 | |
1261 transferInfo = (DtDndTransferCallbackStruct *) callData; | |
1262 if (transferInfo == NULL) | |
1263 return; | |
1264 | |
1265 GCPRO3 (frame, l_type, l_data); | |
1266 | |
771 | 1267 frame = wrap_frame ((struct frame *) clientData); |
428 | 1268 |
1269 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER) | |
1270 { | |
1271 l_type = Qdragdrop_URL; | |
1272 | |
1273 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) | |
1274 { | |
2367 | 1275 Ibyte *fileint; |
1276 Ibyte *hurl; | |
1277 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1278 fileint = |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1279 EXTERNAL_TO_ITEXT (transferInfo->dropData->data.files[ii], |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1280 Qfile_name); |
2367 | 1281 |
1282 hurl = dnd_url_hexify_string (fileint, "file:"); | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1283 l_data = Fcons (build_istring (hurl), l_data); |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1284 xfree (hurl); |
428 | 1285 } |
1286 } | |
1287 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER) | |
1288 { | |
2367 | 1289 int speccount = specpdl_depth (); |
1290 | |
1291 /* !!#### Problem: all buffers a treated as text/plain!!! | |
1292 Not appropriate for intl text. Note that there is a function | |
1293 DtDtsBufferToDataType(), but I don't know what the possible | |
1294 return values are. | |
1295 Solution (?): Also support DtDND_TEXT_TRANSFER (compound text) | |
428 | 1296 perhaps implementation of the Motif protocol |
1297 (which is the base of CDE) will clear this */ | |
1298 l_type = Qdragdrop_MIME; | |
2367 | 1299 record_unwind_protect (abort_current_drag, Qnil); |
428 | 1300 drag_not_done = 1; |
1301 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) | |
1302 { | |
1303 /* let us forget this name thing for now... */ | |
1304 /* filePath = transferInfo->dropData->data.buffers[ii].name; | |
1305 path = (filePath == NULL) ? Qnil | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1306 : build_extstring (filePath, Q???); */ |
428 | 1307 /* what, if the data is no text, and how can I tell it? */ |
2367 | 1308 l_data = |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
1309 Fcons (list3 (list1 (build_ascstring ("text/plain")), |
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
1310 build_ascstring ("8bit"), |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1311 make_extstring |
2367 | 1312 (transferInfo->dropData->data.buffers[ii].bp, |
1313 transferInfo->dropData->data.buffers[ii].size, | |
1314 /* !!#### what goes here? */ | |
1315 Qdt_dnd_encoding)), | |
1316 l_data); | |
428 | 1317 } |
1318 drag_not_done = 0; | |
771 | 1319 unbind_to (speccount); |
428 | 1320 } |
1321 else /* the other cases: NOOP_TRANSFER */ | |
2367 | 1322 enqueue = 0; |
428 | 1323 |
1324 /* The Problem: no button and mods from CDE... */ | |
1325 if (enqueue) | |
2367 | 1326 enqueue_misc_user_event_pos (frame, Qdragdrop_drop_dispatch, |
1327 Fcons (l_type, l_data), | |
1328 0 /* this is the button */, | |
1329 0 /* these are the mods */, | |
1330 transferInfo->x, | |
1331 transferInfo->y); | |
428 | 1332 |
1333 UNGCPRO; | |
1334 return; | |
1335 } | |
1336 #endif /* HAVE_CDE */ | |
1337 | |
1338 | |
1339 /************************************************************************/ | |
1340 /* widget creation */ | |
1341 /************************************************************************/ | |
1342 | |
1343 /* The widget hierarchy is | |
1344 | |
1345 argv[0] shell container FRAME-NAME | |
1346 ApplicationShell EmacsShell EmacsManager EmacsFrame | |
1347 | |
1348 We accept geometry specs in this order: | |
1349 | |
1350 *FRAME-NAME.geometry | |
1351 *EmacsFrame.geometry | |
1352 Emacs.geometry | |
1353 | |
1354 Other possibilities for widget hierarchies might be | |
1355 | |
1356 argv[0] frame container FRAME-NAME | |
1357 ApplicationShell EmacsShell EmacsManager EmacsFrame | |
1358 or | |
1359 argv[0] FRAME-NAME container FRAME-NAME | |
1360 ApplicationShell EmacsShell EmacsManager EmacsFrame | |
1361 or | |
1362 argv[0] FRAME-NAME container emacsTextPane | |
1363 ApplicationShell EmacsShell EmacsManager EmacsFrame | |
1364 | |
1365 #ifdef EXTERNAL_WIDGET | |
1366 The ExternalShell widget is simply a replacement for the Shell widget | |
1367 which is able to deal with using an externally-supplied window instead | |
1368 of always creating its own. | |
1369 #endif | |
1370 | |
1371 */ | |
1372 | |
1373 #ifdef EXTERNAL_WIDGET | |
1374 | |
1375 static int | |
1376 is_valid_window (Window w, struct device *d) | |
1377 { | |
1378 XWindowAttributes xwa; | |
1379 Display *dpy = DEVICE_X_DISPLAY (d); | |
1380 | |
1381 expect_x_error (dpy); | |
1382 XGetWindowAttributes (dpy, w, &xwa); | |
1383 return !x_error_occurred_p (dpy); | |
1384 } | |
1385 | |
1386 #endif /* EXTERNAL_WIDGET */ | |
1387 | |
1388 /* This sends a synthetic mouse-motion event to the frame, if the mouse | |
1389 is over the frame. This ensures that the cursor gets set properly | |
1390 before the user moves the mouse for the first time. */ | |
1391 | |
1392 static void | |
2286 | 1393 x_send_synthetic_mouse_event (struct frame *UNUSED (f)) |
428 | 1394 { |
1395 /* #### write this function. */ | |
1396 } | |
1397 | |
1398 static int | |
1399 first_x_frame_p (struct frame *f) | |
1400 { | |
1401 Lisp_Object rest = DEVICE_FRAME_LIST (XDEVICE (f->device)); | |
1402 while (!NILP (rest) && | |
1403 (f == XFRAME (XCAR (rest)) || | |
1404 !FRAME_X_P (XFRAME (XCAR (rest))))) | |
1405 rest = XCDR (rest); | |
1406 return NILP (rest); | |
1407 } | |
1408 | |
1409 /* Figure out what size the EmacsFrame widget should initially be, | |
1410 and set it. Should be called after the default font has been | |
1411 determined but before the widget has been realized. */ | |
1412 | |
1413 static void | |
1414 x_initialize_frame_size (struct frame *f) | |
1415 { | |
1416 /* Geometry of the AppShell */ | |
1417 int app_flags = 0; | |
1418 int app_x = 0; | |
1419 int app_y = 0; | |
1420 unsigned int app_w = 0; | |
1421 unsigned int app_h = 0; | |
1422 | |
1423 /* Geometry of the EmacsFrame */ | |
1424 int frame_flags = 0; | |
1425 int frame_x = 0; | |
1426 int frame_y = 0; | |
1427 unsigned int frame_w = 0; | |
1428 unsigned int frame_h = 0; | |
1429 | |
1430 /* Hairily merged geometry */ | |
1431 int x = 0; | |
1432 int y = 0; | |
1433 unsigned int w = 80; | |
1434 unsigned int h = 40; | |
1435 int flags = 0; | |
1436 | |
2367 | 1437 Ascbyte *geom = 0, *ew_geom = 0; |
428 | 1438 Boolean iconic_p = False, ew_iconic_p = False; |
1439 | |
1440 Widget wmshell = FRAME_X_SHELL_WIDGET (f); | |
1441 /* #### This may not be an ApplicationShell any more, with the 'popup | |
1442 frame property. */ | |
1443 Widget app_shell = XtParent (wmshell); | |
1444 Widget ew = FRAME_X_TEXT_WIDGET (f); | |
1445 | |
2747 | 1446 /* set the position of the frame's root window now. When the |
1447 frame was created, the position was initialized to (0,0). */ | |
428 | 1448 { |
1449 struct window *win = XWINDOW (f->root_window); | |
1450 | |
5090 | 1451 WINDOW_LEFT (win) = FRAME_PANED_LEFT_EDGE (f); |
1452 WINDOW_TOP (win) = FRAME_PANED_TOP_EDGE (f); | |
428 | 1453 |
1454 if (!NILP (f->minibuffer_window)) | |
1455 { | |
1456 win = XWINDOW (f->minibuffer_window); | |
5090 | 1457 WINDOW_LEFT (win) = FRAME_PANED_LEFT_EDGE (f); |
428 | 1458 } |
1459 } | |
1460 | |
1461 #ifdef EXTERNAL_WIDGET | |
1462 /* If we're an external widget, then the size of the frame is predetermined | |
1463 (by the client) and is not our decision to make. */ | |
1464 if (FRAME_X_EXTERNAL_WINDOW_P (f)) | |
1465 return; | |
1466 #endif | |
1467 | |
1468 #if 0 | |
1469 /* #### this junk has not been tested; therefore it's | |
1470 probably wrong. Doesn't really matter at this point because | |
1471 currently all frames are either top-level or external widgets. */ | |
1472 | |
1473 /* If we're not our own top-level window, then we shouldn't go messing around | |
1474 with top-level shells or "Emacs.geometry" or any such stuff. Therefore, | |
1475 we do as follows to determine the size of the frame: | |
1476 | |
1477 1) If a value for the frame's "geometry" resource was specified, then | |
1478 use it. (This specifies a size in characters.) | |
1479 2) Else, if the "width" and "height" resources were specified, then | |
1480 leave them alone. (This is a value in pixels. Sorry, we can't break | |
1481 Xt conventions here.) | |
1482 3) Else, assume a size of 64x12. (This is somewhat arbitrary, but | |
1483 it's unlikely that a size of 80x40 is desirable because we're probably | |
1484 inside of a dialog box.) | |
1485 | |
1486 Set the widget's x, y, height, and width as determined. Don't set the | |
1487 top-level container widget, because we don't necessarily know what it | |
1488 is. (Assume it is smart and pays attention to our values.) | |
1489 */ | |
1490 | |
1491 if (!FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
1492 { | |
1493 Xt_GET_VALUE (ew, XtNgeometry, &ew_geom); | |
1494 if (ew_geom) | |
1495 frame_flags = XParseGeometry (ew_geom, | |
1496 &frame_x, &frame_y, | |
1497 &frame_w, &frame_h); | |
1498 if (! (frame_flags & (WidthValue | HeightValue))) | |
1499 { | |
1500 Arg al[2]; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1501 Xt_SET_ARG (al [0], XtNwidth, &frame_w); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1502 Xt_SET_ARG (al [1], XtNheight, &frame_h); |
428 | 1503 XtGetValues (ew, al, 2); |
1504 if (!frame_w && !frame_h) | |
1505 { | |
1506 frame_w = 64; | |
1507 frame_h = 12; | |
1508 frame_flags |= WidthValue | HeightValue; | |
1509 } | |
1510 } | |
1511 if (frame_flags & (WidthValue | HeightValue)) | |
1512 EmacsFrameSetCharSize (ew, frame_w, frame_h); | |
1513 if (frame_flags & (XValue | YValue)) | |
1514 { | |
1515 Arg al[2]; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1516 Xt_SET_ARG (al [0], XtNwidth, &frame_w); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1517 Xt_SET_ARG (al [1], XtNheight, &frame_h); |
428 | 1518 XtGetValues (ew, al, 2); |
1519 | |
1520 if (frame_flags & XNegative) | |
1521 frame_x += frame_w; | |
1522 if (frame_flags & YNegative) | |
1523 frame_y += frame_h; | |
1524 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1525 Xt_SET_ARG (al [0], XtNx, frame_x); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1526 Xt_SET_ARG (al [1], XtNy, frame_y); |
428 | 1527 XtSetValues (ew, al, 2); |
1528 } | |
1529 return; | |
1530 } | |
1531 #endif | |
1532 | |
1533 /* OK, we're a top-level shell. */ | |
1534 | |
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
1535 assert (XtIsWMShell (wmshell)); |
428 | 1536 |
1537 /* If the EmacsFrame doesn't have a geometry but the shell does, | |
1538 treat that as the geometry of the frame. | |
1539 (Is this bogus? I'm not sure.) */ | |
1540 | |
1541 Xt_GET_VALUE (ew, XtNgeometry, &ew_geom); | |
1542 if (!ew_geom) | |
1543 { | |
1544 Xt_GET_VALUE (wmshell, XtNgeometry, &geom); | |
1545 if (geom) | |
1546 { | |
1547 ew_geom = geom; | |
1548 Xt_SET_VALUE (ew, XtNgeometry, ew_geom); | |
1549 } | |
1550 } | |
1551 | |
1552 /* If the Shell is iconic, then the EmacsFrame is iconic. | |
1553 (Is this bogus? I'm not sure.) */ | |
1554 Xt_GET_VALUE (ew, XtNiconic, &ew_iconic_p); | |
1555 if (!ew_iconic_p) | |
1556 { | |
1557 Xt_GET_VALUE (wmshell, XtNiconic, &iconic_p); | |
1558 if (iconic_p) | |
1559 { | |
1560 ew_iconic_p = iconic_p; | |
1561 Xt_SET_VALUE (ew, XtNiconic, iconic_p); | |
1562 } | |
1563 } | |
1564 | |
1565 Xt_GET_VALUE (app_shell, XtNgeometry, &geom); | |
1566 if (geom) | |
1567 app_flags = XParseGeometry (geom, &app_x, &app_y, &app_w, &app_h); | |
1568 | |
1569 if (ew_geom) | |
1570 frame_flags = XParseGeometry (ew_geom, | |
1571 &frame_x, &frame_y, | |
1572 &frame_w, &frame_h); | |
1573 | |
1574 if (first_x_frame_p (f)) | |
1575 { | |
1576 /* If this is the first frame created: | |
1577 ==================================== | |
1578 | |
1579 - Use the ApplicationShell's size/position, if specified. | |
1580 (This is "Emacs.geometry", or the "-geometry" command line arg.) | |
1581 - Else use the EmacsFrame's size/position. | |
1582 (This is "*FRAME-NAME.geometry") | |
1583 | |
1584 - If the AppShell is iconic, the frame should be iconic. | |
1585 | |
1586 AppShell comes first so that -geometry always applies to the first | |
1587 frame created, even if there is an "every frame" entry in the | |
1588 resource database. | |
1589 */ | |
1590 if (app_flags & (XValue | YValue)) | |
1591 { | |
1592 x = app_x; y = app_y; | |
1593 flags |= (app_flags & (XValue | YValue | XNegative | YNegative)); | |
1594 } | |
1595 else if (frame_flags & (XValue | YValue)) | |
1596 { | |
1597 x = frame_x; y = frame_y; | |
1598 flags |= (frame_flags & (XValue | YValue | XNegative | YNegative)); | |
1599 } | |
1600 | |
1601 if (app_flags & (WidthValue | HeightValue)) | |
1602 { | |
1603 w = app_w; h = app_h; | |
1604 flags |= (app_flags & (WidthValue | HeightValue)); | |
1605 } | |
1606 else if (frame_flags & (WidthValue | HeightValue)) | |
1607 { | |
1608 w = frame_w; h = frame_h; | |
1609 flags |= (frame_flags & (WidthValue | HeightValue)); | |
1610 } | |
1611 | |
1612 /* If the AppShell is iconic, then the EmacsFrame is iconic. */ | |
1613 if (!ew_iconic_p) | |
1614 { | |
1615 Xt_GET_VALUE (app_shell, XtNiconic, &iconic_p); | |
1616 if (iconic_p) | |
1617 { | |
1618 ew_iconic_p = iconic_p; | |
1619 Xt_SET_VALUE (ew, XtNiconic, iconic_p); | |
1620 } | |
1621 } | |
1622 } | |
1623 else | |
1624 { | |
1625 /* If this is not the first frame created: | |
1626 ======================================== | |
1627 | |
1628 - use the EmacsFrame's size/position if specified | |
1629 - Otherwise, use the ApplicationShell's size, but not position. | |
1630 | |
1631 So that means that one can specify the position of the first frame | |
1632 with "Emacs.geometry" or `-geometry'; but can only specify the | |
1633 position of subsequent frames with "*FRAME-NAME.geometry". | |
1634 | |
1635 AppShell comes second so that -geometry does not apply to subsequent | |
1636 frames when there is an "every frame" entry in the resource db, | |
1637 but does apply to the first frame. | |
1638 */ | |
1639 if (frame_flags & (XValue | YValue)) | |
1640 { | |
1641 x = frame_x; y = frame_y; | |
1642 flags |= (frame_flags & (XValue | YValue | XNegative | YNegative)); | |
1643 } | |
1644 | |
1645 if (frame_flags & (WidthValue | HeightValue)) | |
1646 { | |
1647 w = frame_w; h = frame_h; | |
1648 flags |= (frame_flags & (WidthValue | HeightValue)); | |
1649 } | |
1650 else if (app_flags & (WidthValue | HeightValue)) | |
1651 { | |
1652 w = app_w; | |
1653 h = app_h; | |
1654 flags |= (app_flags & (WidthValue | HeightValue)); | |
1655 } | |
1656 } | |
1657 | |
1658 x_set_initial_frame_size (f, flags, x, y, w, h); | |
1659 } | |
1660 | |
1661 static void | |
1662 x_get_layout_sizes (struct frame *f, Dimension *topbreadth) | |
1663 { | |
1664 int i; | |
1665 | |
1666 /* compute height of all top-area widgets */ | |
1667 for (i=0, *topbreadth = 0; i<FRAME_X_NUM_TOP_WIDGETS (f); i++) | |
1668 { | |
1669 Widget wid = FRAME_X_TOP_WIDGETS (f)[i]; | |
1670 if (wid && XtIsManaged (wid)) | |
1671 *topbreadth += wid->core.height + 2*wid->core.border_width; | |
1672 } | |
1673 } | |
1674 | |
1675 static void | |
2286 | 1676 x_layout_widgets (Widget UNUSED (w), XtPointer client_data, |
1677 XtPointer call_data) | |
428 | 1678 { |
1679 struct frame *f = (struct frame *) client_data; | |
1680 EmacsManagerResizeStruct *emst = (EmacsManagerResizeStruct *) call_data; | |
1681 Dimension width = emst->width; | |
1682 Dimension height = emst->height; | |
1683 Widget text = FRAME_X_TEXT_WIDGET (f); | |
1684 Dimension textbord = text->core.border_width; | |
1685 Dimension topbreadth; | |
1686 Position text_x = 0, text_y = 0; | |
1687 int i; | |
1688 | |
1689 x_get_layout_sizes (f, &topbreadth); | |
1690 | |
1691 /* first the menubar and psheets ... */ | |
1692 for (i=0; i<FRAME_X_NUM_TOP_WIDGETS (f); i++) | |
1693 { | |
1694 Widget wid = FRAME_X_TOP_WIDGETS (f)[i]; | |
1695 if (wid && XtIsManaged (wid)) | |
1696 { | |
1697 Dimension bord = wid->core.border_width; | |
1698 XtConfigureWidget (wid, 0, text_y, | |
1699 width - 2*bord, wid->core.height, | |
1700 bord); | |
1701 text_y += wid->core.height + 2*bord; | |
1702 } | |
1703 } | |
1704 | |
1705 #ifdef HAVE_SCROLLBARS | |
1706 f->scrollbar_y_offset = topbreadth + textbord; | |
1707 #endif | |
1708 | |
1709 /* finally the text area */ | |
1710 XtConfigureWidget (text, text_x, text_y, | |
1711 width - 2*textbord, | |
1712 height - text_y - 2*textbord, | |
1713 textbord); | |
1714 } | |
1715 | |
1716 static void | |
2286 | 1717 x_do_query_geometry (Widget UNUSED (w), XtPointer client_data, |
1718 XtPointer call_data) | |
428 | 1719 { |
1720 struct frame *f = (struct frame *) client_data; | |
1721 EmacsManagerQueryGeometryStruct *emst = | |
1722 (EmacsManagerQueryGeometryStruct *) call_data; | |
1723 Widget text = FRAME_X_TEXT_WIDGET (f); | |
1724 Dimension textbord = text->core.border_width; | |
1725 Dimension topbreadth; | |
1726 XtWidgetGeometry req, repl; | |
1727 int mask = emst->request_mode & (CWWidth | CWHeight); | |
1728 | |
1729 x_get_layout_sizes (f, &topbreadth); | |
1730 | |
1731 /* Strip away menubar from suggested size, and ask the text widget | |
1732 what size it wants to be. */ | |
1733 req.request_mode = mask; | |
1734 if (mask & CWWidth) | |
1735 req.width = emst->proposed_width - 2*textbord; | |
1736 if (mask & CWHeight) | |
1737 req.height = emst->proposed_height - topbreadth - 2*textbord; | |
1738 XtQueryGeometry (text, &req, &repl); | |
1739 | |
1740 /* Now add the menubar back again */ | |
1741 emst->proposed_width = repl.width + 2*textbord; | |
1742 emst->proposed_height = repl.height + topbreadth + 2*textbord; | |
1743 } | |
1744 | |
1745 /* Creates the widgets for a frame. | |
1746 lisp_window_id is a Lisp description of an X window or Xt | |
1747 widget to parse. | |
2747 | 1748 parent is a frame to use as the parent. |
1749 overridep if non-nil says to set the override-redirect setting. | |
428 | 1750 |
1751 This function does not create or map the windows. (That is | |
1752 done by x_popup_frame().) | |
1753 */ | |
1754 static void | |
1755 x_create_widgets (struct frame *f, Lisp_Object lisp_window_id, | |
2747 | 1756 Lisp_Object parent, Lisp_Object overridep) |
428 | 1757 { |
1758 struct device *d = XDEVICE (f->device); | |
1759 Visual *visual = DEVICE_X_VISUAL (d); | |
1760 int depth = DEVICE_X_DEPTH (d); | |
1761 Colormap cmap = DEVICE_X_COLORMAP (d); | |
1762 #ifdef EXTERNAL_WIDGET | |
1763 Window window_id = 0; | |
1764 #endif | |
2367 | 1765 const Extbyte *name; |
1766 Arg al[25]; | |
428 | 1767 int ac = 0; |
1768 Widget text, container, shell; | |
1769 Widget parentwid = 0; | |
1770 #ifdef HAVE_MENUBARS | |
1771 int menubar_visible; | |
1772 Widget menubar; | |
1773 #endif | |
1774 | |
1775 if (STRINGP (f->name)) | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1776 name = LISP_STRING_TO_EXTERNAL (f->name, Qctext); |
428 | 1777 else |
1778 name = "emacs"; | |
1779 | |
1780 /* The widget hierarchy is | |
1781 | |
1782 argv[0] shell pane FRAME-NAME | |
1783 ApplicationShell EmacsShell EmacsManager EmacsFrame | |
1784 | |
1785 (the type of the shell is ExternalShell if this frame is running | |
1786 in another client's window) | |
1787 | |
1788 However the EmacsShell widget has WM_CLASS of FRAME-NAME/Emacs. | |
1789 Normally such shells have name/class shellname/appclass, which in this | |
1790 case would be "shell/Emacs" instead of "frame-name/Emacs". We could | |
1791 also get around this by naming the shell "frame-name", but that would | |
1792 be confusing because the text area (the EmacsFrame widget inferior of | |
1793 the shell) is also called that. So we just set the WM_CLASS property. | |
1794 */ | |
1795 | |
1796 #ifndef EXTERNAL_WIDGET | |
1797 if (!NILP (lisp_window_id)) | |
2367 | 1798 signal_error |
1799 (Qunimplemented, | |
1800 "support for external widgets was not enabled at compile-time", | |
1801 Qunbound); | |
428 | 1802 #else |
1803 if (!NILP (lisp_window_id)) | |
1804 { | |
2367 | 1805 Ibyte *string; |
428 | 1806 |
1807 CHECK_STRING (lisp_window_id); | |
2367 | 1808 string = XSTRING_DATA (lisp_window_id); |
428 | 1809 if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) |
2367 | 1810 qxesscanf_ascii_1 (string + 2, "%lxu", &window_id); |
428 | 1811 #if 0 |
1812 else if (string[0] == 'w') | |
1813 { | |
2367 | 1814 qxesscanf_ascii (string + 1, "%x", &parent_widget); |
428 | 1815 if (parent_widget) |
1816 window_id = XtWindow (parent_widget); | |
1817 } | |
1818 #endif | |
1819 else | |
2367 | 1820 qxesscanf_ascii_1 (string, "%lu", &window_id); |
428 | 1821 if (!is_valid_window (window_id, d)) |
563 | 1822 signal_ferror (Qinvalid_argument, "Invalid window %lu", |
1823 (unsigned long) window_id); | |
428 | 1824 FRAME_X_EXTERNAL_WINDOW_P (f) = 1; |
1825 } else | |
1826 #endif /* EXTERNAL_WIDGET */ | |
1827 FRAME_X_TOP_LEVEL_FRAME_P (f) = 1; | |
1828 | |
1829 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1830 Xt_SET_ARG (al[ac], XtNallowShellResize, True); ac++; |
428 | 1831 #ifdef LWLIB_USES_MOTIF |
1832 /* Motif sucks beans. Without this in here, it will delete the window | |
1833 out from under us when it receives a WM_DESTROY_WINDOW message | |
1834 from the WM. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1835 Xt_SET_ARG (al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++; |
428 | 1836 #endif |
1837 | |
1838 #ifdef EXTERNAL_WIDGET | |
1839 if (window_id) | |
1840 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1841 Xt_SET_ARG (al[ac], XtNwindow, window_id); ac++; |
428 | 1842 } |
1843 else | |
1844 #endif /* EXTERNAL_WIDGET */ | |
1845 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1846 Xt_SET_ARG (al[ac], XtNinput, True); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1847 Xt_SET_ARG (al[ac], XtNminWidthCells, 10); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1848 Xt_SET_ARG (al[ac], XtNminHeightCells, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1849 Xt_SET_ARG (al[ac], XtNvisual, visual); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1850 Xt_SET_ARG (al[ac], XtNdepth, depth); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1851 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++; |
428 | 1852 } |
1853 | |
2747 | 1854 if (!NILP (overridep)) |
1855 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1856 Xt_SET_ARG (al[ac], XtNoverrideRedirect, True); ac++; |
2747 | 1857 } |
1858 | |
1859 /* #### maybe we should check for FRAMEP instead? */ | |
428 | 1860 if (!NILP (parent)) |
1861 { | |
1862 parentwid = FRAME_X_SHELL_WIDGET (XFRAME (parent)); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1863 Xt_SET_ARG (al[ac], XtNtransientFor, parentwid); ac++; |
428 | 1864 } |
1865 | |
1866 shell = XtCreatePopupShell ("shell", | |
1867 ( | |
1868 #ifdef EXTERNAL_WIDGET | |
1869 window_id ? externalShellWidgetClass : | |
1870 #endif | |
1871 parentwid ? transientEmacsShellWidgetClass : | |
1872 topLevelEmacsShellWidgetClass | |
1873 ), | |
1874 parentwid ? parentwid : | |
1875 DEVICE_XT_APP_SHELL (d), | |
1876 al, ac); | |
1877 FRAME_X_SHELL_WIDGET (f) = shell; | |
1878 maybe_set_frame_title_format (shell); | |
1879 | |
1880 /* Create the manager widget */ | |
1881 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1882 Xt_SET_ARG (al[ac], XtNvisual, visual); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1883 Xt_SET_ARG (al[ac], XtNdepth, depth); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1884 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++; |
428 | 1885 |
1886 container = XtCreateWidget ("container", | |
1887 emacsManagerWidgetClass, shell, al, ac); | |
1888 FRAME_X_CONTAINER_WIDGET (f) = container; | |
1889 XtAddCallback (container, XtNresizeCallback, x_layout_widgets, | |
1890 (XtPointer) f); | |
1891 XtAddCallback (container, XtNqueryGeometryCallback, x_do_query_geometry, | |
1892 (XtPointer) f); | |
1893 | |
1894 /* Create the text area */ | |
1895 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1896 Xt_SET_ARG (al[ac], XtNvisual, visual); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1897 Xt_SET_ARG (al[ac], XtNdepth, depth); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1898 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1899 Xt_SET_ARG (al[ac], XtNborderWidth, 0); ac++; /* should this be settable? */ |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1900 Xt_SET_ARG (al[ac], XtNemacsFrame, f); ac++; |
428 | 1901 text = XtCreateWidget (name, emacsFrameClass, container, al, ac); |
1902 FRAME_X_TEXT_WIDGET (f) = text; | |
1903 | |
1904 #ifdef HAVE_MENUBARS | |
1905 /* Create the initial menubar widget. */ | |
1906 menubar_visible = x_initialize_frame_menubar (f); | |
1907 FRAME_X_TOP_WIDGETS (f)[0] = menubar = FRAME_X_MENUBAR_WIDGET (f); | |
1908 FRAME_X_NUM_TOP_WIDGETS (f) = 1; | |
1909 | |
1910 if (menubar_visible) | |
1911 XtManageChild (menubar); | |
1912 #endif /* HAVE_MENUBARS */ | |
1913 XtManageChild (text); | |
1914 XtManageChild (container); | |
1915 } | |
1916 | |
1917 /* We used to call XtPopup() in x_popup_frame, but that doesn't give | |
1918 you control over whether the widget is initially mapped or not | |
1919 because XtPopup() makes an unconditional call to XMapRaised(). | |
1920 Boy, those Xt designers were clever. | |
1921 | |
1922 When we first removed it we only kept the XtRealizeWidget call in | |
1923 XtPopup. For everything except HP's that was enough. For HP's, | |
1924 though, the failure to call the popup callbacks resulted in XEmacs | |
1925 not accepting any input. Bizarre but true. Stupid but true. | |
1926 | |
1927 So, in case there are any other gotchas floating out there along | |
1928 the same lines I've duplicated the majority of XtPopup here. It | |
1929 assumes no grabs and that the widget is not already popped up, both | |
1930 valid assumptions for the one place this is called from. */ | |
1931 static void | |
1932 xemacs_XtPopup (Widget widget) | |
1933 { | |
1934 ShellWidget shell_widget = (ShellWidget) widget; | |
1935 XtGrabKind call_data = XtGrabNone; | |
1936 | |
2367 | 1937 XtCallCallbacks (widget, XtNpopupCallback, (XtPointer) &call_data); |
428 | 1938 |
1939 shell_widget->shell.popped_up = TRUE; | |
1940 shell_widget->shell.grab_kind = XtGrabNone; | |
1941 shell_widget->shell.spring_loaded = False; | |
1942 | |
1943 if (shell_widget->shell.create_popup_child_proc != NULL) | |
2367 | 1944 (*(shell_widget->shell.create_popup_child_proc)) (widget); |
428 | 1945 |
1946 /* The XtSetValues below are not in XtPopup menu. We just want to | |
1947 make absolutely sure... */ | |
1948 Xt_SET_VALUE (widget, XtNmappedWhenManaged, False); | |
1949 XtRealizeWidget (widget); | |
1950 Xt_SET_VALUE (widget, XtNmappedWhenManaged, True); | |
1951 } | |
1952 | |
1953 /* create the windows for the specified frame and display them. | |
1954 Note that the widgets have already been created, and any | |
1955 necessary geometry calculations have already been done. */ | |
1956 static void | |
1957 x_popup_frame (struct frame *f) | |
1958 { | |
1959 Widget shell_widget = FRAME_X_SHELL_WIDGET (f); | |
1960 Widget frame_widget = FRAME_X_TEXT_WIDGET (f); | |
1961 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
1962 | |
1963 /* Before mapping the window, make sure that the WMShell's notion of | |
1964 whether it should be iconified is synchronized with the EmacsFrame's | |
1965 notion. | |
1966 */ | |
1967 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
1968 x_wm_set_shell_iconic_p (shell_widget, | |
1969 ((EmacsFrame) frame_widget) | |
1970 ->emacs_frame.iconic); | |
1971 | |
1972 xemacs_XtPopup (shell_widget); | |
1973 | |
1974 if (!((EmacsFrame) frame_widget)->emacs_frame.initially_unmapped) | |
1975 XtMapWidget (shell_widget); | |
1976 else | |
1977 { | |
1978 /* We may have set f->visible to 1 in x_init_frame(), so undo | |
1979 that now. */ | |
1980 FRAME_X_TOTALLY_VISIBLE_P (f) = 0; | |
1981 f->visible = 0; | |
1982 } | |
1983 | |
1984 #ifdef EXTERNAL_WIDGET | |
1985 if (FRAME_X_EXTERNAL_WINDOW_P (f)) | |
1986 ExternalShellReady (shell_widget, XtWindow (frame_widget), KeyPressMask); | |
1987 else | |
1988 #endif | |
1989 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
1990 { | |
1991 /* tell the window manager about us. */ | |
1992 x_wm_store_class_hints (shell_widget, XtName (frame_widget)); | |
1993 | |
1994 #ifndef HAVE_WMCOMMAND | |
1995 x_wm_maybe_store_wm_command (f); | |
1996 #endif /* HAVE_WMCOMMAND */ | |
1997 | |
1998 x_wm_hack_wm_protocols (shell_widget); | |
1999 } | |
2000 | |
2001 #ifdef HAVE_XIM | |
2002 XIM_init_frame (f); | |
2003 #endif /* HAVE_XIM */ | |
2004 | |
2005 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */ | |
2006 /* Intrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */ | |
2007 /* pp. 483-493. */ | |
2008 XtAddEventHandler (shell_widget, /* the shell widget in question */ | |
2009 (EventMask) NoEventMask,/* OR with existing mask */ | |
2010 True, /* called on non-maskable events? */ | |
2011 (XtEventHandler) _XEditResCheckMessages, /* the handler */ | |
2012 NULL); | |
2013 | |
2014 #ifdef HAVE_CDE | |
2015 { | |
2016 XtCallbackRec dnd_transfer_cb_rec[2]; | |
2017 | |
2018 dnd_transfer_cb_rec[0].callback = x_cde_transfer_callback; | |
2019 dnd_transfer_cb_rec[0].closure = (XtPointer) f; | |
2020 dnd_transfer_cb_rec[1].callback = NULL; | |
2021 dnd_transfer_cb_rec[1].closure = NULL; | |
2022 | |
2023 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f), | |
2024 DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER, | |
2025 XmDROP_COPY, dnd_transfer_cb_rec, | |
2026 DtNtextIsBuffer, True, | |
2027 DtNregisterChildren, True, | |
2028 DtNpreserveRegistration, False, | |
2029 NULL); | |
2030 } | |
2031 #endif /* HAVE_CDE */ | |
2032 | |
2033 /* Do a stupid property change to force the server to generate a | |
2034 propertyNotify event so that the event_stream server timestamp will | |
2035 be initialized to something relevant to the time we created the window. | |
2036 */ | |
2037 XChangeProperty (XtDisplay (frame_widget), XtWindow (frame_widget), | |
2038 DEVICE_XATOM_WM_PROTOCOLS (d), XA_ATOM, 32, PropModeAppend, | |
2367 | 2039 (Rawbyte *) NULL, 0); |
428 | 2040 |
2041 x_send_synthetic_mouse_event (f); | |
2042 } | |
2043 | |
2044 static void | |
2045 allocate_x_frame_struct (struct frame *f) | |
2046 { | |
2047 /* zero out all slots. */ | |
3092 | 2048 #ifdef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
2049 f->frame_data = XX_FRAME (ALLOC_NORMAL_LISP_OBJECT (x_frame)); |
3092 | 2050 #else /* not NEW_GC */ |
428 | 2051 f->frame_data = xnew_and_zero (struct x_frame); |
3092 | 2052 #endif /* not NEW_GC */ |
428 | 2053 |
2054 /* yeah, except the lisp ones */ | |
1346 | 2055 FRAME_X_LAST_MENUBAR_BUFFER (f) = Qnil; |
428 | 2056 FRAME_X_ICON_PIXMAP (f) = Qnil; |
2057 FRAME_X_ICON_PIXMAP_MASK (f) = Qnil; | |
2058 } | |
2059 | |
2060 | |
2061 /************************************************************************/ | |
2062 /* Lisp functions */ | |
2063 /************************************************************************/ | |
2064 | |
2065 static void | |
771 | 2066 x_init_frame_1 (struct frame *f, Lisp_Object props, |
2286 | 2067 int UNUSED (frame_name_is_defaulted)) |
428 | 2068 { |
2069 /* This function can GC */ | |
2070 Lisp_Object device = FRAME_DEVICE (f); | |
2071 Lisp_Object lisp_window_id = Fplist_get (props, Qwindow_id, Qnil); | |
2072 Lisp_Object popup = Fplist_get (props, Qpopup, Qnil); | |
2747 | 2073 Lisp_Object overridep = Fplist_get (props, Qoverride_redirect, Qnil); |
428 | 2074 |
2075 if (!NILP (popup)) | |
2076 { | |
2077 if (EQ (popup, Qt)) | |
2078 popup = Fselected_frame (device); | |
2079 CHECK_LIVE_FRAME (popup); | |
2080 if (!EQ (device, FRAME_DEVICE (XFRAME (popup)))) | |
563 | 2081 invalid_argument_2 ("Parent must be on same device as frame", |
2082 device, popup); | |
428 | 2083 } |
2084 | |
2085 /* | |
2086 * Previously we set this only if NILP (DEVICE_SELECTED_FRAME (d)) | |
2087 * to make sure that messages were displayed as soon as possible | |
2088 * if we're creating the first frame on a device. But it is | |
2089 * better to just set this all the time, so that when a new frame | |
2090 * is created that covers the selected frame, echo area status | |
2091 * messages can still be seen. f->visible is reset later if the | |
2092 * initially-unmapped property is found to be non-nil in the | |
2093 * frame properties. | |
2094 */ | |
2095 f->visible = 1; | |
2096 | |
2097 allocate_x_frame_struct (f); | |
2747 | 2098 x_create_widgets (f, lisp_window_id, popup, overridep); |
428 | 2099 } |
2100 | |
2101 static void | |
2286 | 2102 x_init_frame_2 (struct frame *f, Lisp_Object UNUSED (props)) |
428 | 2103 { |
2104 /* Set up the values of the widget/frame. A case could be made for putting | |
2105 this inside of the widget's initialize method. */ | |
2106 | |
2107 update_frame_face_values (f); | |
2108 x_initialize_frame_size (f); | |
2109 /* Kyle: | |
2110 * update_frame_title() can't be done here, because some of the | |
2111 * modeline specs depend on the frame's device having a selected | |
2112 * frame, and that may not have been set up yet. The redisplay | |
2113 * will update the frame title anyway, so nothing is lost. | |
2114 * JV: | |
2115 * It turns out it gives problems with FVWMs name based mapping. | |
2116 * We'll just need to be careful in the modeline specs. | |
2117 */ | |
2118 update_frame_title (f); | |
4593
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2119 /* Henry S. Thompson: |
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2120 * Must set icon resource before mapping frame, or some WMs may |
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2121 * lose the icon (openbox). See <f5bhc3efb17@hildegard.inf.ed.ac.uk>. |
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2122 * SJT: |
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2123 * This probably means that the frame-icon library won't work with |
4594 | 2124 * that WM. Late breaking news: it *does* work, so possibly the |
2125 * problem at initialization is due to a race condition. | |
4593
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2126 */ |
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2127 update_frame_icon (f); |
428 | 2128 } |
2129 | |
2130 static void | |
2131 x_init_frame_3 (struct frame *f) | |
2132 { | |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2133 /* #### NOTE: This whole business of splitting frame initialization into |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2134 #### different functions is somewhat messy. The latest one seems a good |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2135 #### place to initialize the edit widget's position because we're sure |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2136 #### that the frame is now relalized. -- dvl */ |
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2137 |
428 | 2138 x_popup_frame (f); |
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2139 x_get_frame_text_position (f); |
428 | 2140 } |
2141 | |
2142 static void | |
2143 x_mark_frame (struct frame *f) | |
2144 { | |
1346 | 2145 mark_object (FRAME_X_LAST_MENUBAR_BUFFER (f)); |
428 | 2146 mark_object (FRAME_X_ICON_PIXMAP (f)); |
2147 mark_object (FRAME_X_ICON_PIXMAP_MASK (f)); | |
2148 } | |
2149 | |
2150 static void | |
2151 x_set_frame_icon (struct frame *f) | |
2152 { | |
2153 Pixmap x_pixmap, x_mask; | |
2154 | |
2155 if (IMAGE_INSTANCEP (f->icon) | |
2156 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon))) | |
2157 { | |
2158 x_pixmap = XIMAGE_INSTANCE_X_PIXMAP (f->icon); | |
2159 x_mask = XIMAGE_INSTANCE_X_MASK (f->icon); | |
2160 } | |
2161 else | |
2162 { | |
2163 x_pixmap = 0; | |
2164 x_mask = 0; | |
2165 } | |
2166 | |
2167 /* Store the X data into the widget. */ | |
2168 { | |
2367 | 2169 Arg al[2]; |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2170 Xt_SET_ARG (al[0], XtNiconPixmap, x_pixmap); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2171 Xt_SET_ARG (al[1], XtNiconMask, x_mask); |
428 | 2172 XtSetValues (FRAME_X_SHELL_WIDGET (f), al, 2); |
2173 } | |
2174 } | |
2175 | |
2176 static void | |
2177 x_set_frame_pointer (struct frame *f) | |
2178 { | |
2179 XDefineCursor (XtDisplay (FRAME_X_TEXT_WIDGET (f)), | |
2180 XtWindow (FRAME_X_TEXT_WIDGET (f)), | |
2181 XIMAGE_INSTANCE_X_CURSOR (f->pointer)); | |
2182 XSync (XtDisplay (FRAME_X_TEXT_WIDGET (f)), 0); | |
2183 } | |
2184 | |
2185 static Lisp_Object | |
2186 x_get_frame_parent (struct frame *f) | |
2187 { | |
2188 Widget parentwid = 0; | |
2189 | |
2190 Xt_GET_VALUE (FRAME_X_SHELL_WIDGET (f), XtNtransientFor, &parentwid); | |
2191 /* find the frame whose wid is parentwid */ | |
2192 if (parentwid) | |
2193 { | |
2194 Lisp_Object frmcons; | |
2195 DEVICE_FRAME_LOOP (frmcons, XDEVICE (FRAME_DEVICE (f))) | |
2196 { | |
2197 Lisp_Object frame = XCAR (frmcons); | |
2198 if (FRAME_X_SHELL_WIDGET (XFRAME (frame)) == parentwid) | |
2199 return frame; | |
2200 } | |
2201 } | |
2202 return Qnil; | |
2203 } | |
2204 | |
2205 DEFUN ("x-window-id", Fx_window_id, 0, 1, 0, /* | |
2206 Get the ID of the X11 window. | |
2207 This gives us a chance to manipulate the Emacs window from within a | |
2208 different program. Since the ID is an unsigned long, we return it as | |
2209 a string. | |
2210 */ | |
2211 (frame)) | |
2212 { | |
867 | 2213 Ibyte str[255]; |
428 | 2214 struct frame *f = decode_x_frame (frame); |
2215 | |
771 | 2216 qxesprintf (str, "%lu", XtWindow (FRAME_X_TEXT_WIDGET (f))); |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2217 return build_istring (str); |
428 | 2218 } |
2219 | |
2220 | |
2221 /************************************************************************/ | |
2222 /* manipulating the X window */ | |
2223 /************************************************************************/ | |
2224 | |
2225 static void | |
2226 x_set_frame_position (struct frame *f, int xoff, int yoff) | |
2227 { | |
2228 Widget w = FRAME_X_SHELL_WIDGET (f); | |
2229 Display *dpy = XtDisplay (w); | |
2230 Dimension frame_w = DisplayWidth (dpy, DefaultScreen (dpy)); | |
2231 Dimension frame_h = DisplayHeight (dpy, DefaultScreen (dpy)); | |
2232 Dimension shell_w, shell_h, shell_bord; | |
2233 int win_gravity; | |
2367 | 2234 Arg al[3]; |
2235 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2236 Xt_SET_ARG (al[0], XtNwidth, &shell_w); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2237 Xt_SET_ARG (al[1], XtNheight, &shell_h); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2238 Xt_SET_ARG (al[2], XtNborderWidth, &shell_bord); |
428 | 2239 XtGetValues (w, al, 3); |
2240 | |
2241 win_gravity = | |
2242 xoff >= 0 && yoff >= 0 ? NorthWestGravity : | |
2243 xoff >= 0 ? SouthWestGravity : | |
2244 yoff >= 0 ? NorthEastGravity : | |
2245 SouthEastGravity; | |
2246 if (xoff < 0) | |
2247 xoff += frame_w - shell_w - 2*shell_bord; | |
2248 if (yoff < 0) | |
2249 yoff += frame_h - shell_h - 2*shell_bord; | |
2250 | |
2251 /* Update the hints so that, if this window is currently iconified, it will | |
2252 come back at the right place. We can't look at s->visible to determine | |
2253 whether it is iconified because it might not be up-to-date yet (the queue | |
2254 might not be processed). */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2255 Xt_SET_ARG (al[0], XtNwinGravity, win_gravity); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2256 Xt_SET_ARG (al[1], XtNx, xoff); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2257 Xt_SET_ARG (al[2], XtNy, yoff); |
428 | 2258 XtSetValues (w, al, 3); |
2259 | |
2260 /* Sometimes you will find that | |
2261 | |
2262 (set-frame-position (selected-frame) -50 -50) | |
2263 | |
2264 doesn't put the frame where you expect it to: i.e. it's closer to | |
2265 the lower-right corner than it should be, and it appears that the | |
2266 size of the WM decorations was not taken into account. This is | |
2267 *not* a problem with this function. Both mwm and twm have bugs | |
2268 in handling this situation. (mwm ignores the window gravity and | |
2269 always assumes NorthWest, except the first time you map the | |
2270 window; twm gets things almost right, but forgets to account for | |
2271 the border width of the top-level window.) This function does | |
2272 what it's supposed to according to the ICCCM, and I'm not about | |
2273 to hack around window-manager bugs. */ | |
2274 | |
2275 #if 0 | |
2276 /* This is not necessary under either mwm or twm */ | |
2277 x_wm_mark_shell_position_user_specified (w); | |
2278 #endif | |
2279 } | |
2280 | |
2281 /* Call this to change the size of frame S's x-window. */ | |
2282 | |
2283 static void | |
2284 x_set_frame_size (struct frame *f, int cols, int rows) | |
2285 { | |
2286 EmacsFrameSetCharSize (FRAME_X_TEXT_WIDGET (f), cols, rows); | |
3381 | 2287 |
2288 if (!wedge_metacity) /* cf. EmacsFrameResize */ | |
2289 { | |
2290 /* Kick the manager so that it knows we've changed size. */ | |
2291 XtWidgetGeometry req, repl; | |
2292 req.request_mode = 0; | |
2293 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl); | |
2294 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), | |
2295 repl.width, repl.height); | |
2296 } | |
2297 | |
428 | 2298 #if 0 |
2299 /* this is not correct. x_set_frame_size() is called from | |
2300 Fset_frame_size(), which may or may not have been called | |
2301 by the user (e.g. update_EmacsFrame() calls it when the font | |
2302 changes). For now, don't bother with getting this right. */ | |
2303 x_wm_mark_shell_size_user_specified (FRAME_X_SHELL_WIDGET (f)); | |
2304 #endif | |
2305 } | |
2306 | |
2307 static void | |
2308 x_set_mouse_position (struct window *w, int x, int y) | |
2309 { | |
2310 struct frame *f = XFRAME (w->frame); | |
2311 | |
2312 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
2313 XWarpPointer (display, None, XtWindow (FRAME_X_TEXT_WIDGET (f)), | |
2314 0, 0, 0, 0, w->pixel_left + x, w->pixel_top + y); | |
2315 } | |
2316 | |
2317 static int | |
2318 x_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y) | |
2319 { | |
2320 Display *display = DEVICE_X_DISPLAY (d); | |
2321 Window child_window; | |
2322 Window root_window; | |
2323 Window win; | |
2324 int root_x, root_y; | |
2325 int win_x, win_y; | |
2326 unsigned int keys_and_buttons; | |
2327 struct frame *f; | |
2328 | |
2329 if (XQueryPointer (display, RootWindow (display, DefaultScreen (display)), | |
2330 &root_window, &child_window, &root_x, &root_y, | |
2331 &win_x, &win_y, &keys_and_buttons) == False) | |
2332 return 0; | |
2333 | |
2334 if (child_window == None) | |
2335 return 0; /* not over any window. */ | |
2336 | |
2337 while (1) | |
2338 { | |
2339 win = child_window; | |
2340 if (XTranslateCoordinates (display, root_window, win, root_x, root_y, | |
2341 &win_x, &win_y, &child_window) == False) | |
2342 /* Huh? */ | |
2343 return 0; | |
2344 | |
2345 if (child_window == None) | |
2346 break; | |
2347 } | |
2348 | |
2349 /* At this point, win is the innermost window containing the pointer | |
2350 and win_x and win_y are the coordinates of that window. */ | |
2351 f = x_any_window_to_frame (d, win); | |
2352 if (!f) | |
2353 return 0; | |
793 | 2354 *frame = wrap_frame (f); |
428 | 2355 |
2356 if (XTranslateCoordinates (display, win, | |
2357 XtWindow (FRAME_X_TEXT_WIDGET (f)), | |
2358 win_x, win_y, x, y, &child_window) == False) | |
2359 /* Huh? */ | |
2360 return 0; | |
2361 | |
2362 return 1; | |
2363 } | |
2364 | |
2268 | 2365 static DECLARE_DOESNT_RETURN (x_cant_notify_wm_error (void)); |
2366 | |
2367 static DOESNT_RETURN | |
2368 x_cant_notify_wm_error () | |
428 | 2369 { |
563 | 2370 signal_error (Qgui_error, "Can't notify window manager of iconification", Qunbound); |
428 | 2371 } |
2372 | |
2373 /* Raise frame F. */ | |
2374 static void | |
2375 x_raise_frame_1 (struct frame *f, int force) | |
2376 { | |
2377 if (FRAME_VISIBLE_P (f) || force) | |
2378 { | |
2379 Widget bottom_dialog; | |
2380 XWindowChanges xwc; | |
2381 unsigned int flags; | |
2382 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
2383 Window emacs_window = XtWindow (FRAME_X_SHELL_WIDGET (f)); | |
2384 | |
2385 /* first raises all the dialog boxes, then put emacs just below the | |
2386 * bottom most dialog box */ | |
2387 bottom_dialog = lw_raise_all_pop_up_widgets (); | |
2388 if (bottom_dialog && XtWindow (bottom_dialog)) | |
2389 { | |
2390 xwc.sibling = XtWindow (bottom_dialog); | |
2391 xwc.stack_mode = Below; | |
2392 flags = CWSibling | CWStackMode; | |
2393 } | |
2394 else | |
2395 { | |
2396 xwc.stack_mode = Above; | |
2397 flags = CWStackMode; | |
2398 } | |
2399 | |
2400 if (!XReconfigureWMWindow (display, emacs_window, | |
2401 DefaultScreen (display), | |
2402 flags, &xwc)) | |
2403 x_cant_notify_wm_error (); | |
2404 } | |
2405 } | |
2406 | |
2407 static void | |
2408 x_raise_frame (struct frame *f) | |
2409 { | |
2410 x_raise_frame_1 (f, 1); | |
2411 } | |
2412 | |
2413 /* Lower frame F. */ | |
2414 static void | |
2415 x_lower_frame (struct frame *f) | |
2416 { | |
2417 if (FRAME_VISIBLE_P (f)) | |
2418 { | |
2419 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
2420 XWindowChanges xwc; | |
2421 unsigned int flags = CWStackMode; | |
2422 | |
2423 xwc.stack_mode = Below; | |
2424 if (!XReconfigureWMWindow (display, XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
2425 DefaultScreen (display), flags, &xwc)) | |
2426 x_cant_notify_wm_error (); | |
2427 } | |
2428 } | |
2429 | |
442 | 2430 static void |
2431 x_enable_frame (struct frame *f) | |
2432 { | |
2433 XtSetSensitive (FRAME_X_SHELL_WIDGET (f), True); | |
2434 } | |
2435 | |
2436 static void | |
2437 x_disable_frame (struct frame *f) | |
2438 { | |
2439 XtSetSensitive (FRAME_X_SHELL_WIDGET (f), False); | |
2440 } | |
2441 | |
428 | 2442 /* Change from withdrawn state to mapped state. */ |
2443 static void | |
2444 x_make_frame_visible (struct frame *f) | |
2445 { | |
2446 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
2447 | |
2448 if (!FRAME_VISIBLE_P(f)) | |
2449 XMapRaised (display, XtWindow (FRAME_X_SHELL_WIDGET (f))); | |
2450 else | |
2451 x_raise_frame_1 (f, 0); | |
2452 } | |
2453 | |
2454 /* Change from mapped state to withdrawn state. */ | |
2455 static void | |
2456 x_make_frame_invisible (struct frame *f) | |
2457 { | |
2458 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
2459 | |
2460 if (!FRAME_VISIBLE_P(f)) | |
2461 return; | |
2462 | |
2463 if (!XWithdrawWindow (display, | |
2464 XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
2465 DefaultScreen (display))) | |
2466 x_cant_notify_wm_error (); | |
2467 } | |
2468 | |
2469 static int | |
2470 x_frame_visible_p (struct frame *f) | |
2471 { | |
2472 #if 0 | |
593 | 2473 |
2474 /* #### Ben suggests using x_frame_window_state (f) == NormalState. */ | |
2475 | |
428 | 2476 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); |
2477 XWindowAttributes xwa; | |
2478 int result; | |
2479 | |
2480 /* JV: | |
2481 This is bad, very bad :-( | |
2482 It is not compatible with our tristate visible and | |
2483 it should never ever change the visibility for us, this leads to | |
2484 the frame-freeze problem under fvwm because with the pager | |
2485 | |
2486 Mappedness != Viewability != Visibility != Emacs f->visible | |
2487 | |
2488 This first unequalness is the reason for the frame freezing problem | |
2489 under fvwm (it happens when the frame is another fvwm-page) | |
2490 | |
2491 The second unequalness happen when it is on the same fvwm-page | |
2492 but in an invisible part of the visible screen. | |
2493 | |
2494 For now we just return the XEmacs internal value --- which might not be up | |
2495 to date. Is that a problem? ---. Otherwise we should | |
2496 use async visibility like in standard Emacs. | |
2497 */ | |
2498 | |
2499 if (!XGetWindowAttributes (display, | |
2500 XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
2501 &xwa)) | |
2502 result = 0; | |
2503 else | |
2504 result = xwa.map_state == IsViewable; | |
2505 /* In this implementation it should at least be != IsUnmapped | |
2506 JV */ | |
2507 | |
2508 f->visible = result; | |
2509 return result; | |
2510 #endif /* 0 */ | |
2511 | |
2512 return f->visible; | |
2513 } | |
2514 | |
2515 static int | |
2516 x_frame_totally_visible_p (struct frame *f) | |
2517 { | |
2518 return FRAME_X_TOTALLY_VISIBLE_P (f); | |
2519 } | |
2520 | |
2521 /* Change window state from mapped to iconified. */ | |
2522 static void | |
2523 x_iconify_frame (struct frame *f) | |
2524 { | |
2525 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
2526 | |
2527 if (!XIconifyWindow (display, | |
2528 XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
2529 DefaultScreen (display))) | |
2530 x_cant_notify_wm_error (); | |
2531 | |
2532 f->iconified = 1; | |
2533 } | |
2534 | |
2535 /* Sets the X focus to frame f. */ | |
2536 static void | |
2537 x_focus_on_frame (struct frame *f) | |
2538 { | |
2539 XWindowAttributes xwa; | |
2540 Widget shell_widget; | |
2541 int viewable = 0; | |
2542 | |
2543 assert (FRAME_X_P (f)); | |
2544 | |
2545 shell_widget = FRAME_X_SHELL_WIDGET (f); | |
2546 if (!XtWindow (shell_widget)) | |
2547 return; | |
2548 | |
2549 #ifdef EXTERNAL_WIDGET | |
2550 if (FRAME_X_EXTERNAL_WINDOW_P (f)) | |
2551 ExternalShellSetFocus (shell_widget); | |
2552 #endif /* EXTERNAL_WIDGET */ | |
2553 | |
2554 /* Do the ICCCM focus change if the window is still visible. | |
2555 The s->visible flag might not be up-to-date, because we might | |
2556 not have processed magic events recently. So make a server | |
2557 round-trip to find out whether it's really mapped right now. | |
2558 We grab the server to do this, because that's the only way to | |
2559 eliminate the race condition. | |
2560 */ | |
2561 XGrabServer (XtDisplay (shell_widget)); | |
2562 if (XGetWindowAttributes (XtDisplay (shell_widget), | |
2563 XtWindow (shell_widget), | |
2564 &xwa)) | |
2565 /* JV: it is bad to change the visibility like this, so we don't for the | |
2566 moment, at least change_frame_visibility should be called | |
2567 Note also that under fvwm a frame can be Viewable (and thus Mapped) | |
2568 but still X-invisible | |
2569 f->visible = xwa.map_state == IsViewable; */ | |
2570 viewable = xwa.map_state == IsViewable; | |
2571 | |
2572 | |
2573 if (viewable) | |
2574 { | |
2575 Window focus; | |
2576 int revert_to; | |
2577 XGetInputFocus (XtDisplay (shell_widget), &focus, &revert_to); | |
2578 /* Don't explicitly set the focus on this window unless the focus | |
2579 was on some other window (not PointerRoot). Note that, even when | |
2580 running a point-to-type window manager like *twm, there is always | |
2581 a focus window; the window manager maintains that based on the | |
2582 mouse position. If you set the "NoTitleFocus" option in these | |
2583 window managers, then the server itself maintains the focus via | |
2584 PointerRoot, and changing that to focus on the window would make | |
2585 the window grab the focus. Very bad. | |
2586 */ | |
2587 if (focus != PointerRoot) | |
2588 { | |
2589 XSetInputFocus (XtDisplay (shell_widget), | |
2590 XtWindow (shell_widget), | |
2591 RevertToParent, | |
4706 | 2592 CurrentTime); |
428 | 2593 XFlush (XtDisplay (shell_widget)); |
2594 } | |
2595 } | |
2596 XUngrabServer (XtDisplay (shell_widget)); | |
2597 XFlush (XtDisplay (shell_widget)); /* hey, I'd like to DEBUG this... */ | |
2598 } | |
2599 | |
450 | 2600 /* Destroy the X window of frame F. */ |
428 | 2601 static void |
2602 x_delete_frame (struct frame *f) | |
2603 { | |
2604 Display *dpy; | |
2605 | |
2606 #ifndef HAVE_WMCOMMAND | |
2607 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
2608 x_wm_maybe_move_wm_command (f); | |
2609 #endif /* HAVE_WMCOMMAND */ | |
2610 | |
2611 #ifdef HAVE_CDE | |
2612 DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f)); | |
2613 #endif /* HAVE_CDE */ | |
2614 | |
5239
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2615 #ifdef HAVE_XFT |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2616 /* If we have an XftDraw structure, we need to free it here. |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2617 We can't ever have an XftDraw without a Display, so we are safe |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2618 to free it in here, and we avoid too much playing around with the |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2619 malloc checking hooks this way. */ |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2620 if (FRAME_X_XFTDRAW (f)) |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2621 { |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2622 XftDrawDestroy (FRAME_X_XFTDRAW (f)); |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2623 FRAME_X_XFTDRAW (f) = NULL; |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2624 } |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2625 #endif |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2626 |
f19e6bc25969
Backed out changeset 6466bc9ebf15
Mike Sperber <sperber@deinprogramm.de>
parents:
5237
diff
changeset
|
2627 |
428 | 2628 assert (FRAME_X_SHELL_WIDGET (f) != 0); |
2629 dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f)); | |
2630 | |
2631 #ifdef EXTERNAL_WIDGET | |
1024 | 2632 expect_x_error (dpy); |
428 | 2633 /* for obscure reasons having (I think) to do with the internal |
2634 window-to-widget hierarchy maintained by Xt, we have to call | |
2635 XtUnrealizeWidget() here. Xt can really suck. */ | |
2636 if (f->being_deleted) | |
2637 XtUnrealizeWidget (FRAME_X_SHELL_WIDGET (f)); | |
2638 XtDestroyWidget (FRAME_X_SHELL_WIDGET (f)); | |
1024 | 2639 x_error_occurred_p (dpy); |
428 | 2640 #else |
2641 XtDestroyWidget (FRAME_X_SHELL_WIDGET (f)); | |
2642 /* make sure the windows are really gone! */ | |
440 | 2643 /* #### Is this REALLY necessary? */ |
428 | 2644 XFlush (dpy); |
2645 #endif /* EXTERNAL_WIDGET */ | |
2646 | |
2647 FRAME_X_SHELL_WIDGET (f) = 0; | |
2648 | |
2649 if (FRAME_X_GEOM_FREE_ME_PLEASE (f)) | |
2650 { | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
2651 xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f)); |
428 | 2652 FRAME_X_GEOM_FREE_ME_PLEASE (f) = 0; |
2653 } | |
2654 | |
2655 if (f->frame_data) | |
2656 { | |
4117 | 2657 #ifndef NEW_GC |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
2658 xfree (f->frame_data); |
3092 | 2659 #endif /* not NEW_GC */ |
428 | 2660 f->frame_data = 0; |
2661 } | |
2662 } | |
2663 | |
2664 static void | |
2367 | 2665 x_update_frame_external_traits (struct frame *frm, Lisp_Object name) |
428 | 2666 { |
2667 Arg al[10]; | |
2668 int ac = 0; | |
793 | 2669 Lisp_Object frame = wrap_frame (frm); |
2670 | |
428 | 2671 |
2672 if (EQ (name, Qforeground)) | |
2673 { | |
2674 Lisp_Object color = FACE_FOREGROUND (Vdefault_face, frame); | |
2675 XColor fgc; | |
2676 | |
2677 if (!EQ (color, Vthe_null_color_instance)) | |
2678 { | |
2679 fgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2680 Xt_SET_ARG (al[ac], XtNforeground, (void *) fgc.pixel); ac++; |
428 | 2681 } |
2682 } | |
2683 else if (EQ (name, Qbackground)) | |
2684 { | |
2685 Lisp_Object color = FACE_BACKGROUND (Vdefault_face, frame); | |
2686 XColor bgc; | |
2687 | |
2688 if (!EQ (color, Vthe_null_color_instance)) | |
2689 { | |
2690 bgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2691 Xt_SET_ARG (al[ac], XtNbackground, (void *) bgc.pixel); ac++; |
428 | 2692 } |
2693 | |
2694 /* Really crappy way to force the modeline shadows to be | |
2695 redrawn. But effective. */ | |
2696 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (frm); | |
2697 MARK_FRAME_CHANGED (frm); | |
2698 } | |
2699 else if (EQ (name, Qfont)) | |
2700 { | |
2701 Lisp_Object font = FACE_FONT (Vdefault_face, frame, Vcharset_ascii); | |
2702 | |
3676 | 2703 /* It may be that instantiating the font has deleted the frame (will |
2704 happen if the user has specified a charset registry for ASCII that | |
2705 isn't available on the server, and our fallback of iso8859-1 isn't | |
2706 available; something vanishingly rare.) In that case, return from | |
2707 this function without further manipulation of the dead frame. */ | |
2708 | |
2709 if (!FRAME_LIVE_P(frm)) | |
2710 { | |
2711 return; | |
2712 } | |
2713 | |
3094 | 2714 /* #### what to do about Xft? I don't think the font is actually used |
2715 to compute cell size for computing frame pixel dimensions (see call | |
2716 to EmacsFrameRecomputeCellSize() below); where is it used? -- sjt | |
2717 What does XtSetValues() do if that resource isn't present? */ | |
428 | 2718 if (!EQ (font, Vthe_null_font_instance)) |
1746 | 2719 { |
3094 | 2720 if (0) |
2721 ; | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
2722 #ifdef HAVE_XFT |
3094 | 2723 else if (FONT_INSTANCE_X_XFTFONT (XFONT_INSTANCE (font))) |
2724 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2725 Xt_SET_ARG (al[ac], XtNxftFont, |
3094 | 2726 (void *) FONT_INSTANCE_X_XFTFONT (XFONT_INSTANCE (font))); |
2727 ac++; | |
2728 } | |
2729 #endif | |
2730 else if (FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))) | |
2731 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2732 Xt_SET_ARG (al[ac], XtNfont, |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2733 (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))); |
3094 | 2734 ac++; |
2735 } | |
1746 | 2736 } |
428 | 2737 } |
2738 else | |
2500 | 2739 ABORT (); |
428 | 2740 |
2741 XtSetValues (FRAME_X_TEXT_WIDGET (frm), al, ac); | |
2742 | |
2743 #ifdef HAVE_TOOLBARS | |
2744 /* Setting the background clears the entire frame area | |
2745 including the toolbar so we force an immediate redraw of | |
2746 it. */ | |
2747 if (EQ (name, Qbackground)) | |
2748 MAYBE_DEVMETH (XDEVICE (frm->device), redraw_frame_toolbars, (frm)); | |
2749 #endif /* HAVE_TOOLBARS */ | |
2750 | |
2751 /* Set window manager resize increment hints according to | |
2752 the new character size */ | |
2753 if (EQ (name, Qfont)) | |
2754 EmacsFrameRecomputeCellSize (FRAME_X_TEXT_WIDGET (frm)); | |
2755 } | |
2756 | |
2757 | |
2758 /************************************************************************/ | |
2759 /* initialization */ | |
2760 /************************************************************************/ | |
2761 | |
2762 void | |
2763 syms_of_frame_x (void) | |
2764 { | |
3092 | 2765 #ifdef NEW_GC |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
2766 INIT_LISP_OBJECT (x_frame); |
3092 | 2767 #endif /* NEW_GC */ |
2768 | |
2747 | 2769 DEFSYMBOL (Qoverride_redirect); |
563 | 2770 DEFSYMBOL (Qx_resource_name); |
428 | 2771 |
2772 DEFSUBR (Fx_window_id); | |
2773 #ifdef HAVE_CDE | |
2774 DEFSUBR (Fcde_start_drag_internal); | |
2775 #endif | |
2776 } | |
2777 | |
2778 void | |
2779 console_type_create_frame_x (void) | |
2780 { | |
2781 /* frame methods */ | |
2782 CONSOLE_HAS_METHOD (x, init_frame_1); | |
2783 CONSOLE_HAS_METHOD (x, init_frame_2); | |
2784 CONSOLE_HAS_METHOD (x, init_frame_3); | |
2785 CONSOLE_HAS_METHOD (x, mark_frame); | |
2786 CONSOLE_HAS_METHOD (x, focus_on_frame); | |
2787 CONSOLE_HAS_METHOD (x, delete_frame); | |
2788 CONSOLE_HAS_METHOD (x, get_mouse_position); | |
2789 CONSOLE_HAS_METHOD (x, set_mouse_position); | |
2790 CONSOLE_HAS_METHOD (x, raise_frame); | |
2791 CONSOLE_HAS_METHOD (x, lower_frame); | |
442 | 2792 CONSOLE_HAS_METHOD (x, enable_frame); |
2793 CONSOLE_HAS_METHOD (x, disable_frame); | |
428 | 2794 CONSOLE_HAS_METHOD (x, make_frame_visible); |
2795 CONSOLE_HAS_METHOD (x, make_frame_invisible); | |
2796 CONSOLE_HAS_METHOD (x, iconify_frame); | |
2797 CONSOLE_HAS_METHOD (x, set_frame_size); | |
2798 CONSOLE_HAS_METHOD (x, set_frame_position); | |
2799 CONSOLE_HAS_METHOD (x, frame_property); | |
2800 CONSOLE_HAS_METHOD (x, internal_frame_property_p); | |
2801 CONSOLE_HAS_METHOD (x, frame_properties); | |
2802 CONSOLE_HAS_METHOD (x, set_frame_properties); | |
867 | 2803 CONSOLE_HAS_METHOD (x, set_title_from_ibyte); |
2804 CONSOLE_HAS_METHOD (x, set_icon_name_from_ibyte); | |
428 | 2805 CONSOLE_HAS_METHOD (x, frame_visible_p); |
2806 CONSOLE_HAS_METHOD (x, frame_totally_visible_p); | |
2807 CONSOLE_HAS_METHOD (x, frame_iconified_p); | |
2808 CONSOLE_HAS_METHOD (x, set_frame_pointer); | |
2809 CONSOLE_HAS_METHOD (x, set_frame_icon); | |
2810 CONSOLE_HAS_METHOD (x, get_frame_parent); | |
2811 CONSOLE_HAS_METHOD (x, update_frame_external_traits); | |
2812 } | |
2813 | |
2814 void | |
2815 vars_of_frame_x (void) | |
2816 { | |
2817 #ifdef EXTERNAL_WIDGET | |
2818 Fprovide (intern ("external-widget")); | |
2819 #endif | |
2820 | |
2821 /* this call uses only safe functions from emacs.c */ | |
2822 init_x_prop_symbols (); | |
2823 | |
2824 DEFVAR_LISP ("default-x-frame-plist", &Vdefault_x_frame_plist /* | |
2825 Plist of default frame-creation properties for X frames. | |
2826 These override what is specified in the resource database and in | |
2827 `default-frame-plist', but are overridden by the arguments to the | |
2828 particular call to `make-frame'. | |
2829 | |
2830 Note: In many cases, properties of a frame are available as specifiers | |
2831 instead of through the frame-properties mechanism. | |
2832 | |
2833 Here is a list of recognized frame properties, other than those | |
2834 documented in `set-frame-properties' (they can be queried and | |
2835 set at any time, except as otherwise noted): | |
2836 | |
2837 window-id The X window ID corresponding to the | |
2838 frame. May be set only at startup, and | |
2839 only if external widget support was | |
2840 compiled in; doing so causes the frame | |
2841 to be created as an "external widget" | |
2842 in another program that uses an existing | |
2843 window in the program rather than creating | |
2844 a new one. | |
2845 initially-unmapped If non-nil, the frame will not be visible | |
2846 when it is created. In this case, you | |
2847 need to call `make-frame-visible' to make | |
2848 the frame appear. | |
2849 popup If non-nil, it should be a frame, and this | |
2850 frame will be created as a "popup" frame | |
2851 whose parent is the given frame. This | |
2852 will make the window manager treat the | |
2853 frame as a dialog box, which may entail | |
2854 doing different things (e.g. not asking | |
2855 for positioning, and not iconifying | |
2856 separate from its parent). | |
2747 | 2857 override-redirect If non-nil, the frame will not be subject to |
2858 window-manager control. In particular, it | |
2859 will lack decorations, for more attractive | |
2860 appearance of balloon help, aka tooltips. | |
428 | 2861 inter-line-space Not currently implemented. |
2862 toolbar-shadow-thickness Thickness of toolbar shadows. | |
2863 background-toolbar-color Color of toolbar background. | |
2864 bottom-toolbar-shadow-color Color of bottom shadows on toolbars. | |
2865 (*Not* specific to the bottom-toolbar.) | |
2866 top-toolbar-shadow-color Color of top shadows on toolbars. | |
2867 (*Not* specific to the top-toolbar.) | |
2868 internal-border-width Width of internal border around text area. | |
2869 border-width Width of external border around text area. | |
2870 top Y position (in pixels) of the upper-left | |
2871 outermost corner of the frame (i.e. the | |
2872 upper-left of the window-manager | |
2873 decorations). | |
2874 left X position (in pixels) of the upper-left | |
2875 outermost corner of the frame (i.e. the | |
2876 upper-left of the window-manager | |
2877 decorations). | |
2878 border-color Color of external border around text area. | |
2879 cursor-color Color of text cursor. | |
2880 | |
2881 See also `default-frame-plist', which specifies properties which apply | |
2882 to all frames, not just X frames. | |
2883 */ ); | |
2884 Vdefault_x_frame_plist = Qnil; | |
2885 | |
2886 x_console_methods->device_specific_frame_props = &Vdefault_x_frame_plist; | |
2887 } |