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