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