Mercurial > hg > xemacs-beta
annotate src/frame.c @ 4985:358aa3bb603f
Automatic merge
| author | Ben Wing <ben@xemacs.org> |
|---|---|
| date | Fri, 05 Feb 2010 12:12:28 -0600 |
| parents | 16112448d484 |
| children | d0c14ea98592 6f2158fa75ed b5df3737028a |
| rev | line source |
|---|---|
| 428 | 1 /* Generic frame functions. |
| 2 Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | |
| 3025 | 3 Copyright (C) 1995, 1996, 2002, 2003, 2005 Ben Wing. |
| 428 | 4 Copyright (C) 1995 Sun Microsystems, Inc. |
| 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: FSF 19.30. */ | |
| 24 | |
| 25 /* This file has been Mule-ized. */ | |
| 26 | |
| 27 #include <config.h> | |
| 28 #include "lisp.h" | |
| 29 | |
| 30 #include "buffer.h" /* for Vbuffer_alist */ | |
| 31 #include "console.h" | |
| 872 | 32 #include "device-impl.h" |
| 428 | 33 #include "events.h" |
| 34 #include "extents.h" | |
| 35 #include "faces.h" | |
| 872 | 36 #include "frame-impl.h" |
| 428 | 37 #include "glyphs.h" |
| 38 #include "gutter.h" | |
| 39 #include "menubar.h" | |
| 2681 | 40 #include "process.h" /* for egetenv */ |
| 428 | 41 #include "redisplay.h" |
| 42 #include "scrollbar.h" | |
| 800 | 43 #include "toolbar.h" |
| 428 | 44 #include "window.h" |
| 45 | |
| 46 Lisp_Object Vselect_frame_hook, Qselect_frame_hook; | |
| 47 Lisp_Object Vdeselect_frame_hook, Qdeselect_frame_hook; | |
| 48 Lisp_Object Vcreate_frame_hook, Qcreate_frame_hook; | |
| 49 Lisp_Object Vdelete_frame_hook, Qdelete_frame_hook; | |
| 50 Lisp_Object Vmouse_enter_frame_hook, Qmouse_enter_frame_hook; | |
| 51 Lisp_Object Vmouse_leave_frame_hook, Qmouse_leave_frame_hook; | |
| 52 Lisp_Object Vmap_frame_hook, Qmap_frame_hook; | |
| 53 Lisp_Object Vunmap_frame_hook, Qunmap_frame_hook; | |
| 54 int allow_deletion_of_last_visible_frame; | |
| 55 Lisp_Object Vadjust_frame_function; | |
| 56 Lisp_Object Vmouse_motion_handler; | |
| 57 Lisp_Object Vsynchronize_minibuffers; | |
| 58 Lisp_Object Qsynchronize_minibuffers; | |
| 59 Lisp_Object Qbuffer_predicate; | |
| 60 Lisp_Object Qmake_initial_minibuffer_frame; | |
| 61 Lisp_Object Qcustom_initialize_frame; | |
| 62 | |
| 63 /* We declare all these frame properties here even though many of them | |
| 64 are currently only used in frame-x.c, because we should generalize | |
| 65 them. */ | |
| 66 | |
| 67 Lisp_Object Qminibuffer; | |
| 68 Lisp_Object Qunsplittable; | |
| 69 Lisp_Object Qinternal_border_width; | |
| 70 Lisp_Object Qtop_toolbar_shadow_color; | |
| 71 Lisp_Object Qbottom_toolbar_shadow_color; | |
| 72 Lisp_Object Qbackground_toolbar_color; | |
| 73 Lisp_Object Qtop_toolbar_shadow_pixmap; | |
| 74 Lisp_Object Qbottom_toolbar_shadow_pixmap; | |
| 75 Lisp_Object Qtoolbar_shadow_thickness; | |
| 76 Lisp_Object Qscrollbar_placement; | |
| 77 Lisp_Object Qinter_line_space; | |
| 78 Lisp_Object Qvisual_bell; | |
| 79 Lisp_Object Qbell_volume; | |
| 80 Lisp_Object Qpointer_background; | |
| 81 Lisp_Object Qpointer_color; | |
| 82 Lisp_Object Qtext_pointer; | |
| 83 Lisp_Object Qspace_pointer; | |
| 84 Lisp_Object Qmodeline_pointer; | |
| 85 Lisp_Object Qgc_pointer; | |
| 86 Lisp_Object Qinitially_unmapped; | |
| 87 Lisp_Object Quse_backing_store; | |
| 88 Lisp_Object Qborder_color; | |
| 89 Lisp_Object Qborder_width; | |
| 90 | |
| 91 Lisp_Object Qframep, Qframe_live_p; | |
| 92 Lisp_Object Qdelete_frame; | |
| 93 | |
| 94 Lisp_Object Qframe_title_format, Vframe_title_format; | |
| 95 Lisp_Object Qframe_icon_title_format, Vframe_icon_title_format; | |
| 96 | |
| 97 Lisp_Object Vdefault_frame_name; | |
| 98 Lisp_Object Vdefault_frame_plist; | |
| 99 | |
| 100 Lisp_Object Vframe_icon_glyph; | |
| 101 | |
| 102 Lisp_Object Qhidden; | |
| 103 | |
| 104 Lisp_Object Qvisible, Qiconic, Qinvisible, Qvisible_iconic, Qinvisible_iconic; | |
| 105 Lisp_Object Qnomini, Qvisible_nomini, Qiconic_nomini, Qinvisible_nomini; | |
| 106 Lisp_Object Qvisible_iconic_nomini, Qinvisible_iconic_nomini; | |
| 107 | |
| 442 | 108 Lisp_Object Qset_specifier, Qset_face_property; |
| 428 | 109 Lisp_Object Qface_property_instance; |
| 110 | |
| 111 Lisp_Object Qframe_property_alias; | |
| 112 | |
| 113 /* If this is non-nil, it is the frame that make-frame is currently | |
| 114 creating. We can't set the current frame to this in case the | |
| 115 debugger goes off because it would try and display to it. However, | |
| 116 there are some places which need to reference it which have no | |
| 117 other way of getting it if it isn't the selected frame. */ | |
| 118 Lisp_Object Vframe_being_created; | |
| 119 Lisp_Object Qframe_being_created; | |
| 120 | |
| 121 static void store_minibuf_frame_prop (struct frame *f, Lisp_Object val); | |
| 1125 | 122 |
| 123 typedef enum { | |
| 124 DISPLAYABLE_PIXEL_TO_CHAR, | |
| 125 TOTAL_PIXEL_TO_CHAR, | |
| 126 CHAR_TO_TOTAL_PIXEL, | |
| 1429 | 127 CHAR_TO_DISPLAYABLE_PIXEL |
| 1125 | 128 } pixel_to_char_mode_t; |
| 129 | |
| 130 static void frame_conversion_internal (struct frame *f, | |
| 131 pixel_to_char_mode_t pixel_to_char, | |
| 863 | 132 int *pixel_width, int *pixel_height, |
| 133 int *char_width, int *char_height, | |
| 134 int real_face); | |
| 438 | 135 static struct display_line title_string_display_line; |
| 136 /* Used by generate_title_string. Global because they get used so much that | |
| 137 the dynamic allocation time adds up. */ | |
| 867 | 138 static Ichar_dynarr *title_string_ichar_dynarr; |
| 428 | 139 |
| 140 | |
| 1204 | 141 |
| 3092 | 142 #ifndef NEW_GC |
| 1204 | 143 extern const struct sized_memory_description gtk_frame_data_description; |
| 144 extern const struct sized_memory_description mswindows_frame_data_description; | |
| 145 extern const struct sized_memory_description x_frame_data_description; | |
| 3092 | 146 #endif /* not NEW_GC */ |
| 1204 | 147 |
| 148 static const struct memory_description frame_data_description_1 []= { | |
| 3092 | 149 #ifdef NEW_GC |
| 150 #ifdef HAVE_GTK | |
| 151 { XD_LISP_OBJECT, gtk_console }, | |
| 152 #endif | |
| 153 #ifdef HAVE_MS_WINDOWS | |
| 154 { XD_LISP_OBJECT, mswindows_console }, | |
| 155 #endif | |
| 156 #ifdef HAVE_X_WINDOWS | |
| 157 { XD_LISP_OBJECT, x_console }, | |
| 158 #endif | |
| 159 #else /* not NEW_GC */ | |
| 1204 | 160 #ifdef HAVE_GTK |
| 2551 | 161 { XD_BLOCK_PTR, gtk_console, 1, { >k_frame_data_description} }, |
| 1204 | 162 #endif |
| 163 #ifdef HAVE_MS_WINDOWS | |
| 2551 | 164 { XD_BLOCK_PTR, mswindows_console, 1, { &mswindows_frame_data_description} }, |
| 1204 | 165 #endif |
| 166 #ifdef HAVE_X_WINDOWS | |
| 2551 | 167 { XD_BLOCK_PTR, x_console, 1, { &x_frame_data_description} }, |
| 1204 | 168 #endif |
| 3092 | 169 #endif /* not NEW_GC */ |
| 1204 | 170 { XD_END } |
| 171 }; | |
| 172 | |
| 173 static const struct sized_memory_description frame_data_description = { | |
| 174 sizeof (void *), frame_data_description_1 | |
| 175 }; | |
| 176 | |
| 3092 | 177 #ifdef NEW_GC |
| 178 static const struct memory_description expose_ignore_description_1 [] = { | |
| 179 { XD_LISP_OBJECT, offsetof (struct expose_ignore, next) }, | |
| 180 { XD_END } | |
| 181 }; | |
| 182 | |
| 4207 | 183 DEFINE_LRECORD_IMPLEMENTATION ("expose-ignore", |
| 3092 | 184 expose_ignore, |
| 185 1, /*dumpable-flag*/ | |
| 4207 | 186 0, 0, 0, 0, 0, |
| 3092 | 187 expose_ignore_description_1, |
| 188 struct expose_ignore); | |
| 189 #else /* not NEW_GC */ | |
| 1204 | 190 extern const struct sized_memory_description expose_ignore_description; |
| 191 | |
| 192 static const struct memory_description expose_ignore_description_1 [] = { | |
| 2367 | 193 { XD_BLOCK_PTR, offsetof (struct expose_ignore, next), |
| 2551 | 194 1, { &expose_ignore_description } }, |
| 1204 | 195 { XD_END } |
| 196 }; | |
| 197 | |
| 198 const struct sized_memory_description expose_ignore_description = { | |
| 199 sizeof (struct expose_ignore), | |
| 200 expose_ignore_description_1 | |
| 201 }; | |
| 3092 | 202 #endif /* not NEW_GC */ |
| 1204 | 203 |
| 204 static const struct memory_description display_line_dynarr_pointer_description_1 []= { | |
| 2551 | 205 { XD_BLOCK_PTR, 0, 1, { &display_line_dynarr_description} }, |
| 1204 | 206 { XD_END } |
| 207 }; | |
| 208 | |
| 209 static const struct sized_memory_description display_line_dynarr_pointer_description = { | |
| 210 sizeof (display_line_dynarr *), display_line_dynarr_pointer_description_1 | |
| 211 }; | |
| 212 | |
| 213 static const struct memory_description frame_description [] = { | |
| 214 { XD_INT, offsetof (struct frame, frametype) }, | |
| 215 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (struct frame, x) }, | |
| 216 #define MARKED_SLOT_ARRAY(slot, size) \ | |
| 217 { XD_LISP_OBJECT_ARRAY, offsetof (struct frame, slot), size }, | |
| 218 #include "frameslots.h" | |
| 219 | |
| 3092 | 220 #ifdef NEW_GC |
| 221 { XD_LISP_OBJECT, offsetof (struct frame, subwindow_exposures) }, | |
| 222 { XD_LISP_OBJECT, offsetof (struct frame, subwindow_exposures_tail) }, | |
| 223 #else /* not NEW_GC */ | |
| 2367 | 224 { XD_BLOCK_PTR, offsetof (struct frame, subwindow_exposures), |
| 2551 | 225 1, { &expose_ignore_description } }, |
| 2367 | 226 { XD_BLOCK_PTR, offsetof (struct frame, subwindow_exposures_tail), |
| 2551 | 227 1, { &expose_ignore_description } }, |
| 3092 | 228 #endif /* not NEW_GC */ |
| 1204 | 229 |
| 230 #ifdef HAVE_SCROLLBARS | |
| 231 { XD_LISP_OBJECT, offsetof (struct frame, sb_vcache) }, | |
| 232 { XD_LISP_OBJECT, offsetof (struct frame, sb_hcache) }, | |
| 233 #endif /* HAVE_SCROLLBARS */ | |
| 234 | |
| 2367 | 235 { XD_BLOCK_ARRAY, offsetof (struct frame, current_display_lines), |
| 2551 | 236 4, { &display_line_dynarr_pointer_description } }, |
| 2367 | 237 { XD_BLOCK_ARRAY, offsetof (struct frame, desired_display_lines), |
| 2551 | 238 4, { &display_line_dynarr_pointer_description } }, |
| 1204 | 239 |
| 2367 | 240 { XD_BLOCK_PTR, offsetof (struct frame, framemeths), 1, |
| 2551 | 241 { &console_methods_description } }, |
| 4207 | 242 { XD_UNION, offsetof (struct frame, frame_data), |
| 2551 | 243 XD_INDIRECT (0, 0), { &frame_data_description } }, |
| 1204 | 244 { XD_END } |
| 245 }; | |
| 246 | |
| 428 | 247 static Lisp_Object |
| 248 mark_frame (Lisp_Object obj) | |
| 249 { | |
| 250 struct frame *f = XFRAME (obj); | |
| 251 | |
| 1204 | 252 #define MARKED_SLOT(x) mark_object (f->x); |
| 428 | 253 #include "frameslots.h" |
| 254 | |
| 255 if (FRAME_LIVE_P (f)) /* device is nil for a dead frame */ | |
| 256 MAYBE_FRAMEMETH (f, mark_frame, (f)); | |
| 257 | |
| 617 | 258 #ifdef HAVE_SCROLLBARS |
| 259 if (f->sb_vcache) | |
| 260 mark_object (wrap_scrollbar_instance (f->sb_vcache)); | |
| 261 if (f->sb_hcache) | |
| 262 mark_object (wrap_scrollbar_instance (f->sb_hcache)); | |
| 263 #endif | |
| 264 | |
| 265 mark_gutters (f); | |
| 266 | |
| 428 | 267 return Qnil; |
| 268 } | |
| 269 | |
| 270 static void | |
| 2286 | 271 print_frame (Lisp_Object obj, Lisp_Object printcharfun, |
| 272 int UNUSED (escapeflag)) | |
| 428 | 273 { |
| 274 struct frame *frm = XFRAME (obj); | |
| 275 | |
| 276 if (print_readably) | |
| 4846 | 277 printing_unreadable_lcrecord (obj, XSTRING_DATA (frm->name)); |
| 428 | 278 |
| 800 | 279 write_fmt_string (printcharfun, "#<%s-frame ", !FRAME_LIVE_P (frm) ? "dead" : |
| 280 FRAME_TYPE_NAME (frm)); | |
| 428 | 281 print_internal (frm->name, printcharfun, 1); |
| 800 | 282 write_fmt_string (printcharfun, " 0x%x>", frm->header.uid); |
| 428 | 283 } |
| 284 | |
| 934 | 285 DEFINE_LRECORD_IMPLEMENTATION ("frame", frame, |
| 286 0, /*dumpable-flag*/ | |
| 4207 | 287 mark_frame, print_frame, 0, 0, 0, |
| 1204 | 288 frame_description, |
| 934 | 289 struct frame); |
| 428 | 290 |
| 291 static void | |
| 292 nuke_all_frame_slots (struct frame *f) | |
| 293 { | |
| 3017 | 294 ZERO_LCRECORD (f); |
| 617 | 295 |
| 1204 | 296 #define MARKED_SLOT(x) f->x = Qnil; |
| 428 | 297 #include "frameslots.h" |
| 298 } | |
| 299 | |
| 300 /* Allocate a new frame object and set all its fields to reasonable | |
| 301 values. The root window is created but the minibuffer will be done | |
| 302 later. */ | |
| 303 | |
| 304 static struct frame * | |
| 305 allocate_frame_core (Lisp_Object device) | |
| 306 { | |
| 307 /* This function can GC */ | |
| 308 Lisp_Object frame; | |
| 309 Lisp_Object root_window; | |
| 3017 | 310 struct frame *f = ALLOC_LCRECORD_TYPE (struct frame, &lrecord_frame); |
| 428 | 311 |
| 312 nuke_all_frame_slots (f); | |
| 793 | 313 frame = wrap_frame (f); |
| 428 | 314 |
| 315 f->device = device; | |
| 316 f->framemeths = XDEVICE (device)->devmeths; | |
| 1204 | 317 f->frametype = get_console_variant (XDEVICE_TYPE (device)); |
| 428 | 318 f->buffer_alist = Fcopy_sequence (Vbuffer_alist); |
| 319 | |
| 320 root_window = allocate_window (); | |
| 321 XWINDOW (root_window)->frame = frame; | |
| 322 | |
| 323 /* 10 is arbitrary, | |
| 324 Just so that there is "something there." | |
| 325 Correct size will be set up later with change_frame_size. */ | |
| 326 | |
| 327 f->width = 10; | |
| 328 f->height = 10; | |
| 329 | |
| 330 XWINDOW (root_window)->pixel_width = 10; | |
| 331 XWINDOW (root_window)->pixel_height = 9; | |
| 332 | |
| 333 f->root_window = root_window; | |
| 334 f->selected_window = root_window; | |
| 335 f->last_nonminibuf_window = root_window; | |
| 336 | |
| 337 /* cache of subwindows visible on frame */ | |
| 442 | 338 f->subwindow_instance_cache = make_weak_list (WEAK_LIST_SIMPLE); |
| 428 | 339 |
| 340 /* associated exposure ignore list */ | |
| 341 f->subwindow_exposures = 0; | |
| 342 f->subwindow_exposures_tail = 0; | |
| 343 | |
| 442 | 344 FRAME_SET_PAGENUMBER (f, 1); |
| 345 | |
| 853 | 346 note_object_created (root_window); |
| 347 | |
| 428 | 348 /* Choose a buffer for the frame's root window. */ |
| 349 XWINDOW (root_window)->buffer = Qt; | |
| 350 { | |
| 351 Lisp_Object buf; | |
| 352 | |
| 353 buf = Fcurrent_buffer (); | |
| 354 /* If buf is a 'hidden' buffer (i.e. one whose name starts with | |
| 355 a space), try to find another one. */ | |
| 867 | 356 if (string_ichar (Fbuffer_name (buf), 0) == ' ') |
| 428 | 357 buf = Fother_buffer (buf, Qnil, Qnil); |
| 440 | 358 Fset_window_buffer (root_window, buf, Qnil); |
| 428 | 359 } |
| 360 | |
| 361 return f; | |
| 362 } | |
| 363 | |
| 364 static void | |
| 365 setup_normal_frame (struct frame *f) | |
| 366 { | |
| 367 Lisp_Object mini_window; | |
| 793 | 368 Lisp_Object frame = wrap_frame (f); |
| 369 | |
| 428 | 370 |
| 371 mini_window = allocate_window (); | |
| 372 XWINDOW (f->root_window)->next = mini_window; | |
| 373 XWINDOW (mini_window)->prev = f->root_window; | |
| 374 XWINDOW (mini_window)->mini_p = Qt; | |
| 375 XWINDOW (mini_window)->frame = frame; | |
| 376 f->minibuffer_window = mini_window; | |
| 377 f->has_minibuffer = 1; | |
| 378 | |
| 853 | 379 note_object_created (mini_window); |
| 380 | |
| 428 | 381 XWINDOW (mini_window)->buffer = Qt; |
| 440 | 382 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); |
| 428 | 383 } |
| 384 | |
| 385 /* Make a frame using a separate minibuffer window on another frame. | |
| 386 MINI_WINDOW is the minibuffer window to use. nil means use the | |
| 387 default-minibuffer-frame. */ | |
| 388 | |
| 389 static void | |
| 390 setup_frame_without_minibuffer (struct frame *f, Lisp_Object mini_window) | |
| 391 { | |
| 392 /* This function can GC */ | |
| 393 Lisp_Object device = f->device; | |
| 394 | |
| 395 if (!NILP (mini_window)) | |
| 396 CHECK_LIVE_WINDOW (mini_window); | |
| 397 | |
| 398 if (!NILP (mini_window) | |
| 399 && !EQ (DEVICE_CONSOLE (XDEVICE (device)), | |
| 400 FRAME_CONSOLE (XFRAME (XWINDOW (mini_window)->frame)))) | |
| 563 | 401 invalid_argument ("frame and minibuffer must be on the same console", Qunbound); |
| 428 | 402 |
| 442 | 403 /* Do not create a default minibuffer frame on printer devices. */ |
| 404 if (NILP (mini_window) | |
| 405 && DEVICE_DISPLAY_P (XDEVICE (FRAME_DEVICE (f)))) | |
| 428 | 406 { |
| 407 struct console *con = XCONSOLE (FRAME_CONSOLE (f)); | |
| 408 /* Use default-minibuffer-frame if possible. */ | |
| 409 if (!FRAMEP (con->default_minibuffer_frame) | |
| 410 || ! FRAME_LIVE_P (XFRAME (con->default_minibuffer_frame))) | |
| 411 { | |
| 412 /* If there's no minibuffer frame to use, create one. */ | |
| 413 con->default_minibuffer_frame | |
| 414 = call1 (Qmake_initial_minibuffer_frame, device); | |
| 415 } | |
| 416 mini_window = XFRAME (con->default_minibuffer_frame)->minibuffer_window; | |
| 417 } | |
| 418 | |
| 419 /* Install the chosen minibuffer window, with proper buffer. */ | |
| 442 | 420 if (!NILP (mini_window)) |
| 421 { | |
| 422 store_minibuf_frame_prop (f, mini_window); | |
| 423 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); | |
| 424 } | |
| 425 else | |
| 426 f->minibuffer_window = Qnil; | |
| 428 | 427 } |
| 428 | |
| 429 /* Make a frame containing only a minibuffer window. */ | |
| 430 | |
| 431 static void | |
| 432 setup_minibuffer_frame (struct frame *f) | |
| 433 { | |
| 434 /* This function can GC */ | |
| 435 /* First make a frame containing just a root window, no minibuffer. */ | |
| 436 Lisp_Object mini_window; | |
| 793 | 437 Lisp_Object frame = wrap_frame (f); |
| 438 | |
| 428 | 439 |
| 440 f->no_split = 1; | |
| 441 f->has_minibuffer = 1; | |
| 442 | |
| 443 /* Now label the root window as also being the minibuffer. | |
| 444 Avoid infinite looping on the window chain by marking next pointer | |
| 445 as nil. */ | |
| 446 | |
| 447 mini_window = f->minibuffer_window = f->root_window; | |
| 448 XWINDOW (mini_window)->mini_p = Qt; | |
| 449 XWINDOW (mini_window)->next = Qnil; | |
| 450 XWINDOW (mini_window)->prev = Qnil; | |
| 451 XWINDOW (mini_window)->frame = frame; | |
| 452 | |
| 453 /* Put the proper buffer in that window. */ | |
| 454 | |
| 440 | 455 Fset_window_buffer (mini_window, Vminibuffer_zero, Qt); |
| 428 | 456 } |
| 457 | |
| 458 static Lisp_Object | |
| 459 make_sure_its_a_fresh_plist (Lisp_Object foolist) | |
| 460 { | |
| 461 if (CONSP (Fcar (foolist))) | |
| 462 { | |
| 463 /* looks like an alist to me. */ | |
| 464 foolist = Fcopy_alist (foolist); | |
| 465 foolist = Fdestructive_alist_to_plist (foolist); | |
| 466 } | |
| 467 else | |
| 468 foolist = Fcopy_sequence (foolist); | |
| 469 | |
| 470 return foolist; | |
| 471 } | |
| 472 | |
| 558 | 473 static Lisp_Object |
| 546 | 474 restore_frame_list_to_its_unbesmirched_state (Lisp_Object kawnz) |
| 475 { | |
| 476 Lisp_Object lissed = XCDR (kawnz); | |
| 477 if (!EQ (lissed, Qunbound)) | |
| 478 DEVICE_FRAME_LIST (XDEVICE (XCAR (kawnz))) = lissed; | |
| 479 return Qnil; | |
| 4207 | 480 } |
| 546 | 481 |
| 428 | 482 DEFUN ("make-frame", Fmake_frame, 0, 2, "", /* |
| 483 Create and return a new frame, displaying the current buffer. | |
| 484 Runs the functions listed in `create-frame-hook' after frame creation. | |
| 485 | |
| 486 Optional argument PROPS is a property list (a list of alternating | |
| 487 keyword-value specifications) of properties for the new frame. | |
| 488 \(An alist is accepted for backward compatibility but should not | |
| 489 be passed in.) | |
| 490 | |
| 491 See `set-frame-properties', `default-x-frame-plist', and | |
| 492 `default-tty-frame-plist' for the specially-recognized properties. | |
| 493 */ | |
| 494 (props, device)) | |
| 495 { | |
| 496 struct frame *f; | |
| 497 struct device *d; | |
| 498 Lisp_Object frame = Qnil, name = Qnil, minibuf; | |
| 499 struct gcpro gcpro1, gcpro2, gcpro3; | |
| 546 | 500 int speccount = specpdl_depth (), speccount2; |
| 428 | 501 int first_frame_on_device = 0; |
| 502 int first_frame_on_console = 0; | |
| 546 | 503 Lisp_Object besmirched_cons = Qnil; |
| 771 | 504 int frame_name_is_defaulted = 1; |
| 428 | 505 |
| 506 d = decode_device (device); | |
| 793 | 507 device = wrap_device (d); |
| 428 | 508 |
| 509 /* PROPS and NAME may be freshly-created, so make sure to GCPRO. */ | |
| 510 GCPRO3 (frame, props, name); | |
| 511 | |
| 512 props = make_sure_its_a_fresh_plist (props); | |
| 513 if (DEVICE_SPECIFIC_FRAME_PROPS (d)) | |
| 514 /* Put the device-specific props before the more general ones so | |
| 515 that they override them. */ | |
| 516 props = nconc2 (props, | |
| 517 make_sure_its_a_fresh_plist | |
| 518 (*DEVICE_SPECIFIC_FRAME_PROPS (d))); | |
| 519 props = nconc2 (props, make_sure_its_a_fresh_plist (Vdefault_frame_plist)); | |
| 520 Fcanonicalize_lax_plist (props, Qnil); | |
| 521 | |
| 522 name = Flax_plist_get (props, Qname, Qnil); | |
| 523 if (!NILP (name)) | |
| 771 | 524 { |
| 525 CHECK_STRING (name); | |
| 526 frame_name_is_defaulted = 0; | |
| 527 } | |
| 2681 | 528 else if (!initialized) |
| 529 { | |
| 530 /* We leave Vdefault_frame_name alone here so that it'll remain Qnil | |
| 531 in the dumped executable, and we can choose it at runtime. */ | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
532 name = build_ascstring ("XEmacs"); |
| 2681 | 533 } |
| 4207 | 534 else if (NILP (Vdefault_frame_name)) |
| 535 { | |
| 2681 | 536 if (egetenv ("USE_EMACS_AS_DEFAULT_APPLICATION_CLASS")) |
| 537 { | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
538 Vdefault_frame_name = build_ascstring ("emacs"); |
| 2681 | 539 } |
| 4207 | 540 else |
| 2681 | 541 { |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
542 Vdefault_frame_name = build_ascstring ("XEmacs"); |
| 2681 | 543 } |
| 544 } | |
| 545 | |
| 546 if (NILP(name) && STRINGP(Vdefault_frame_name)) | |
| 547 { | |
| 548 name = Vdefault_frame_name; | |
| 549 } | |
| 428 | 550 |
| 867 | 551 if (!NILP (Fstring_match (make_string ((const Ibyte *) "\\.", 2), name, |
| 428 | 552 Qnil, Qnil))) |
| 563 | 553 syntax_error (". not allowed in frame names", name); |
| 428 | 554 |
| 555 f = allocate_frame_core (device); | |
| 793 | 556 frame = wrap_frame (f); |
| 428 | 557 |
| 558 specbind (Qframe_being_created, name); | |
| 559 f->name = name; | |
| 560 | |
| 771 | 561 FRAMEMETH (f, init_frame_1, (f, props, frame_name_is_defaulted)); |
| 428 | 562 |
| 563 minibuf = Flax_plist_get (props, Qminibuffer, Qunbound); | |
| 564 if (UNBOUNDP (minibuf)) | |
| 565 { | |
| 566 /* If minibuf is unspecified, then look for a minibuffer X resource. */ | |
| 567 /* #### Not implemented any more. We need to fix things up so | |
| 568 that we search out all X resources and append them to the end of | |
| 569 props, above. This is the only way in general to assure | |
| 570 coherent behavior for all frame properties/resources/etc. */ | |
| 571 } | |
| 572 else | |
| 573 props = Flax_plist_remprop (props, Qminibuffer); | |
| 574 | |
| 575 if (EQ (minibuf, Qnone) || NILP (minibuf)) | |
| 576 setup_frame_without_minibuffer (f, Qnil); | |
| 577 else if (EQ (minibuf, Qonly)) | |
| 578 setup_minibuffer_frame (f); | |
| 579 else if (WINDOWP (minibuf)) | |
| 580 setup_frame_without_minibuffer (f, minibuf); | |
| 581 else if (EQ (minibuf, Qt) || UNBOUNDP (minibuf)) | |
| 582 setup_normal_frame (f); | |
| 583 else | |
| 563 | 584 invalid_argument ("Invalid value for `minibuffer'", minibuf); |
| 428 | 585 |
| 586 update_frame_window_mirror (f); | |
| 587 | |
| 4968 | 588 /* #### Do we need to be calling reset_face_cachels here, and then again |
| 589 down below? */ | |
| 428 | 590 if (initialized && !DEVICE_STREAM_P (d)) |
| 591 { | |
| 592 if (!NILP (f->minibuffer_window)) | |
| 4207 | 593 reset_face_cachels (XWINDOW (f->minibuffer_window)); |
| 428 | 594 reset_face_cachels (XWINDOW (f->root_window)); |
| 595 } | |
| 596 | |
| 597 /* If no frames on this device formerly existed, say this is the | |
| 598 first frame. It kind of assumes that frameless devices don't | |
| 599 exist, but it shouldn't be too harmful. */ | |
| 600 if (NILP (DEVICE_FRAME_LIST (d))) | |
| 601 first_frame_on_device = 1; | |
| 602 | |
| 546 | 603 /* It's possible for one of the init methods below to signal an error; |
| 604 in that case, let's make sure the device isn't besmirched by | |
| 605 having a half-initialized frame attached to it */ | |
| 606 speccount2 = specpdl_depth (); | |
| 607 record_unwind_protect (restore_frame_list_to_its_unbesmirched_state, | |
| 608 besmirched_cons = | |
| 609 Fcons (device, DEVICE_FRAME_LIST (d))); | |
| 610 | |
| 428 | 611 /* This *must* go before the init_*() methods. Those functions |
| 612 call Lisp code, and if any of them causes a warning to be displayed | |
| 613 and the *Warnings* buffer to be created, it won't get added to | |
| 614 the frame-specific version of the buffer-alist unless the frame | |
| 615 is accessible from the device. */ | |
| 616 | |
| 617 #if 0 | |
| 618 DEVICE_FRAME_LIST (d) = nconc2 (DEVICE_FRAME_LIST (d), Fcons (frame, Qnil)); | |
| 619 #endif | |
| 620 DEVICE_FRAME_LIST (d) = Fcons (frame, DEVICE_FRAME_LIST (d)); | |
| 621 RESET_CHANGED_SET_FLAGS; | |
| 622 | |
| 853 | 623 note_object_created (frame); |
| 624 | |
| 428 | 625 /* Now make sure that the initial cached values are set correctly. |
| 626 Do this after the init_frame method is called because that may | |
| 627 do things (e.g. create widgets) that are necessary for the | |
| 628 specifier value-changed methods to work OK. */ | |
| 629 recompute_all_cached_specifiers_in_frame (f); | |
| 630 | |
| 631 if (!DEVICE_STREAM_P (d)) | |
| 632 { | |
| 633 init_frame_faces (f); | |
| 634 | |
| 635 #ifdef HAVE_SCROLLBARS | |
| 636 /* Finish up resourcing the scrollbars. */ | |
| 637 init_frame_scrollbars (f); | |
| 638 #endif | |
| 639 | |
| 640 #ifdef HAVE_TOOLBARS | |
| 641 /* Create the initial toolbars. We have to do this after the frame | |
| 642 methods are called because it may potentially call some things itself | |
| 643 which depend on the normal frame methods having initialized | |
| 644 things. */ | |
| 645 init_frame_toolbars (f); | |
| 646 #endif | |
| 4968 | 647 /* Added this assert recently (2-1-10); seems there should be only |
| 648 two windows, root and minibufer. Probably we should just be | |
| 649 calling reset_*_cachels on the root window directly instead of the | |
| 650 selected window, but I want to make sure they are always the | |
| 651 same. --ben */ | |
| 652 assert (EQ (FRAME_SELECTED_WINDOW (f), f->root_window)); | |
| 428 | 653 reset_face_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); |
| 654 reset_glyph_cachels (XWINDOW (FRAME_SELECTED_WINDOW (f))); | |
| 4968 | 655 if (!NILP (f->minibuffer_window)) |
| 656 { | |
| 657 reset_face_cachels (XWINDOW (f->minibuffer_window)); | |
| 658 reset_glyph_cachels (XWINDOW (f->minibuffer_window)); | |
| 659 } | |
| 442 | 660 |
| 428 | 661 change_frame_size (f, f->height, f->width, 0); |
| 662 } | |
| 663 | |
| 664 MAYBE_FRAMEMETH (f, init_frame_2, (f, props)); | |
| 665 Fset_frame_properties (frame, props); | |
| 666 MAYBE_FRAMEMETH (f, init_frame_3, (f)); | |
| 667 | |
| 668 /* Hallelujah, praise the lord. */ | |
| 669 f->init_finished = 1; | |
| 670 | |
| 546 | 671 XCDR (besmirched_cons) = Qunbound; |
| 672 | |
| 771 | 673 unbind_to (speccount2); |
| 546 | 674 |
| 428 | 675 /* If this is the first frame on the device, make it the selected one. */ |
| 676 if (first_frame_on_device && NILP (DEVICE_SELECTED_FRAME (d))) | |
| 677 set_device_selected_frame (d, frame); | |
| 678 | |
| 679 /* If at startup or if the current console is a stream console | |
| 680 (usually also at startup), make this console the selected one | |
| 681 so that messages show up on it. */ | |
| 682 if (NILP (Fselected_console ()) || | |
| 683 CONSOLE_STREAM_P (XCONSOLE (Fselected_console ()))) | |
| 684 Fselect_console (DEVICE_CONSOLE (d)); | |
| 685 | |
| 686 first_frame_on_console = | |
| 687 (first_frame_on_device && | |
| 688 XINT (Flength (CONSOLE_DEVICE_LIST (XCONSOLE (DEVICE_CONSOLE (d))))) | |
| 689 == 1); | |
| 690 | |
| 691 /* #### all this calling of frame methods at various odd times | |
| 692 is somewhat of a mess. It's necessary to do it this way due | |
| 693 to strange console-type-specific things that need to be done. */ | |
| 694 MAYBE_FRAMEMETH (f, after_init_frame, (f, first_frame_on_device, | |
| 695 first_frame_on_console)); | |
| 696 | |
| 442 | 697 if (!DEVICE_STREAM_P (d)) |
| 698 { | |
| 699 /* Now initialise the gutters. This won't change the frame size, | |
| 4207 | 700 but is needed as input to the layout that change_frame_size |
| 701 will eventually do. Unfortunately gutter sizing code relies | |
| 702 on the frame in question being visible so we can't do this | |
| 703 earlier. */ | |
| 442 | 704 init_frame_gutters (f); |
| 705 | |
| 706 change_frame_size (f, f->height, f->width, 0); | |
| 707 } | |
| 708 | |
| 428 | 709 if (first_frame_on_device) |
| 710 { | |
| 711 if (first_frame_on_console) | |
| 712 va_run_hook_with_args (Qcreate_console_hook, 1, DEVICE_CONSOLE (d)); | |
| 713 va_run_hook_with_args (Qcreate_device_hook, 1, device); | |
| 714 } | |
| 715 va_run_hook_with_args (Qcreate_frame_hook, 1, frame); | |
| 716 | |
| 717 /* Initialize custom-specific stuff. */ | |
| 718 if (!UNBOUNDP (symbol_function (XSYMBOL (Qcustom_initialize_frame)))) | |
| 719 call1 (Qcustom_initialize_frame, frame); | |
| 720 | |
| 1204 | 721 UNGCPRO; |
| 771 | 722 unbind_to (speccount); |
| 428 | 723 |
| 724 return frame; | |
| 725 } | |
| 726 | |
| 727 | |
| 728 /* this function should be used in most cases when a Lisp function is passed | |
| 729 a FRAME argument. Use this unless you don't accept nil == current frame | |
| 730 (in which case, do a CHECK_LIVE_FRAME() and then an XFRAME()) or you | |
| 731 allow dead frames. Note that very few functions should accept dead | |
| 732 frames. It could be argued that functions should just do nothing when | |
| 733 given a dead frame, but the presence of a dead frame usually indicates | |
| 734 an oversight in the Lisp code that could potentially lead to strange | |
| 735 results and so it is better to catch the error early. | |
| 736 | |
| 737 If you only accept X frames, use decode_x_frame(), which does what this | |
| 738 function does but also makes sure the frame is an X frame. */ | |
| 739 | |
| 740 struct frame * | |
| 741 decode_frame (Lisp_Object frame) | |
| 742 { | |
| 743 if (NILP (frame)) | |
| 744 return selected_frame (); | |
| 745 | |
| 746 CHECK_LIVE_FRAME (frame); | |
| 747 return XFRAME (frame); | |
| 748 } | |
| 749 | |
| 750 struct frame * | |
| 751 decode_frame_or_selected (Lisp_Object cdf) | |
| 752 { | |
| 753 if (CONSOLEP (cdf)) | |
| 754 cdf = CONSOLE_SELECTED_DEVICE (decode_console (cdf)); | |
| 755 if (DEVICEP (cdf)) | |
| 756 cdf = DEVICE_SELECTED_FRAME (decode_device (cdf)); | |
| 757 return decode_frame (cdf); | |
| 758 } | |
| 759 | |
| 872 | 760 Lisp_Object |
| 761 frame_device (struct frame *f) | |
| 762 { | |
| 763 return FRAME_DEVICE (f); | |
| 764 } | |
| 765 | |
| 766 int | |
| 767 frame_live_p (struct frame *f) | |
| 768 { | |
| 769 return FRAME_LIVE_P (f); | |
| 770 } | |
| 771 | |
| 428 | 772 |
| 773 void | |
| 774 invalidate_vertical_divider_cache_in_frame (struct frame *f) | |
| 775 { | |
| 776 /* Invalidate cached value of needs_vertical_divider_p in | |
| 777 every and all windows */ | |
| 778 map_windows (f, invalidate_vertical_divider_cache_in_window, 0); | |
| 779 } | |
| 780 | |
| 781 /* | |
| 782 * Frame size may change due to changes in scrollbars, toolbars, | |
| 783 * default font etc. These changes are applied early in redisplay | |
| 784 * frame. | |
| 785 */ | |
| 786 void | |
| 787 adjust_frame_size (struct frame *f) | |
| 788 { | |
| 1318 | 789 /* This can call Lisp. */ |
| 428 | 790 int keep_char_size = 0; |
| 793 | 791 Lisp_Object frame = wrap_frame (f); |
| 792 | |
| 428 | 793 if (!f->size_slipped) |
| 794 return; | |
| 795 | |
| 796 /* Don't adjust tty frames. #### May break when TTY have menubars. | |
| 797 Then, write an Vadjust_frame_function which will return t for TTY | |
| 798 frames. Another solution is frame_size_fixed_p method for TTYs, | |
| 799 which always returned yes it's fixed. | |
| 800 */ | |
| 801 if (!FRAME_WIN_P (f)) | |
| 802 { | |
| 803 CLEAR_FRAME_SIZE_SLIPPED (f); | |
| 804 return; | |
| 805 } | |
| 806 | |
| 807 /* frame_size_fixed_p tells that frame size cannot currently | |
| 808 be changed change due to external conditions */ | |
| 809 if (!FRAMEMETH_OR_GIVEN (f, frame_size_fixed_p, (f), 0)) | |
| 810 { | |
| 811 if (NILP (Vadjust_frame_function)) | |
| 812 keep_char_size = 1; | |
| 813 else if (EQ (Vadjust_frame_function, Qt)) | |
| 814 keep_char_size = 0; | |
| 815 else | |
| 816 keep_char_size = | |
| 853 | 817 NILP (call1_trapping_problems ("Error in adjust-frame-function", |
| 818 Vadjust_frame_function, frame, | |
| 819 0)); | |
| 428 | 820 |
| 821 if (keep_char_size) | |
| 822 Fset_frame_size (frame, make_int (FRAME_CHARWIDTH(f)), | |
| 823 make_int (FRAME_CHARHEIGHT(f)), Qnil); | |
| 824 } | |
| 825 | |
| 826 if (!keep_char_size) | |
| 827 { | |
| 828 int height, width; | |
| 829 pixel_to_char_size (f, FRAME_PIXWIDTH(f), FRAME_PIXHEIGHT(f), | |
| 830 &width, &height); | |
| 831 change_frame_size (f, height, width, 0); | |
| 832 CLEAR_FRAME_SIZE_SLIPPED (f); | |
| 833 } | |
| 834 } | |
| 835 | |
| 836 /* | |
| 837 * This is a "specifier changed in frame" handler for various specifiers | |
| 838 * changing which causes frame size adjustment | |
| 839 */ | |
| 840 void | |
| 2286 | 841 frame_size_slipped (Lisp_Object UNUSED (specifier), struct frame *f, |
| 842 Lisp_Object UNUSED (oldval)) | |
| 428 | 843 { |
| 844 MARK_FRAME_SIZE_SLIPPED(f); | |
| 845 } | |
| 846 | |
| 847 DEFUN ("framep", Fframep, 1, 1, 0, /* | |
| 848 Return non-nil if OBJECT is a frame. | |
| 849 Also see `frame-live-p'. | |
| 850 Note that FSF Emacs kludgily returns a value indicating what type of | |
| 851 frame this is. Use the cleaner function `frame-type' for that. | |
| 852 */ | |
| 853 (object)) | |
| 854 { | |
| 855 return FRAMEP (object) ? Qt : Qnil; | |
| 856 } | |
| 857 | |
| 858 DEFUN ("frame-live-p", Fframe_live_p, 1, 1, 0, /* | |
| 859 Return non-nil if OBJECT is a frame which has not been deleted. | |
| 860 */ | |
| 861 (object)) | |
| 862 { | |
| 863 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; | |
| 864 } | |
| 865 | |
| 866 | |
| 867 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /* | |
| 868 Select FRAME and give it the window system focus. | |
| 869 This function is not affected by the value of `focus-follows-mouse'. | |
| 870 */ | |
| 871 (frame)) | |
| 872 { | |
| 873 CHECK_LIVE_FRAME (frame); | |
| 874 | |
| 875 MAYBE_DEVMETH (XDEVICE (FRAME_DEVICE (XFRAME (frame))), focus_on_frame, | |
| 876 (XFRAME (frame))); | |
| 877 /* FRAME will be selected by the time we receive the next event. | |
| 878 However, it is better to select it explicitly now, in case the | |
| 879 Lisp code depends on frame being selected. */ | |
| 880 Fselect_frame (frame); | |
| 881 return Qnil; | |
| 882 } | |
| 883 | |
| 884 /* Called from Fselect_window() */ | |
| 885 void | |
| 886 select_frame_1 (Lisp_Object frame) | |
| 887 { | |
| 888 struct frame *f = XFRAME (frame); | |
| 889 Lisp_Object old_selected_frame = Fselected_frame (Qnil); | |
| 890 | |
| 891 if (EQ (frame, old_selected_frame)) | |
| 892 return; | |
| 893 | |
| 894 /* now select the frame's device */ | |
| 895 set_device_selected_frame (XDEVICE (FRAME_DEVICE (f)), frame); | |
| 896 select_device_1 (FRAME_DEVICE (f)); | |
| 897 | |
| 898 update_frame_window_mirror (f); | |
| 899 } | |
| 900 | |
| 901 DEFUN ("select-frame", Fselect_frame, 1, 1, 0, /* | |
| 902 Select the frame FRAME. | |
| 903 Subsequent editing commands apply to its selected window. | |
| 904 The selection of FRAME lasts until the next time the user does | |
| 905 something to select a different frame, or until the next time this | |
| 906 function is called. | |
| 907 | |
| 908 Note that this does not actually cause the window-system focus to be | |
| 909 set to this frame, or the `select-frame-hook' or `deselect-frame-hook' | |
| 910 to be run, until the next time that XEmacs is waiting for an event. | |
| 911 | |
| 912 Also note that when focus-follows-mouse is non-nil, the frame | |
| 913 selection is temporary and is reverted when the current command | |
| 914 terminates, much like the buffer selected by `set-buffer'. In order | |
| 915 to effect a permanent focus change, use `focus-frame'. | |
| 916 */ | |
| 917 (frame)) | |
| 918 { | |
| 919 CHECK_LIVE_FRAME (frame); | |
| 920 | |
| 921 /* select the frame's selected window. This will call | |
| 922 selected_frame_1(). */ | |
| 923 Fselect_window (FRAME_SELECTED_WINDOW (XFRAME (frame)), Qnil); | |
| 924 | |
| 925 /* Nothing should be depending on the return value of this function. | |
| 926 But, of course, there is stuff out there which is. */ | |
| 927 return frame; | |
| 928 } | |
| 929 | |
| 930 /* use this to retrieve the currently selected frame. You should use | |
| 931 this in preference to Fselected_frame (Qnil) unless you are prepared | |
| 932 to handle the possibility of there being no selected frame (this | |
| 933 happens at some points during startup). */ | |
| 934 | |
| 935 struct frame * | |
| 936 selected_frame (void) | |
| 937 { | |
| 938 Lisp_Object device = Fselected_device (Qnil); | |
| 939 Lisp_Object frame = DEVICE_SELECTED_FRAME (XDEVICE (device)); | |
| 940 if (NILP (frame)) | |
| 563 | 941 gui_error ("No frames exist on device", device); |
| 428 | 942 return XFRAME (frame); |
| 943 } | |
| 944 | |
| 945 /* use this instead of XFRAME (DEVICE_SELECTED_FRAME (d)) to catch | |
| 946 the possibility of there being no frames on the device (just created). | |
| 947 There is no point doing this inside of redisplay because errors | |
| 2500 | 948 cause an ABORT(), indicating a flaw in the logic, and error_check_frame() |
| 428 | 949 will catch this just as well. */ |
| 950 | |
| 951 struct frame * | |
| 952 device_selected_frame (struct device *d) | |
| 953 { | |
| 954 Lisp_Object frame = DEVICE_SELECTED_FRAME (d); | |
| 955 if (NILP (frame)) | |
| 956 { | |
| 793 | 957 Lisp_Object device = wrap_device (d); |
| 958 | |
| 563 | 959 gui_error ("No frames exist on device", device); |
| 428 | 960 } |
| 961 return XFRAME (frame); | |
| 962 } | |
| 963 | |
| 964 #if 0 /* FSFmacs */ | |
| 965 | |
| 826 | 966 DEFUN ("handle-switch-frame", Fhandle_switch_frame, 1, 2, "e", /* |
| 428 | 967 Handle a switch-frame event EVENT. |
| 968 Switch-frame events are usually bound to this function. | |
| 969 A switch-frame event tells Emacs that the window manager has requested | |
| 970 that the user's events be directed to the frame mentioned in the event. | |
| 971 This function selects the selected window of the frame of EVENT. | |
| 972 | |
| 973 If EVENT is frame object, handle it as if it were a switch-frame event | |
| 974 to that frame. | |
| 975 */ | |
| 976 (frame, no_enter)) | |
| 977 { | |
| 978 /* Preserve prefix arg that the command loop just cleared. */ | |
| 979 XCONSOLE (Vselected_console)->prefix_arg = Vcurrent_prefix_arg; | |
| 980 #if 0 /* unclean! */ | |
| 981 run_hook (Qmouse_leave_buffer_hook); | |
| 982 #endif | |
| 983 return do_switch_frame (frame, no_enter, 0); | |
| 984 } | |
| 985 | |
| 986 /* A load of garbage. */ | |
| 826 | 987 DEFUN ("ignore-event", Fignore_event, 0, 0, "", /* |
| 428 | 988 Do nothing, but preserve any prefix argument already specified. |
| 989 This is a suitable binding for iconify-frame and make-frame-visible. | |
| 990 */ | |
| 991 ()) | |
| 992 { | |
| 993 struct console *c = XCONSOLE (Vselected_console); | |
| 994 | |
| 995 c->prefix_arg = Vcurrent_prefix_arg; | |
| 996 return Qnil; | |
| 997 } | |
| 998 | |
| 999 #endif /* 0 */ | |
| 1000 | |
| 1001 DEFUN ("selected-frame", Fselected_frame, 0, 1, 0, /* | |
| 1002 Return the frame that is now selected on device DEVICE. | |
| 1003 If DEVICE is not specified, the selected device will be used. | |
| 1004 If no frames exist on the device, nil is returned. | |
| 1005 */ | |
| 1006 (device)) | |
| 1007 { | |
| 1008 if (NILP (device) && NILP (Fselected_device (Qnil))) | |
| 1009 return Qnil; /* happens early in temacs */ | |
| 1010 return DEVICE_SELECTED_FRAME (decode_device (device)); | |
| 1011 } | |
| 1012 | |
| 1013 Lisp_Object | |
| 1014 frame_first_window (struct frame *f) | |
| 1015 { | |
| 1016 Lisp_Object w = f->root_window; | |
| 1017 | |
| 1018 while (1) | |
| 1019 { | |
| 1020 if (! NILP (XWINDOW (w)->hchild)) | |
| 1021 w = XWINDOW (w)->hchild; | |
| 1022 else if (! NILP (XWINDOW (w)->vchild)) | |
| 1023 w = XWINDOW (w)->vchild; | |
| 1024 else | |
| 1025 break; | |
| 1026 } | |
| 1027 | |
| 1028 return w; | |
| 1029 } | |
| 1030 | |
| 1031 DEFUN ("active-minibuffer-window", Factive_minibuffer_window, 0, 0, 0, /* | |
| 1032 Return the currently active minibuffer window, or nil if none. | |
| 1033 */ | |
| 1034 ()) | |
| 1035 { | |
| 1036 return minibuf_level ? minibuf_window : Qnil; | |
| 1037 } | |
| 1038 | |
| 1039 DEFUN ("last-nonminibuf-frame", Flast_nonminibuf_frame, 0, 1, 0, /* | |
| 1040 Return the most-recently-selected non-minibuffer-only frame on CONSOLE. | |
| 1041 This will always be the same as (selected-frame device) unless the | |
| 1042 selected frame is a minibuffer-only frame. | |
| 1043 CONSOLE defaults to the selected console if omitted. | |
| 1044 */ | |
| 1045 (console)) | |
| 1046 { | |
| 1047 Lisp_Object result; | |
| 1048 | |
| 793 | 1049 console = wrap_console (decode_console (console)); |
| 428 | 1050 /* Just in case the machinations in delete_frame_internal() resulted |
| 1051 in the last-nonminibuf-frame getting out of sync, make sure and | |
| 1052 return the selected frame if it's acceptable. */ | |
| 1053 result = Fselected_frame (CONSOLE_SELECTED_DEVICE (XCONSOLE (console))); | |
| 1054 if (!NILP (result) && !FRAME_MINIBUF_ONLY_P (XFRAME (result))) | |
| 1055 return result; | |
| 1056 return CONSOLE_LAST_NONMINIBUF_FRAME (XCONSOLE (console)); | |
| 1057 } | |
| 1058 | |
| 1059 DEFUN ("frame-root-window", Fframe_root_window, 0, 1, 0, /* | |
| 1060 Return the root-window of FRAME. | |
| 1061 If omitted, FRAME defaults to the currently selected frame. | |
| 1062 */ | |
| 1063 (frame)) | |
| 1064 { | |
| 1065 struct frame *f = decode_frame (frame); | |
| 1066 return FRAME_ROOT_WINDOW (f); | |
| 1067 } | |
| 1068 | |
| 1069 DEFUN ("frame-selected-window", Fframe_selected_window, 0, 1, 0, /* | |
| 1070 Return the selected window of frame object FRAME. | |
| 1071 If omitted, FRAME defaults to the currently selected frame. | |
| 1072 */ | |
| 1073 (frame)) | |
| 1074 { | |
| 1075 struct frame *f = decode_frame (frame); | |
| 1076 return FRAME_SELECTED_WINDOW (f); | |
| 1077 } | |
| 1078 | |
| 1079 void | |
| 1080 set_frame_selected_window (struct frame *f, Lisp_Object window) | |
| 1081 { | |
| 1082 assert (XFRAME (WINDOW_FRAME (XWINDOW (window))) == f); | |
| 1083 f->selected_window = window; | |
| 1084 if (!MINI_WINDOW_P (XWINDOW (window)) || FRAME_MINIBUF_ONLY_P (f)) | |
| 1085 { | |
| 1086 if (!EQ (f->last_nonminibuf_window, window)) | |
| 1087 { | |
| 442 | 1088 #ifdef HAVE_TOOLBARS |
| 428 | 1089 MARK_TOOLBAR_CHANGED; |
| 442 | 1090 #endif |
| 428 | 1091 MARK_GUTTER_CHANGED; |
| 1092 } | |
| 1093 f->last_nonminibuf_window = window; | |
| 1094 } | |
| 1095 } | |
| 1096 | |
| 1097 DEFUN ("set-frame-selected-window", Fset_frame_selected_window, 2, 2, 0, /* | |
| 460 | 1098 Set the selected window of FRAME to WINDOW. |
| 428 | 1099 If FRAME is nil, the selected frame is used. |
| 1100 If FRAME is the selected frame, this makes WINDOW the selected window. | |
| 1101 */ | |
| 1102 (frame, window)) | |
| 1103 { | |
| 793 | 1104 frame = wrap_frame (decode_frame (frame)); |
| 428 | 1105 CHECK_LIVE_WINDOW (window); |
| 1106 | |
| 1107 if (! EQ (frame, WINDOW_FRAME (XWINDOW (window)))) | |
| 563 | 1108 invalid_argument ("In `set-frame-selected-window', WINDOW is not on FRAME", Qunbound); |
| 428 | 1109 |
| 1110 if (XFRAME (frame) == selected_frame ()) | |
| 1111 return Fselect_window (window, Qnil); | |
| 1112 | |
| 1113 set_frame_selected_window (XFRAME (frame), window); | |
| 1114 return window; | |
| 1115 } | |
| 1116 | |
| 1117 | |
| 1118 DEFUN ("frame-device", Fframe_device, 0, 1, 0, /* | |
| 1119 Return the device that FRAME is on. | |
| 1120 If omitted, FRAME defaults to the currently selected frame. | |
| 1121 */ | |
| 1122 (frame)) | |
| 1123 { | |
| 1124 return FRAME_DEVICE (decode_frame (frame)); | |
| 1125 } | |
| 1126 | |
| 1127 int | |
| 1128 is_surrogate_for_selected_frame (struct frame *f) | |
| 1129 { | |
| 1130 struct device *d = XDEVICE (f->device); | |
| 1131 struct frame *dsf = device_selected_frame (d); | |
| 1132 | |
| 1133 /* Can't be a surrogate for ourselves. */ | |
| 1134 if (f == dsf) | |
| 1135 return 0; | |
| 1136 | |
| 1137 if (!FRAME_HAS_MINIBUF_P (dsf) && | |
| 1138 f == XFRAME (WINDOW_FRAME (XWINDOW (FRAME_MINIBUF_WINDOW (dsf))))) | |
| 1139 return 1; | |
| 1140 else | |
| 1141 return 0; | |
| 1142 } | |
| 1143 | |
| 1144 static int | |
| 444 | 1145 frame_matches_frame_spec (Lisp_Object frame, Lisp_Object type) |
| 428 | 1146 { |
| 1147 struct frame *f = XFRAME (frame); | |
| 1148 | |
| 1149 if (WINDOWP (type)) | |
| 1150 { | |
| 1151 CHECK_LIVE_WINDOW (type); | |
| 1152 | |
| 1153 if (EQ (FRAME_MINIBUF_WINDOW (f), type) | |
| 1154 /* Check that F either is, or has forwarded | |
| 1155 its focus to, TYPE's frame. */ | |
| 1156 && (EQ (WINDOW_FRAME (XWINDOW (type)), frame) | |
| 1157 || EQ (WINDOW_FRAME (XWINDOW (type)), | |
| 1158 FRAME_FOCUS_FRAME (f)))) | |
| 1159 return 1; | |
| 1160 else | |
| 1161 return 0; | |
| 1162 } | |
| 1163 | |
| 1164 #if 0 /* FSFmacs */ | |
| 1165 if (EQ (type, Qvisible) || EQ (type, Qiconic) || EQ (type, Qvisible_iconic) | |
| 1166 || EQ (type, Qvisible_nomini) || EQ (type, Qiconic_nomini) | |
| 1167 || EQ (type, Qvisible_iconic_nomini)) | |
| 1168 FRAME_SAMPLE_VISIBILITY (f); | |
| 1169 #endif | |
| 1170 | |
| 1171 if (NILP (type)) | |
| 1172 type = Qnomini; | |
| 1173 if (ZEROP (type)) | |
| 1174 type = Qvisible_iconic; | |
| 1175 | |
| 1176 if (EQ (type, Qvisible)) | |
| 1177 return FRAME_VISIBLE_P (f); | |
| 1178 if (EQ (type, Qiconic)) | |
| 1179 return FRAME_ICONIFIED_P (f); | |
| 1180 if (EQ (type, Qinvisible)) | |
| 1181 return !FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f); | |
| 1182 if (EQ (type, Qvisible_iconic)) | |
| 1183 return FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f); | |
| 1184 if (EQ (type, Qinvisible_iconic)) | |
| 1185 return !FRAME_VISIBLE_P (f); | |
| 1186 | |
| 1187 if (EQ (type, Qnomini)) | |
| 1188 return !FRAME_MINIBUF_ONLY_P (f); | |
| 1189 if (EQ (type, Qvisible_nomini)) | |
| 1190 return FRAME_VISIBLE_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
| 1191 if (EQ (type, Qiconic_nomini)) | |
| 1192 return FRAME_ICONIFIED_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
| 1193 if (EQ (type, Qinvisible_nomini)) | |
| 1194 return !FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f) && | |
| 1195 !FRAME_MINIBUF_ONLY_P (f); | |
| 1196 if (EQ (type, Qvisible_iconic_nomini)) | |
| 1197 return ((FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)) | |
| 1198 && !FRAME_MINIBUF_ONLY_P (f)); | |
| 1199 if (EQ (type, Qinvisible_iconic_nomini)) | |
| 1200 return !FRAME_VISIBLE_P (f) && !FRAME_MINIBUF_ONLY_P (f); | |
| 1201 | |
| 1202 return 1; | |
| 1203 } | |
| 1204 | |
| 1205 int | |
| 444 | 1206 device_matches_device_spec (Lisp_Object device, Lisp_Object device_spec) |
| 428 | 1207 { |
| 444 | 1208 if (EQ (device_spec, Qwindow_system)) |
| 428 | 1209 return DEVICE_WIN_P (XDEVICE (device)); |
| 444 | 1210 if (DEVICEP (device_spec)) |
| 1211 return EQ (device, device_spec); | |
| 1212 if (CONSOLEP (device_spec)) | |
| 1213 return EQ (DEVICE_CONSOLE (XDEVICE (device)), device_spec); | |
| 1214 if (valid_console_type_p (device_spec)) | |
| 1215 return EQ (DEVICE_TYPE (XDEVICE (device)), device_spec); | |
| 428 | 1216 return 1; |
| 1217 } | |
| 1218 | |
| 1219 /* Return the next frame in the frame list after FRAME. | |
| 444 | 1220 WHICH-FRAMES and WHICH-DEVICES control which frames and devices |
| 428 | 1221 are considered; see `next-frame'. */ |
| 1222 | |
| 1223 Lisp_Object | |
| 444 | 1224 next_frame (Lisp_Object frame, Lisp_Object which_frames, Lisp_Object which_devices) |
| 428 | 1225 { |
| 442 | 1226 Lisp_Object first = Qnil; |
| 1227 Lisp_Object devcons, concons; | |
| 1228 int passed = 0; | |
| 1229 | |
| 1230 CHECK_LIVE_FRAME (frame); | |
| 1231 | |
| 1232 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
| 1233 { | |
| 1234 Lisp_Object device = XCAR (devcons); | |
| 1235 Lisp_Object frmcons; | |
| 1236 | |
| 444 | 1237 if (!device_matches_device_spec (device, which_devices)) |
| 442 | 1238 { |
| 1239 if (EQ (device, FRAME_DEVICE (XFRAME (frame)))) | |
| 1240 passed = 1; | |
| 1241 continue; | |
| 1242 } | |
| 1243 | |
| 1244 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | |
| 1245 { | |
| 1246 Lisp_Object f = XCAR (frmcons); | |
| 1247 | |
| 1248 if (passed) | |
| 1249 { | |
| 444 | 1250 if (frame_matches_frame_spec (f, which_frames)) |
| 442 | 1251 return f; |
| 1252 } | |
| 1253 else | |
| 1254 { | |
| 1255 if (EQ (frame, f)) | |
| 1256 { | |
| 1257 passed = 1; | |
| 1258 } | |
| 1259 else | |
| 1260 { | |
| 444 | 1261 if (NILP (first) && frame_matches_frame_spec (f, which_frames)) |
| 442 | 1262 first = f; |
| 1263 } | |
| 1264 } | |
| 1265 } | |
| 1266 } | |
| 1267 | |
| 1268 if (NILP (first)) | |
| 1269 /* We went through the whole frame list without finding a single | |
| 1270 acceptable frame. Return the original frame. */ | |
| 1271 return frame; | |
| 1272 else | |
| 1273 /* There were no acceptable frames in the list after FRAME; otherwise, | |
| 1274 we would have returned directly from the loop. Since FIRST is the last | |
| 1275 acceptable frame in the list, return it. */ | |
| 1276 return first; | |
| 428 | 1277 } |
| 1278 | |
| 1279 /* Return the previous frame in the frame list before FRAME. | |
| 444 | 1280 WHICH-FRAMES and WHICH-DEVICES control which frames and devices |
| 428 | 1281 are considered; see `next-frame'. */ |
| 1282 | |
| 1283 Lisp_Object | |
| 444 | 1284 previous_frame (Lisp_Object frame, Lisp_Object which_frames, Lisp_Object which_devices) |
| 428 | 1285 { |
| 1286 Lisp_Object devcons, concons; | |
| 442 | 1287 Lisp_Object last = Qnil; |
| 1288 | |
| 428 | 1289 CHECK_LIVE_FRAME (frame); |
| 1290 | |
| 1291 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
| 1292 { | |
| 1293 Lisp_Object device = XCAR (devcons); | |
| 1294 Lisp_Object frmcons; | |
| 1295 | |
| 444 | 1296 if (!device_matches_device_spec (device, which_devices)) |
| 442 | 1297 { |
| 1298 if (EQ (device, FRAME_DEVICE (XFRAME (frame))) | |
| 1299 && !NILP (last)) | |
| 1300 return last; | |
| 1301 continue; | |
| 1302 } | |
| 428 | 1303 |
| 1304 DEVICE_FRAME_LOOP (frmcons, XDEVICE (device)) | |
| 1305 { | |
| 1306 Lisp_Object f = XCAR (frmcons); | |
| 1307 | |
| 442 | 1308 if (EQ (frame, f)) |
| 1309 { | |
| 1310 if (!NILP (last)) | |
| 1311 return last; | |
| 1312 } | |
| 1313 else | |
| 1314 { | |
| 444 | 1315 if (frame_matches_frame_spec (f, which_frames)) |
| 442 | 1316 last = f; |
| 1317 } | |
| 428 | 1318 } |
| 1319 } | |
| 1320 | |
| 442 | 1321 if (NILP (last)) |
| 428 | 1322 /* We went through the whole frame list without finding a single |
| 1323 acceptable frame. Return the original frame. */ | |
| 1324 return frame; | |
| 1325 else | |
| 1326 /* There were no acceptable frames in the list before FRAME; otherwise, | |
| 442 | 1327 we would have returned directly from the loop. Since LAST is the last |
| 428 | 1328 acceptable frame in the list, return it. */ |
| 442 | 1329 return last; |
| 428 | 1330 } |
| 1331 | |
| 1332 DEFUN ("next-frame", Fnext_frame, 0, 3, 0, /* | |
| 1333 Return the next frame of the right type in the frame list after FRAME. | |
| 444 | 1334 WHICH-FRAMES controls which frames are eligible to be returned; all |
| 428 | 1335 others will be skipped. Note that if there is only one eligible |
| 1336 frame, then `next-frame' called repeatedly will always return | |
| 1337 the same frame, and if there is no eligible frame, then FRAME is | |
| 1338 returned. | |
| 1339 | |
| 444 | 1340 Possible values for WHICH-FRAMES are |
| 428 | 1341 |
| 3025 | 1342 `visible' Consider only frames that are visible. |
| 1343 `iconic' Consider only frames that are iconic. | |
| 1344 `invisible' Consider only frames that are invisible | |
| 4207 | 1345 (this is different from iconic). |
| 3025 | 1346 `visible-iconic' Consider frames that are visible or iconic. |
| 1347 `invisible-iconic' Consider frames that are invisible or iconic. | |
| 1348 `nomini' Consider all frames except minibuffer-only ones. | |
| 1349 `visible-nomini' Like `visible' but omits minibuffer-only frames. | |
| 1350 `iconic-nomini' Like `iconic' but omits minibuffer-only frames. | |
| 1351 `invisible-nomini' Like `invisible' but omits minibuffer-only frames. | |
| 1352 `visible-iconic-nomini' Like `visible-iconic' but omits minibuffer-only | |
| 4207 | 1353 frames. |
| 3025 | 1354 `invisible-iconic-nomini' Like `invisible-iconic' but omits minibuffer-only |
| 4207 | 1355 frames. |
| 3025 | 1356 any other value Consider all frames. |
| 1357 | |
| 1358 If WHICH-FRAMES is omitted, `nomini' is used. A value for WHICH-FRAMES | |
| 1359 of 0 (a number) is treated like `iconic', for backwards compatibility. | |
| 444 | 1360 |
| 1361 If WHICH-FRAMES is a window, include only its own frame and any frame | |
| 1362 now using that window as the minibuffer. | |
| 1363 | |
| 1364 The optional third argument WHICH-DEVICES further clarifies on which | |
| 1365 devices to search for frames as specified by WHICH-FRAMES. | |
| 1366 If nil or omitted, search all devices on FRAME's console. | |
| 1367 If a device, only search that device. | |
| 1368 If a console, search all devices on that console. | |
| 1369 If a device type, search all devices of that type. | |
| 1370 If `window-system', search all window-system devices. | |
| 1371 Any other non-nil value means search all devices. | |
| 428 | 1372 */ |
| 444 | 1373 (frame, which_frames, which_devices)) |
| 428 | 1374 { |
| 793 | 1375 frame = wrap_frame (decode_frame (frame)); |
| 428 | 1376 |
| 444 | 1377 return next_frame (frame, which_frames, which_devices); |
| 428 | 1378 } |
| 1379 | |
| 1380 DEFUN ("previous-frame", Fprevious_frame, 0, 3, 0, /* | |
| 1381 Return the next frame of the right type in the frame list after FRAME. | |
| 444 | 1382 WHICH-FRAMES controls which frames are eligible to be returned; all |
| 428 | 1383 others will be skipped. Note that if there is only one eligible |
| 1384 frame, then `previous-frame' called repeatedly will always return | |
| 1385 the same frame, and if there is no eligible frame, then FRAME is | |
| 1386 returned. | |
| 1387 | |
| 444 | 1388 See `next-frame' for an explanation of the WHICH-FRAMES and WHICH-DEVICES |
| 428 | 1389 arguments. |
| 1390 */ | |
| 444 | 1391 (frame, which_frames, which_devices)) |
| 428 | 1392 { |
| 793 | 1393 frame = wrap_frame (decode_frame (frame)); |
| 428 | 1394 |
| 444 | 1395 return previous_frame (frame, which_frames, which_devices); |
| 428 | 1396 } |
| 1397 | |
| 1398 /* Return any frame for which PREDICATE is non-zero, or return Qnil | |
| 1399 if there aren't any. */ | |
| 1400 | |
| 1401 Lisp_Object | |
| 1402 find_some_frame (int (*predicate) (Lisp_Object, void *), | |
| 1403 void *closure) | |
| 1404 { | |
| 1405 Lisp_Object framecons, devcons, concons; | |
| 1406 | |
| 1407 FRAME_LOOP_NO_BREAK (framecons, devcons, concons) | |
| 1408 { | |
| 1409 Lisp_Object frame = XCAR (framecons); | |
| 1410 | |
| 1411 if ((predicate) (frame, closure)) | |
| 1412 return frame; | |
| 1413 } | |
| 1414 | |
| 1415 return Qnil; | |
| 1416 } | |
| 1417 | |
| 1418 | |
| 1419 | |
| 1420 /* extern void free_line_insertion_deletion_costs (struct frame *f); */ | |
| 1421 | |
| 1422 /* Return 1 if it is ok to delete frame F; | |
| 1423 0 if all frames aside from F are invisible. | |
| 1424 (Exception: if F is a stream frame, it's OK to delete if | |
| 1425 any other frames exist.) */ | |
| 1426 | |
| 442 | 1427 int |
| 1428 other_visible_frames (struct frame *f) | |
| 428 | 1429 { |
| 793 | 1430 Lisp_Object frame = wrap_frame (f); |
| 1431 | |
| 428 | 1432 if (FRAME_STREAM_P (f)) |
| 442 | 1433 return !EQ (frame, next_frame (frame, Qt, Qt)); |
| 1434 return !EQ (frame, next_frame (frame, Qvisible_iconic_nomini, Qt)); | |
| 428 | 1435 } |
| 1436 | |
| 1437 /* Delete frame F. | |
| 1438 | |
| 1439 If FORCE is non-zero, allow deletion of the only frame. | |
| 1440 | |
| 1441 If CALLED_FROM_DELETE_DEVICE is non-zero, then, if | |
| 1442 deleting the last frame on a device, just delete it, | |
| 1443 instead of calling `delete-device'. | |
| 1444 | |
| 1445 If FROM_IO_ERROR is non-zero, then the frame is gone due | |
| 1446 to an I/O error. This affects what happens if we exit | |
| 1447 (we do an emergency exit instead of `save-buffers-kill-emacs'.) | |
| 1448 */ | |
| 1449 | |
| 1450 void | |
| 1451 delete_frame_internal (struct frame *f, int force, | |
| 1452 int called_from_delete_device, | |
| 1453 int from_io_error) | |
| 1454 { | |
| 1455 /* This function can GC */ | |
| 1456 int minibuffer_selected; | |
| 1457 struct device *d; | |
| 1458 struct console *con; | |
| 1459 Lisp_Object frame; | |
| 1460 Lisp_Object device; | |
| 1461 Lisp_Object console; | |
| 1462 struct gcpro gcpro1; | |
| 1313 | 1463 int depth; |
| 428 | 1464 |
| 1465 /* OK to delete an already deleted frame. */ | |
| 853 | 1466 if (!FRAME_LIVE_P (f)) |
| 428 | 1467 return; |
| 1468 | |
| 793 | 1469 frame = wrap_frame (f); |
| 853 | 1470 |
| 1471 if (!force) | |
| 1472 check_allowed_operation (OPERATION_DELETE_OBJECT, frame, Qnil); | |
| 1473 | |
| 428 | 1474 GCPRO1 (frame); |
| 1475 | |
| 1476 device = FRAME_DEVICE (f); | |
| 1477 d = XDEVICE (device); | |
| 1478 console = DEVICE_CONSOLE (d); | |
| 1479 con = XCONSOLE (console); | |
| 1480 | |
| 545 | 1481 if (!called_from_delete_device |
| 1482 && !DEVICE_IMPL_FLAG (d, XDEVIMPF_FRAMELESS_OK)) | |
| 428 | 1483 { |
| 1484 /* If we're deleting the only non-minibuffer frame on the | |
| 1485 device, delete the device. */ | |
| 1486 if (EQ (frame, next_frame (frame, Qnomini, FRAME_DEVICE (f)))) | |
| 1487 { | |
| 1488 delete_device_internal (d, force, 0, from_io_error); | |
| 1489 UNGCPRO; | |
| 1490 return; | |
| 1491 } | |
| 1492 } | |
| 1493 | |
| 1494 /* In FSF, delete-frame will not normally allow you to delete the | |
| 1495 last visible frame. This was too annoying, so we changed it to the | |
| 1496 only frame. However, this would let people shoot themselves by | |
| 1497 deleting all frames which were either visible or iconified and thus | |
| 1498 losing any way of communicating with the still running XEmacs process. | |
| 1499 So we put it back. */ | |
| 1500 if (!force && !allow_deletion_of_last_visible_frame && | |
| 442 | 1501 !other_visible_frames (f)) |
| 563 | 1502 invalid_operation ("Attempt to delete the sole visible or iconified frame", Qunbound); |
| 428 | 1503 |
| 1504 /* Does this frame have a minibuffer, and is it the surrogate | |
| 1505 minibuffer for any other frame? */ | |
| 1506 if (FRAME_HAS_MINIBUF_P (f)) | |
| 1507 { | |
| 1508 Lisp_Object frmcons, devcons, concons; | |
| 1509 | |
| 1510 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) | |
| 1511 { | |
| 2552 | 1512 Lisp_Object this_frame = XCAR (frmcons); |
| 1513 | |
| 1514 if (! EQ (this_frame, frame) | |
| 428 | 1515 && EQ (frame, (WINDOW_FRAME |
| 1516 (XWINDOW | |
| 2552 | 1517 (FRAME_MINIBUF_WINDOW (XFRAME (this_frame))))))) |
| 428 | 1518 { |
| 1519 /* We've found another frame whose minibuffer is on | |
| 1520 this frame. */ | |
| 563 | 1521 gui_error |
| 428 | 1522 ("Attempt to delete a surrogate minibuffer frame", frame); |
| 1523 } | |
| 1524 } | |
| 1525 } | |
| 1526 | |
| 1527 /* Test for popup frames hanging around. */ | |
| 1528 /* Deletion of a parent frame with popups is deadly. */ | |
| 1529 { | |
| 1530 Lisp_Object frmcons, devcons, concons; | |
| 1531 | |
| 1532 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) | |
| 1533 { | |
| 2552 | 1534 Lisp_Object this_frame = XCAR (frmcons); |
| 1535 | |
| 1536 | |
| 1537 if (! EQ (this_frame, frame)) | |
| 428 | 1538 { |
| 1539 struct device *devcons_d = XDEVICE (XCAR (devcons)); | |
| 1540 if (EQ (frame, DEVMETH_OR_GIVEN (devcons_d, get_frame_parent, | |
| 2552 | 1541 (XFRAME (this_frame)), |
| 428 | 1542 Qnil))) |
| 1543 /* We've found a popup frame whose parent is this frame. */ | |
| 563 | 1544 gui_error |
| 428 | 1545 ("Attempt to delete a frame with live popups", frame); |
| 1546 } | |
| 1547 } | |
| 1548 } | |
| 1549 | |
| 1550 /* Before here, we haven't made any dangerous changes (just checked for | |
| 1551 error conditions). Now run the delete-frame-hook. Remember that | |
| 1552 user code there could do any number of dangerous things, including | |
| 1553 signalling an error. */ | |
| 1554 | |
| 1555 va_run_hook_with_args (Qdelete_frame_hook, 1, frame); | |
| 1556 | |
| 1557 if (!FRAME_LIVE_P (f)) /* Make sure the delete-frame-hook didn't */ | |
| 1558 { /* go ahead and delete anything. */ | |
| 1559 UNGCPRO; | |
| 1560 return; | |
| 1561 } | |
| 1562 | |
| 1563 /* Call the delete-device-hook and delete-console-hook now if | |
| 1564 appropriate, before we do any dangerous things -- they too could | |
| 1565 signal an error. */ | |
| 1566 if (XINT (Flength (DEVICE_FRAME_LIST (d))) == 1) | |
| 1567 { | |
| 1568 va_run_hook_with_args (Qdelete_device_hook, 1, device); | |
| 1569 if (!FRAME_LIVE_P (f)) /* Make sure the delete-device-hook didn't */ | |
| 1570 { /* go ahead and delete anything. */ | |
| 1571 UNGCPRO; | |
| 1572 return; | |
| 1573 } | |
| 1574 | |
| 1575 if (XINT (Flength (CONSOLE_DEVICE_LIST (con))) == 1) | |
| 1576 { | |
| 1577 va_run_hook_with_args (Qdelete_console_hook, 1, console); | |
| 1578 if (!FRAME_LIVE_P (f)) /* Make sure the delete-console-hook didn't */ | |
| 1579 { /* go ahead and delete anything. */ | |
| 1580 UNGCPRO; | |
| 1581 return; | |
| 1582 } | |
| 1583 } | |
| 1584 } | |
| 1585 | |
| 1586 minibuffer_selected = EQ (minibuf_window, Fselected_window (Qnil)); | |
| 1587 | |
| 1588 /* If we were focused on this frame, then we're not any more. | |
| 1589 Assume that we lost the focus; that way, the call to | |
| 1590 Fselect_frame() below won't end up making us explicitly | |
| 1591 focus on another frame, which is generally undesirable in | |
| 1592 a point-to-type world. If our mouse ends up sitting over | |
| 1593 another frame, we will receive a FocusIn event and end up | |
| 1594 making that frame the selected frame. | |
| 1595 | |
| 1596 #### This may not be an ideal solution in a click-to-type | |
| 1597 world (in that case, we might want to explicitly choose | |
| 1598 another frame to have the focus, rather than relying on | |
| 1599 the WM, which might focus on a frame in a different app | |
| 1600 or focus on nothing at all). But there's no easy way | |
| 1601 to detect which focus model we're running on, and the | |
| 1602 alternative is more heinous. */ | |
| 1603 | |
| 1604 if (EQ (frame, DEVICE_FRAME_WITH_FOCUS_REAL (d))) | |
| 1605 DEVICE_FRAME_WITH_FOCUS_REAL (d) = Qnil; | |
| 1606 if (EQ (frame, DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d))) | |
| 1607 DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d) = Qnil; | |
| 1608 if (EQ (frame, DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d))) | |
| 1609 DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d) = Qnil; | |
| 1610 | |
| 1611 /* Don't allow the deleted frame to remain selected. | |
| 1612 Note that in the former scheme of things, this would | |
| 1613 have caused us to regain the focus. This no longer | |
| 1614 applies (see above); I think the new behavior is more | |
| 1615 logical. If someone disagrees, it can always be | |
| 1616 changed (or a new user variable can be introduced, ugh.) */ | |
| 1617 if (EQ (frame, DEVICE_SELECTED_FRAME (d))) | |
| 1618 { | |
| 1619 Lisp_Object next; | |
| 1620 | |
| 1621 /* If this is a popup frame, select its parent if possible. | |
| 1622 Otherwise, find another visible frame; if none, just take any frame. | |
| 4207 | 1623 First try the same device, then the same console. */ |
| 428 | 1624 |
| 1625 next = DEVMETH_OR_GIVEN (d, get_frame_parent, (f), Qnil); | |
| 1626 if (NILP (next) || EQ (next, frame) || ! FRAME_LIVE_P (XFRAME (next))) | |
| 442 | 1627 next = next_frame (frame, Qvisible, device); |
| 428 | 1628 if (NILP (next) || EQ (next, frame)) |
| 442 | 1629 next = next_frame (frame, Qvisible, console); |
| 1630 if (NILP (next) || EQ (next, frame)) | |
| 1631 next = next_frame (frame, Qvisible, Qt); | |
| 428 | 1632 if (NILP (next) || EQ (next, frame)) |
| 442 | 1633 next = next_frame (frame, Qt, device); |
| 428 | 1634 if (NILP (next) || EQ (next, frame)) |
| 442 | 1635 next = next_frame (frame, Qt, console); |
| 428 | 1636 if (NILP (next) || EQ (next, frame)) |
| 442 | 1637 next = next_frame (frame, Qt, Qt); |
| 428 | 1638 |
| 1639 /* if we haven't found another frame at this point | |
| 1640 then there aren't any. */ | |
| 1641 if (NILP (next) || EQ (next, frame)) | |
| 1642 ; | |
| 1643 else | |
| 1644 { | |
| 1645 int did_select = 0; | |
| 1646 /* if this is the global selected frame, select another one. */ | |
| 1647 if (EQ (frame, Fselected_frame (Qnil))) | |
| 1648 { | |
| 1649 Fselect_frame (next); | |
| 1650 did_select = 1; | |
| 1651 } | |
| 1652 /* | |
| 1653 * If the new frame we just selected is on a different | |
| 1654 * device then we still need to change DEVICE_SELECTED_FRAME(d) | |
| 1655 * to a live frame, if there are any left on this device. | |
| 1656 */ | |
| 1657 if (!EQ (device, FRAME_DEVICE(XFRAME(next)))) | |
| 1658 { | |
| 442 | 1659 Lisp_Object next_f = next_frame (frame, Qt, device); |
| 428 | 1660 if (NILP (next_f) || EQ (next_f, frame)) |
| 440 | 1661 set_device_selected_frame (d, Qnil); |
| 428 | 1662 else |
| 1663 set_device_selected_frame (d, next_f); | |
| 1664 } | |
| 1665 else if (! did_select) | |
| 1666 set_device_selected_frame (d, next); | |
| 1667 | |
| 1668 } | |
| 1669 } | |
| 1670 | |
| 1671 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
| 1672 if (EQ (f->minibuffer_window, minibuf_window)) | |
| 1673 { | |
| 1674 struct frame *sel_frame = selected_frame (); | |
| 1675 Fset_window_buffer (sel_frame->minibuffer_window, | |
| 440 | 1676 XWINDOW (minibuf_window)->buffer, Qt); |
| 428 | 1677 minibuf_window = sel_frame->minibuffer_window; |
| 1678 | |
| 1679 /* If the dying minibuffer window was selected, | |
| 1680 select the new one. */ | |
| 1681 if (minibuffer_selected) | |
| 1682 Fselect_window (minibuf_window, Qnil); | |
| 1683 } | |
| 1684 | |
| 1685 /* After this point, no errors must be allowed to occur. */ | |
| 1686 | |
| 1313 | 1687 /* Checking for QUIT can run all sorts of weird code and may be deadly |
| 1688 so don't let it happen. */ | |
| 1689 depth = begin_dont_check_for_quit (); | |
| 1690 | |
| 428 | 1691 #ifdef HAVE_MENUBARS |
| 1692 free_frame_menubars (f); | |
| 1693 #endif | |
| 1694 #ifdef HAVE_SCROLLBARS | |
| 1695 free_frame_scrollbars (f); | |
| 1696 #endif | |
| 1697 #ifdef HAVE_TOOLBARS | |
| 1698 free_frame_toolbars (f); | |
| 1699 #endif | |
| 1700 free_frame_gutters (f); | |
| 442 | 1701 /* Unfortunately deleting the frame will also delete the parent of |
| 1702 all of the subwindow instances current on the frame. I think this | |
| 1703 can lead to bad things when trying to finalize the | |
| 1704 instances. Thus we loop over all instance caches calling the | |
| 1705 finalize method for each instance. */ | |
| 1706 free_frame_subwindow_instances (f); | |
| 428 | 1707 |
| 1708 /* This must be done before the window and window_mirror structures | |
| 1709 are freed. The scrollbar information is attached to them. */ | |
| 1710 MAYBE_FRAMEMETH (f, delete_frame, (f)); | |
| 1711 | |
| 1712 /* Mark all the windows that used to be on FRAME as deleted, and then | |
| 1713 remove the reference to them. */ | |
| 1714 delete_all_subwindows (XWINDOW (f->root_window)); | |
| 1715 f->root_window = Qnil; | |
| 1716 | |
| 1717 /* clear out the cached glyph information */ | |
| 442 | 1718 f->subwindow_instance_cache = Qnil; |
| 428 | 1719 |
| 1720 /* Remove the frame now from the list. This way, any events generated | |
| 1721 on this frame by the maneuvers below will disperse themselves. */ | |
| 1722 | |
| 1723 /* This used to be Fdelq(), but that will cause a seg fault if the | |
| 1724 QUIT checker happens to get invoked, because the frame list is in | |
| 1725 an inconsistent state. */ | |
| 1726 d->frame_list = delq_no_quit (frame, d->frame_list); | |
| 1727 RESET_CHANGED_SET_FLAGS; | |
| 1728 | |
| 1729 f->visible = 0; | |
| 1730 | |
| 617 | 1731 free_window_mirror (XWINDOW_MIRROR (f->root_mirror)); |
| 853 | 1732 |
| 428 | 1733 /* free_line_insertion_deletion_costs (f); */ |
| 1734 | |
| 1735 /* If we've deleted the last non-minibuf frame, then try to find | |
| 1736 another one. */ | |
| 1737 if (EQ (frame, CONSOLE_LAST_NONMINIBUF_FRAME (con))) | |
| 1738 { | |
| 1739 Lisp_Object frmcons, devcons; | |
| 1740 | |
| 1741 set_console_last_nonminibuf_frame (con, Qnil); | |
| 1742 | |
| 1743 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, con) | |
| 1744 { | |
| 1745 Lisp_Object ecran = XCAR (frmcons); | |
| 1746 if (!FRAME_MINIBUF_ONLY_P (XFRAME (ecran))) | |
| 1747 { | |
| 1748 set_console_last_nonminibuf_frame (con, ecran); | |
| 1749 goto double_break_1; | |
| 1750 } | |
| 1751 } | |
| 1752 } | |
| 1753 double_break_1: | |
| 1754 | |
| 1755 #if 0 | |
| 1756 /* The following test is degenerate FALSE */ | |
| 1757 if (called_from_delete_device < 0) | |
| 1758 /* then we're being called from delete-console, and we shouldn't | |
| 1759 try to find another default-minibuffer frame for the console. | |
| 1760 */ | |
| 1761 con->default_minibuffer_frame = Qnil; | |
| 1762 #endif | |
| 1763 | |
| 1764 /* If we've deleted this console's default_minibuffer_frame, try to | |
| 1765 find another one. Prefer minibuffer-only frames, but also notice | |
| 1766 frames with other windows. */ | |
| 1767 if (EQ (frame, con->default_minibuffer_frame)) | |
| 1768 { | |
| 1769 Lisp_Object frmcons, devcons; | |
| 1770 /* The last frame we saw with a minibuffer, minibuffer-only or not. */ | |
| 1771 Lisp_Object frame_with_minibuf; | |
| 1772 /* Some frame we found on the same console, or nil if there are none. */ | |
| 1773 Lisp_Object frame_on_same_console; | |
| 1774 | |
| 1775 frame_on_same_console = Qnil; | |
| 1776 frame_with_minibuf = Qnil; | |
| 1777 | |
| 1778 set_console_last_nonminibuf_frame (con, Qnil); | |
| 1779 | |
| 1780 CONSOLE_FRAME_LOOP_NO_BREAK (frmcons, devcons, con) | |
| 1781 { | |
| 2552 | 1782 Lisp_Object this_frame; |
| 428 | 1783 struct frame *f1; |
| 1784 | |
| 2552 | 1785 this_frame = XCAR (frmcons); |
| 1786 f1 = XFRAME (this_frame); | |
| 428 | 1787 |
| 1788 /* Consider only frames on the same console | |
| 1789 and only those with minibuffers. */ | |
| 1790 if (FRAME_HAS_MINIBUF_P (f1)) | |
| 1791 { | |
| 2552 | 1792 frame_with_minibuf = this_frame; |
| 428 | 1793 if (FRAME_MINIBUF_ONLY_P (f1)) |
| 1794 goto double_break_2; | |
| 1795 } | |
| 1796 | |
| 2552 | 1797 frame_on_same_console = this_frame; |
| 428 | 1798 } |
| 1799 double_break_2: | |
| 1800 | |
| 1801 if (!NILP (frame_on_same_console)) | |
| 1802 { | |
| 1803 /* We know that there must be some frame with a minibuffer out | |
| 1804 there. If this were not true, all of the frames present | |
| 1805 would have to be minibuffer-less, which implies that at some | |
| 1806 point their minibuffer frames must have been deleted, but | |
| 1807 that is prohibited at the top; you can't delete surrogate | |
| 1808 minibuffer frames. */ | |
| 1809 if (NILP (frame_with_minibuf)) | |
| 2500 | 1810 ABORT (); |
| 428 | 1811 |
| 1812 con->default_minibuffer_frame = frame_with_minibuf; | |
| 1813 } | |
| 1814 else | |
| 1815 /* No frames left on this console--say no minibuffer either. */ | |
| 1816 con->default_minibuffer_frame = Qnil; | |
| 1817 } | |
| 1818 | |
| 617 | 1819 /* Nobody should be accessing anything in this object any more, and |
| 1820 making all Lisp_Objects Qnil allows for better GC'ing in case a | |
| 1821 pointer to the dead frame continues to hang around. Zero all | |
| 1822 other structs in case someone tries to access something through | |
| 1823 them. */ | |
| 1824 | |
| 1825 nuke_all_frame_slots (f); | |
| 428 | 1826 f->framemeths = dead_console_methods; |
| 1204 | 1827 f->frametype = dead_console; |
| 617 | 1828 |
| 853 | 1829 note_object_deleted (frame); |
| 1830 | |
| 1313 | 1831 unbind_to (depth); |
| 1832 | |
| 428 | 1833 UNGCPRO; |
| 1834 } | |
| 1835 | |
| 1836 void | |
| 1837 io_error_delete_frame (Lisp_Object frame) | |
| 1838 { | |
| 1839 delete_frame_internal (XFRAME (frame), 1, 0, 1); | |
| 1840 } | |
| 1841 | |
| 1842 DEFUN ("delete-frame", Fdelete_frame, 0, 2, "", /* | |
| 1843 Delete FRAME, permanently eliminating it from use. | |
| 1844 If omitted, FRAME defaults to the selected frame. | |
| 1845 A frame may not be deleted if its minibuffer is used by other frames. | |
| 1846 Normally, you cannot delete the last non-minibuffer-only frame (you must | |
| 1847 use `save-buffers-kill-emacs' or `kill-emacs'). However, if optional | |
| 1848 second argument FORCE is non-nil, you can delete the last frame. (This | |
| 1849 will automatically call `save-buffers-kill-emacs'.) | |
| 1850 */ | |
| 1851 (frame, force)) | |
| 1852 { | |
| 1853 /* This function can GC */ | |
| 1854 struct frame *f; | |
| 1855 | |
| 1856 if (NILP (frame)) | |
| 1857 { | |
| 1858 f = selected_frame (); | |
| 793 | 1859 frame = wrap_frame (f); |
| 428 | 1860 } |
| 1861 else | |
| 1862 { | |
| 1863 CHECK_FRAME (frame); | |
| 1864 f = XFRAME (frame); | |
| 1865 } | |
| 1866 | |
| 1867 delete_frame_internal (f, !NILP (force), 0, 0); | |
| 1868 return Qnil; | |
| 1869 } | |
| 1870 | |
| 1871 | |
| 1872 /* Return mouse position in character cell units. */ | |
| 1873 | |
| 1874 static int | |
| 1875 mouse_pixel_position_1 (struct device *d, Lisp_Object *frame, | |
| 1876 int *x, int *y) | |
| 1877 { | |
| 1878 switch (DEVMETH_OR_GIVEN (d, get_mouse_position, (d, frame, x, y), -1)) | |
| 1879 { | |
| 1880 case 1: | |
| 1881 return 1; | |
| 1882 | |
| 1883 case 0: | |
| 1884 *frame = Qnil; | |
| 1885 break; | |
| 1886 | |
| 1887 case -1: | |
| 1888 *frame = DEVICE_SELECTED_FRAME (d); | |
| 1889 break; | |
| 1890 | |
| 1891 default: | |
| 2500 | 1892 ABORT (); /* method is incorrectly written */ |
| 428 | 1893 } |
| 1894 | |
| 1895 return 0; | |
| 1896 } | |
| 1897 | |
| 1898 DEFUN ("mouse-pixel-position", Fmouse_pixel_position, 0, 1, 0, /* | |
| 1899 Return a list (WINDOW X . Y) giving the current mouse window and position. | |
| 442 | 1900 The position is given in pixel units, where (0, 0) is the upper-left corner |
| 1901 of the window. | |
| 428 | 1902 |
| 1903 When the cursor is not over a window, the return value is a list (nil nil). | |
| 1904 | |
| 1905 DEVICE specifies the device on which to read the mouse position, and | |
| 1906 defaults to the selected device. If the device is a mouseless terminal | |
| 442 | 1907 or XEmacs hasn't been programmed to read its mouse position, it returns |
| 428 | 1908 the device's selected window for WINDOW and nil for X and Y. |
| 1909 */ | |
| 1910 (device)) | |
| 1911 { | |
| 1912 struct device *d = decode_device (device); | |
| 1913 Lisp_Object frame; | |
| 1914 Lisp_Object window = Qnil; | |
| 1915 Lisp_Object x = Qnil; | |
| 1916 Lisp_Object y = Qnil; | |
| 1917 int intx, inty; | |
| 1918 | |
| 1919 if (mouse_pixel_position_1 (d, &frame, &intx, &inty) > 0) | |
| 1920 { | |
| 1921 struct window *w = | |
| 1922 find_window_by_pixel_pos (intx, inty, XFRAME (frame)->root_window); | |
| 1923 if (w) | |
| 1924 { | |
| 793 | 1925 window = wrap_window (w); |
| 428 | 1926 |
| 1927 /* Adjust the position to be relative to the window. */ | |
| 1928 intx -= w->pixel_left; | |
| 1929 inty -= w->pixel_top; | |
| 793 | 1930 x = make_int (intx); |
| 1931 y = make_int (inty); | |
| 428 | 1932 } |
| 1933 } | |
| 1934 else if (FRAMEP (frame)) | |
| 1935 window = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
| 1936 | |
| 1937 return Fcons (window, Fcons (x, y)); | |
| 1938 } | |
| 1939 | |
| 1940 DEFUN ("mouse-position", Fmouse_position, 0, 1, 0, /* | |
| 1941 Return a list (WINDOW X . Y) giving the current mouse window and position. | |
| 1942 The position is of a character under cursor, where (0, 0) is the upper-left | |
| 1943 corner of the window. | |
| 1944 | |
| 1945 When the cursor is not over a character, or not over a window, the return | |
| 1946 value is a list (nil nil). | |
| 1947 | |
| 1948 DEVICE specifies the device on which to read the mouse position, and | |
| 1949 defaults to the selected device. If the device is a mouseless terminal | |
| 1950 or Emacs hasn't been programmed to read its mouse position, it returns | |
| 1951 the device's selected window for WINDOW and nil for X and Y. | |
| 1952 */ | |
| 1953 (device)) | |
| 1954 { | |
| 1955 struct device *d = decode_device (device); | |
| 1956 struct window *w; | |
| 1957 Lisp_Object frame, window = Qnil, lisp_x = Qnil, lisp_y = Qnil; | |
| 1958 int x, y, obj_x, obj_y; | |
| 665 | 1959 Charbpos charbpos, closest; |
| 428 | 1960 Charcount modeline_closest; |
| 1961 Lisp_Object obj1, obj2; | |
| 1962 | |
| 1963 if (mouse_pixel_position_1 (d, &frame, &x, &y) > 0) | |
| 1964 { | |
| 1965 int res = pixel_to_glyph_translation (XFRAME (frame), x, y, &x, &y, | |
| 665 | 1966 &obj_x, &obj_y, &w, &charbpos, |
| 428 | 1967 &closest, &modeline_closest, |
| 1968 &obj1, &obj2); | |
| 1969 if (res == OVER_TEXT) | |
| 1970 { | |
| 1971 lisp_x = make_int (x); | |
| 1972 lisp_y = make_int (y); | |
| 793 | 1973 window = wrap_window (w); |
| 428 | 1974 } |
| 1975 } | |
| 1976 else if (FRAMEP (frame)) | |
| 1977 window = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
| 1978 | |
| 1979 return Fcons (window, Fcons (lisp_x, lisp_y)); | |
| 1980 } | |
| 1981 | |
| 1982 DEFUN ("mouse-position-as-motion-event", Fmouse_position_as_motion_event, 0, 1, 0, /* | |
| 1983 Return the current mouse position as a motion event. | |
| 1984 This allows you to call the standard event functions such as | |
| 1985 `event-over-toolbar-p' to determine where the mouse is. | |
| 1986 | |
| 1987 DEVICE specifies the device on which to read the mouse position, and | |
| 1988 defaults to the selected device. If the mouse position can't be determined | |
| 1989 \(e.g. DEVICE is a TTY device), nil is returned instead of an event. | |
| 1990 */ | |
| 1991 (device)) | |
| 1992 { | |
| 1993 struct device *d = decode_device (device); | |
| 1994 Lisp_Object frame; | |
| 1995 int intx, inty; | |
| 1996 | |
| 1997 if (mouse_pixel_position_1 (d, &frame, &intx, &inty)) | |
| 1998 { | |
| 1999 Lisp_Object event = Fmake_event (Qnil, Qnil); | |
| 934 | 2000 XSET_EVENT_TYPE (event, pointer_motion_event); |
| 2001 XSET_EVENT_CHANNEL (event, frame); | |
| 1204 | 2002 XSET_EVENT_MOTION_X (event, intx); |
| 2003 XSET_EVENT_MOTION_Y (event, inty); | |
| 428 | 2004 return event; |
| 2005 } | |
| 2006 else | |
| 2007 return Qnil; | |
| 2008 } | |
| 2009 | |
| 2010 DEFUN ("set-mouse-position", Fset_mouse_position, 3, 3, 0, /* | |
| 2011 Move the mouse pointer to the center of character cell (X,Y) in WINDOW. | |
| 2012 Note, this is a no-op for an X frame that is not visible. | |
| 2013 If you have just created a frame, you must wait for it to become visible | |
| 2014 before calling this function on it, like this. | |
| 2015 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
| 2016 Note also: Warping the mouse is contrary to the ICCCM, so be very sure | |
| 2017 that the behavior won't end up being obnoxious! | |
| 2018 */ | |
| 2019 (window, x, y)) | |
| 2020 { | |
| 2021 struct window *w; | |
| 2022 int pix_x, pix_y; | |
| 2023 | |
| 2024 CHECK_LIVE_WINDOW (window); | |
| 2025 CHECK_INT (x); | |
| 2026 CHECK_INT (y); | |
| 2027 | |
| 2028 /* Warping the mouse will cause EnterNotify and Focus events under X. */ | |
| 2029 w = XWINDOW (window); | |
| 2030 glyph_to_pixel_translation (w, XINT (x), XINT (y), &pix_x, &pix_y); | |
| 2031 | |
| 2032 MAYBE_FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, pix_x, pix_y)); | |
| 2033 | |
| 2034 return Qnil; | |
| 2035 } | |
| 2036 | |
| 2037 DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position, 3, 3, 0, /* | |
| 2038 Move the mouse pointer to pixel position (X,Y) in WINDOW. | |
| 2039 Note, this is a no-op for an X frame that is not visible. | |
| 2040 If you have just created a frame, you must wait for it to become visible | |
| 2041 before calling this function on it, like this. | |
| 2042 (while (not (frame-visible-p frame)) (sleep-for .5)) | |
| 2043 */ | |
| 2044 (window, x, y)) | |
| 2045 { | |
| 2046 struct window *w; | |
| 2047 | |
| 2048 CHECK_LIVE_WINDOW (window); | |
| 2049 CHECK_INT (x); | |
| 2050 CHECK_INT (y); | |
| 2051 | |
| 2052 /* Warping the mouse will cause EnterNotify and Focus events under X. */ | |
| 2053 w = XWINDOW (window); | |
| 2054 FRAMEMETH (XFRAME (w->frame), set_mouse_position, (w, XINT (x), XINT (y))); | |
| 2055 | |
| 2056 return Qnil; | |
| 2057 } | |
| 2058 | |
| 2059 DEFUN ("make-frame-visible", Fmake_frame_visible, 0, 1, 0, /* | |
| 2060 Make the frame FRAME visible (assuming it is an X-window). | |
| 2061 If omitted, FRAME defaults to the currently selected frame. | |
| 2062 Also raises the frame so that nothing obscures it. | |
| 2063 */ | |
| 2064 (frame)) | |
| 2065 { | |
| 2066 struct frame *f = decode_frame (frame); | |
| 2067 | |
| 2068 MAYBE_FRAMEMETH (f, make_frame_visible, (f)); | |
| 2069 return frame; | |
| 2070 } | |
| 2071 | |
| 2072 DEFUN ("make-frame-invisible", Fmake_frame_invisible, 0, 2, 0, /* | |
| 2073 Unconditionally removes frame from the display (assuming it is an X-window). | |
| 2074 If omitted, FRAME defaults to the currently selected frame. | |
| 2075 If what you want to do is iconify the frame (if the window manager uses | |
| 2076 icons) then you should call `iconify-frame' instead. | |
| 2077 Normally you may not make FRAME invisible if all other frames are invisible | |
| 2078 and uniconified, but if the second optional argument FORCE is non-nil, | |
| 2079 you may do so. | |
| 2080 */ | |
| 2081 (frame, force)) | |
| 2082 { | |
| 2083 struct frame *f, *sel_frame; | |
| 2084 struct device *d; | |
| 2085 | |
| 2086 f = decode_frame (frame); | |
| 2087 d = XDEVICE (FRAME_DEVICE (f)); | |
| 2088 sel_frame = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
| 2089 | |
| 2090 if (NILP (force) && !other_visible_frames (f)) | |
| 563 | 2091 invalid_operation ("Attempt to make invisible the sole visible or iconified frame", Qunbound); |
| 428 | 2092 |
| 2093 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
| 2094 if (EQ (f->minibuffer_window, minibuf_window)) | |
| 2095 { | |
| 2096 Fset_window_buffer (sel_frame->minibuffer_window, | |
| 440 | 2097 XWINDOW (minibuf_window)->buffer, Qt); |
| 428 | 2098 minibuf_window = sel_frame->minibuffer_window; |
| 2099 } | |
| 2100 | |
| 2101 MAYBE_FRAMEMETH (f, make_frame_invisible, (f)); | |
| 2102 | |
| 2103 return Qnil; | |
| 2104 } | |
| 2105 | |
| 2106 DEFUN ("iconify-frame", Ficonify_frame, 0, 1, "", /* | |
| 2107 Make the frame FRAME into an icon, if the window manager supports icons. | |
| 2108 If omitted, FRAME defaults to the currently selected frame. | |
| 2109 */ | |
| 2110 (frame)) | |
| 2111 { | |
| 2112 struct frame *f, *sel_frame; | |
| 2113 struct device *d; | |
| 2114 | |
| 2115 f = decode_frame (frame); | |
| 2116 d = XDEVICE (FRAME_DEVICE (f)); | |
| 2117 sel_frame = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
| 2118 | |
| 2119 /* Don't allow minibuf_window to remain on a deleted frame. */ | |
| 2120 if (EQ (f->minibuffer_window, minibuf_window)) | |
| 2121 { | |
| 2122 Fset_window_buffer (sel_frame->minibuffer_window, | |
| 440 | 2123 XWINDOW (minibuf_window)->buffer, Qt); |
| 428 | 2124 minibuf_window = sel_frame->minibuffer_window; |
| 2125 } | |
| 2126 | |
| 2127 MAYBE_FRAMEMETH (f, iconify_frame, (f)); | |
| 2128 | |
| 2129 return Qnil; | |
| 2130 } | |
| 2131 | |
| 2132 DEFUN ("deiconify-frame", Fdeiconify_frame, 0, 1, 0, /* | |
| 2133 Open (de-iconify) the iconified frame FRAME. | |
| 2134 Under X, this is currently the same as `make-frame-visible'. | |
| 2135 If omitted, FRAME defaults to the currently selected frame. | |
| 2136 Also raises the frame so that nothing obscures it. | |
| 2137 */ | |
| 2138 (frame)) | |
| 2139 { | |
| 2140 return Fmake_frame_visible (frame); | |
| 2141 } | |
| 2142 | |
| 3025 | 2143 /* FSF returns `icon' for iconized frames. What a crock! */ |
| 428 | 2144 |
| 2145 DEFUN ("frame-visible-p", Fframe_visible_p, 0, 1, 0, /* | |
| 2146 Return non NIL if FRAME is now "visible" (actually in use for display). | |
| 2147 A frame that is not visible is not updated, and, if it works through a | |
| 2148 window system, may not show at all. | |
| 2149 N.B. Under X "visible" means Mapped. It the window is mapped but not | |
| 3025 | 2150 actually visible on screen then `frame-visible-p' returns `hidden'. |
| 428 | 2151 */ |
| 2152 (frame)) | |
| 2153 { | |
| 2154 struct frame *f = decode_frame (frame); | |
| 2155 int visible = FRAMEMETH_OR_GIVEN (f, frame_visible_p, (f), f->visible); | |
| 2156 return visible ? ( visible > 0 ? Qt : Qhidden ) : Qnil; | |
| 2157 } | |
| 2158 | |
| 2159 DEFUN ("frame-totally-visible-p", Fframe_totally_visible_p, 0, 1, 0, /* | |
| 2160 Return t if frame is not obscured by any other window system windows. | |
| 2161 Always returns t for tty frames. | |
| 2162 */ | |
| 2163 (frame)) | |
| 2164 { | |
| 2165 struct frame *f = decode_frame (frame); | |
| 2166 return (FRAMEMETH_OR_GIVEN (f, frame_totally_visible_p, (f), f->visible) | |
| 2167 ? Qt : Qnil); | |
| 2168 } | |
| 2169 | |
| 2170 DEFUN ("frame-iconified-p", Fframe_iconified_p, 0, 1, 0, /* | |
| 2171 Return t if FRAME is iconified. | |
| 2172 Not all window managers use icons; some merely unmap the window, so this | |
| 2173 function is not the inverse of `frame-visible-p'. It is possible for a | |
| 2174 frame to not be visible and not be iconified either. However, if the | |
| 2175 frame is iconified, it will not be visible. | |
| 2176 */ | |
| 2177 (frame)) | |
| 2178 { | |
| 2179 struct frame *f = decode_frame (frame); | |
| 2180 if (f->visible) | |
| 2181 return Qnil; | |
| 2182 f->iconified = FRAMEMETH_OR_GIVEN (f, frame_iconified_p, (f), 0); | |
| 2183 return f->iconified ? Qt : Qnil; | |
| 2184 } | |
| 2185 | |
| 2186 DEFUN ("visible-frame-list", Fvisible_frame_list, 0, 1, 0, /* | |
| 2187 Return a list of all frames now "visible" (being updated). | |
| 2188 If DEVICE is specified only frames on that device will be returned. | |
| 460 | 2189 Note that under virtual window managers not all these frames are |
| 2190 necessarily really updated. | |
| 428 | 2191 */ |
| 2192 (device)) | |
| 2193 { | |
| 2194 Lisp_Object devcons, concons; | |
| 2195 struct frame *f; | |
| 2196 Lisp_Object value; | |
| 2197 | |
| 2198 value = Qnil; | |
| 2199 | |
| 2200 DEVICE_LOOP_NO_BREAK (devcons, concons) | |
| 2201 { | |
| 2202 assert (DEVICEP (XCAR (devcons))); | |
| 2203 | |
| 2204 if (NILP (device) || EQ (device, XCAR (devcons))) | |
| 2205 { | |
| 2206 Lisp_Object frmcons; | |
| 2207 | |
| 2208 DEVICE_FRAME_LOOP (frmcons, XDEVICE (XCAR (devcons))) | |
| 2209 { | |
| 2210 Lisp_Object frame = XCAR (frmcons); | |
| 2211 f = XFRAME (frame); | |
| 2212 if (FRAME_VISIBLE_P(f)) | |
| 2213 value = Fcons (frame, value); | |
| 2214 } | |
| 2215 } | |
| 2216 } | |
| 2217 | |
| 2218 return value; | |
| 2219 } | |
| 2220 | |
| 2221 | |
| 2222 DEFUN ("raise-frame", Fraise_frame, 0, 1, "", /* | |
| 2223 Bring FRAME to the front, so it occludes any frames it overlaps. | |
| 2224 If omitted, FRAME defaults to the currently selected frame. | |
| 2225 If FRAME is invisible, make it visible. | |
| 2226 If Emacs is displaying on an ordinary terminal or some other device which | |
| 2227 doesn't support multiple overlapping frames, this function does nothing. | |
| 2228 */ | |
| 2229 (frame)) | |
| 2230 { | |
| 2231 struct frame *f = decode_frame (frame); | |
| 2232 | |
| 2233 /* Do like the documentation says. */ | |
| 2234 Fmake_frame_visible (frame); | |
| 2235 MAYBE_FRAMEMETH (f, raise_frame, (f)); | |
| 2236 return Qnil; | |
| 2237 } | |
| 2238 | |
| 2239 DEFUN ("lower-frame", Flower_frame, 0, 1, "", /* | |
| 2240 Send FRAME to the back, so it is occluded by any frames that overlap it. | |
| 2241 If omitted, FRAME defaults to the currently selected frame. | |
| 2242 If Emacs is displaying on an ordinary terminal or some other device which | |
| 2243 doesn't support multiple overlapping frames, this function does nothing. | |
| 2244 */ | |
| 2245 (frame)) | |
| 2246 { | |
| 2247 struct frame *f = decode_frame (frame); | |
| 2248 | |
| 2249 MAYBE_FRAMEMETH (f, lower_frame, (f)); | |
| 2250 return Qnil; | |
| 2251 } | |
| 2252 | |
| 442 | 2253 |
| 2254 DEFUN ("disable-frame", Fdisable_frame, 1, 1, 0, /* | |
| 2255 Disable frame FRAME, so that it cannot have the focus or receive user input. | |
| 2256 This is normally used during modal dialog boxes. | |
| 2257 WARNING: Be very careful not to wedge XEmacs! | |
| 2258 Use an `unwind-protect' that re-enables the frame to avoid this. | |
| 2259 */ | |
| 2260 (frame)) | |
| 2261 { | |
| 2262 struct frame *f = decode_frame (frame); | |
| 2263 | |
| 2264 f->disabled = 1; | |
| 2265 MAYBE_FRAMEMETH (f, disable_frame, (f)); | |
| 2266 return Qnil; | |
| 2267 } | |
| 2268 | |
| 2269 DEFUN ("enable-frame", Fenable_frame, 1, 1, 0, /* | |
| 2270 Enable frame FRAME, so that it can have the focus and receive user input. | |
| 2271 Frames are normally enabled, unless explicitly disabled using `disable-frame'. | |
| 2272 */ | |
| 2273 (frame)) | |
| 2274 { | |
| 2275 struct frame *f = decode_frame (frame); | |
| 2276 f->disabled = 0; | |
| 2277 MAYBE_FRAMEMETH (f, enable_frame, (f)); | |
| 2278 return Qnil; | |
| 2279 } | |
| 2280 | |
| 428 | 2281 /* Ben thinks there is no need for `redirect-frame-focus' or `frame-focus', |
| 2282 crockish FSFmacs functions. See summary on focus in event-stream.c. */ | |
| 442 | 2283 |
| 2284 DEFUN ("print-job-page-number", Fprint_job_page_number, 1, 1, 0, /* | |
| 2285 Return current page number for the print job FRAME. | |
| 2286 */ | |
| 2287 (frame)) | |
| 2288 { | |
| 2289 CHECK_PRINTER_FRAME (frame); | |
| 2290 return make_int (FRAME_PAGENUMBER (XFRAME (frame))); | |
| 2291 } | |
| 2292 | |
| 2293 DEFUN ("print-job-eject-page", Fprint_job_eject_page, 1, 1, 0, /* | |
| 2294 Eject page in the print job FRAME. | |
| 2295 */ | |
| 2296 (frame)) | |
| 2297 { | |
| 2298 struct frame *f; | |
| 2299 | |
| 2300 CHECK_PRINTER_FRAME (frame); | |
| 2301 f = XFRAME (frame); | |
| 2302 FRAMEMETH (f, eject_page, (f)); | |
| 2303 FRAME_SET_PAGENUMBER (f, 1 + FRAME_PAGENUMBER (f)); | |
| 2304 f->clear = 1; | |
| 2305 | |
| 2306 return Qnil; | |
| 2307 } | |
| 428 | 2308 |
| 2309 | |
| 2310 /***************************************************************************/ | |
| 2311 /* frame properties */ | |
| 2312 /***************************************************************************/ | |
| 2313 | |
| 2314 static void internal_set_frame_size (struct frame *f, int cols, int rows, | |
| 2315 int pretend); | |
| 2316 | |
| 2317 static void | |
| 2318 store_minibuf_frame_prop (struct frame *f, Lisp_Object val) | |
| 2319 { | |
| 1318 | 2320 /* This can call Lisp. */ |
| 793 | 2321 Lisp_Object frame = wrap_frame (f); |
| 2322 | |
| 428 | 2323 if (WINDOWP (val)) |
| 2324 { | |
| 2325 if (! MINI_WINDOW_P (XWINDOW (val))) | |
| 563 | 2326 gui_error |
| 428 | 2327 ("Surrogate minibuffer windows must be minibuffer windows", |
| 2328 val); | |
| 2329 | |
| 2330 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) | |
| 563 | 2331 gui_error |
| 428 | 2332 ("Can't change the surrogate minibuffer of a frame with its own minibuffer", frame); |
| 2333 | |
| 2334 /* Install the chosen minibuffer window, with proper buffer. */ | |
| 2335 f->minibuffer_window = val; | |
| 2336 } | |
| 2337 else if (EQ (val, Qt)) | |
| 2338 { | |
| 2339 if (FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) | |
| 563 | 2340 gui_error |
| 428 | 2341 ("Frame already has its own minibuffer", frame); |
| 2342 else | |
| 2343 { | |
| 2344 setup_normal_frame (f); | |
| 2345 f->mirror_dirty = 1; | |
| 2346 | |
| 2347 update_frame_window_mirror (f); | |
| 2348 internal_set_frame_size (f, f->width, f->height, 1); | |
| 2349 } | |
| 2350 } | |
| 2351 } | |
| 2352 | |
| 2353 #if 0 | |
| 2354 | |
| 2355 /* possible code if you want to have symbols such as `default-background' | |
| 2356 map to setting the background of `default', etc. */ | |
| 2357 | |
| 2358 static int | |
| 2359 dissect_as_face_setting (Lisp_Object sym, Lisp_Object *face_out, | |
| 2360 Lisp_Object *face_prop_out) | |
| 2361 { | |
| 2362 Lisp_Object list = Vbuilt_in_face_specifiers; | |
| 793 | 2363 Lisp_Object s; |
| 428 | 2364 |
| 2365 if (!SYMBOLP (sym)) | |
| 2366 return 0; | |
| 2367 | |
| 2368 s = symbol_name (XSYMBOL (sym)); | |
| 2369 | |
| 2370 while (!NILP (list)) | |
| 2371 { | |
| 2372 Lisp_Object prop = Fcar (list); | |
| 793 | 2373 Lisp_Object prop_name; |
| 428 | 2374 |
| 2375 if (!SYMBOLP (prop)) | |
| 2376 continue; | |
| 2377 prop_name = symbol_name (XSYMBOL (prop)); | |
| 793 | 2378 if (XSTRING_LENGTH (s) > XSTRING_LENGTH (prop_name) + 1 |
| 2379 && !memcmp (XSTRING_DATA (prop_name), | |
| 2380 XSTRING_DATA (s) + XSTRING_LENGTH (s) | |
| 2381 - XSTRING_LENGTH (prop_name), | |
| 2382 XSTRING_LENGTH (prop_name)) | |
| 2383 && XSTRING_DATA (s)[XSTRING_LENGTH (s) - XSTRING_LENGTH (prop_name) | |
| 428 | 2384 - 1] == '-') |
| 2385 { | |
| 2386 Lisp_Object face = | |
| 793 | 2387 Ffind_face (make_string (XSTRING_DATA (s), |
| 2388 XSTRING_LENGTH (s) | |
| 2389 - XSTRING_LENGTH (prop_name) | |
| 428 | 2390 - 1)); |
| 2391 if (!NILP (face)) | |
| 2392 { | |
| 2393 *face_out = face; | |
| 2394 *face_prop_out = prop; | |
| 2395 return 1; | |
| 2396 } | |
| 2397 } | |
| 2398 | |
| 2399 list = Fcdr (list); | |
| 2400 } | |
| 2401 | |
| 2402 return 0; | |
| 2403 } | |
| 2404 | |
| 2405 #endif /* 0 */ | |
| 2406 | |
| 2407 static Lisp_Object | |
| 2408 get_property_alias (Lisp_Object prop) | |
| 2409 { | |
| 2410 while (1) | |
| 2411 { | |
| 2412 Lisp_Object alias = Qnil; | |
| 2413 | |
| 2414 if (SYMBOLP (prop)) | |
| 2415 alias = Fget (prop, Qframe_property_alias, Qnil); | |
| 2416 if (NILP (alias)) | |
| 2417 break; | |
| 2418 prop = alias; | |
| 2419 QUIT; | |
| 2420 } | |
| 2421 | |
| 2422 return prop; | |
| 2423 } | |
| 2424 | |
| 2425 /* #### Using this to modify the internal border width has no effect | |
| 2426 because the change isn't propagated to the windows. Are there | |
| 2427 other properties which this claims to handle, but doesn't? | |
| 2428 | |
| 2429 But of course. This stuff needs more work, but it's a lot closer | |
| 2430 to sanity now than before with the horrible frame-params stuff. */ | |
| 2431 | |
| 2432 DEFUN ("set-frame-properties", Fset_frame_properties, 2, 2, 0, /* | |
| 2433 Change some properties of a frame. | |
| 2434 PLIST is a property list. | |
| 2435 You can also change frame properties individually using `set-frame-property', | |
| 2436 but it may be more efficient to change many properties at once. | |
| 2437 | |
| 2438 Frame properties can be retrieved using `frame-property' or `frame-properties'. | |
| 2439 | |
| 2440 The following symbols etc. have predefined meanings: | |
| 2441 | |
| 2442 name Name of the frame. Used with X resources. | |
| 2443 Unchangeable after creation. | |
| 2444 | |
| 2445 height Height of the frame, in lines. | |
| 2446 | |
| 2447 width Width of the frame, in characters. | |
| 2448 | |
| 2449 minibuffer Gives the minibuffer behavior for this frame. Either | |
| 2450 t (frame has its own minibuffer), `only' (frame is | |
| 442 | 2451 a minibuffer-only frame), `none' (frame has no minibuffer) |
| 2452 or a window (frame uses that window, which is on another | |
| 2453 frame, as the minibuffer). | |
| 428 | 2454 |
| 2455 unsplittable If non-nil, frame cannot be split by `display-buffer'. | |
| 2456 | |
| 2457 current-display-table, menubar-visible-p, left-margin-width, | |
| 2458 right-margin-width, minimum-line-ascent, minimum-line-descent, | |
| 2459 use-left-overflow, use-right-overflow, scrollbar-width, scrollbar-height, | |
| 2460 default-toolbar, top-toolbar, bottom-toolbar, left-toolbar, right-toolbar, | |
| 2461 default-toolbar-height, default-toolbar-width, top-toolbar-height, | |
| 2462 bottom-toolbar-height, left-toolbar-width, right-toolbar-width, | |
| 2463 default-toolbar-visible-p, top-toolbar-visible-p, bottom-toolbar-visible-p, | |
| 2464 left-toolbar-visible-p, right-toolbar-visible-p, toolbar-buttons-captioned-p, | |
| 2465 top-toolbar-border-width, bottom-toolbar-border-width, | |
| 2466 left-toolbar-border-width, right-toolbar-border-width, | |
| 442 | 2467 modeline-shadow-thickness, has-modeline-p, |
| 2468 default-gutter, top-gutter, bottom-gutter, left-gutter, right-gutter, | |
| 2469 default-gutter-height, default-gutter-width, top-gutter-height, | |
| 2470 bottom-gutter-height, left-gutter-width, right-gutter-width, | |
| 2471 default-gutter-visible-p, top-gutter-visible-p, bottom-gutter-visible-p, | |
| 2472 left-gutter-visible-p, right-gutter-visible-p, top-gutter-border-width, | |
| 2473 bottom-gutter-border-width, left-gutter-border-width, right-gutter-border-width, | |
| 428 | 2474 [Giving the name of any built-in specifier variable is |
| 2475 equivalent to calling `set-specifier' on the specifier, | |
| 2476 with a locale of FRAME. Giving the name to `frame-property' | |
| 2477 calls `specifier-instance' on the specifier.] | |
| 2478 | |
| 2479 text-pointer-glyph, nontext-pointer-glyph, modeline-pointer-glyph, | |
| 2480 selection-pointer-glyph, busy-pointer-glyph, toolbar-pointer-glyph, | |
| 2481 menubar-pointer-glyph, scrollbar-pointer-glyph, gc-pointer-glyph, | |
| 2482 octal-escape-glyph, control-arrow-glyph, invisible-text-glyph, | |
| 2483 hscroll-glyph, truncation-glyph, continuation-glyph | |
| 2484 [Giving the name of any glyph variable is equivalent to | |
| 2485 calling `set-glyph-image' on the glyph, with a locale | |
| 2486 of FRAME. Giving the name to `frame-property' calls | |
| 2487 `glyph-image-instance' on the glyph.] | |
| 2488 | |
| 2489 [default foreground], [default background], [default font], | |
| 2490 [modeline foreground], [modeline background], [modeline font], | |
| 2491 etc. | |
| 2492 [Giving a vector of a face and a property is equivalent | |
| 2493 to calling `set-face-property' on the face and property, | |
| 2494 with a locale of FRAME. Giving the vector to | |
| 2495 `frame-property' calls `face-property-instance' on the | |
| 2496 face and property.] | |
| 2497 | |
| 2498 Finally, if a frame property symbol has the property `frame-property-alias' | |
| 2499 on it, then the value will be used in place of that symbol when looking | |
| 2500 up and setting frame property values. This allows you to alias one | |
| 2501 frame property name to another. | |
| 2502 | |
| 2503 See the variables `default-x-frame-plist', `default-tty-frame-plist' | |
| 2504 and `default-mswindows-frame-plist' for a description of the properties | |
| 2505 recognized for particular types of frames. | |
| 2506 */ | |
| 2507 (frame, plist)) | |
| 2508 { | |
| 1318 | 2509 /* This can call Lisp. */ |
| 428 | 2510 struct frame *f = decode_frame (frame); |
| 2511 Lisp_Object tail; | |
| 2512 Lisp_Object *tailp; | |
| 2513 struct gcpro gcpro1, gcpro2; | |
| 2514 | |
| 793 | 2515 frame = wrap_frame (f); |
| 428 | 2516 GCPRO2 (frame, plist); |
| 2517 Fcheck_valid_plist (plist); | |
| 2518 plist = Fcopy_sequence (plist); | |
| 2519 Fcanonicalize_lax_plist (plist, Qnil); | |
| 2520 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) | |
| 2521 { | |
| 2522 Lisp_Object prop = Fcar (tail); | |
| 2523 Lisp_Object val = Fcar (Fcdr (tail)); | |
| 2524 | |
| 2525 prop = get_property_alias (prop); | |
| 2526 | |
| 2527 #if 0 | |
| 2528 /* mly wants this, but it's not reasonable to change the name of a | |
| 2529 frame after it has been created, because the old name was used | |
| 2530 for resource lookup. */ | |
| 2531 if (EQ (prop, Qname)) | |
| 4207 | 2532 { |
| 2533 CHECK_STRING (val); | |
| 2534 f->name = val; | |
| 2535 } | |
| 428 | 2536 #endif /* 0 */ |
| 2537 if (EQ (prop, Qminibuffer)) | |
| 2538 store_minibuf_frame_prop (f, val); | |
| 2539 if (EQ (prop, Qunsplittable)) | |
| 2540 f->no_split = !NILP (val); | |
| 2541 if (EQ (prop, Qbuffer_predicate)) | |
| 2542 f->buffer_predicate = val; | |
| 2543 if (SYMBOLP (prop) && EQ (Fbuilt_in_variable_type (prop), | |
| 2544 Qconst_specifier)) | |
| 2545 call3 (Qset_specifier, Fsymbol_value (prop), val, frame); | |
| 2546 if (SYMBOLP (prop) && !NILP (Fget (prop, Qconst_glyph_variable, Qnil))) | |
| 2547 call3 (Qset_glyph_image, Fsymbol_value (prop), val, frame); | |
| 2548 if (VECTORP (prop) && XVECTOR_LENGTH (prop) == 2) | |
| 2549 { | |
| 2550 Lisp_Object face_prop = XVECTOR_DATA (prop)[1]; | |
| 2551 CHECK_SYMBOL (face_prop); | |
| 2552 call4 (Qset_face_property, | |
| 2553 Fget_face (XVECTOR_DATA (prop)[0]), | |
| 2554 face_prop, val, frame); | |
| 2555 } | |
| 2556 } | |
| 2557 | |
| 2558 MAYBE_FRAMEMETH (f, set_frame_properties, (f, plist)); | |
| 2559 for (tailp = &plist; !NILP (*tailp);) | |
| 2560 { | |
| 2561 Lisp_Object *next_tailp; | |
| 2562 Lisp_Object next; | |
| 2563 Lisp_Object prop; | |
| 2564 | |
| 2565 next = Fcdr (*tailp); | |
| 2566 CHECK_CONS (next); | |
| 2567 next_tailp = &XCDR (next); | |
| 2568 prop = Fcar (*tailp); | |
| 2569 | |
| 2570 prop = get_property_alias (prop); | |
| 2571 | |
| 2572 if (EQ (prop, Qminibuffer) | |
| 2573 || EQ (prop, Qunsplittable) | |
| 2574 || EQ (prop, Qbuffer_predicate) | |
| 2575 || EQ (prop, Qheight) | |
| 2576 || EQ (prop, Qwidth) | |
| 2577 || (SYMBOLP (prop) && EQ (Fbuilt_in_variable_type (prop), | |
| 2578 Qconst_specifier)) | |
| 2579 || (SYMBOLP (prop) && !NILP (Fget (prop, Qconst_glyph_variable, | |
| 2580 Qnil))) | |
| 2581 || (VECTORP (prop) && XVECTOR_LENGTH (prop) == 2) | |
| 2582 || FRAMEMETH_OR_GIVEN (f, internal_frame_property_p, (f, prop), 0)) | |
| 2583 *tailp = *next_tailp; | |
| 2584 tailp = next_tailp; | |
| 2585 } | |
| 2586 | |
| 2587 f->plist = nconc2 (plist, f->plist); | |
| 2588 Fcanonicalize_lax_plist (f->plist, Qnil); | |
| 2589 UNGCPRO; | |
| 2590 return Qnil; | |
| 2591 } | |
| 2592 | |
| 2593 DEFUN ("frame-property", Fframe_property, 2, 3, 0, /* | |
| 2594 Return FRAME's value for property PROPERTY. | |
| 444 | 2595 Return DEFAULT if there is no such property. |
| 428 | 2596 See `set-frame-properties' for the built-in property names. |
| 2597 */ | |
| 2598 (frame, property, default_)) | |
| 2599 { | |
| 2600 struct frame *f = decode_frame (frame); | |
| 2601 Lisp_Object value; | |
| 2602 | |
| 793 | 2603 frame = wrap_frame (f); |
| 428 | 2604 |
| 2605 property = get_property_alias (property); | |
| 2606 | |
| 2607 if (EQ (Qname, property)) return f->name; | |
| 2608 | |
| 2609 if (EQ (Qheight, property) || EQ (Qwidth, property)) | |
| 2610 { | |
| 2611 if (window_system_pixelated_geometry (frame)) | |
| 2612 { | |
| 2613 int width, height; | |
| 2614 pixel_to_real_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | |
| 2615 &width, &height); | |
| 2616 return make_int (EQ (Qheight, property) ? height: width); | |
| 2617 } | |
| 2618 else | |
| 2619 return make_int (EQ (Qheight, property) ? | |
| 2620 FRAME_HEIGHT (f) : | |
| 2621 FRAME_WIDTH (f)); | |
| 2622 } | |
| 2623 | |
| 2624 /* NOTE: FSF returns Qnil instead of Qt for FRAME_HAS_MINIBUF_P. | |
| 2625 This is over-the-top bogosity, because it's inconsistent with | |
| 2626 the semantics of `minibuffer' when passed to `make-frame'. | |
| 2627 Returning Qt makes things consistent. */ | |
| 2628 if (EQ (Qminibuffer, property)) | |
| 2629 return (FRAME_MINIBUF_ONLY_P (f) ? Qonly : | |
| 2630 FRAME_HAS_MINIBUF_P (f) ? Qt : | |
| 2631 FRAME_MINIBUF_WINDOW (f)); | |
| 2632 if (EQ (Qunsplittable, property)) | |
| 2633 return FRAME_NO_SPLIT_P (f) ? Qt : Qnil; | |
| 2634 if (EQ (Qbuffer_predicate, property)) | |
| 2635 return f->buffer_predicate; | |
| 2636 | |
| 2637 if (SYMBOLP (property)) | |
| 2638 { | |
| 2639 if (EQ (Fbuilt_in_variable_type (property), Qconst_specifier)) | |
| 2640 return Fspecifier_instance (Fsymbol_value (property), | |
| 2641 frame, default_, Qnil); | |
| 2642 if (!NILP (Fget (property, Qconst_glyph_variable, Qnil))) | |
| 2643 { | |
| 2644 Lisp_Object glyph = Fsymbol_value (property); | |
| 2645 CHECK_GLYPH (glyph); | |
| 2646 return Fspecifier_instance (XGLYPH_IMAGE (glyph), | |
| 2647 frame, default_, Qnil); | |
| 2648 } | |
| 2649 } | |
| 2650 | |
| 2651 if (VECTORP (property) && XVECTOR_LENGTH (property) == 2) | |
| 2652 { | |
| 2653 Lisp_Object face_prop = XVECTOR_DATA (property)[1]; | |
| 2654 CHECK_SYMBOL (face_prop); | |
| 2655 return call3 (Qface_property_instance, | |
| 2656 Fget_face (XVECTOR_DATA (property)[0]), | |
| 2657 face_prop, frame); | |
| 2658 } | |
| 2659 | |
| 2660 if (HAS_FRAMEMETH_P (f, frame_property)) | |
| 2661 if (!UNBOUNDP (value = FRAMEMETH (f, frame_property, (f, property)))) | |
| 2662 return value; | |
| 2663 | |
| 2664 if (!UNBOUNDP (value = external_plist_get (&f->plist, property, 1, ERROR_ME))) | |
| 2665 return value; | |
| 2666 | |
| 2667 return default_; | |
| 2668 } | |
| 2669 | |
| 2670 DEFUN ("frame-properties", Fframe_properties, 0, 1, 0, /* | |
| 2671 Return a property list of the properties of FRAME. | |
| 2672 Do not modify this list; use `set-frame-property' instead. | |
| 2673 */ | |
| 2674 (frame)) | |
| 2675 { | |
| 2676 struct frame *f = decode_frame (frame); | |
| 2677 Lisp_Object result = Qnil; | |
| 2678 struct gcpro gcpro1; | |
| 2679 | |
| 2680 GCPRO1 (result); | |
| 2681 | |
| 793 | 2682 frame = wrap_frame (f); |
| 428 | 2683 |
| 2684 /* #### for the moment (since old code uses `frame-parameters'), | |
| 2685 we call `copy-sequence' on f->plist. That allows frame-parameters | |
| 2686 to destructively convert the plist into an alist, which is more | |
| 2687 efficient than doing it non-destructively. At some point we | |
| 2688 should remove the call to copy-sequence. */ | |
| 2689 result = Fcopy_sequence (f->plist); | |
| 2690 | |
| 2691 /* #### should we be adding all the specifiers and glyphs? | |
| 2692 That would entail having a list of them all. */ | |
| 2693 if (HAS_FRAMEMETH_P (f, frame_properties)) | |
| 2694 result = nconc2 (FRAMEMETH (f, frame_properties, (f)), result); | |
| 2695 | |
| 2696 if (!NILP (f->buffer_predicate)) | |
| 2697 result = cons3 (Qbuffer_predicate, f->buffer_predicate, result); | |
| 2698 | |
| 2699 if (FRAME_NO_SPLIT_P (f)) | |
| 2700 result = cons3 (Qunsplittable, Qt, result); | |
| 2701 | |
| 2702 /* NOTE: FSF returns Qnil instead of Qt for FRAME_HAS_MINIBUF_P. | |
| 2703 This is over-the-top bogosity, because it's inconsistent with | |
| 2704 the semantics of `minibuffer' when passed to `make-frame'. | |
| 2705 Returning Qt makes things consistent. */ | |
| 2706 result = cons3 (Qminibuffer, | |
| 2707 (FRAME_MINIBUF_ONLY_P (f) ? Qonly : | |
| 2708 FRAME_HAS_MINIBUF_P (f) ? Qt : | |
| 2709 FRAME_MINIBUF_WINDOW (f)), | |
| 2710 result); | |
| 2711 { | |
| 2712 int width, height; | |
| 2713 | |
| 2714 if (window_system_pixelated_geometry (frame)) | |
| 2715 { | |
| 2716 pixel_to_real_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | |
| 2717 &width, &height); | |
| 2718 } | |
| 2719 else | |
| 2720 { | |
| 2721 height = FRAME_HEIGHT (f); | |
| 2722 width = FRAME_WIDTH (f); | |
| 2723 } | |
| 2724 result = cons3 (Qwidth , make_int (width), result); | |
| 2725 result = cons3 (Qheight, make_int (height), result); | |
| 2726 } | |
| 2727 | |
| 2728 result = cons3 (Qname, f->name, result); | |
| 2729 | |
| 2730 UNGCPRO; | |
| 2731 return result; | |
| 2732 } | |
| 2733 | |
| 2734 | |
| 2735 DEFUN ("frame-pixel-height", Fframe_pixel_height, 0, 1, 0, /* | |
| 1125 | 2736 Return the total height in pixels of FRAME. |
| 428 | 2737 */ |
| 2738 (frame)) | |
| 2739 { | |
| 2740 return make_int (decode_frame (frame)->pixheight); | |
| 2741 } | |
| 2742 | |
| 1125 | 2743 DEFUN ("frame-displayable-pixel-height", Fframe_displayable_pixel_height, 0, 1, 0, /* |
| 2744 Return the height of the displayable area in pixels of FRAME. | |
| 2745 */ | |
| 2746 (frame)) | |
| 2747 { | |
| 2748 struct frame *f = decode_frame (frame); | |
| 2749 int height, pheight; | |
| 2750 frame = wrap_frame (f); | |
| 2751 | |
| 4207 | 2752 if (!window_system_pixelated_geometry (frame)) |
| 1125 | 2753 { |
| 2754 height = FRAME_HEIGHT (f); | |
| 2755 | |
| 2756 frame_conversion_internal (f, CHAR_TO_DISPLAYABLE_PIXEL, | |
| 2757 0, &pheight, 0, &height, 0); | |
| 2758 } | |
| 4207 | 2759 else |
| 1125 | 2760 pheight = FRAME_PIXHEIGHT (f); |
| 2761 | |
| 2762 return make_int (pheight); | |
| 2763 } | |
| 2764 | |
| 428 | 2765 DEFUN ("frame-pixel-width", Fframe_pixel_width, 0, 1, 0, /* |
| 1125 | 2766 Return the total width in pixels of FRAME. |
| 428 | 2767 */ |
| 2768 (frame)) | |
| 2769 { | |
| 2770 return make_int (decode_frame (frame)->pixwidth); | |
| 2771 } | |
| 2772 | |
| 1125 | 2773 DEFUN ("frame-displayable-pixel-width", Fframe_displayable_pixel_width, 0, 1, 0, /* |
| 2774 Return the width of the displayable area in pixels of FRAME. | |
| 2775 */ | |
| 2776 (frame)) | |
| 2777 { | |
| 2778 struct frame *f = decode_frame (frame); | |
| 2779 int width, pwidth; | |
| 2780 frame = wrap_frame (f); | |
| 2781 | |
| 4207 | 2782 if (!window_system_pixelated_geometry (frame)) |
| 1125 | 2783 { |
| 2784 width = FRAME_WIDTH (f); | |
| 2785 | |
| 2786 frame_conversion_internal (f, CHAR_TO_DISPLAYABLE_PIXEL, | |
| 2787 &pwidth, 0, &width, 0, 0); | |
| 2788 } | |
| 4207 | 2789 else |
| 1125 | 2790 pwidth = FRAME_PIXWIDTH (f); |
| 2791 | |
| 2792 return make_int (pwidth); | |
| 2793 } | |
| 2794 | |
| 428 | 2795 DEFUN ("frame-name", Fframe_name, 0, 1, 0, /* |
| 2796 Return the name of FRAME (defaulting to the selected frame). | |
| 2797 This is not the same as the `title' of the frame. | |
| 2798 */ | |
| 2799 (frame)) | |
| 2800 { | |
| 2801 return decode_frame (frame)->name; | |
| 2802 } | |
| 2803 | |
| 2804 DEFUN ("frame-modified-tick", Fframe_modified_tick, 0, 1, 0, /* | |
| 2805 Return FRAME's tick counter, incremented for each change to the frame. | |
| 2806 Each frame has a tick counter which is incremented each time the frame | |
| 2807 is resized, a window is resized, added, or deleted, a face is changed, | |
| 2808 `set-window-buffer' or `select-window' is called on a window in the | |
| 2809 frame, the window-start of a window in the frame has changed, or | |
| 2810 anything else interesting has happened. It wraps around occasionally. | |
| 2811 No argument or nil as argument means use selected frame as FRAME. | |
| 2812 */ | |
| 2813 (frame)) | |
| 2814 { | |
| 2815 return make_int (decode_frame (frame)->modiff); | |
| 2816 } | |
| 2817 | |
| 2818 static void | |
| 2819 internal_set_frame_size (struct frame *f, int cols, int rows, int pretend) | |
| 2820 { | |
| 1318 | 2821 /* This can call Lisp. See mswindows_set_frame_size(). */ |
| 428 | 2822 /* An explicit size change cancels any pending frame size adjustment */ |
| 1318 | 2823 CLEAR_FRAME_SIZE_SLIPPED (f); |
| 428 | 2824 |
| 2825 if (pretend || !HAS_FRAMEMETH_P (f, set_frame_size)) | |
| 2826 change_frame_size (f, rows, cols, 0); | |
| 2827 else | |
| 2828 FRAMEMETH (f, set_frame_size, (f, cols, rows)); | |
| 2829 } | |
| 2830 | |
| 2831 DEFUN ("set-frame-height", Fset_frame_height, 2, 3, 0, /* | |
| 2832 Specify that the frame FRAME has LINES lines. | |
| 2833 Optional third arg non-nil means that redisplay should use LINES lines | |
| 2834 but that the idea of the actual height of the frame should not be changed. | |
| 2835 */ | |
| 444 | 2836 (frame, lines, pretend)) |
| 428 | 2837 { |
| 1318 | 2838 /* This can call Lisp. */ |
| 428 | 2839 struct frame *f = decode_frame (frame); |
| 2840 int height, width; | |
| 793 | 2841 frame = wrap_frame (f); |
| 444 | 2842 CHECK_INT (lines); |
| 428 | 2843 |
| 2844 if (window_system_pixelated_geometry (frame)) | |
| 2845 { | |
| 444 | 2846 char_to_real_pixel_size (f, 0, XINT (lines), 0, &height); |
| 428 | 2847 width = FRAME_PIXWIDTH (f); |
| 2848 } | |
| 2849 else | |
| 2850 { | |
| 444 | 2851 height = XINT (lines); |
| 428 | 2852 width = FRAME_WIDTH (f); |
| 2853 } | |
| 2854 | |
| 2855 internal_set_frame_size (f, width, height, !NILP (pretend)); | |
| 2856 return frame; | |
| 2857 } | |
| 2858 | |
| 863 | 2859 DEFUN ("set-frame-pixel-height", Fset_frame_pixel_height, 2, 3, 0, /* |
| 1125 | 2860 Specify that the frame FRAME is a total of HEIGHT pixels tall. |
| 863 | 2861 Optional third arg non-nil means that redisplay should be HEIGHT pixels tall |
| 2862 but that the idea of the actual height of the frame should not be changed. | |
| 2863 */ | |
| 2864 (frame, height, pretend)) | |
| 2865 { | |
| 1318 | 2866 /* This can call Lisp. */ |
| 863 | 2867 struct frame *f = decode_frame (frame); |
| 2868 int pheight, width; | |
| 2869 frame = wrap_frame (f); | |
| 2870 CHECK_INT (height); | |
| 2871 | |
| 4207 | 2872 if (!window_system_pixelated_geometry (frame)) |
| 863 | 2873 { |
| 2874 int h = XINT (height); | |
| 2875 width = FRAME_WIDTH (f); | |
| 1125 | 2876 |
| 2877 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, 0, &h, 0, &pheight, 0); | |
| 863 | 2878 } |
| 4207 | 2879 else |
| 863 | 2880 { |
| 2881 width = FRAME_PIXWIDTH (f); | |
| 2882 pheight = XINT (height); | |
| 2883 } | |
| 2884 | |
| 2885 internal_set_frame_size (f, width, pheight, !NILP (pretend)); | |
| 2886 return frame; | |
| 2887 } | |
| 2888 | |
| 1125 | 2889 DEFUN ("set-frame-displayable-pixel-height", Fset_frame_displayable_pixel_height, 2, 3, 0, /* |
| 2890 Specify that the displayable area of frame FRAME is HEIGHT pixels tall. | |
| 2891 Optional third arg non-nil means that redisplay should be HEIGHT pixels tall | |
| 2892 but that the idea of the actual height of the frame should not be changed. | |
| 2893 */ | |
| 2894 (frame, height, pretend)) | |
| 2895 { | |
| 1318 | 2896 /* This can call Lisp. */ |
| 1125 | 2897 struct frame *f = decode_frame (frame); |
| 2898 int pheight, width; | |
| 2899 frame = wrap_frame (f); | |
| 2900 CHECK_INT (height); | |
| 2901 | |
| 4207 | 2902 if (!window_system_pixelated_geometry (frame)) |
| 1125 | 2903 { |
| 2904 int h = XINT (height); | |
| 2905 width = FRAME_WIDTH (f); | |
| 2906 frame_conversion_internal (f, DISPLAYABLE_PIXEL_TO_CHAR, 0, &h, 0, &pheight, 0); | |
| 2907 } | |
| 4207 | 2908 else |
| 1125 | 2909 { |
| 2910 width = FRAME_PIXWIDTH (f); | |
| 2911 pheight = XINT (height); | |
| 2912 } | |
| 2913 | |
| 2914 internal_set_frame_size (f, width, pheight, !NILP (pretend)); | |
| 2915 return frame; | |
| 2916 } | |
| 2917 | |
| 2918 | |
| 428 | 2919 DEFUN ("set-frame-width", Fset_frame_width, 2, 3, 0, /* |
| 2920 Specify that the frame FRAME has COLS columns. | |
| 2921 Optional third arg non-nil means that redisplay should use COLS columns | |
| 2922 but that the idea of the actual width of the frame should not be changed. | |
| 2923 */ | |
| 2924 (frame, cols, pretend)) | |
| 2925 { | |
| 1318 | 2926 /* This can call Lisp. */ |
| 428 | 2927 struct frame *f = decode_frame (frame); |
| 2928 int width, height; | |
| 793 | 2929 frame = wrap_frame (f); |
| 428 | 2930 CHECK_INT (cols); |
| 2931 | |
| 2932 if (window_system_pixelated_geometry (frame)) | |
| 2933 { | |
| 2934 char_to_real_pixel_size (f, XINT (cols), 0, &width, 0); | |
| 2935 height = FRAME_PIXHEIGHT (f); | |
| 2936 } | |
| 2937 else | |
| 2938 { | |
| 2939 width = XINT (cols); | |
| 2940 height = FRAME_HEIGHT (f); | |
| 2941 } | |
| 2942 | |
| 2943 internal_set_frame_size (f, width, height, !NILP (pretend)); | |
| 2944 return frame; | |
| 2945 } | |
| 2946 | |
| 863 | 2947 DEFUN ("set-frame-pixel-width", Fset_frame_pixel_width, 2, 3, 0, /* |
| 1125 | 2948 Specify that the frame FRAME is a total of WIDTH pixels wide. |
| 863 | 2949 Optional third arg non-nil means that redisplay should be WIDTH wide |
| 2950 but that the idea of the actual height of the frame should not be changed. | |
| 2951 */ | |
| 2952 (frame, width, pretend)) | |
| 2953 { | |
| 1318 | 2954 /* This can call Lisp. */ |
| 863 | 2955 struct frame *f = decode_frame (frame); |
| 2956 int height, pwidth; | |
| 2957 frame = wrap_frame (f); | |
| 2958 CHECK_INT (width); | |
| 2959 | |
| 2960 if (!window_system_pixelated_geometry (frame)) | |
| 2961 { | |
| 2962 int w = XINT (width); | |
| 2963 height = FRAME_HEIGHT (f); | |
| 1125 | 2964 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, &w, 0, &pwidth, 0, 0); |
| 2965 } | |
| 2966 else | |
| 2967 { | |
| 2968 height = FRAME_PIXHEIGHT (f); | |
| 2969 pwidth = XINT (width); | |
| 2970 } | |
| 2971 | |
| 2972 internal_set_frame_size (f, pwidth, height, !NILP (pretend)); | |
| 2973 return frame; | |
| 2974 } | |
| 2975 | |
| 2976 DEFUN ("set-frame-displayable-pixel-width", Fset_frame_displayable_pixel_width, 2, 3, 0, /* | |
| 2977 Specify that the displayable area of frame FRAME is WIDTH pixels wide. | |
| 2978 Optional third arg non-nil means that redisplay should be WIDTH wide | |
| 2979 but that the idea of the actual height of the frame should not be changed. | |
| 2980 */ | |
| 2981 (frame, width, pretend)) | |
| 2982 { | |
| 1318 | 2983 /* This can call Lisp. */ |
| 1125 | 2984 struct frame *f = decode_frame (frame); |
| 2985 int height, pwidth; | |
| 2986 frame = wrap_frame (f); | |
| 2987 CHECK_INT (width); | |
| 2988 | |
| 2989 if (!window_system_pixelated_geometry (frame)) | |
| 2990 { | |
| 2991 int w = XINT (width); | |
| 2992 height = FRAME_HEIGHT (f); | |
| 2993 frame_conversion_internal (f, DISPLAYABLE_PIXEL_TO_CHAR, &w, 0, &pwidth, 0, 0); | |
| 863 | 2994 } |
| 2995 else | |
| 2996 { | |
| 2997 height = FRAME_PIXHEIGHT (f); | |
| 2998 pwidth = XINT (width); | |
| 2999 } | |
| 3000 | |
| 3001 internal_set_frame_size (f, pwidth, height, !NILP (pretend)); | |
| 3002 return frame; | |
| 3003 } | |
| 3004 | |
| 428 | 3005 DEFUN ("set-frame-size", Fset_frame_size, 3, 4, 0, /* |
| 444 | 3006 Set the size of FRAME to COLS by ROWS, measured in characters. |
| 428 | 3007 Optional fourth arg non-nil means that redisplay should use COLS by ROWS |
| 3008 but that the idea of the actual size of the frame should not be changed. | |
| 3009 */ | |
| 3010 (frame, cols, rows, pretend)) | |
| 3011 { | |
| 1318 | 3012 /* This can call Lisp. */ |
| 428 | 3013 struct frame *f = decode_frame (frame); |
| 3014 int height, width; | |
| 793 | 3015 frame = wrap_frame (f); |
| 428 | 3016 CHECK_INT (cols); |
| 3017 CHECK_INT (rows); | |
| 3018 | |
| 3019 if (window_system_pixelated_geometry (frame)) | |
| 3020 char_to_real_pixel_size (f, XINT (cols), XINT (rows), &width, &height); | |
| 3021 else | |
| 3022 { | |
| 3023 height = XINT (rows); | |
| 3024 width = XINT (cols); | |
| 3025 } | |
| 3026 | |
| 3027 internal_set_frame_size (f, width, height, !NILP (pretend)); | |
| 3028 return frame; | |
| 3029 } | |
| 3030 | |
| 863 | 3031 DEFUN ("set-frame-pixel-size", Fset_frame_pixel_size, 3, 4, 0, /* |
| 1125 | 3032 Set the total size of FRAME to WIDTH by HEIGHT, measured in pixels. |
| 863 | 3033 Optional fourth arg non-nil means that redisplay should use WIDTH by HEIGHT |
| 3034 but that the idea of the actual size of the frame should not be changed. | |
| 3035 */ | |
| 3036 (frame, width, height, pretend)) | |
| 3037 { | |
| 1318 | 3038 /* This can call Lisp. */ |
| 863 | 3039 struct frame *f = decode_frame (frame); |
| 3040 int pheight, pwidth; | |
| 3041 frame = wrap_frame (f); | |
| 3042 CHECK_INT (width); | |
| 3043 CHECK_INT (height); | |
| 3044 | |
| 4207 | 3045 if (!window_system_pixelated_geometry (frame)) |
| 863 | 3046 { |
| 3047 int w = XINT (width); | |
| 3048 int h = XINT (height); | |
| 1125 | 3049 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, &w, &h, &pwidth, &pheight, 0); |
| 3050 } | |
| 3051 else | |
| 3052 { | |
| 3053 pheight = XINT (height); | |
| 3054 pwidth = XINT (width); | |
| 3055 } | |
| 3056 | |
| 3057 internal_set_frame_size (f, pwidth, pheight, !NILP (pretend)); | |
| 3058 return frame; | |
| 3059 } | |
| 3060 | |
| 3061 DEFUN ("set-frame-displayable-pixel-size", Fset_frame_displayable_pixel_size, 3, 4, 0, /* | |
| 3062 Set the displayable size of FRAME to WIDTH by HEIGHT, measured in pixels. | |
| 3063 Optional fourth arg non-nil means that redisplay should use WIDTH by HEIGHT | |
| 3064 but that the idea of the actual size of the frame should not be changed. | |
| 3065 */ | |
| 3066 (frame, width, height, pretend)) | |
| 3067 { | |
| 1318 | 3068 /* This can call Lisp. */ |
| 1125 | 3069 struct frame *f = decode_frame (frame); |
| 3070 int pheight, pwidth; | |
| 3071 frame = wrap_frame (f); | |
| 3072 CHECK_INT (width); | |
| 3073 CHECK_INT (height); | |
| 3074 | |
| 4207 | 3075 if (!window_system_pixelated_geometry (frame)) |
| 1125 | 3076 { |
| 3077 int w = XINT (width); | |
| 3078 int h = XINT (height); | |
| 3079 frame_conversion_internal (f, DISPLAYABLE_PIXEL_TO_CHAR, &w, &h, &pwidth, &pheight, 0); | |
| 863 | 3080 } |
| 3081 else | |
| 3082 { | |
| 3083 pheight = XINT (height); | |
| 3084 pwidth = XINT (width); | |
| 3085 } | |
| 3086 | |
| 3087 internal_set_frame_size (f, pwidth, pheight, !NILP (pretend)); | |
| 3088 return frame; | |
| 3089 } | |
| 3090 | |
| 428 | 3091 DEFUN ("set-frame-position", Fset_frame_position, 3, 3, 0, /* |
| 3092 Set position of FRAME in pixels to XOFFSET by YOFFSET. | |
| 3093 This is actually the position of the upper left corner of the frame. | |
| 3094 Negative values for XOFFSET or YOFFSET are interpreted relative to | |
| 3095 the rightmost or bottommost possible position (that stays within the screen). | |
| 3096 */ | |
| 3097 (frame, xoffset, yoffset)) | |
| 3098 { | |
| 3099 struct frame *f = decode_frame (frame); | |
| 3100 CHECK_INT (xoffset); | |
| 3101 CHECK_INT (yoffset); | |
| 3102 | |
| 3103 MAYBE_FRAMEMETH (f, set_frame_position, (f, XINT (xoffset), XINT (yoffset))); | |
| 3104 | |
| 3105 return Qt; | |
| 3106 } | |
| 3107 | |
| 3108 | |
| 3109 | |
| 3110 /* Frame size conversion functions moved here from EmacsFrame.c | |
| 3111 because they're generic and really don't belong in that file. | |
| 3112 Function get_default_char_pixel_size() removed because it's | |
| 3113 exactly the same as default_face_height_and_width(). */ | |
| 3114 static void | |
| 1125 | 3115 frame_conversion_internal (struct frame *f, |
| 3116 pixel_to_char_mode_t pixel_to_char, | |
| 428 | 3117 int *pixel_width, int *pixel_height, |
| 3118 int *char_width, int *char_height, | |
| 3119 int real_face) | |
| 3120 { | |
| 3121 int cpw; | |
| 3122 int cph; | |
| 3123 int egw; | |
| 3124 int obw, obh, bdr; | |
| 3125 Lisp_Object frame, window; | |
| 3126 | |
| 793 | 3127 frame = wrap_frame (f); |
| 428 | 3128 if (real_face) |
| 3129 default_face_height_and_width (frame, &cph, &cpw); | |
| 3130 else | |
| 3131 default_face_height_and_width_1 (frame, &cph, &cpw); | |
| 3132 | |
| 3133 window = FRAME_SELECTED_WINDOW (f); | |
| 3134 | |
| 438 | 3135 egw = max (glyph_width (Vcontinuation_glyph, window), |
| 3136 glyph_width (Vtruncation_glyph, window)); | |
| 428 | 3137 egw = max (egw, cpw); |
| 3138 bdr = 2 * f->internal_border_width; | |
| 3139 obw = FRAME_SCROLLBAR_WIDTH (f) + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) + | |
| 3140 FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) + | |
| 3141 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) + | |
| 3142 2 * FRAME_THEORETICAL_RIGHT_TOOLBAR_BORDER_WIDTH (f); | |
| 3143 obh = FRAME_SCROLLBAR_HEIGHT (f) + FRAME_THEORETICAL_TOP_TOOLBAR_HEIGHT (f) + | |
| 3144 FRAME_THEORETICAL_BOTTOM_TOOLBAR_HEIGHT (f) + | |
| 3145 2 * FRAME_THEORETICAL_TOP_TOOLBAR_BORDER_WIDTH (f) + | |
| 3146 2 * FRAME_THEORETICAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f); | |
| 3147 | |
| 863 | 3148 /* Convert to chars so that the displayable area is pixel_width x |
| 3149 pixel_height. | |
| 3150 | |
| 3151 #### Consider rounding up to 0.5 characters to avoid adding too | |
| 3152 much space. */ | |
| 1125 | 3153 switch (pixel_to_char) |
| 863 | 3154 { |
| 1125 | 3155 case DISPLAYABLE_PIXEL_TO_CHAR: |
| 863 | 3156 if (char_width) |
| 3157 *char_width = ROUND_UP (*pixel_width, cpw) / cpw; | |
| 3158 if (char_height) | |
| 3159 *char_height = ROUND_UP (*pixel_height, cph) / cph; | |
| 1125 | 3160 break; |
| 3161 case TOTAL_PIXEL_TO_CHAR: | |
| 3162 /* Convert to chars so that the total frame size is pixel_width x | |
| 3163 pixel_height. */ | |
| 428 | 3164 if (char_width) |
| 3165 *char_width = 1 + ((*pixel_width - egw) - bdr - obw) / cpw; | |
| 3166 if (char_height) | |
| 3167 *char_height = (*pixel_height - bdr - obh) / cph; | |
| 1125 | 3168 break; |
| 3169 case CHAR_TO_TOTAL_PIXEL: | |
| 428 | 3170 if (pixel_width) |
| 3171 *pixel_width = (*char_width - 1) * cpw + egw + bdr + obw; | |
| 3172 if (pixel_height) | |
| 3173 *pixel_height = *char_height * cph + bdr + obh; | |
| 1125 | 3174 break; |
| 3175 case CHAR_TO_DISPLAYABLE_PIXEL: | |
| 3176 if (pixel_width) | |
| 3177 *pixel_width = *char_width * cpw; | |
| 3178 if (pixel_height) | |
| 3179 *pixel_height = *char_height * cph; | |
| 3180 break; | |
| 428 | 3181 } |
| 3182 } | |
| 3183 | |
| 3184 /* This takes the size in pixels of the text area, and returns the number | |
| 3185 of characters that will fit there, taking into account the internal | |
| 3186 border width, and the pixel width of the line terminator glyphs (which | |
| 3187 always count as one "character" wide, even if they are not the same size | |
| 3188 as the default character size of the default font). The frame scrollbar | |
| 3189 width and left and right toolbar widths are also subtracted out of the | |
| 3190 available width. The frame scrollbar height and top and bottom toolbar | |
| 3191 heights are subtracted out of the available height. | |
| 3192 | |
| 3193 Therefore the result is not necessarily a multiple of anything in | |
| 3194 particular. */ | |
| 3195 void | |
| 3196 pixel_to_char_size (struct frame *f, int pixel_width, int pixel_height, | |
| 3197 int *char_width, int *char_height) | |
| 3198 { | |
| 1125 | 3199 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, |
| 3200 &pixel_width, &pixel_height, char_width, | |
| 428 | 3201 char_height, 0); |
| 3202 } | |
| 3203 | |
| 3204 /* Given a character size, this returns the minimum number of pixels | |
| 3205 necessary to display that many characters, taking into account the | |
| 3206 internal border width, scrollbar height and width, toolbar heights and | |
| 3207 widths and the size of the line terminator glyphs (assuming the line | |
| 3208 terminators take up exactly one character position). | |
| 3209 | |
| 3210 Therefore the result is not necessarily a multiple of anything in | |
| 3211 particular. */ | |
| 3212 void | |
| 3213 char_to_pixel_size (struct frame *f, int char_width, int char_height, | |
| 3214 int *pixel_width, int *pixel_height) | |
| 3215 { | |
| 1125 | 3216 frame_conversion_internal (f, CHAR_TO_TOTAL_PIXEL, |
| 3217 pixel_width, pixel_height, &char_width, | |
| 428 | 3218 &char_height, 0); |
| 3219 } | |
| 3220 | |
| 3221 /* Given a pixel size, rounds DOWN to the smallest size in pixels necessary | |
| 3222 to display the same number of characters as are displayable now. | |
| 3223 */ | |
| 3224 void | |
| 3225 round_size_to_char (struct frame *f, int in_width, int in_height, | |
| 3226 int *out_width, int *out_height) | |
| 3227 { | |
| 3228 int char_width; | |
| 3229 int char_height; | |
| 3230 pixel_to_char_size (f, in_width, in_height, &char_width, &char_height); | |
| 3231 char_to_pixel_size (f, char_width, char_height, out_width, out_height); | |
| 3232 } | |
| 3233 | |
| 3234 /* Versions of the above which always account for real font metrics. | |
| 3235 */ | |
| 3236 void | |
| 3237 pixel_to_real_char_size (struct frame *f, int pixel_width, int pixel_height, | |
| 3238 int *char_width, int *char_height) | |
| 3239 { | |
| 1125 | 3240 frame_conversion_internal (f, TOTAL_PIXEL_TO_CHAR, |
| 3241 &pixel_width, &pixel_height, char_width, | |
| 428 | 3242 char_height, 1); |
| 3243 } | |
| 3244 | |
| 3245 void | |
| 3246 char_to_real_pixel_size (struct frame *f, int char_width, int char_height, | |
| 3247 int *pixel_width, int *pixel_height) | |
| 3248 { | |
| 1125 | 3249 frame_conversion_internal (f, CHAR_TO_TOTAL_PIXEL, |
| 3250 pixel_width, pixel_height, &char_width, | |
| 428 | 3251 &char_height, 1); |
| 3252 } | |
| 3253 | |
| 3254 void | |
| 3255 round_size_to_real_char (struct frame *f, int in_width, int in_height, | |
| 3256 int *out_width, int *out_height) | |
| 3257 { | |
| 3258 int char_width; | |
| 3259 int char_height; | |
| 3260 pixel_to_real_char_size (f, in_width, in_height, &char_width, &char_height); | |
| 3261 char_to_real_pixel_size (f, char_width, char_height, out_width, out_height); | |
| 3262 } | |
| 3263 | |
| 3264 /* Change the frame height and/or width. Values may be given as zero to | |
| 3265 indicate no change is to take place. */ | |
| 3266 static void | |
| 3267 change_frame_size_1 (struct frame *f, int newheight, int newwidth) | |
| 3268 { | |
| 3269 Lisp_Object frame; | |
| 3270 int new_pixheight, new_pixwidth; | |
| 3271 int font_height, real_font_height, font_width; | |
| 3272 | |
| 3273 /* #### Chuck -- shouldn't we be checking to see if the frame | |
| 3274 is being "changed" to its existing size, and do nothing if so? */ | |
| 3275 /* No, because it would hose toolbar updates. The toolbar | |
| 3276 update code relies on this function to cause window `top' and | |
| 3277 `left' coordinates to be recomputed even though no frame size | |
| 3278 change occurs. --kyle */ | |
| 1318 | 3279 if (in_display || hold_frame_size_changes) |
| 2500 | 3280 ABORT (); |
| 428 | 3281 |
| 793 | 3282 frame = wrap_frame (f); |
| 428 | 3283 |
| 3284 default_face_height_and_width (frame, &real_font_height, 0); | |
| 3285 default_face_height_and_width_1 (frame, &font_height, &font_width); | |
| 3286 | |
| 3287 /* This size-change overrides any pending one for this frame. */ | |
| 4307 | 3288 f->size_change_pending = 0; |
| 428 | 3289 FRAME_NEW_HEIGHT (f) = 0; |
| 3290 FRAME_NEW_WIDTH (f) = 0; | |
| 3291 | |
| 3292 new_pixheight = newheight * font_height; | |
| 3293 new_pixwidth = (newwidth - 1) * font_width; | |
| 3294 | |
| 3295 /* #### dependency on FRAME_WIN_P should be removed. */ | |
| 3296 if (FRAME_WIN_P (f)) | |
| 3297 { | |
| 3298 new_pixheight += FRAME_SCROLLBAR_HEIGHT (f); | |
| 3299 new_pixwidth += FRAME_SCROLLBAR_WIDTH (f); | |
| 3300 } | |
| 3301 | |
| 3302 /* when frame_conversion_internal() calculated the number of rows/cols | |
| 3303 in the frame, the theoretical toolbar sizes were subtracted out. | |
| 3304 The calculations below adjust for real toolbar height/width in | |
| 3305 frame, which may be different from frame spec, taking the above | |
| 3306 fact into account */ | |
| 3307 new_pixheight += | |
| 3308 + FRAME_THEORETICAL_TOP_TOOLBAR_HEIGHT (f) | |
| 3309 + 2 * FRAME_THEORETICAL_TOP_TOOLBAR_BORDER_WIDTH (f) | |
| 3310 - FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) | |
| 3311 - 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f); | |
| 3312 | |
| 3313 new_pixheight += | |
| 3314 + FRAME_THEORETICAL_BOTTOM_TOOLBAR_HEIGHT (f) | |
| 3315 + 2 * FRAME_THEORETICAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f) | |
| 3316 - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) | |
| 3317 - 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f); | |
| 3318 | |
| 3319 new_pixwidth += | |
| 3320 + FRAME_THEORETICAL_LEFT_TOOLBAR_WIDTH (f) | |
| 3321 + 2 * FRAME_THEORETICAL_LEFT_TOOLBAR_BORDER_WIDTH (f) | |
| 3322 - FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) | |
| 3323 - 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f); | |
| 3324 | |
| 3325 new_pixwidth += | |
| 3326 + FRAME_THEORETICAL_RIGHT_TOOLBAR_WIDTH (f) | |
| 3327 + 2 * FRAME_THEORETICAL_RIGHT_TOOLBAR_BORDER_WIDTH (f) | |
| 3328 - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) | |
| 3329 - 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f); | |
| 3330 | |
| 3331 /* Adjust the width for the end glyph which may be a different width | |
| 3332 than the default character width. */ | |
| 3333 { | |
| 3334 int adjustment, trunc_width, cont_width; | |
| 3335 | |
| 440 | 3336 trunc_width = glyph_width (Vtruncation_glyph, |
| 428 | 3337 FRAME_SELECTED_WINDOW (f)); |
| 440 | 3338 cont_width = glyph_width (Vcontinuation_glyph, |
| 428 | 3339 FRAME_SELECTED_WINDOW (f)); |
| 3340 adjustment = max (trunc_width, cont_width); | |
| 3341 adjustment = max (adjustment, font_width); | |
| 3342 | |
| 3343 new_pixwidth += adjustment; | |
| 3344 } | |
| 3345 | |
| 3346 /* If we don't have valid values, exit. */ | |
| 3347 if (!new_pixheight && !new_pixwidth) | |
| 3348 return; | |
| 3349 | |
| 3350 if (new_pixheight) | |
| 3351 { | |
| 442 | 3352 /* Adjust for gutters here so that we always get set |
| 4207 | 3353 properly. */ |
| 442 | 3354 new_pixheight -= |
| 3355 (FRAME_TOP_GUTTER_BOUNDS (f) | |
| 3356 + FRAME_BOTTOM_GUTTER_BOUNDS (f)); | |
| 3357 | |
| 3358 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_top | |
| 3359 = FRAME_TOP_BORDER_END (f) + FRAME_TOP_GUTTER_BOUNDS (f); | |
| 428 | 3360 |
| 3361 if (FRAME_HAS_MINIBUF_P (f) | |
| 3362 && ! FRAME_MINIBUF_ONLY_P (f)) | |
| 3363 /* Frame has both root and minibuffer. */ | |
| 3364 { | |
| 3365 /* | |
| 3366 * Leave the minibuffer height the same if the frame has | |
| 3367 * been initialized, and the minibuffer height is tall | |
| 3368 * enough to display at least one line of text in the default | |
| 3369 * font, and the old minibuffer height is a multiple of the | |
| 3370 * default font height. This should cause the minibuffer | |
| 3371 * height to be recomputed on font changes but not for | |
| 3372 * other frame size changes, which seems reasonable. | |
| 3373 */ | |
| 3374 int old_minibuf_height = | |
| 3375 XWINDOW(FRAME_MINIBUF_WINDOW(f))->pixel_height; | |
| 3376 int minibuf_height = | |
| 3377 f->init_finished && (old_minibuf_height % real_font_height) == 0 ? | |
| 3378 max(old_minibuf_height, real_font_height) : | |
| 3379 real_font_height; | |
| 3380 set_window_pixheight (FRAME_ROOT_WINDOW (f), | |
| 3381 /* - font_height for minibuffer */ | |
| 3382 new_pixheight - minibuf_height, 0); | |
| 3383 | |
| 3384 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_top = | |
| 442 | 3385 FRAME_TOP_BORDER_END (f) + |
| 3386 FRAME_TOP_GUTTER_BOUNDS (f) + | |
| 3387 FRAME_BOTTOM_GUTTER_BOUNDS (f) + | |
| 3388 new_pixheight - minibuf_height; | |
| 428 | 3389 |
| 3390 set_window_pixheight (FRAME_MINIBUF_WINDOW (f), minibuf_height, 0); | |
| 3391 } | |
| 3392 else | |
| 3393 /* Frame has just one top-level window. */ | |
| 3394 set_window_pixheight (FRAME_ROOT_WINDOW (f), new_pixheight, 0); | |
| 3395 | |
| 3396 FRAME_HEIGHT (f) = newheight; | |
| 3397 if (FRAME_TTY_P (f)) | |
| 3398 f->pixheight = newheight; | |
| 3399 } | |
| 3400 | |
| 3401 if (new_pixwidth) | |
| 3402 { | |
| 442 | 3403 /* Adjust for gutters here so that we always get set |
| 4207 | 3404 properly. */ |
| 442 | 3405 new_pixwidth -= |
| 3406 (FRAME_LEFT_GUTTER_BOUNDS (f) | |
| 3407 + FRAME_RIGHT_GUTTER_BOUNDS (f)); | |
| 3408 | |
| 3409 XWINDOW (FRAME_ROOT_WINDOW (f))->pixel_left = | |
| 3410 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f); | |
| 428 | 3411 set_window_pixwidth (FRAME_ROOT_WINDOW (f), new_pixwidth, 0); |
| 3412 | |
| 3413 if (FRAME_HAS_MINIBUF_P (f)) | |
| 3414 { | |
| 3415 XWINDOW (FRAME_MINIBUF_WINDOW (f))->pixel_left = | |
| 442 | 3416 FRAME_LEFT_BORDER_END (f) + FRAME_LEFT_GUTTER_BOUNDS (f); |
| 428 | 3417 set_window_pixwidth (FRAME_MINIBUF_WINDOW (f), new_pixwidth, 0); |
| 3418 } | |
| 3419 | |
| 3420 FRAME_WIDTH (f) = newwidth; | |
| 3421 if (FRAME_TTY_P (f)) | |
| 3422 f->pixwidth = newwidth; | |
| 3423 } | |
| 3424 | |
| 3425 if (window_system_pixelated_geometry (frame)) | |
| 3426 pixel_to_real_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | |
| 3427 &FRAME_CHARWIDTH (f), &FRAME_CHARHEIGHT (f)); | |
| 3428 else | |
| 3429 { | |
| 3430 FRAME_CHARWIDTH (f) = FRAME_WIDTH (f); | |
| 3431 FRAME_CHARHEIGHT (f) = FRAME_HEIGHT (f); | |
| 3432 } | |
| 3433 | |
| 3434 MARK_FRAME_TOOLBARS_CHANGED (f); | |
| 442 | 3435 MARK_FRAME_GUTTERS_CHANGED (f); |
| 428 | 3436 MARK_FRAME_CHANGED (f); |
| 3437 f->echo_area_garbaged = 1; | |
| 3438 } | |
| 3439 | |
| 3440 void | |
| 3441 change_frame_size (struct frame *f, int newheight, int newwidth, int delay) | |
| 3442 { | |
| 3443 /* sometimes we get passed a size that's too small (esp. when a | |
| 3444 client widget gets resized, since we have no control over this). | |
| 3445 So deal. */ | |
| 3446 check_frame_size (f, &newheight, &newwidth); | |
| 3447 | |
| 450 | 3448 /* Unconditionally mark that the frame has changed size. This is |
| 3449 because many things need to know after the | |
| 3450 fact. f->size_change_pending will get reset below. The most that | |
| 3451 can happen is that we will cycle through redisplay once more | |
| 3452 --andy. */ | |
| 3453 MARK_FRAME_SIZE_CHANGED (f); | |
| 3454 | |
| 3092 | 3455 #ifdef NEW_GC |
| 3456 if (delay || hold_frame_size_changes) | |
| 3457 #else /* not NEW_GC */ | |
| 1318 | 3458 if (delay || hold_frame_size_changes || gc_in_progress) |
| 3092 | 3459 #endif /* not NEW_GC */ |
| 428 | 3460 { |
| 3461 f->new_width = newwidth; | |
| 3462 f->new_height = newheight; | |
| 3463 return; | |
| 3464 } | |
| 3465 | |
| 3466 /* For TTY frames, it's like one, like all ... | |
| 3467 Can't have two TTY frames of different sizes on the same device. */ | |
| 3468 if (FRAME_TTY_P (f)) | |
| 3469 { | |
| 3470 Lisp_Object frmcons; | |
| 3471 | |
| 3472 DEVICE_FRAME_LOOP (frmcons, XDEVICE (FRAME_DEVICE (f))) | |
| 3473 change_frame_size_1 (XFRAME (XCAR (frmcons)), newheight, newwidth); | |
| 3474 } | |
| 3475 else | |
| 3476 change_frame_size_1 (f, newheight, newwidth); | |
| 3477 } | |
| 3478 | |
| 3479 | |
| 438 | 3480 /* The caller is responsible for freeing the returned string. */ |
| 867 | 3481 static Ibyte * |
| 438 | 3482 generate_title_string (struct window *w, Lisp_Object format_str, |
| 3483 face_index findex, int type) | |
| 3484 { | |
| 3485 struct display_line *dl; | |
| 3486 struct display_block *db; | |
| 3487 int elt = 0; | |
| 3488 | |
| 3489 dl = &title_string_display_line; | |
| 3490 db = get_display_block_from_line (dl, TEXT); | |
| 3491 Dynarr_reset (db->runes); | |
| 3492 | |
| 3493 generate_formatted_string_db (format_str, Qnil, w, dl, db, findex, 0, | |
| 4207 | 3494 -1, type); |
| 438 | 3495 |
| 867 | 3496 Dynarr_reset (title_string_ichar_dynarr); |
| 438 | 3497 while (elt < Dynarr_length (db->runes)) |
| 3498 { | |
| 3499 if (Dynarr_atp (db->runes, elt)->type == RUNE_CHAR) | |
| 867 | 3500 Dynarr_add (title_string_ichar_dynarr, |
| 438 | 3501 Dynarr_atp (db->runes, elt)->object.chr.ch); |
| 3502 elt++; | |
| 3503 } | |
| 3504 | |
| 3505 return | |
| 867 | 3506 convert_ichar_string_into_malloced_string |
| 4967 | 3507 (Dynarr_begin (title_string_ichar_dynarr), |
| 867 | 3508 Dynarr_length (title_string_ichar_dynarr), 0); |
| 438 | 3509 } |
| 3510 | |
| 428 | 3511 void |
| 3512 update_frame_title (struct frame *f) | |
| 3513 { | |
| 3514 struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); | |
| 3515 Lisp_Object title_format; | |
| 3516 Lisp_Object icon_format; | |
| 867 | 3517 Ibyte *title; |
| 428 | 3518 |
| 3519 /* We don't change the title for the minibuffer unless the frame | |
| 3520 only has a minibuffer. */ | |
| 3521 if (MINI_WINDOW_P (w) && !FRAME_MINIBUF_ONLY_P (f)) | |
| 3522 return; | |
| 3523 | |
| 3524 /* And we don't want dead buffers to blow up on us. */ | |
| 3525 if (!BUFFER_LIVE_P (XBUFFER (w->buffer))) | |
| 3526 return; | |
| 3527 | |
| 3528 title = NULL; | |
| 3529 title_format = symbol_value_in_buffer (Qframe_title_format, w->buffer); | |
| 3530 icon_format = symbol_value_in_buffer (Qframe_icon_title_format, w->buffer); | |
| 3531 | |
| 867 | 3532 if (HAS_FRAMEMETH_P (f, set_title_from_ibyte)) |
| 428 | 3533 { |
| 438 | 3534 title = generate_title_string (w, title_format, |
| 3535 DEFAULT_INDEX, CURRENT_DISP); | |
| 867 | 3536 FRAMEMETH (f, set_title_from_ibyte, (f, title)); |
| 428 | 3537 } |
| 3538 | |
| 867 | 3539 if (HAS_FRAMEMETH_P (f, set_icon_name_from_ibyte)) |
| 428 | 3540 { |
| 3541 if (!EQ (icon_format, title_format) || !title) | |
| 3542 { | |
| 3543 if (title) | |
|
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4968
diff
changeset
|
3544 xfree (title); |
| 428 | 3545 |
| 438 | 3546 title = generate_title_string (w, icon_format, |
| 3547 DEFAULT_INDEX, CURRENT_DISP); | |
| 428 | 3548 } |
| 867 | 3549 FRAMEMETH (f, set_icon_name_from_ibyte, (f, title)); |
| 428 | 3550 } |
| 3551 | |
| 3552 if (title) | |
|
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4968
diff
changeset
|
3553 xfree (title); |
| 428 | 3554 } |
| 3555 | |
| 3556 | |
| 3557 DEFUN ("set-frame-pointer", Fset_frame_pointer, 2, 2, 0, /* | |
| 3558 Set the mouse pointer of FRAME to the given pointer image instance. | |
| 3559 You should not call this function directly. Instead, set one of | |
| 3560 the variables `text-pointer-glyph', `nontext-pointer-glyph', | |
| 3561 `modeline-pointer-glyph', `selection-pointer-glyph', | |
| 3562 `busy-pointer-glyph', or `toolbar-pointer-glyph'. | |
| 3563 */ | |
| 3564 (frame, image_instance)) | |
| 3565 { | |
| 3566 struct frame *f = decode_frame (frame); | |
| 3567 CHECK_POINTER_IMAGE_INSTANCE (image_instance); | |
| 3568 if (!EQ (f->pointer, image_instance)) | |
| 3569 { | |
| 3570 f->pointer = image_instance; | |
| 3571 MAYBE_FRAMEMETH (f, set_frame_pointer, (f)); | |
| 3572 } | |
| 3573 return Qnil; | |
| 3574 } | |
| 3575 | |
| 3576 | |
| 3577 void | |
| 3578 update_frame_icon (struct frame *f) | |
| 3579 { | |
| 3580 if (f->icon_changed || f->windows_changed) | |
| 3581 { | |
| 3582 Lisp_Object frame; | |
| 3583 Lisp_Object new_icon; | |
| 3584 | |
| 793 | 3585 frame = wrap_frame (f); |
| 428 | 3586 new_icon = glyph_image_instance (Vframe_icon_glyph, frame, |
| 3587 ERROR_ME_WARN, 0); | |
| 3588 if (!EQ (new_icon, f->icon)) | |
| 3589 { | |
| 3590 f->icon = new_icon; | |
| 3591 MAYBE_FRAMEMETH (f, set_frame_icon, (f)); | |
| 3592 } | |
| 3593 } | |
| 3594 | |
| 3595 f->icon_changed = 0; | |
| 3596 } | |
| 3597 | |
| 3598 static void | |
| 2286 | 3599 icon_glyph_changed (Lisp_Object UNUSED (glyph), Lisp_Object UNUSED (property), |
| 3600 Lisp_Object UNUSED (locale)) | |
| 428 | 3601 { |
| 3602 MARK_ICON_CHANGED; | |
| 3603 } | |
| 3604 | |
| 3605 | |
| 438 | 3606 /***************************************************************************/ |
| 3607 /* */ | |
| 3608 /* initialization */ | |
| 3609 /* */ | |
| 3610 /***************************************************************************/ | |
| 3611 | |
| 3612 void | |
| 3613 init_frame (void) | |
| 3614 { | |
| 3615 #ifndef PDUMP | |
| 3616 if (!initialized) | |
| 3617 #endif | |
| 3618 { | |
| 867 | 3619 title_string_ichar_dynarr = Dynarr_new (Ichar); |
| 4207 | 3620 DISPLAY_LINE_INIT (title_string_display_line); |
| 438 | 3621 } |
| 3622 } | |
| 3623 | |
| 428 | 3624 void |
| 3625 syms_of_frame (void) | |
| 3626 { | |
| 442 | 3627 INIT_LRECORD_IMPLEMENTATION (frame); |
| 3092 | 3628 #ifdef NEW_GC |
| 3629 INIT_LRECORD_IMPLEMENTATION (expose_ignore); | |
| 3630 #endif /* NEW_GC */ | |
| 442 | 3631 |
| 563 | 3632 DEFSYMBOL (Qdelete_frame_hook); |
| 3633 DEFSYMBOL (Qselect_frame_hook); | |
| 3634 DEFSYMBOL (Qdeselect_frame_hook); | |
| 3635 DEFSYMBOL (Qcreate_frame_hook); | |
| 3636 DEFSYMBOL (Qcustom_initialize_frame); | |
| 3637 DEFSYMBOL (Qmouse_enter_frame_hook); | |
| 3638 DEFSYMBOL (Qmouse_leave_frame_hook); | |
| 3639 DEFSYMBOL (Qmap_frame_hook); | |
| 3640 DEFSYMBOL (Qunmap_frame_hook); | |
| 3641 | |
| 3642 DEFSYMBOL (Qframep); | |
| 3643 DEFSYMBOL (Qframe_live_p); | |
| 3644 DEFSYMBOL (Qdelete_frame); | |
| 3645 DEFSYMBOL (Qsynchronize_minibuffers); | |
| 3646 DEFSYMBOL (Qbuffer_predicate); | |
| 3647 DEFSYMBOL (Qframe_being_created); | |
| 3648 DEFSYMBOL (Qmake_initial_minibuffer_frame); | |
| 3649 | |
| 3650 DEFSYMBOL (Qframe_title_format); | |
| 3651 DEFSYMBOL (Qframe_icon_title_format); | |
| 3652 | |
| 3653 DEFSYMBOL (Qhidden); | |
| 3654 DEFSYMBOL (Qvisible); | |
| 3655 DEFSYMBOL (Qiconic); | |
| 3656 DEFSYMBOL (Qinvisible); | |
| 3657 DEFSYMBOL (Qvisible_iconic); | |
| 3658 DEFSYMBOL (Qinvisible_iconic); | |
| 3659 DEFSYMBOL (Qnomini); | |
| 3660 DEFSYMBOL (Qvisible_nomini); | |
| 3661 DEFSYMBOL (Qiconic_nomini); | |
| 3662 DEFSYMBOL (Qinvisible_nomini); | |
| 3663 DEFSYMBOL (Qvisible_iconic_nomini); | |
| 3664 DEFSYMBOL (Qinvisible_iconic_nomini); | |
| 3665 | |
| 3666 DEFSYMBOL (Qminibuffer); | |
| 3667 DEFSYMBOL (Qunsplittable); | |
| 3668 DEFSYMBOL (Qinternal_border_width); | |
| 3669 DEFSYMBOL (Qtop_toolbar_shadow_color); | |
| 3670 DEFSYMBOL (Qbottom_toolbar_shadow_color); | |
| 3671 DEFSYMBOL (Qbackground_toolbar_color); | |
| 3672 DEFSYMBOL (Qtop_toolbar_shadow_pixmap); | |
| 3673 DEFSYMBOL (Qbottom_toolbar_shadow_pixmap); | |
| 3674 DEFSYMBOL (Qtoolbar_shadow_thickness); | |
| 3675 DEFSYMBOL (Qscrollbar_placement); | |
| 3676 DEFSYMBOL (Qinter_line_space); | |
| 428 | 3677 /* Qiconic already in this function. */ |
| 563 | 3678 DEFSYMBOL (Qvisual_bell); |
| 3679 DEFSYMBOL (Qbell_volume); | |
| 3680 DEFSYMBOL (Qpointer_background); | |
| 3681 DEFSYMBOL (Qpointer_color); | |
| 3682 DEFSYMBOL (Qtext_pointer); | |
| 3683 DEFSYMBOL (Qspace_pointer); | |
| 3684 DEFSYMBOL (Qmodeline_pointer); | |
| 3685 DEFSYMBOL (Qgc_pointer); | |
| 3686 DEFSYMBOL (Qinitially_unmapped); | |
| 3687 DEFSYMBOL (Quse_backing_store); | |
| 3688 DEFSYMBOL (Qborder_color); | |
| 3689 DEFSYMBOL (Qborder_width); | |
| 428 | 3690 /* Qwidth, Qheight, Qleft, Qtop in general.c */ |
| 563 | 3691 DEFSYMBOL (Qset_specifier); |
| 3692 DEFSYMBOL (Qset_face_property); | |
| 3693 DEFSYMBOL (Qface_property_instance); | |
| 3694 DEFSYMBOL (Qframe_property_alias); | |
| 428 | 3695 |
| 3696 DEFSUBR (Fmake_frame); | |
| 3697 DEFSUBR (Fframep); | |
| 3698 DEFSUBR (Fframe_live_p); | |
| 3699 #if 0 /* FSFmacs */ | |
| 3700 DEFSUBR (Fignore_event); | |
| 3701 #endif | |
| 3702 DEFSUBR (Ffocus_frame); | |
| 3703 DEFSUBR (Fselect_frame); | |
| 3704 DEFSUBR (Fselected_frame); | |
| 3705 DEFSUBR (Factive_minibuffer_window); | |
| 3706 DEFSUBR (Flast_nonminibuf_frame); | |
| 3707 DEFSUBR (Fframe_root_window); | |
| 3708 DEFSUBR (Fframe_selected_window); | |
| 3709 DEFSUBR (Fset_frame_selected_window); | |
| 3710 DEFSUBR (Fframe_device); | |
| 3711 DEFSUBR (Fnext_frame); | |
| 3712 DEFSUBR (Fprevious_frame); | |
| 3713 DEFSUBR (Fdelete_frame); | |
| 3714 DEFSUBR (Fmouse_position); | |
| 3715 DEFSUBR (Fmouse_pixel_position); | |
| 3716 DEFSUBR (Fmouse_position_as_motion_event); | |
| 3717 DEFSUBR (Fset_mouse_position); | |
| 3718 DEFSUBR (Fset_mouse_pixel_position); | |
| 3719 DEFSUBR (Fmake_frame_visible); | |
| 3720 DEFSUBR (Fmake_frame_invisible); | |
| 3721 DEFSUBR (Ficonify_frame); | |
| 3722 DEFSUBR (Fdeiconify_frame); | |
| 3723 DEFSUBR (Fframe_visible_p); | |
| 3724 DEFSUBR (Fframe_totally_visible_p); | |
| 3725 DEFSUBR (Fframe_iconified_p); | |
| 3726 DEFSUBR (Fvisible_frame_list); | |
| 3727 DEFSUBR (Fraise_frame); | |
| 3728 DEFSUBR (Flower_frame); | |
| 442 | 3729 DEFSUBR (Fdisable_frame); |
| 3730 DEFSUBR (Fenable_frame); | |
| 428 | 3731 DEFSUBR (Fframe_property); |
| 3732 DEFSUBR (Fframe_properties); | |
| 3733 DEFSUBR (Fset_frame_properties); | |
| 3734 DEFSUBR (Fframe_pixel_height); | |
| 1125 | 3735 DEFSUBR (Fframe_displayable_pixel_height); |
| 428 | 3736 DEFSUBR (Fframe_pixel_width); |
| 1125 | 3737 DEFSUBR (Fframe_displayable_pixel_width); |
| 428 | 3738 DEFSUBR (Fframe_name); |
| 3739 DEFSUBR (Fframe_modified_tick); | |
| 3740 DEFSUBR (Fset_frame_height); | |
| 3741 DEFSUBR (Fset_frame_width); | |
| 3742 DEFSUBR (Fset_frame_size); | |
| 863 | 3743 DEFSUBR (Fset_frame_pixel_height); |
| 1125 | 3744 DEFSUBR (Fset_frame_displayable_pixel_height); |
| 863 | 3745 DEFSUBR (Fset_frame_pixel_width); |
| 1125 | 3746 DEFSUBR (Fset_frame_displayable_pixel_width); |
| 863 | 3747 DEFSUBR (Fset_frame_pixel_size); |
| 1125 | 3748 DEFSUBR (Fset_frame_displayable_pixel_size); |
| 428 | 3749 DEFSUBR (Fset_frame_position); |
| 3750 DEFSUBR (Fset_frame_pointer); | |
| 442 | 3751 DEFSUBR (Fprint_job_page_number); |
| 3752 DEFSUBR (Fprint_job_eject_page); | |
| 428 | 3753 } |
| 3754 | |
| 3755 void | |
| 3756 vars_of_frame (void) | |
| 3757 { | |
| 3758 /* */ | |
| 3759 Vframe_being_created = Qnil; | |
| 3760 staticpro (&Vframe_being_created); | |
| 3761 | |
| 3762 #ifdef HAVE_CDE | |
| 3763 Fprovide (intern ("cde")); | |
| 3764 #endif | |
| 3765 | |
| 3766 #if 0 /* FSFmacs stupidity */ | |
| 3767 xxDEFVAR_LISP ("emacs-iconified", &Vemacs_iconified /* | |
| 3768 Non-nil if all of emacs is iconified and frame updates are not needed. | |
| 3769 */ ); | |
| 3770 Vemacs_iconified = Qnil; | |
| 3771 #endif | |
| 3772 | |
| 3773 DEFVAR_LISP ("select-frame-hook", &Vselect_frame_hook /* | |
| 3774 Function or functions to run just after a new frame is given the focus. | |
| 3775 Note that calling `select-frame' does not necessarily set the focus: | |
| 3776 The actual window-system focus will not be changed until the next time | |
| 3777 that XEmacs is waiting for an event, and even then, the window manager | |
| 3778 may refuse the focus-change request. | |
| 3779 */ ); | |
| 3780 Vselect_frame_hook = Qnil; | |
| 3781 | |
| 3782 DEFVAR_LISP ("deselect-frame-hook", &Vdeselect_frame_hook /* | |
| 3783 Function or functions to run just before a frame loses the focus. | |
| 3784 See `select-frame-hook'. | |
| 3785 */ ); | |
| 3786 Vdeselect_frame_hook = Qnil; | |
| 3787 | |
| 3788 DEFVAR_LISP ("delete-frame-hook", &Vdelete_frame_hook /* | |
| 3789 Function or functions to call when a frame is deleted. | |
| 3790 One argument, the about-to-be-deleted frame. | |
| 3791 */ ); | |
| 3792 Vdelete_frame_hook = Qnil; | |
| 3793 | |
| 3794 DEFVAR_LISP ("create-frame-hook", &Vcreate_frame_hook /* | |
| 3795 Function or functions to call when a frame is created. | |
| 3796 One argument, the newly-created frame. | |
| 3797 */ ); | |
| 3798 Vcreate_frame_hook = Qnil; | |
| 3799 | |
| 3800 DEFVAR_LISP ("mouse-enter-frame-hook", &Vmouse_enter_frame_hook /* | |
| 3801 Function or functions to call when the mouse enters a frame. | |
| 3802 One argument, the frame. | |
| 3803 Be careful not to make assumptions about the window manager's focus model. | |
| 3804 In most cases, the `deselect-frame-hook' is more appropriate. | |
| 3805 */ ); | |
| 3806 Vmouse_enter_frame_hook = Qnil; | |
| 3807 | |
| 3808 DEFVAR_LISP ("mouse-leave-frame-hook", &Vmouse_leave_frame_hook /* | |
| 3809 Function or functions to call when the mouse leaves a frame. | |
| 3810 One argument, the frame. | |
| 3811 Be careful not to make assumptions about the window manager's focus model. | |
| 3812 In most cases, the `select-frame-hook' is more appropriate. | |
| 3813 */ ); | |
| 3814 Vmouse_leave_frame_hook = Qnil; | |
| 3815 | |
| 3816 DEFVAR_LISP ("map-frame-hook", &Vmap_frame_hook /* | |
| 3817 Function or functions to call when a frame is mapped. | |
| 3818 One argument, the frame. | |
| 3819 */ ); | |
| 3820 Vmap_frame_hook = Qnil; | |
| 3821 | |
| 3822 DEFVAR_LISP ("unmap-frame-hook", &Vunmap_frame_hook /* | |
| 3823 Function or functions to call when a frame is unmapped. | |
| 3824 One argument, the frame. | |
| 3825 */ ); | |
| 3826 Vunmap_frame_hook = Qnil; | |
| 3827 | |
| 3828 DEFVAR_BOOL ("allow-deletion-of-last-visible-frame", | |
| 3829 &allow_deletion_of_last_visible_frame /* | |
| 3830 *Non-nil means to assume the force option to delete-frame. | |
| 3831 */ ); | |
| 3832 allow_deletion_of_last_visible_frame = 0; | |
| 3833 | |
| 3834 DEFVAR_LISP ("adjust-frame-function", &Vadjust_frame_function /* | |
| 3835 Function or constant controlling adjustment of frame. | |
| 3836 When scrollbars, toolbars, default font etc. change in frame, the frame | |
| 3837 needs to be adjusted. The adjustment is controlled by this variable. | |
| 3838 Legal values are: | |
| 3839 nil to keep character frame size unchanged when possible (resize) | |
| 3840 t to keep pixel size unchanged (never resize) | |
| 3841 function symbol or lambda form. This function must return boolean | |
| 3842 value which is treated as above. Function is passed one parameter, | |
| 3843 the frame being adjusted. It function should not modify or delete | |
| 3844 the frame. | |
| 3845 */ ); | |
| 3846 Vadjust_frame_function = Qnil; | |
| 3847 | |
| 3848 DEFVAR_LISP ("mouse-motion-handler", &Vmouse_motion_handler /* | |
| 3577 | 3849 Handler for motion events. Must be a function taking one argument, the event. |
| 428 | 3850 For most applications, you should use `mode-motion-hook' instead of this. |
| 3577 | 3851 The default value is `default-mouse-motion-handler'. |
| 3852 | |
| 3853 Note that this is NOT a hook variable, so there is no standard way to remove | |
| 3854 actions from it. Instead, when adding a new kind of action, a hook variable | |
| 3855 should be defined and initialized to the current value of this variable, then | |
| 3856 this variable set to a function that runs the new hook. To disable the new | |
| 3857 actions, use `remove-hook' rather than setting `mouse-motion-handler'. | |
| 3858 | |
| 3859 `mouse-motion-hook' in the balloon-help library exemplifies this pattern. | |
| 428 | 3860 */ ); |
| 3861 Vmouse_motion_handler = Qnil; | |
| 3862 | |
| 3863 DEFVAR_LISP ("synchronize-minibuffers",&Vsynchronize_minibuffers /* | |
| 3864 Set to t if all minibuffer windows are to be synchronized. | |
| 3865 This will cause echo area messages to appear in the minibuffers of all | |
| 3866 visible frames. | |
| 3867 */ ); | |
| 3868 Vsynchronize_minibuffers = Qnil; | |
| 3869 | |
| 3870 DEFVAR_LISP ("frame-title-format", &Vframe_title_format /* | |
| 442 | 3871 Controls the title of the window-system window of the selected frame. |
| 428 | 3872 This is the same format as `modeline-format' with the exception that |
| 3873 %- is ignored. | |
| 3874 */ ); | |
| 442 | 3875 /* #### I would change this unilaterally but for the wrath of the Kyles |
| 3876 of the world. */ | |
| 3877 #ifdef WIN32_NATIVE | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
3878 Vframe_title_format = build_ascstring ("%b - XEmacs"); |
| 442 | 3879 #else |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
3880 Vframe_title_format = build_ascstring ("%S: %b"); |
| 442 | 3881 #endif |
| 428 | 3882 |
| 3883 DEFVAR_LISP ("frame-icon-title-format", &Vframe_icon_title_format /* | |
| 3884 Controls the title of the icon corresponding to the selected frame. | |
| 3885 See also the variable `frame-title-format'. | |
| 3886 */ ); | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4846
diff
changeset
|
3887 Vframe_icon_title_format = build_ascstring ("%b"); |
| 428 | 3888 |
| 3889 DEFVAR_LISP ("default-frame-name", &Vdefault_frame_name /* | |
| 3890 The default name to assign to newly-created frames. | |
| 442 | 3891 This can be overridden by arguments to `make-frame'. This must be a string. |
| 3892 This is used primarily for picking up X resources, and is *not* the title | |
| 3893 of the frame. (See `frame-title-format'.) | |
| 2681 | 3894 |
| 3895 Previous to 21.5.21, this defaulted to `emacs'; since that release, it has | |
| 3896 defaulted to `XEmacs'. In the short term you can restore the old default by | |
| 3897 setting the environment variable USE_EMACS_AS_DEFAULT_APPLICATION_CLASS | |
| 3898 (which does affect the frame name, despite what it's called) to some value | |
| 3899 before starting XEmacs, but this is deprecated. | |
| 428 | 3900 */ ); |
| 2681 | 3901 Vdefault_frame_name = Qnil; |
| 428 | 3902 |
| 3903 DEFVAR_LISP ("default-frame-plist", &Vdefault_frame_plist /* | |
| 3904 Plist of default values for frame creation, other than the first one. | |
| 3905 These may be set in your init file, like this: | |
| 3906 | |
| 3907 \(setq default-frame-plist '(width 80 height 55)) | |
| 3908 | |
| 2747 | 3909 Predefined properties are described in `set-frame-properties'. |
| 3910 | |
| 428 | 3911 The properties may be in alist format for backward compatibility |
| 3912 but you should not rely on this behavior. | |
| 3913 | |
| 3914 These override values given in window system configuration data, | |
| 2747 | 3915 including X Windows' defaults database. |
| 3916 | |
| 3917 Values for the first Emacs frame are taken from `initial-frame-plist'. | |
| 3918 Since the first X frame is created before loading your .emacs file, you | |
| 3919 may wish use the X resource database to avoid flashing. | |
| 3920 | |
| 428 | 3921 For values specific to the separate minibuffer frame, see |
| 2747 | 3922 `minibuffer-frame-plist'. See also the variables `default-x-frame-plist' |
| 3923 and `default-tty-frame-plist', which are like `default-frame-plist' | |
| 3924 except that they apply only to X or tty frames, respectively \(whereas | |
| 3925 `default-frame-plist' applies to all types of frames). | |
| 428 | 3926 */ ); |
| 3927 Vdefault_frame_plist = Qnil; | |
| 3928 | |
| 3929 DEFVAR_LISP ("frame-icon-glyph", &Vframe_icon_glyph /* | |
| 3930 Icon glyph used to iconify a frame. | |
| 3931 */ ); | |
| 3932 } | |
| 3933 | |
| 3934 void | |
| 3935 complex_vars_of_frame (void) | |
| 3936 { | |
| 3937 Vframe_icon_glyph = allocate_glyph (GLYPH_ICON, icon_glyph_changed); | |
| 3938 } |
