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