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