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