Mercurial > hg > xemacs-beta
annotate src/frame-x.c @ 5086:47bcef7b0b44
Print multiple values with #<INTERNAL OBJECT (XEmacs bug?) ...>, too
2010-03-02 Aidan Kehoe <kehoea@parhasard.net>
* eval.c (print_multiple_value):
Say #<INTERNAL OBJECT (XEmacs bug?) ...> when printing these, for
consistency with the rest of the print code.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Tue, 02 Mar 2010 13:20:51 +0000 |
| parents | 5502045ec510 |
| children | 0ca81354c4c7 |
| 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 | |
| 442 | 1455 WINDOW_LEFT (win) = FRAME_LEFT_BORDER_END (f) |
| 1456 + FRAME_LEFT_GUTTER_BOUNDS (f); | |
| 1457 WINDOW_TOP (win) = FRAME_TOP_BORDER_END (f) | |
| 1458 + FRAME_TOP_GUTTER_BOUNDS (f); | |
| 428 | 1459 |
| 1460 if (!NILP (f->minibuffer_window)) | |
| 1461 { | |
| 1462 win = XWINDOW (f->minibuffer_window); | |
| 442 | 1463 WINDOW_LEFT (win) = FRAME_LEFT_BORDER_END (f) |
| 1464 + FRAME_LEFT_GUTTER_BOUNDS (f); | |
| 428 | 1465 } |
| 1466 } | |
| 1467 | |
| 1468 #ifdef EXTERNAL_WIDGET | |
| 1469 /* If we're an external widget, then the size of the frame is predetermined | |
| 1470 (by the client) and is not our decision to make. */ | |
| 1471 if (FRAME_X_EXTERNAL_WINDOW_P (f)) | |
| 1472 return; | |
| 1473 #endif | |
| 1474 | |
| 1475 #if 0 | |
| 1476 /* #### this junk has not been tested; therefore it's | |
| 1477 probably wrong. Doesn't really matter at this point because | |
| 1478 currently all frames are either top-level or external widgets. */ | |
| 1479 | |
| 1480 /* If we're not our own top-level window, then we shouldn't go messing around | |
| 1481 with top-level shells or "Emacs.geometry" or any such stuff. Therefore, | |
| 1482 we do as follows to determine the size of the frame: | |
| 1483 | |
| 1484 1) If a value for the frame's "geometry" resource was specified, then | |
| 1485 use it. (This specifies a size in characters.) | |
| 1486 2) Else, if the "width" and "height" resources were specified, then | |
| 1487 leave them alone. (This is a value in pixels. Sorry, we can't break | |
| 1488 Xt conventions here.) | |
| 1489 3) Else, assume a size of 64x12. (This is somewhat arbitrary, but | |
| 1490 it's unlikely that a size of 80x40 is desirable because we're probably | |
| 1491 inside of a dialog box.) | |
| 1492 | |
| 1493 Set the widget's x, y, height, and width as determined. Don't set the | |
| 1494 top-level container widget, because we don't necessarily know what it | |
| 1495 is. (Assume it is smart and pays attention to our values.) | |
| 1496 */ | |
| 1497 | |
| 1498 if (!FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
| 1499 { | |
| 1500 Xt_GET_VALUE (ew, XtNgeometry, &ew_geom); | |
| 1501 if (ew_geom) | |
| 1502 frame_flags = XParseGeometry (ew_geom, | |
| 1503 &frame_x, &frame_y, | |
| 1504 &frame_w, &frame_h); | |
| 1505 if (! (frame_flags & (WidthValue | HeightValue))) | |
| 1506 { | |
| 1507 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
|
1508 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
|
1509 Xt_SET_ARG (al [1], XtNheight, &frame_h); |
| 428 | 1510 XtGetValues (ew, al, 2); |
| 1511 if (!frame_w && !frame_h) | |
| 1512 { | |
| 1513 frame_w = 64; | |
| 1514 frame_h = 12; | |
| 1515 frame_flags |= WidthValue | HeightValue; | |
| 1516 } | |
| 1517 } | |
| 1518 if (frame_flags & (WidthValue | HeightValue)) | |
| 1519 EmacsFrameSetCharSize (ew, frame_w, frame_h); | |
| 1520 if (frame_flags & (XValue | YValue)) | |
| 1521 { | |
| 1522 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
|
1523 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
|
1524 Xt_SET_ARG (al [1], XtNheight, &frame_h); |
| 428 | 1525 XtGetValues (ew, al, 2); |
| 1526 | |
| 1527 if (frame_flags & XNegative) | |
| 1528 frame_x += frame_w; | |
| 1529 if (frame_flags & YNegative) | |
| 1530 frame_y += frame_h; | |
| 1531 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1532 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
|
1533 Xt_SET_ARG (al [1], XtNy, frame_y); |
| 428 | 1534 XtSetValues (ew, al, 2); |
| 1535 } | |
| 1536 return; | |
| 1537 } | |
| 1538 #endif | |
| 1539 | |
| 1540 /* OK, we're a top-level shell. */ | |
| 1541 | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
1542 assert (XtIsWMShell (wmshell)); |
| 428 | 1543 |
| 1544 /* If the EmacsFrame doesn't have a geometry but the shell does, | |
| 1545 treat that as the geometry of the frame. | |
| 1546 (Is this bogus? I'm not sure.) */ | |
| 1547 | |
| 1548 Xt_GET_VALUE (ew, XtNgeometry, &ew_geom); | |
| 1549 if (!ew_geom) | |
| 1550 { | |
| 1551 Xt_GET_VALUE (wmshell, XtNgeometry, &geom); | |
| 1552 if (geom) | |
| 1553 { | |
| 1554 ew_geom = geom; | |
| 1555 Xt_SET_VALUE (ew, XtNgeometry, ew_geom); | |
| 1556 } | |
| 1557 } | |
| 1558 | |
| 1559 /* If the Shell is iconic, then the EmacsFrame is iconic. | |
| 1560 (Is this bogus? I'm not sure.) */ | |
| 1561 Xt_GET_VALUE (ew, XtNiconic, &ew_iconic_p); | |
| 1562 if (!ew_iconic_p) | |
| 1563 { | |
| 1564 Xt_GET_VALUE (wmshell, XtNiconic, &iconic_p); | |
| 1565 if (iconic_p) | |
| 1566 { | |
| 1567 ew_iconic_p = iconic_p; | |
| 1568 Xt_SET_VALUE (ew, XtNiconic, iconic_p); | |
| 1569 } | |
| 1570 } | |
| 1571 | |
| 1572 Xt_GET_VALUE (app_shell, XtNgeometry, &geom); | |
| 1573 if (geom) | |
| 1574 app_flags = XParseGeometry (geom, &app_x, &app_y, &app_w, &app_h); | |
| 1575 | |
| 1576 if (ew_geom) | |
| 1577 frame_flags = XParseGeometry (ew_geom, | |
| 1578 &frame_x, &frame_y, | |
| 1579 &frame_w, &frame_h); | |
| 1580 | |
| 1581 if (first_x_frame_p (f)) | |
| 1582 { | |
| 1583 /* If this is the first frame created: | |
| 1584 ==================================== | |
| 1585 | |
| 1586 - Use the ApplicationShell's size/position, if specified. | |
| 1587 (This is "Emacs.geometry", or the "-geometry" command line arg.) | |
| 1588 - Else use the EmacsFrame's size/position. | |
| 1589 (This is "*FRAME-NAME.geometry") | |
| 1590 | |
| 1591 - If the AppShell is iconic, the frame should be iconic. | |
| 1592 | |
| 1593 AppShell comes first so that -geometry always applies to the first | |
| 1594 frame created, even if there is an "every frame" entry in the | |
| 1595 resource database. | |
| 1596 */ | |
| 1597 if (app_flags & (XValue | YValue)) | |
| 1598 { | |
| 1599 x = app_x; y = app_y; | |
| 1600 flags |= (app_flags & (XValue | YValue | XNegative | YNegative)); | |
| 1601 } | |
| 1602 else if (frame_flags & (XValue | YValue)) | |
| 1603 { | |
| 1604 x = frame_x; y = frame_y; | |
| 1605 flags |= (frame_flags & (XValue | YValue | XNegative | YNegative)); | |
| 1606 } | |
| 1607 | |
| 1608 if (app_flags & (WidthValue | HeightValue)) | |
| 1609 { | |
| 1610 w = app_w; h = app_h; | |
| 1611 flags |= (app_flags & (WidthValue | HeightValue)); | |
| 1612 } | |
| 1613 else if (frame_flags & (WidthValue | HeightValue)) | |
| 1614 { | |
| 1615 w = frame_w; h = frame_h; | |
| 1616 flags |= (frame_flags & (WidthValue | HeightValue)); | |
| 1617 } | |
| 1618 | |
| 1619 /* If the AppShell is iconic, then the EmacsFrame is iconic. */ | |
| 1620 if (!ew_iconic_p) | |
| 1621 { | |
| 1622 Xt_GET_VALUE (app_shell, XtNiconic, &iconic_p); | |
| 1623 if (iconic_p) | |
| 1624 { | |
| 1625 ew_iconic_p = iconic_p; | |
| 1626 Xt_SET_VALUE (ew, XtNiconic, iconic_p); | |
| 1627 } | |
| 1628 } | |
| 1629 } | |
| 1630 else | |
| 1631 { | |
| 1632 /* If this is not the first frame created: | |
| 1633 ======================================== | |
| 1634 | |
| 1635 - use the EmacsFrame's size/position if specified | |
| 1636 - Otherwise, use the ApplicationShell's size, but not position. | |
| 1637 | |
| 1638 So that means that one can specify the position of the first frame | |
| 1639 with "Emacs.geometry" or `-geometry'; but can only specify the | |
| 1640 position of subsequent frames with "*FRAME-NAME.geometry". | |
| 1641 | |
| 1642 AppShell comes second so that -geometry does not apply to subsequent | |
| 1643 frames when there is an "every frame" entry in the resource db, | |
| 1644 but does apply to the first frame. | |
| 1645 */ | |
| 1646 if (frame_flags & (XValue | YValue)) | |
| 1647 { | |
| 1648 x = frame_x; y = frame_y; | |
| 1649 flags |= (frame_flags & (XValue | YValue | XNegative | YNegative)); | |
| 1650 } | |
| 1651 | |
| 1652 if (frame_flags & (WidthValue | HeightValue)) | |
| 1653 { | |
| 1654 w = frame_w; h = frame_h; | |
| 1655 flags |= (frame_flags & (WidthValue | HeightValue)); | |
| 1656 } | |
| 1657 else if (app_flags & (WidthValue | HeightValue)) | |
| 1658 { | |
| 1659 w = app_w; | |
| 1660 h = app_h; | |
| 1661 flags |= (app_flags & (WidthValue | HeightValue)); | |
| 1662 } | |
| 1663 } | |
| 1664 | |
| 1665 x_set_initial_frame_size (f, flags, x, y, w, h); | |
| 1666 } | |
| 1667 | |
| 1668 static void | |
| 1669 x_get_layout_sizes (struct frame *f, Dimension *topbreadth) | |
| 1670 { | |
| 1671 int i; | |
| 1672 | |
| 1673 /* compute height of all top-area widgets */ | |
| 1674 for (i=0, *topbreadth = 0; i<FRAME_X_NUM_TOP_WIDGETS (f); i++) | |
| 1675 { | |
| 1676 Widget wid = FRAME_X_TOP_WIDGETS (f)[i]; | |
| 1677 if (wid && XtIsManaged (wid)) | |
| 1678 *topbreadth += wid->core.height + 2*wid->core.border_width; | |
| 1679 } | |
| 1680 } | |
| 1681 | |
| 1682 static void | |
| 2286 | 1683 x_layout_widgets (Widget UNUSED (w), XtPointer client_data, |
| 1684 XtPointer call_data) | |
| 428 | 1685 { |
| 1686 struct frame *f = (struct frame *) client_data; | |
| 1687 EmacsManagerResizeStruct *emst = (EmacsManagerResizeStruct *) call_data; | |
| 1688 Dimension width = emst->width; | |
| 1689 Dimension height = emst->height; | |
| 1690 Widget text = FRAME_X_TEXT_WIDGET (f); | |
| 1691 Dimension textbord = text->core.border_width; | |
| 1692 Dimension topbreadth; | |
| 1693 Position text_x = 0, text_y = 0; | |
| 1694 int i; | |
| 1695 | |
| 1696 x_get_layout_sizes (f, &topbreadth); | |
| 1697 | |
| 1698 /* first the menubar and psheets ... */ | |
| 1699 for (i=0; i<FRAME_X_NUM_TOP_WIDGETS (f); i++) | |
| 1700 { | |
| 1701 Widget wid = FRAME_X_TOP_WIDGETS (f)[i]; | |
| 1702 if (wid && XtIsManaged (wid)) | |
| 1703 { | |
| 1704 Dimension bord = wid->core.border_width; | |
| 1705 XtConfigureWidget (wid, 0, text_y, | |
| 1706 width - 2*bord, wid->core.height, | |
| 1707 bord); | |
| 1708 text_y += wid->core.height + 2*bord; | |
| 1709 } | |
| 1710 } | |
| 1711 | |
| 1712 #ifdef HAVE_SCROLLBARS | |
| 1713 f->scrollbar_y_offset = topbreadth + textbord; | |
| 1714 #endif | |
| 1715 | |
| 1716 /* finally the text area */ | |
| 1717 XtConfigureWidget (text, text_x, text_y, | |
| 1718 width - 2*textbord, | |
| 1719 height - text_y - 2*textbord, | |
| 1720 textbord); | |
| 1721 } | |
| 1722 | |
| 1723 static void | |
| 2286 | 1724 x_do_query_geometry (Widget UNUSED (w), XtPointer client_data, |
| 1725 XtPointer call_data) | |
| 428 | 1726 { |
| 1727 struct frame *f = (struct frame *) client_data; | |
| 1728 EmacsManagerQueryGeometryStruct *emst = | |
| 1729 (EmacsManagerQueryGeometryStruct *) call_data; | |
| 1730 Widget text = FRAME_X_TEXT_WIDGET (f); | |
| 1731 Dimension textbord = text->core.border_width; | |
| 1732 Dimension topbreadth; | |
| 1733 XtWidgetGeometry req, repl; | |
| 1734 int mask = emst->request_mode & (CWWidth | CWHeight); | |
| 1735 | |
| 1736 x_get_layout_sizes (f, &topbreadth); | |
| 1737 | |
| 1738 /* Strip away menubar from suggested size, and ask the text widget | |
| 1739 what size it wants to be. */ | |
| 1740 req.request_mode = mask; | |
| 1741 if (mask & CWWidth) | |
| 1742 req.width = emst->proposed_width - 2*textbord; | |
| 1743 if (mask & CWHeight) | |
| 1744 req.height = emst->proposed_height - topbreadth - 2*textbord; | |
| 1745 XtQueryGeometry (text, &req, &repl); | |
| 1746 | |
| 1747 /* Now add the menubar back again */ | |
| 1748 emst->proposed_width = repl.width + 2*textbord; | |
| 1749 emst->proposed_height = repl.height + topbreadth + 2*textbord; | |
| 1750 } | |
| 1751 | |
| 1752 /* Creates the widgets for a frame. | |
| 1753 lisp_window_id is a Lisp description of an X window or Xt | |
| 1754 widget to parse. | |
| 2747 | 1755 parent is a frame to use as the parent. |
| 1756 overridep if non-nil says to set the override-redirect setting. | |
| 428 | 1757 |
| 1758 This function does not create or map the windows. (That is | |
| 1759 done by x_popup_frame().) | |
| 1760 */ | |
| 1761 static void | |
| 1762 x_create_widgets (struct frame *f, Lisp_Object lisp_window_id, | |
| 2747 | 1763 Lisp_Object parent, Lisp_Object overridep) |
| 428 | 1764 { |
| 1765 struct device *d = XDEVICE (f->device); | |
| 1766 Visual *visual = DEVICE_X_VISUAL (d); | |
| 1767 int depth = DEVICE_X_DEPTH (d); | |
| 1768 Colormap cmap = DEVICE_X_COLORMAP (d); | |
| 1769 #ifdef EXTERNAL_WIDGET | |
| 1770 Window window_id = 0; | |
| 1771 #endif | |
| 2367 | 1772 const Extbyte *name; |
| 1773 Arg al[25]; | |
| 428 | 1774 int ac = 0; |
| 1775 Widget text, container, shell; | |
| 1776 Widget parentwid = 0; | |
| 1777 #ifdef HAVE_MENUBARS | |
| 1778 int menubar_visible; | |
| 1779 Widget menubar; | |
| 1780 #endif | |
| 1781 | |
| 1782 if (STRINGP (f->name)) | |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
1783 name = LISP_STRING_TO_EXTERNAL (f->name, Qctext); |
| 428 | 1784 else |
| 1785 name = "emacs"; | |
| 1786 | |
| 1787 /* The widget hierarchy is | |
| 1788 | |
| 1789 argv[0] shell pane FRAME-NAME | |
| 1790 ApplicationShell EmacsShell EmacsManager EmacsFrame | |
| 1791 | |
| 1792 (the type of the shell is ExternalShell if this frame is running | |
| 1793 in another client's window) | |
| 1794 | |
| 1795 However the EmacsShell widget has WM_CLASS of FRAME-NAME/Emacs. | |
| 1796 Normally such shells have name/class shellname/appclass, which in this | |
| 1797 case would be "shell/Emacs" instead of "frame-name/Emacs". We could | |
| 1798 also get around this by naming the shell "frame-name", but that would | |
| 1799 be confusing because the text area (the EmacsFrame widget inferior of | |
| 1800 the shell) is also called that. So we just set the WM_CLASS property. | |
| 1801 */ | |
| 1802 | |
| 1803 #ifndef EXTERNAL_WIDGET | |
| 1804 if (!NILP (lisp_window_id)) | |
| 2367 | 1805 signal_error |
| 1806 (Qunimplemented, | |
| 1807 "support for external widgets was not enabled at compile-time", | |
| 1808 Qunbound); | |
| 428 | 1809 #else |
| 1810 if (!NILP (lisp_window_id)) | |
| 1811 { | |
| 2367 | 1812 Ibyte *string; |
| 428 | 1813 |
| 1814 CHECK_STRING (lisp_window_id); | |
| 2367 | 1815 string = XSTRING_DATA (lisp_window_id); |
| 428 | 1816 if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) |
| 2367 | 1817 qxesscanf_ascii_1 (string + 2, "%lxu", &window_id); |
| 428 | 1818 #if 0 |
| 1819 else if (string[0] == 'w') | |
| 1820 { | |
| 2367 | 1821 qxesscanf_ascii (string + 1, "%x", &parent_widget); |
| 428 | 1822 if (parent_widget) |
| 1823 window_id = XtWindow (parent_widget); | |
| 1824 } | |
| 1825 #endif | |
| 1826 else | |
| 2367 | 1827 qxesscanf_ascii_1 (string, "%lu", &window_id); |
| 428 | 1828 if (!is_valid_window (window_id, d)) |
| 563 | 1829 signal_ferror (Qinvalid_argument, "Invalid window %lu", |
| 1830 (unsigned long) window_id); | |
| 428 | 1831 FRAME_X_EXTERNAL_WINDOW_P (f) = 1; |
| 1832 } else | |
| 1833 #endif /* EXTERNAL_WIDGET */ | |
| 1834 FRAME_X_TOP_LEVEL_FRAME_P (f) = 1; | |
| 1835 | |
| 1836 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
|
1837 Xt_SET_ARG (al[ac], XtNallowShellResize, True); ac++; |
| 428 | 1838 #ifdef LWLIB_USES_MOTIF |
| 1839 /* Motif sucks beans. Without this in here, it will delete the window | |
| 1840 out from under us when it receives a WM_DESTROY_WINDOW message | |
| 1841 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
|
1842 Xt_SET_ARG (al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++; |
| 428 | 1843 #endif |
| 1844 | |
| 1845 #ifdef EXTERNAL_WIDGET | |
| 1846 if (window_id) | |
| 1847 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1848 Xt_SET_ARG (al[ac], XtNwindow, window_id); ac++; |
| 428 | 1849 } |
| 1850 else | |
| 1851 #endif /* EXTERNAL_WIDGET */ | |
| 1852 { | |
|
4528
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], 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
|
1854 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
|
1855 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
|
1856 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
|
1857 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
|
1858 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++; |
| 428 | 1859 } |
| 1860 | |
| 2747 | 1861 if (!NILP (overridep)) |
| 1862 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1863 Xt_SET_ARG (al[ac], XtNoverrideRedirect, True); ac++; |
| 2747 | 1864 } |
| 1865 | |
| 1866 /* #### maybe we should check for FRAMEP instead? */ | |
| 428 | 1867 if (!NILP (parent)) |
| 1868 { | |
| 1869 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
|
1870 Xt_SET_ARG (al[ac], XtNtransientFor, parentwid); ac++; |
| 428 | 1871 } |
| 1872 | |
| 1873 shell = XtCreatePopupShell ("shell", | |
| 1874 ( | |
| 1875 #ifdef EXTERNAL_WIDGET | |
| 1876 window_id ? externalShellWidgetClass : | |
| 1877 #endif | |
| 1878 parentwid ? transientEmacsShellWidgetClass : | |
| 1879 topLevelEmacsShellWidgetClass | |
| 1880 ), | |
| 1881 parentwid ? parentwid : | |
| 1882 DEVICE_XT_APP_SHELL (d), | |
| 1883 al, ac); | |
| 1884 FRAME_X_SHELL_WIDGET (f) = shell; | |
| 1885 maybe_set_frame_title_format (shell); | |
| 1886 | |
| 1887 /* Create the manager widget */ | |
| 1888 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
|
1889 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
|
1890 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
|
1891 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++; |
| 428 | 1892 |
| 1893 container = XtCreateWidget ("container", | |
| 1894 emacsManagerWidgetClass, shell, al, ac); | |
| 1895 FRAME_X_CONTAINER_WIDGET (f) = container; | |
| 1896 XtAddCallback (container, XtNresizeCallback, x_layout_widgets, | |
| 1897 (XtPointer) f); | |
| 1898 XtAddCallback (container, XtNqueryGeometryCallback, x_do_query_geometry, | |
| 1899 (XtPointer) f); | |
| 1900 | |
| 1901 /* Create the text area */ | |
| 1902 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
|
1903 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
|
1904 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
|
1905 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
|
1906 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
|
1907 Xt_SET_ARG (al[ac], XtNemacsFrame, f); ac++; |
| 428 | 1908 text = XtCreateWidget (name, emacsFrameClass, container, al, ac); |
| 1909 FRAME_X_TEXT_WIDGET (f) = text; | |
| 1910 | |
| 1911 #ifdef HAVE_MENUBARS | |
| 1912 /* Create the initial menubar widget. */ | |
| 1913 menubar_visible = x_initialize_frame_menubar (f); | |
| 1914 FRAME_X_TOP_WIDGETS (f)[0] = menubar = FRAME_X_MENUBAR_WIDGET (f); | |
| 1915 FRAME_X_NUM_TOP_WIDGETS (f) = 1; | |
| 1916 | |
| 1917 if (menubar_visible) | |
| 1918 XtManageChild (menubar); | |
| 1919 #endif /* HAVE_MENUBARS */ | |
| 1920 XtManageChild (text); | |
| 1921 XtManageChild (container); | |
| 1922 } | |
| 1923 | |
| 1924 /* We used to call XtPopup() in x_popup_frame, but that doesn't give | |
| 1925 you control over whether the widget is initially mapped or not | |
| 1926 because XtPopup() makes an unconditional call to XMapRaised(). | |
| 1927 Boy, those Xt designers were clever. | |
| 1928 | |
| 1929 When we first removed it we only kept the XtRealizeWidget call in | |
| 1930 XtPopup. For everything except HP's that was enough. For HP's, | |
| 1931 though, the failure to call the popup callbacks resulted in XEmacs | |
| 1932 not accepting any input. Bizarre but true. Stupid but true. | |
| 1933 | |
| 1934 So, in case there are any other gotchas floating out there along | |
| 1935 the same lines I've duplicated the majority of XtPopup here. It | |
| 1936 assumes no grabs and that the widget is not already popped up, both | |
| 1937 valid assumptions for the one place this is called from. */ | |
| 1938 static void | |
| 1939 xemacs_XtPopup (Widget widget) | |
| 1940 { | |
| 1941 ShellWidget shell_widget = (ShellWidget) widget; | |
| 1942 XtGrabKind call_data = XtGrabNone; | |
| 1943 | |
| 2367 | 1944 XtCallCallbacks (widget, XtNpopupCallback, (XtPointer) &call_data); |
| 428 | 1945 |
| 1946 shell_widget->shell.popped_up = TRUE; | |
| 1947 shell_widget->shell.grab_kind = XtGrabNone; | |
| 1948 shell_widget->shell.spring_loaded = False; | |
| 1949 | |
| 1950 if (shell_widget->shell.create_popup_child_proc != NULL) | |
| 2367 | 1951 (*(shell_widget->shell.create_popup_child_proc)) (widget); |
| 428 | 1952 |
| 1953 /* The XtSetValues below are not in XtPopup menu. We just want to | |
| 1954 make absolutely sure... */ | |
| 1955 Xt_SET_VALUE (widget, XtNmappedWhenManaged, False); | |
| 1956 XtRealizeWidget (widget); | |
| 1957 Xt_SET_VALUE (widget, XtNmappedWhenManaged, True); | |
| 1958 } | |
| 1959 | |
| 1960 /* create the windows for the specified frame and display them. | |
| 1961 Note that the widgets have already been created, and any | |
| 1962 necessary geometry calculations have already been done. */ | |
| 1963 static void | |
| 1964 x_popup_frame (struct frame *f) | |
| 1965 { | |
| 1966 Widget shell_widget = FRAME_X_SHELL_WIDGET (f); | |
| 1967 Widget frame_widget = FRAME_X_TEXT_WIDGET (f); | |
| 1968 struct device *d = XDEVICE (FRAME_DEVICE (f)); | |
| 1969 | |
| 1970 /* Before mapping the window, make sure that the WMShell's notion of | |
| 1971 whether it should be iconified is synchronized with the EmacsFrame's | |
| 1972 notion. | |
| 1973 */ | |
| 1974 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
| 1975 x_wm_set_shell_iconic_p (shell_widget, | |
| 1976 ((EmacsFrame) frame_widget) | |
| 1977 ->emacs_frame.iconic); | |
| 1978 | |
| 1979 xemacs_XtPopup (shell_widget); | |
| 1980 | |
| 1981 if (!((EmacsFrame) frame_widget)->emacs_frame.initially_unmapped) | |
| 1982 XtMapWidget (shell_widget); | |
| 1983 else | |
| 1984 { | |
| 1985 /* We may have set f->visible to 1 in x_init_frame(), so undo | |
| 1986 that now. */ | |
| 1987 FRAME_X_TOTALLY_VISIBLE_P (f) = 0; | |
| 1988 f->visible = 0; | |
| 1989 } | |
| 1990 | |
| 1991 #ifdef EXTERNAL_WIDGET | |
| 1992 if (FRAME_X_EXTERNAL_WINDOW_P (f)) | |
| 1993 ExternalShellReady (shell_widget, XtWindow (frame_widget), KeyPressMask); | |
| 1994 else | |
| 1995 #endif | |
| 1996 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
| 1997 { | |
| 1998 /* tell the window manager about us. */ | |
| 1999 x_wm_store_class_hints (shell_widget, XtName (frame_widget)); | |
| 2000 | |
| 2001 #ifndef HAVE_WMCOMMAND | |
| 2002 x_wm_maybe_store_wm_command (f); | |
| 2003 #endif /* HAVE_WMCOMMAND */ | |
| 2004 | |
| 2005 x_wm_hack_wm_protocols (shell_widget); | |
| 2006 } | |
| 2007 | |
| 2008 #ifdef HAVE_XIM | |
| 2009 XIM_init_frame (f); | |
| 2010 #endif /* HAVE_XIM */ | |
| 2011 | |
| 2012 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */ | |
| 2013 /* Intrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */ | |
| 2014 /* pp. 483-493. */ | |
| 2015 XtAddEventHandler (shell_widget, /* the shell widget in question */ | |
| 2016 (EventMask) NoEventMask,/* OR with existing mask */ | |
| 2017 True, /* called on non-maskable events? */ | |
| 2018 (XtEventHandler) _XEditResCheckMessages, /* the handler */ | |
| 2019 NULL); | |
| 2020 | |
| 2021 #ifdef HAVE_CDE | |
| 2022 { | |
| 2023 XtCallbackRec dnd_transfer_cb_rec[2]; | |
| 2024 | |
| 2025 dnd_transfer_cb_rec[0].callback = x_cde_transfer_callback; | |
| 2026 dnd_transfer_cb_rec[0].closure = (XtPointer) f; | |
| 2027 dnd_transfer_cb_rec[1].callback = NULL; | |
| 2028 dnd_transfer_cb_rec[1].closure = NULL; | |
| 2029 | |
| 2030 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f), | |
| 2031 DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER, | |
| 2032 XmDROP_COPY, dnd_transfer_cb_rec, | |
| 2033 DtNtextIsBuffer, True, | |
| 2034 DtNregisterChildren, True, | |
| 2035 DtNpreserveRegistration, False, | |
| 2036 NULL); | |
| 2037 } | |
| 2038 #endif /* HAVE_CDE */ | |
| 2039 | |
| 2040 /* Do a stupid property change to force the server to generate a | |
| 2041 propertyNotify event so that the event_stream server timestamp will | |
| 2042 be initialized to something relevant to the time we created the window. | |
| 2043 */ | |
| 2044 XChangeProperty (XtDisplay (frame_widget), XtWindow (frame_widget), | |
| 2045 DEVICE_XATOM_WM_PROTOCOLS (d), XA_ATOM, 32, PropModeAppend, | |
| 2367 | 2046 (Rawbyte *) NULL, 0); |
| 428 | 2047 |
| 2048 x_send_synthetic_mouse_event (f); | |
| 2049 } | |
| 2050 | |
| 2051 static void | |
| 2052 allocate_x_frame_struct (struct frame *f) | |
| 2053 { | |
| 2054 /* zero out all slots. */ | |
| 3092 | 2055 #ifdef NEW_GC |
| 2056 f->frame_data = alloc_lrecord_type (struct x_frame, &lrecord_x_frame); | |
| 2057 #else /* not NEW_GC */ | |
| 428 | 2058 f->frame_data = xnew_and_zero (struct x_frame); |
| 3092 | 2059 #endif /* not NEW_GC */ |
| 428 | 2060 |
| 2061 /* yeah, except the lisp ones */ | |
| 1346 | 2062 FRAME_X_LAST_MENUBAR_BUFFER (f) = Qnil; |
| 428 | 2063 FRAME_X_ICON_PIXMAP (f) = Qnil; |
| 2064 FRAME_X_ICON_PIXMAP_MASK (f) = Qnil; | |
| 2065 } | |
| 2066 | |
| 2067 | |
| 2068 /************************************************************************/ | |
| 2069 /* Lisp functions */ | |
| 2070 /************************************************************************/ | |
| 2071 | |
| 2072 static void | |
| 771 | 2073 x_init_frame_1 (struct frame *f, Lisp_Object props, |
| 2286 | 2074 int UNUSED (frame_name_is_defaulted)) |
| 428 | 2075 { |
| 2076 /* This function can GC */ | |
| 2077 Lisp_Object device = FRAME_DEVICE (f); | |
| 2078 Lisp_Object lisp_window_id = Fplist_get (props, Qwindow_id, Qnil); | |
| 2079 Lisp_Object popup = Fplist_get (props, Qpopup, Qnil); | |
| 2747 | 2080 Lisp_Object overridep = Fplist_get (props, Qoverride_redirect, Qnil); |
| 428 | 2081 |
| 2082 if (!NILP (popup)) | |
| 2083 { | |
| 2084 if (EQ (popup, Qt)) | |
| 2085 popup = Fselected_frame (device); | |
| 2086 CHECK_LIVE_FRAME (popup); | |
| 2087 if (!EQ (device, FRAME_DEVICE (XFRAME (popup)))) | |
| 563 | 2088 invalid_argument_2 ("Parent must be on same device as frame", |
| 2089 device, popup); | |
| 428 | 2090 } |
| 2091 | |
| 2092 /* | |
| 2093 * Previously we set this only if NILP (DEVICE_SELECTED_FRAME (d)) | |
| 2094 * to make sure that messages were displayed as soon as possible | |
| 2095 * if we're creating the first frame on a device. But it is | |
| 2096 * better to just set this all the time, so that when a new frame | |
| 2097 * is created that covers the selected frame, echo area status | |
| 2098 * messages can still be seen. f->visible is reset later if the | |
| 2099 * initially-unmapped property is found to be non-nil in the | |
| 2100 * frame properties. | |
| 2101 */ | |
| 2102 f->visible = 1; | |
| 2103 | |
| 2104 allocate_x_frame_struct (f); | |
| 2747 | 2105 x_create_widgets (f, lisp_window_id, popup, overridep); |
| 428 | 2106 } |
| 2107 | |
| 2108 static void | |
| 2286 | 2109 x_init_frame_2 (struct frame *f, Lisp_Object UNUSED (props)) |
| 428 | 2110 { |
| 2111 /* Set up the values of the widget/frame. A case could be made for putting | |
| 2112 this inside of the widget's initialize method. */ | |
| 2113 | |
| 2114 update_frame_face_values (f); | |
| 2115 x_initialize_frame_size (f); | |
| 2116 /* Kyle: | |
| 2117 * update_frame_title() can't be done here, because some of the | |
| 2118 * modeline specs depend on the frame's device having a selected | |
| 2119 * frame, and that may not have been set up yet. The redisplay | |
| 2120 * will update the frame title anyway, so nothing is lost. | |
| 2121 * JV: | |
| 2122 * It turns out it gives problems with FVWMs name based mapping. | |
| 2123 * We'll just need to be careful in the modeline specs. | |
| 2124 */ | |
| 2125 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
|
2126 /* 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
|
2127 * 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
|
2128 * 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
|
2129 * SJT: |
|
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2130 * This probably means that the frame-icon library won't work with |
| 4594 | 2131 * that WM. Late breaking news: it *does* work, so possibly the |
| 2132 * 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
|
2133 */ |
|
3623446b34bc
Set icon resource on frame early enough for openbox to find it.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4528
diff
changeset
|
2134 update_frame_icon (f); |
| 428 | 2135 } |
| 2136 | |
| 2137 static void | |
| 2138 x_init_frame_3 (struct frame *f) | |
| 2139 { | |
|
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2140 /* #### 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
|
2141 #### 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
|
2142 #### 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
|
2143 #### that the frame is now relalized. -- dvl */ |
|
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2144 |
| 428 | 2145 x_popup_frame (f); |
|
5080
5502045ec510
The background-placement face property.
Didier Verna <didier@lrde.epita.fr>
parents:
5050
diff
changeset
|
2146 x_get_frame_text_position (f); |
| 428 | 2147 } |
| 2148 | |
| 2149 static void | |
| 2150 x_mark_frame (struct frame *f) | |
| 2151 { | |
| 1346 | 2152 mark_object (FRAME_X_LAST_MENUBAR_BUFFER (f)); |
| 428 | 2153 mark_object (FRAME_X_ICON_PIXMAP (f)); |
| 2154 mark_object (FRAME_X_ICON_PIXMAP_MASK (f)); | |
| 2155 } | |
| 2156 | |
| 2157 static void | |
| 2158 x_set_frame_icon (struct frame *f) | |
| 2159 { | |
| 2160 Pixmap x_pixmap, x_mask; | |
| 2161 | |
| 2162 if (IMAGE_INSTANCEP (f->icon) | |
| 2163 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (f->icon))) | |
| 2164 { | |
| 2165 x_pixmap = XIMAGE_INSTANCE_X_PIXMAP (f->icon); | |
| 2166 x_mask = XIMAGE_INSTANCE_X_MASK (f->icon); | |
| 2167 } | |
| 2168 else | |
| 2169 { | |
| 2170 x_pixmap = 0; | |
| 2171 x_mask = 0; | |
| 2172 } | |
| 2173 | |
| 2174 /* Store the X data into the widget. */ | |
| 2175 { | |
| 2367 | 2176 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
|
2177 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
|
2178 Xt_SET_ARG (al[1], XtNiconMask, x_mask); |
| 428 | 2179 XtSetValues (FRAME_X_SHELL_WIDGET (f), al, 2); |
| 2180 } | |
| 2181 } | |
| 2182 | |
| 2183 static void | |
| 2184 x_set_frame_pointer (struct frame *f) | |
| 2185 { | |
| 2186 XDefineCursor (XtDisplay (FRAME_X_TEXT_WIDGET (f)), | |
| 2187 XtWindow (FRAME_X_TEXT_WIDGET (f)), | |
| 2188 XIMAGE_INSTANCE_X_CURSOR (f->pointer)); | |
| 2189 XSync (XtDisplay (FRAME_X_TEXT_WIDGET (f)), 0); | |
| 2190 } | |
| 2191 | |
| 2192 static Lisp_Object | |
| 2193 x_get_frame_parent (struct frame *f) | |
| 2194 { | |
| 2195 Widget parentwid = 0; | |
| 2196 | |
| 2197 Xt_GET_VALUE (FRAME_X_SHELL_WIDGET (f), XtNtransientFor, &parentwid); | |
| 2198 /* find the frame whose wid is parentwid */ | |
| 2199 if (parentwid) | |
| 2200 { | |
| 2201 Lisp_Object frmcons; | |
| 2202 DEVICE_FRAME_LOOP (frmcons, XDEVICE (FRAME_DEVICE (f))) | |
| 2203 { | |
| 2204 Lisp_Object frame = XCAR (frmcons); | |
| 2205 if (FRAME_X_SHELL_WIDGET (XFRAME (frame)) == parentwid) | |
| 2206 return frame; | |
| 2207 } | |
| 2208 } | |
| 2209 return Qnil; | |
| 2210 } | |
| 2211 | |
| 2212 DEFUN ("x-window-id", Fx_window_id, 0, 1, 0, /* | |
| 2213 Get the ID of the X11 window. | |
| 2214 This gives us a chance to manipulate the Emacs window from within a | |
| 2215 different program. Since the ID is an unsigned long, we return it as | |
| 2216 a string. | |
| 2217 */ | |
| 2218 (frame)) | |
| 2219 { | |
| 867 | 2220 Ibyte str[255]; |
| 428 | 2221 struct frame *f = decode_x_frame (frame); |
| 2222 | |
| 771 | 2223 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
|
2224 return build_istring (str); |
| 428 | 2225 } |
| 2226 | |
| 2227 | |
| 2228 /************************************************************************/ | |
| 2229 /* manipulating the X window */ | |
| 2230 /************************************************************************/ | |
| 2231 | |
| 2232 static void | |
| 2233 x_set_frame_position (struct frame *f, int xoff, int yoff) | |
| 2234 { | |
| 2235 Widget w = FRAME_X_SHELL_WIDGET (f); | |
| 2236 Display *dpy = XtDisplay (w); | |
| 2237 Dimension frame_w = DisplayWidth (dpy, DefaultScreen (dpy)); | |
| 2238 Dimension frame_h = DisplayHeight (dpy, DefaultScreen (dpy)); | |
| 2239 Dimension shell_w, shell_h, shell_bord; | |
| 2240 int win_gravity; | |
| 2367 | 2241 Arg al[3]; |
| 2242 | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2243 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
|
2244 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
|
2245 Xt_SET_ARG (al[2], XtNborderWidth, &shell_bord); |
| 428 | 2246 XtGetValues (w, al, 3); |
| 2247 | |
| 2248 win_gravity = | |
| 2249 xoff >= 0 && yoff >= 0 ? NorthWestGravity : | |
| 2250 xoff >= 0 ? SouthWestGravity : | |
| 2251 yoff >= 0 ? NorthEastGravity : | |
| 2252 SouthEastGravity; | |
| 2253 if (xoff < 0) | |
| 2254 xoff += frame_w - shell_w - 2*shell_bord; | |
| 2255 if (yoff < 0) | |
| 2256 yoff += frame_h - shell_h - 2*shell_bord; | |
| 2257 | |
| 2258 /* Update the hints so that, if this window is currently iconified, it will | |
| 2259 come back at the right place. We can't look at s->visible to determine | |
| 2260 whether it is iconified because it might not be up-to-date yet (the queue | |
| 2261 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
|
2262 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
|
2263 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
|
2264 Xt_SET_ARG (al[2], XtNy, yoff); |
| 428 | 2265 XtSetValues (w, al, 3); |
| 2266 | |
| 2267 /* Sometimes you will find that | |
| 2268 | |
| 2269 (set-frame-position (selected-frame) -50 -50) | |
| 2270 | |
| 2271 doesn't put the frame where you expect it to: i.e. it's closer to | |
| 2272 the lower-right corner than it should be, and it appears that the | |
| 2273 size of the WM decorations was not taken into account. This is | |
| 2274 *not* a problem with this function. Both mwm and twm have bugs | |
| 2275 in handling this situation. (mwm ignores the window gravity and | |
| 2276 always assumes NorthWest, except the first time you map the | |
| 2277 window; twm gets things almost right, but forgets to account for | |
| 2278 the border width of the top-level window.) This function does | |
| 2279 what it's supposed to according to the ICCCM, and I'm not about | |
| 2280 to hack around window-manager bugs. */ | |
| 2281 | |
| 2282 #if 0 | |
| 2283 /* This is not necessary under either mwm or twm */ | |
| 2284 x_wm_mark_shell_position_user_specified (w); | |
| 2285 #endif | |
| 2286 } | |
| 2287 | |
| 2288 /* Call this to change the size of frame S's x-window. */ | |
| 2289 | |
| 2290 static void | |
| 2291 x_set_frame_size (struct frame *f, int cols, int rows) | |
| 2292 { | |
| 2293 EmacsFrameSetCharSize (FRAME_X_TEXT_WIDGET (f), cols, rows); | |
| 3381 | 2294 |
| 2295 if (!wedge_metacity) /* cf. EmacsFrameResize */ | |
| 2296 { | |
| 2297 /* Kick the manager so that it knows we've changed size. */ | |
| 2298 XtWidgetGeometry req, repl; | |
| 2299 req.request_mode = 0; | |
| 2300 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl); | |
| 2301 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), | |
| 2302 repl.width, repl.height); | |
| 2303 } | |
| 2304 | |
| 428 | 2305 #if 0 |
| 2306 /* this is not correct. x_set_frame_size() is called from | |
| 2307 Fset_frame_size(), which may or may not have been called | |
| 2308 by the user (e.g. update_EmacsFrame() calls it when the font | |
| 2309 changes). For now, don't bother with getting this right. */ | |
| 2310 x_wm_mark_shell_size_user_specified (FRAME_X_SHELL_WIDGET (f)); | |
| 2311 #endif | |
| 2312 } | |
| 2313 | |
| 2314 static void | |
| 2315 x_set_mouse_position (struct window *w, int x, int y) | |
| 2316 { | |
| 2317 struct frame *f = XFRAME (w->frame); | |
| 2318 | |
| 2319 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
| 2320 XWarpPointer (display, None, XtWindow (FRAME_X_TEXT_WIDGET (f)), | |
| 2321 0, 0, 0, 0, w->pixel_left + x, w->pixel_top + y); | |
| 2322 } | |
| 2323 | |
| 2324 static int | |
| 2325 x_get_mouse_position (struct device *d, Lisp_Object *frame, int *x, int *y) | |
| 2326 { | |
| 2327 Display *display = DEVICE_X_DISPLAY (d); | |
| 2328 Window child_window; | |
| 2329 Window root_window; | |
| 2330 Window win; | |
| 2331 int root_x, root_y; | |
| 2332 int win_x, win_y; | |
| 2333 unsigned int keys_and_buttons; | |
| 2334 struct frame *f; | |
| 2335 | |
| 2336 if (XQueryPointer (display, RootWindow (display, DefaultScreen (display)), | |
| 2337 &root_window, &child_window, &root_x, &root_y, | |
| 2338 &win_x, &win_y, &keys_and_buttons) == False) | |
| 2339 return 0; | |
| 2340 | |
| 2341 if (child_window == None) | |
| 2342 return 0; /* not over any window. */ | |
| 2343 | |
| 2344 while (1) | |
| 2345 { | |
| 2346 win = child_window; | |
| 2347 if (XTranslateCoordinates (display, root_window, win, root_x, root_y, | |
| 2348 &win_x, &win_y, &child_window) == False) | |
| 2349 /* Huh? */ | |
| 2350 return 0; | |
| 2351 | |
| 2352 if (child_window == None) | |
| 2353 break; | |
| 2354 } | |
| 2355 | |
| 2356 /* At this point, win is the innermost window containing the pointer | |
| 2357 and win_x and win_y are the coordinates of that window. */ | |
| 2358 f = x_any_window_to_frame (d, win); | |
| 2359 if (!f) | |
| 2360 return 0; | |
| 793 | 2361 *frame = wrap_frame (f); |
| 428 | 2362 |
| 2363 if (XTranslateCoordinates (display, win, | |
| 2364 XtWindow (FRAME_X_TEXT_WIDGET (f)), | |
| 2365 win_x, win_y, x, y, &child_window) == False) | |
| 2366 /* Huh? */ | |
| 2367 return 0; | |
| 2368 | |
| 2369 return 1; | |
| 2370 } | |
| 2371 | |
| 2268 | 2372 static DECLARE_DOESNT_RETURN (x_cant_notify_wm_error (void)); |
| 2373 | |
| 2374 static DOESNT_RETURN | |
| 2375 x_cant_notify_wm_error () | |
| 428 | 2376 { |
| 563 | 2377 signal_error (Qgui_error, "Can't notify window manager of iconification", Qunbound); |
| 428 | 2378 } |
| 2379 | |
| 2380 /* Raise frame F. */ | |
| 2381 static void | |
| 2382 x_raise_frame_1 (struct frame *f, int force) | |
| 2383 { | |
| 2384 if (FRAME_VISIBLE_P (f) || force) | |
| 2385 { | |
| 2386 Widget bottom_dialog; | |
| 2387 XWindowChanges xwc; | |
| 2388 unsigned int flags; | |
| 2389 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
| 2390 Window emacs_window = XtWindow (FRAME_X_SHELL_WIDGET (f)); | |
| 2391 | |
| 2392 /* first raises all the dialog boxes, then put emacs just below the | |
| 2393 * bottom most dialog box */ | |
| 2394 bottom_dialog = lw_raise_all_pop_up_widgets (); | |
| 2395 if (bottom_dialog && XtWindow (bottom_dialog)) | |
| 2396 { | |
| 2397 xwc.sibling = XtWindow (bottom_dialog); | |
| 2398 xwc.stack_mode = Below; | |
| 2399 flags = CWSibling | CWStackMode; | |
| 2400 } | |
| 2401 else | |
| 2402 { | |
| 2403 xwc.stack_mode = Above; | |
| 2404 flags = CWStackMode; | |
| 2405 } | |
| 2406 | |
| 2407 if (!XReconfigureWMWindow (display, emacs_window, | |
| 2408 DefaultScreen (display), | |
| 2409 flags, &xwc)) | |
| 2410 x_cant_notify_wm_error (); | |
| 2411 } | |
| 2412 } | |
| 2413 | |
| 2414 static void | |
| 2415 x_raise_frame (struct frame *f) | |
| 2416 { | |
| 2417 x_raise_frame_1 (f, 1); | |
| 2418 } | |
| 2419 | |
| 2420 /* Lower frame F. */ | |
| 2421 static void | |
| 2422 x_lower_frame (struct frame *f) | |
| 2423 { | |
| 2424 if (FRAME_VISIBLE_P (f)) | |
| 2425 { | |
| 2426 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
| 2427 XWindowChanges xwc; | |
| 2428 unsigned int flags = CWStackMode; | |
| 2429 | |
| 2430 xwc.stack_mode = Below; | |
| 2431 if (!XReconfigureWMWindow (display, XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
| 2432 DefaultScreen (display), flags, &xwc)) | |
| 2433 x_cant_notify_wm_error (); | |
| 2434 } | |
| 2435 } | |
| 2436 | |
| 442 | 2437 static void |
| 2438 x_enable_frame (struct frame *f) | |
| 2439 { | |
| 2440 XtSetSensitive (FRAME_X_SHELL_WIDGET (f), True); | |
| 2441 } | |
| 2442 | |
| 2443 static void | |
| 2444 x_disable_frame (struct frame *f) | |
| 2445 { | |
| 2446 XtSetSensitive (FRAME_X_SHELL_WIDGET (f), False); | |
| 2447 } | |
| 2448 | |
| 428 | 2449 /* Change from withdrawn state to mapped state. */ |
| 2450 static void | |
| 2451 x_make_frame_visible (struct frame *f) | |
| 2452 { | |
| 2453 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
| 2454 | |
| 2455 if (!FRAME_VISIBLE_P(f)) | |
| 2456 XMapRaised (display, XtWindow (FRAME_X_SHELL_WIDGET (f))); | |
| 2457 else | |
| 2458 x_raise_frame_1 (f, 0); | |
| 2459 } | |
| 2460 | |
| 2461 /* Change from mapped state to withdrawn state. */ | |
| 2462 static void | |
| 2463 x_make_frame_invisible (struct frame *f) | |
| 2464 { | |
| 2465 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
| 2466 | |
| 2467 if (!FRAME_VISIBLE_P(f)) | |
| 2468 return; | |
| 2469 | |
| 2470 if (!XWithdrawWindow (display, | |
| 2471 XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
| 2472 DefaultScreen (display))) | |
| 2473 x_cant_notify_wm_error (); | |
| 2474 } | |
| 2475 | |
| 2476 static int | |
| 2477 x_frame_visible_p (struct frame *f) | |
| 2478 { | |
| 2479 #if 0 | |
| 593 | 2480 |
| 2481 /* #### Ben suggests using x_frame_window_state (f) == NormalState. */ | |
| 2482 | |
| 428 | 2483 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); |
| 2484 XWindowAttributes xwa; | |
| 2485 int result; | |
| 2486 | |
| 2487 /* JV: | |
| 2488 This is bad, very bad :-( | |
| 2489 It is not compatible with our tristate visible and | |
| 2490 it should never ever change the visibility for us, this leads to | |
| 2491 the frame-freeze problem under fvwm because with the pager | |
| 2492 | |
| 2493 Mappedness != Viewability != Visibility != Emacs f->visible | |
| 2494 | |
| 2495 This first unequalness is the reason for the frame freezing problem | |
| 2496 under fvwm (it happens when the frame is another fvwm-page) | |
| 2497 | |
| 2498 The second unequalness happen when it is on the same fvwm-page | |
| 2499 but in an invisible part of the visible screen. | |
| 2500 | |
| 2501 For now we just return the XEmacs internal value --- which might not be up | |
| 2502 to date. Is that a problem? ---. Otherwise we should | |
| 2503 use async visibility like in standard Emacs. | |
| 2504 */ | |
| 2505 | |
| 2506 if (!XGetWindowAttributes (display, | |
| 2507 XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
| 2508 &xwa)) | |
| 2509 result = 0; | |
| 2510 else | |
| 2511 result = xwa.map_state == IsViewable; | |
| 2512 /* In this implementation it should at least be != IsUnmapped | |
| 2513 JV */ | |
| 2514 | |
| 2515 f->visible = result; | |
| 2516 return result; | |
| 2517 #endif /* 0 */ | |
| 2518 | |
| 2519 return f->visible; | |
| 2520 } | |
| 2521 | |
| 2522 static int | |
| 2523 x_frame_totally_visible_p (struct frame *f) | |
| 2524 { | |
| 2525 return FRAME_X_TOTALLY_VISIBLE_P (f); | |
| 2526 } | |
| 2527 | |
| 2528 /* Change window state from mapped to iconified. */ | |
| 2529 static void | |
| 2530 x_iconify_frame (struct frame *f) | |
| 2531 { | |
| 2532 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
| 2533 | |
| 2534 if (!XIconifyWindow (display, | |
| 2535 XtWindow (FRAME_X_SHELL_WIDGET (f)), | |
| 2536 DefaultScreen (display))) | |
| 2537 x_cant_notify_wm_error (); | |
| 2538 | |
| 2539 f->iconified = 1; | |
| 2540 } | |
| 2541 | |
| 2542 /* Sets the X focus to frame f. */ | |
| 2543 static void | |
| 2544 x_focus_on_frame (struct frame *f) | |
| 2545 { | |
| 2546 XWindowAttributes xwa; | |
| 2547 Widget shell_widget; | |
| 2548 int viewable = 0; | |
| 2549 | |
| 2550 assert (FRAME_X_P (f)); | |
| 2551 | |
| 2552 shell_widget = FRAME_X_SHELL_WIDGET (f); | |
| 2553 if (!XtWindow (shell_widget)) | |
| 2554 return; | |
| 2555 | |
| 2556 #ifdef EXTERNAL_WIDGET | |
| 2557 if (FRAME_X_EXTERNAL_WINDOW_P (f)) | |
| 2558 ExternalShellSetFocus (shell_widget); | |
| 2559 #endif /* EXTERNAL_WIDGET */ | |
| 2560 | |
| 2561 /* Do the ICCCM focus change if the window is still visible. | |
| 2562 The s->visible flag might not be up-to-date, because we might | |
| 2563 not have processed magic events recently. So make a server | |
| 2564 round-trip to find out whether it's really mapped right now. | |
| 2565 We grab the server to do this, because that's the only way to | |
| 2566 eliminate the race condition. | |
| 2567 */ | |
| 2568 XGrabServer (XtDisplay (shell_widget)); | |
| 2569 if (XGetWindowAttributes (XtDisplay (shell_widget), | |
| 2570 XtWindow (shell_widget), | |
| 2571 &xwa)) | |
| 2572 /* JV: it is bad to change the visibility like this, so we don't for the | |
| 2573 moment, at least change_frame_visibility should be called | |
| 2574 Note also that under fvwm a frame can be Viewable (and thus Mapped) | |
| 2575 but still X-invisible | |
| 2576 f->visible = xwa.map_state == IsViewable; */ | |
| 2577 viewable = xwa.map_state == IsViewable; | |
| 2578 | |
| 2579 | |
| 2580 if (viewable) | |
| 2581 { | |
| 2582 Window focus; | |
| 2583 int revert_to; | |
| 2584 XGetInputFocus (XtDisplay (shell_widget), &focus, &revert_to); | |
| 2585 /* Don't explicitly set the focus on this window unless the focus | |
| 2586 was on some other window (not PointerRoot). Note that, even when | |
| 2587 running a point-to-type window manager like *twm, there is always | |
| 2588 a focus window; the window manager maintains that based on the | |
| 2589 mouse position. If you set the "NoTitleFocus" option in these | |
| 2590 window managers, then the server itself maintains the focus via | |
| 2591 PointerRoot, and changing that to focus on the window would make | |
| 2592 the window grab the focus. Very bad. | |
| 2593 */ | |
| 2594 if (focus != PointerRoot) | |
| 2595 { | |
| 2596 XSetInputFocus (XtDisplay (shell_widget), | |
| 2597 XtWindow (shell_widget), | |
| 2598 RevertToParent, | |
| 4706 | 2599 CurrentTime); |
| 428 | 2600 XFlush (XtDisplay (shell_widget)); |
| 2601 } | |
| 2602 } | |
| 2603 XUngrabServer (XtDisplay (shell_widget)); | |
| 2604 XFlush (XtDisplay (shell_widget)); /* hey, I'd like to DEBUG this... */ | |
| 2605 } | |
| 2606 | |
| 450 | 2607 /* Destroy the X window of frame F. */ |
| 428 | 2608 static void |
| 2609 x_delete_frame (struct frame *f) | |
| 2610 { | |
| 2611 Display *dpy; | |
| 2612 | |
| 2613 #ifndef HAVE_WMCOMMAND | |
| 2614 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) | |
| 2615 x_wm_maybe_move_wm_command (f); | |
| 2616 #endif /* HAVE_WMCOMMAND */ | |
| 2617 | |
| 2618 #ifdef HAVE_CDE | |
| 2619 DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f)); | |
| 2620 #endif /* HAVE_CDE */ | |
| 2621 | |
|
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
2622 #ifdef HAVE_XFT |
| 3094 | 2623 /* If we have an XftDraw structure, we need to free it here. |
| 2624 We can't ever have an XftDraw without a Display, so we are safe | |
| 2625 to free it in here, and we avoid too much playing around with the | |
| 2626 malloc checking hooks this way. */ | |
| 2627 if (FRAME_X_XFTDRAW (f)) | |
| 2628 { | |
| 2629 XftDrawDestroy (FRAME_X_XFTDRAW (f)); | |
| 2630 FRAME_X_XFTDRAW (f) = NULL; | |
| 2631 } | |
| 2632 #endif | |
| 2633 | |
| 2634 | |
| 428 | 2635 assert (FRAME_X_SHELL_WIDGET (f) != 0); |
| 2636 dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f)); | |
| 2637 | |
| 2638 #ifdef EXTERNAL_WIDGET | |
| 1024 | 2639 expect_x_error (dpy); |
| 428 | 2640 /* for obscure reasons having (I think) to do with the internal |
| 2641 window-to-widget hierarchy maintained by Xt, we have to call | |
| 2642 XtUnrealizeWidget() here. Xt can really suck. */ | |
| 2643 if (f->being_deleted) | |
| 2644 XtUnrealizeWidget (FRAME_X_SHELL_WIDGET (f)); | |
| 2645 XtDestroyWidget (FRAME_X_SHELL_WIDGET (f)); | |
| 1024 | 2646 x_error_occurred_p (dpy); |
| 428 | 2647 #else |
| 2648 XtDestroyWidget (FRAME_X_SHELL_WIDGET (f)); | |
| 2649 /* make sure the windows are really gone! */ | |
| 440 | 2650 /* #### Is this REALLY necessary? */ |
| 428 | 2651 XFlush (dpy); |
| 2652 #endif /* EXTERNAL_WIDGET */ | |
| 2653 | |
| 2654 FRAME_X_SHELL_WIDGET (f) = 0; | |
| 2655 | |
| 2656 if (FRAME_X_GEOM_FREE_ME_PLEASE (f)) | |
| 2657 { | |
|
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
2658 xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f)); |
| 428 | 2659 FRAME_X_GEOM_FREE_ME_PLEASE (f) = 0; |
| 2660 } | |
| 2661 | |
| 2662 if (f->frame_data) | |
| 2663 { | |
| 4117 | 2664 #ifndef NEW_GC |
|
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
2665 xfree (f->frame_data); |
| 3092 | 2666 #endif /* not NEW_GC */ |
| 428 | 2667 f->frame_data = 0; |
| 2668 } | |
| 2669 } | |
| 2670 | |
| 2671 static void | |
| 2367 | 2672 x_update_frame_external_traits (struct frame *frm, Lisp_Object name) |
| 428 | 2673 { |
| 2674 Arg al[10]; | |
| 2675 int ac = 0; | |
| 793 | 2676 Lisp_Object frame = wrap_frame (frm); |
| 2677 | |
| 428 | 2678 |
| 2679 if (EQ (name, Qforeground)) | |
| 2680 { | |
| 2681 Lisp_Object color = FACE_FOREGROUND (Vdefault_face, frame); | |
| 2682 XColor fgc; | |
| 2683 | |
| 2684 if (!EQ (color, Vthe_null_color_instance)) | |
| 2685 { | |
| 2686 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
|
2687 Xt_SET_ARG (al[ac], XtNforeground, (void *) fgc.pixel); ac++; |
| 428 | 2688 } |
| 2689 } | |
| 2690 else if (EQ (name, Qbackground)) | |
| 2691 { | |
| 2692 Lisp_Object color = FACE_BACKGROUND (Vdefault_face, frame); | |
| 2693 XColor bgc; | |
| 2694 | |
| 2695 if (!EQ (color, Vthe_null_color_instance)) | |
| 2696 { | |
| 2697 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
|
2698 Xt_SET_ARG (al[ac], XtNbackground, (void *) bgc.pixel); ac++; |
| 428 | 2699 } |
| 2700 | |
| 2701 /* Really crappy way to force the modeline shadows to be | |
| 2702 redrawn. But effective. */ | |
| 2703 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (frm); | |
| 2704 MARK_FRAME_CHANGED (frm); | |
| 2705 } | |
| 2706 else if (EQ (name, Qfont)) | |
| 2707 { | |
| 2708 Lisp_Object font = FACE_FONT (Vdefault_face, frame, Vcharset_ascii); | |
| 2709 | |
| 3676 | 2710 /* It may be that instantiating the font has deleted the frame (will |
| 2711 happen if the user has specified a charset registry for ASCII that | |
| 2712 isn't available on the server, and our fallback of iso8859-1 isn't | |
| 2713 available; something vanishingly rare.) In that case, return from | |
| 2714 this function without further manipulation of the dead frame. */ | |
| 2715 | |
| 2716 if (!FRAME_LIVE_P(frm)) | |
| 2717 { | |
| 2718 return; | |
| 2719 } | |
| 2720 | |
| 3094 | 2721 /* #### what to do about Xft? I don't think the font is actually used |
| 2722 to compute cell size for computing frame pixel dimensions (see call | |
| 2723 to EmacsFrameRecomputeCellSize() below); where is it used? -- sjt | |
| 2724 What does XtSetValues() do if that resource isn't present? */ | |
| 428 | 2725 if (!EQ (font, Vthe_null_font_instance)) |
| 1746 | 2726 { |
| 3094 | 2727 if (0) |
| 2728 ; | |
|
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4790
diff
changeset
|
2729 #ifdef HAVE_XFT |
| 3094 | 2730 else if (FONT_INSTANCE_X_XFTFONT (XFONT_INSTANCE (font))) |
| 2731 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2732 Xt_SET_ARG (al[ac], XtNxftFont, |
| 3094 | 2733 (void *) FONT_INSTANCE_X_XFTFONT (XFONT_INSTANCE (font))); |
| 2734 ac++; | |
| 2735 } | |
| 2736 #endif | |
| 2737 else if (FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))) | |
| 2738 { | |
|
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2739 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
|
2740 (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))); |
| 3094 | 2741 ac++; |
| 2742 } | |
| 1746 | 2743 } |
| 428 | 2744 } |
| 2745 else | |
| 2500 | 2746 ABORT (); |
| 428 | 2747 |
| 2748 XtSetValues (FRAME_X_TEXT_WIDGET (frm), al, ac); | |
| 2749 | |
| 2750 #ifdef HAVE_TOOLBARS | |
| 2751 /* Setting the background clears the entire frame area | |
| 2752 including the toolbar so we force an immediate redraw of | |
| 2753 it. */ | |
| 2754 if (EQ (name, Qbackground)) | |
| 2755 MAYBE_DEVMETH (XDEVICE (frm->device), redraw_frame_toolbars, (frm)); | |
| 2756 #endif /* HAVE_TOOLBARS */ | |
| 2757 | |
| 2758 /* Set window manager resize increment hints according to | |
| 2759 the new character size */ | |
| 2760 if (EQ (name, Qfont)) | |
| 2761 EmacsFrameRecomputeCellSize (FRAME_X_TEXT_WIDGET (frm)); | |
| 2762 } | |
| 2763 | |
| 2764 | |
| 2765 /************************************************************************/ | |
| 2766 /* initialization */ | |
| 2767 /************************************************************************/ | |
| 2768 | |
| 2769 void | |
| 2770 syms_of_frame_x (void) | |
| 2771 { | |
| 3092 | 2772 #ifdef NEW_GC |
| 2773 INIT_LRECORD_IMPLEMENTATION (x_frame); | |
| 2774 #endif /* NEW_GC */ | |
| 2775 | |
| 2747 | 2776 DEFSYMBOL (Qoverride_redirect); |
| 563 | 2777 DEFSYMBOL (Qx_resource_name); |
| 428 | 2778 |
| 2779 DEFSUBR (Fx_window_id); | |
| 2780 #ifdef HAVE_CDE | |
| 2781 DEFSUBR (Fcde_start_drag_internal); | |
| 2782 #endif | |
| 2783 } | |
| 2784 | |
| 2785 void | |
| 2786 console_type_create_frame_x (void) | |
| 2787 { | |
| 2788 /* frame methods */ | |
| 2789 CONSOLE_HAS_METHOD (x, init_frame_1); | |
| 2790 CONSOLE_HAS_METHOD (x, init_frame_2); | |
| 2791 CONSOLE_HAS_METHOD (x, init_frame_3); | |
| 2792 CONSOLE_HAS_METHOD (x, mark_frame); | |
| 2793 CONSOLE_HAS_METHOD (x, focus_on_frame); | |
| 2794 CONSOLE_HAS_METHOD (x, delete_frame); | |
| 2795 CONSOLE_HAS_METHOD (x, get_mouse_position); | |
| 2796 CONSOLE_HAS_METHOD (x, set_mouse_position); | |
| 2797 CONSOLE_HAS_METHOD (x, raise_frame); | |
| 2798 CONSOLE_HAS_METHOD (x, lower_frame); | |
| 442 | 2799 CONSOLE_HAS_METHOD (x, enable_frame); |
| 2800 CONSOLE_HAS_METHOD (x, disable_frame); | |
| 428 | 2801 CONSOLE_HAS_METHOD (x, make_frame_visible); |
| 2802 CONSOLE_HAS_METHOD (x, make_frame_invisible); | |
| 2803 CONSOLE_HAS_METHOD (x, iconify_frame); | |
| 2804 CONSOLE_HAS_METHOD (x, set_frame_size); | |
| 2805 CONSOLE_HAS_METHOD (x, set_frame_position); | |
| 2806 CONSOLE_HAS_METHOD (x, frame_property); | |
| 2807 CONSOLE_HAS_METHOD (x, internal_frame_property_p); | |
| 2808 CONSOLE_HAS_METHOD (x, frame_properties); | |
| 2809 CONSOLE_HAS_METHOD (x, set_frame_properties); | |
| 867 | 2810 CONSOLE_HAS_METHOD (x, set_title_from_ibyte); |
| 2811 CONSOLE_HAS_METHOD (x, set_icon_name_from_ibyte); | |
| 428 | 2812 CONSOLE_HAS_METHOD (x, frame_visible_p); |
| 2813 CONSOLE_HAS_METHOD (x, frame_totally_visible_p); | |
| 2814 CONSOLE_HAS_METHOD (x, frame_iconified_p); | |
| 2815 CONSOLE_HAS_METHOD (x, set_frame_pointer); | |
| 2816 CONSOLE_HAS_METHOD (x, set_frame_icon); | |
| 2817 CONSOLE_HAS_METHOD (x, get_frame_parent); | |
| 2818 CONSOLE_HAS_METHOD (x, update_frame_external_traits); | |
| 2819 } | |
| 2820 | |
| 2821 void | |
| 2822 vars_of_frame_x (void) | |
| 2823 { | |
| 2824 #ifdef EXTERNAL_WIDGET | |
| 2825 Fprovide (intern ("external-widget")); | |
| 2826 #endif | |
| 2827 | |
| 2828 /* this call uses only safe functions from emacs.c */ | |
| 2829 init_x_prop_symbols (); | |
| 2830 | |
| 2831 DEFVAR_LISP ("default-x-frame-plist", &Vdefault_x_frame_plist /* | |
| 2832 Plist of default frame-creation properties for X frames. | |
| 2833 These override what is specified in the resource database and in | |
| 2834 `default-frame-plist', but are overridden by the arguments to the | |
| 2835 particular call to `make-frame'. | |
| 2836 | |
| 2837 Note: In many cases, properties of a frame are available as specifiers | |
| 2838 instead of through the frame-properties mechanism. | |
| 2839 | |
| 2840 Here is a list of recognized frame properties, other than those | |
| 2841 documented in `set-frame-properties' (they can be queried and | |
| 2842 set at any time, except as otherwise noted): | |
| 2843 | |
| 2844 window-id The X window ID corresponding to the | |
| 2845 frame. May be set only at startup, and | |
| 2846 only if external widget support was | |
| 2847 compiled in; doing so causes the frame | |
| 2848 to be created as an "external widget" | |
| 2849 in another program that uses an existing | |
| 2850 window in the program rather than creating | |
| 2851 a new one. | |
| 2852 initially-unmapped If non-nil, the frame will not be visible | |
| 2853 when it is created. In this case, you | |
| 2854 need to call `make-frame-visible' to make | |
| 2855 the frame appear. | |
| 2856 popup If non-nil, it should be a frame, and this | |
| 2857 frame will be created as a "popup" frame | |
| 2858 whose parent is the given frame. This | |
| 2859 will make the window manager treat the | |
| 2860 frame as a dialog box, which may entail | |
| 2861 doing different things (e.g. not asking | |
| 2862 for positioning, and not iconifying | |
| 2863 separate from its parent). | |
| 2747 | 2864 override-redirect If non-nil, the frame will not be subject to |
| 2865 window-manager control. In particular, it | |
| 2866 will lack decorations, for more attractive | |
| 2867 appearance of balloon help, aka tooltips. | |
| 428 | 2868 inter-line-space Not currently implemented. |
| 2869 toolbar-shadow-thickness Thickness of toolbar shadows. | |
| 2870 background-toolbar-color Color of toolbar background. | |
| 2871 bottom-toolbar-shadow-color Color of bottom shadows on toolbars. | |
| 2872 (*Not* specific to the bottom-toolbar.) | |
| 2873 top-toolbar-shadow-color Color of top shadows on toolbars. | |
| 2874 (*Not* specific to the top-toolbar.) | |
| 2875 internal-border-width Width of internal border around text area. | |
| 2876 border-width Width of external border around text area. | |
| 2877 top Y position (in pixels) of the upper-left | |
| 2878 outermost corner of the frame (i.e. the | |
| 2879 upper-left of the window-manager | |
| 2880 decorations). | |
| 2881 left X position (in pixels) of the upper-left | |
| 2882 outermost corner of the frame (i.e. the | |
| 2883 upper-left of the window-manager | |
| 2884 decorations). | |
| 2885 border-color Color of external border around text area. | |
| 2886 cursor-color Color of text cursor. | |
| 2887 | |
| 2888 See also `default-frame-plist', which specifies properties which apply | |
| 2889 to all frames, not just X frames. | |
| 2890 */ ); | |
| 2891 Vdefault_x_frame_plist = Qnil; | |
| 2892 | |
| 2893 x_console_methods->device_specific_frame_props = &Vdefault_x_frame_plist; | |
| 2894 } |
