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