| 1 | /* Generic frame functions. |
| 2 | Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001 |
| 3 | Free Software Foundation. |
| 4 | |
| 5 | This file is part of GNU Emacs. |
| 6 | |
| 7 | GNU Emacs is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2, or (at your option) |
| 10 | any later version. |
| 11 | |
| 12 | GNU Emacs is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with GNU Emacs; see the file COPYING. If not, write to |
| 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | Boston, MA 02111-1307, USA. */ |
| 21 | |
| 22 | #include <config.h> |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include "lisp.h" |
| 26 | #include "charset.h" |
| 27 | #ifdef HAVE_X_WINDOWS |
| 28 | #include "xterm.h" |
| 29 | #endif |
| 30 | #ifdef WINDOWSNT |
| 31 | #include "w32term.h" |
| 32 | #endif |
| 33 | #ifdef MAC_OS |
| 34 | #include "macterm.h" |
| 35 | #endif |
| 36 | #include "buffer.h" |
| 37 | /* These help us bind and responding to switch-frame events. */ |
| 38 | #include "commands.h" |
| 39 | #include "keyboard.h" |
| 40 | #include "frame.h" |
| 41 | #ifdef HAVE_WINDOW_SYSTEM |
| 42 | #include "fontset.h" |
| 43 | #endif |
| 44 | #include "blockinput.h" |
| 45 | #include "termhooks.h" |
| 46 | #include "dispextern.h" |
| 47 | #include "window.h" |
| 48 | #ifdef MSDOS |
| 49 | #include "msdos.h" |
| 50 | #include "dosfns.h" |
| 51 | #endif |
| 52 | |
| 53 | |
| 54 | /* The name we're using in resource queries. Most often "emacs". */ |
| 55 | |
| 56 | Lisp_Object Vx_resource_name; |
| 57 | |
| 58 | /* The application class we're using in resource queries. |
| 59 | Normally "Emacs". */ |
| 60 | |
| 61 | Lisp_Object Vx_resource_class; |
| 62 | |
| 63 | |
| 64 | Lisp_Object Qframep, Qframe_live_p; |
| 65 | Lisp_Object Qicon, Qmodeline; |
| 66 | Lisp_Object Qonly; |
| 67 | Lisp_Object Qx, Qw32, Qmac, Qpc; |
| 68 | Lisp_Object Qvisible; |
| 69 | Lisp_Object Qdisplay_type; |
| 70 | Lisp_Object Qbackground_mode; |
| 71 | Lisp_Object Qinhibit_default_face_x_resources; |
| 72 | |
| 73 | Lisp_Object Qx_frame_parameter; |
| 74 | Lisp_Object Qx_resource_name; |
| 75 | |
| 76 | /* Frame parameters (set or reported). */ |
| 77 | |
| 78 | Lisp_Object Qauto_raise, Qauto_lower; |
| 79 | Lisp_Object Qborder_color, Qborder_width; |
| 80 | Lisp_Object Qcursor_color, Qcursor_type; |
| 81 | Lisp_Object Qgeometry; /* Not used */ |
| 82 | Lisp_Object Qheight, Qwidth; |
| 83 | Lisp_Object Qleft, Qright; |
| 84 | Lisp_Object Qicon_left, Qicon_top, Qicon_type, Qicon_name; |
| 85 | Lisp_Object Qinternal_border_width; |
| 86 | Lisp_Object Qmouse_color; |
| 87 | Lisp_Object Qminibuffer; |
| 88 | Lisp_Object Qscroll_bar_width, Qvertical_scroll_bars; |
| 89 | Lisp_Object Qvisibility; |
| 90 | Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; |
| 91 | Lisp_Object Qscreen_gamma; |
| 92 | Lisp_Object Qline_spacing; |
| 93 | Lisp_Object Quser_position, Quser_size; |
| 94 | Lisp_Object Qwait_for_wm; |
| 95 | Lisp_Object Qwindow_id; |
| 96 | #ifdef HAVE_X_WINDOWS |
| 97 | Lisp_Object Qouter_window_id; |
| 98 | #endif |
| 99 | Lisp_Object Qparent_id; |
| 100 | Lisp_Object Qtitle, Qname; |
| 101 | Lisp_Object Qunsplittable; |
| 102 | Lisp_Object Qmenu_bar_lines, Qtool_bar_lines; |
| 103 | Lisp_Object Qleft_fringe, Qright_fringe; |
| 104 | Lisp_Object Qbuffer_predicate, Qbuffer_list; |
| 105 | Lisp_Object Qtty_color_mode; |
| 106 | |
| 107 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; |
| 108 | |
| 109 | Lisp_Object Qface_set_after_frame_default; |
| 110 | |
| 111 | |
| 112 | Lisp_Object Vterminal_frame; |
| 113 | Lisp_Object Vdefault_frame_alist; |
| 114 | Lisp_Object Vmouse_position_function; |
| 115 | Lisp_Object Vmouse_highlight; |
| 116 | Lisp_Object Vdelete_frame_functions; |
| 117 | \f |
| 118 | static void |
| 119 | set_menu_bar_lines_1 (window, n) |
| 120 | Lisp_Object window; |
| 121 | int n; |
| 122 | { |
| 123 | struct window *w = XWINDOW (window); |
| 124 | |
| 125 | XSETFASTINT (w->last_modified, 0); |
| 126 | XSETFASTINT (w->top, XFASTINT (w->top) + n); |
| 127 | XSETFASTINT (w->height, XFASTINT (w->height) - n); |
| 128 | |
| 129 | if (INTEGERP (w->orig_top)) |
| 130 | XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n); |
| 131 | if (INTEGERP (w->orig_height)) |
| 132 | XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n); |
| 133 | |
| 134 | /* Handle just the top child in a vertical split. */ |
| 135 | if (!NILP (w->vchild)) |
| 136 | set_menu_bar_lines_1 (w->vchild, n); |
| 137 | |
| 138 | /* Adjust all children in a horizontal split. */ |
| 139 | for (window = w->hchild; !NILP (window); window = w->next) |
| 140 | { |
| 141 | w = XWINDOW (window); |
| 142 | set_menu_bar_lines_1 (window, n); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void |
| 147 | set_menu_bar_lines (f, value, oldval) |
| 148 | struct frame *f; |
| 149 | Lisp_Object value, oldval; |
| 150 | { |
| 151 | int nlines; |
| 152 | int olines = FRAME_MENU_BAR_LINES (f); |
| 153 | |
| 154 | /* Right now, menu bars don't work properly in minibuf-only frames; |
| 155 | most of the commands try to apply themselves to the minibuffer |
| 156 | frame itself, and get an error because you can't switch buffers |
| 157 | in or split the minibuffer window. */ |
| 158 | if (FRAME_MINIBUF_ONLY_P (f)) |
| 159 | return; |
| 160 | |
| 161 | if (INTEGERP (value)) |
| 162 | nlines = XINT (value); |
| 163 | else |
| 164 | nlines = 0; |
| 165 | |
| 166 | if (nlines != olines) |
| 167 | { |
| 168 | windows_or_buffers_changed++; |
| 169 | FRAME_WINDOW_SIZES_CHANGED (f) = 1; |
| 170 | FRAME_MENU_BAR_LINES (f) = nlines; |
| 171 | set_menu_bar_lines_1 (f->root_window, nlines - olines); |
| 172 | adjust_glyphs (f); |
| 173 | } |
| 174 | } |
| 175 | \f |
| 176 | Lisp_Object Vemacs_iconified; |
| 177 | Lisp_Object Vframe_list; |
| 178 | |
| 179 | struct x_output tty_display; |
| 180 | |
| 181 | extern Lisp_Object Vminibuffer_list; |
| 182 | extern Lisp_Object get_minibuffer (); |
| 183 | extern Lisp_Object Fhandle_switch_frame (); |
| 184 | extern Lisp_Object Fredirect_frame_focus (); |
| 185 | extern Lisp_Object x_get_focus_frame (); |
| 186 | \f |
| 187 | DEFUN ("framep", Fframep, Sframep, 1, 1, 0, |
| 188 | doc: /* Return non-nil if OBJECT is a frame. |
| 189 | Value is t for a termcap frame (a character-only terminal), |
| 190 | `x' for an Emacs frame that is really an X window, |
| 191 | `w32' for an Emacs frame that is a window on MS-Windows display, |
| 192 | `mac' for an Emacs frame on a Macintosh display, |
| 193 | `pc' for a direct-write MS-DOS frame. |
| 194 | See also `frame-live-p'. */) |
| 195 | (object) |
| 196 | Lisp_Object object; |
| 197 | { |
| 198 | if (!FRAMEP (object)) |
| 199 | return Qnil; |
| 200 | switch (XFRAME (object)->output_method) |
| 201 | { |
| 202 | case output_termcap: |
| 203 | return Qt; |
| 204 | case output_x_window: |
| 205 | return Qx; |
| 206 | case output_w32: |
| 207 | return Qw32; |
| 208 | case output_msdos_raw: |
| 209 | return Qpc; |
| 210 | case output_mac: |
| 211 | return Qmac; |
| 212 | default: |
| 213 | abort (); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0, |
| 218 | doc: /* Return non-nil if OBJECT is a frame which has not been deleted. |
| 219 | Value is nil if OBJECT is not a live frame. If object is a live |
| 220 | frame, the return value indicates what sort of output device it is |
| 221 | displayed on. See the documentation of `framep' for possible |
| 222 | return values. */) |
| 223 | (object) |
| 224 | Lisp_Object object; |
| 225 | { |
| 226 | return ((FRAMEP (object) |
| 227 | && FRAME_LIVE_P (XFRAME (object))) |
| 228 | ? Fframep (object) |
| 229 | : Qnil); |
| 230 | } |
| 231 | |
| 232 | struct frame * |
| 233 | make_frame (mini_p) |
| 234 | int mini_p; |
| 235 | { |
| 236 | Lisp_Object frame; |
| 237 | register struct frame *f; |
| 238 | register Lisp_Object root_window; |
| 239 | register Lisp_Object mini_window; |
| 240 | |
| 241 | f = allocate_frame (); |
| 242 | XSETFRAME (frame, f); |
| 243 | |
| 244 | f->desired_matrix = 0; |
| 245 | f->current_matrix = 0; |
| 246 | f->desired_pool = 0; |
| 247 | f->current_pool = 0; |
| 248 | f->glyphs_initialized_p = 0; |
| 249 | f->decode_mode_spec_buffer = 0; |
| 250 | f->visible = 0; |
| 251 | f->async_visible = 0; |
| 252 | f->output_data.nothing = 0; |
| 253 | f->iconified = 0; |
| 254 | f->async_iconified = 0; |
| 255 | f->wants_modeline = 1; |
| 256 | f->auto_raise = 0; |
| 257 | f->auto_lower = 0; |
| 258 | f->no_split = 0; |
| 259 | f->garbaged = 1; |
| 260 | f->has_minibuffer = mini_p; |
| 261 | f->focus_frame = Qnil; |
| 262 | f->explicit_name = 0; |
| 263 | f->can_have_scroll_bars = 0; |
| 264 | f->vertical_scroll_bar_type = vertical_scroll_bar_none; |
| 265 | f->param_alist = Qnil; |
| 266 | f->scroll_bars = Qnil; |
| 267 | f->condemned_scroll_bars = Qnil; |
| 268 | f->face_alist = Qnil; |
| 269 | f->face_cache = NULL; |
| 270 | f->menu_bar_items = Qnil; |
| 271 | f->menu_bar_vector = Qnil; |
| 272 | f->menu_bar_items_used = 0; |
| 273 | f->buffer_predicate = Qnil; |
| 274 | f->buffer_list = Qnil; |
| 275 | #ifdef MULTI_KBOARD |
| 276 | f->kboard = initial_kboard; |
| 277 | #endif |
| 278 | f->namebuf = 0; |
| 279 | f->title = Qnil; |
| 280 | f->menu_bar_window = Qnil; |
| 281 | f->tool_bar_window = Qnil; |
| 282 | f->tool_bar_items = Qnil; |
| 283 | f->desired_tool_bar_string = f->current_tool_bar_string = Qnil; |
| 284 | f->n_tool_bar_items = 0; |
| 285 | |
| 286 | root_window = make_window (); |
| 287 | if (mini_p) |
| 288 | { |
| 289 | mini_window = make_window (); |
| 290 | XWINDOW (root_window)->next = mini_window; |
| 291 | XWINDOW (mini_window)->prev = root_window; |
| 292 | XWINDOW (mini_window)->mini_p = Qt; |
| 293 | XWINDOW (mini_window)->frame = frame; |
| 294 | f->minibuffer_window = mini_window; |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | mini_window = Qnil; |
| 299 | XWINDOW (root_window)->next = Qnil; |
| 300 | f->minibuffer_window = Qnil; |
| 301 | } |
| 302 | |
| 303 | XWINDOW (root_window)->frame = frame; |
| 304 | |
| 305 | /* 10 is arbitrary, |
| 306 | just so that there is "something there." |
| 307 | Correct size will be set up later with change_frame_size. */ |
| 308 | |
| 309 | SET_FRAME_WIDTH (f, 10); |
| 310 | f->height = 10; |
| 311 | |
| 312 | XSETFASTINT (XWINDOW (root_window)->width, 10); |
| 313 | XSETFASTINT (XWINDOW (root_window)->height, (mini_p ? 9 : 10)); |
| 314 | |
| 315 | if (mini_p) |
| 316 | { |
| 317 | XSETFASTINT (XWINDOW (mini_window)->width, 10); |
| 318 | XSETFASTINT (XWINDOW (mini_window)->top, 9); |
| 319 | XSETFASTINT (XWINDOW (mini_window)->height, 1); |
| 320 | } |
| 321 | |
| 322 | /* Choose a buffer for the frame's root window. */ |
| 323 | { |
| 324 | Lisp_Object buf; |
| 325 | |
| 326 | XWINDOW (root_window)->buffer = Qt; |
| 327 | buf = Fcurrent_buffer (); |
| 328 | /* If buf is a 'hidden' buffer (i.e. one whose name starts with |
| 329 | a space), try to find another one. */ |
| 330 | if (SREF (Fbuffer_name (buf), 0) == ' ') |
| 331 | buf = Fother_buffer (buf, Qnil, Qnil); |
| 332 | |
| 333 | /* Use set_window_buffer, not Fset_window_buffer, and don't let |
| 334 | hooks be run by it. The reason is that the whole frame/window |
| 335 | arrangement is not yet fully intialized at this point. Windows |
| 336 | don't have the right size, glyph matrices aren't initialized |
| 337 | etc. Running Lisp functions at this point surely ends in a |
| 338 | SEGV. */ |
| 339 | set_window_buffer (root_window, buf, 0); |
| 340 | f->buffer_list = Fcons (buf, Qnil); |
| 341 | } |
| 342 | |
| 343 | if (mini_p) |
| 344 | { |
| 345 | XWINDOW (mini_window)->buffer = Qt; |
| 346 | set_window_buffer (mini_window, |
| 347 | (NILP (Vminibuffer_list) |
| 348 | ? get_minibuffer (0) |
| 349 | : Fcar (Vminibuffer_list)), |
| 350 | 0); |
| 351 | } |
| 352 | |
| 353 | f->root_window = root_window; |
| 354 | f->selected_window = root_window; |
| 355 | /* Make sure this window seems more recently used than |
| 356 | a newly-created, never-selected window. */ |
| 357 | XSETFASTINT (XWINDOW (f->selected_window)->use_time, ++window_select_count); |
| 358 | |
| 359 | return f; |
| 360 | } |
| 361 | \f |
| 362 | #ifdef HAVE_WINDOW_SYSTEM |
| 363 | /* Make a frame using a separate minibuffer window on another frame. |
| 364 | MINI_WINDOW is the minibuffer window to use. nil means use the |
| 365 | default (the global minibuffer). */ |
| 366 | |
| 367 | struct frame * |
| 368 | make_frame_without_minibuffer (mini_window, kb, display) |
| 369 | register Lisp_Object mini_window; |
| 370 | KBOARD *kb; |
| 371 | Lisp_Object display; |
| 372 | { |
| 373 | register struct frame *f; |
| 374 | struct gcpro gcpro1; |
| 375 | |
| 376 | if (!NILP (mini_window)) |
| 377 | CHECK_LIVE_WINDOW (mini_window); |
| 378 | |
| 379 | #ifdef MULTI_KBOARD |
| 380 | if (!NILP (mini_window) |
| 381 | && XFRAME (XWINDOW (mini_window)->frame)->kboard != kb) |
| 382 | error ("frame and minibuffer must be on the same display"); |
| 383 | #endif |
| 384 | |
| 385 | /* Make a frame containing just a root window. */ |
| 386 | f = make_frame (0); |
| 387 | |
| 388 | if (NILP (mini_window)) |
| 389 | { |
| 390 | /* Use default-minibuffer-frame if possible. */ |
| 391 | if (!FRAMEP (kb->Vdefault_minibuffer_frame) |
| 392 | || ! FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame))) |
| 393 | { |
| 394 | Lisp_Object frame_dummy; |
| 395 | |
| 396 | XSETFRAME (frame_dummy, f); |
| 397 | GCPRO1 (frame_dummy); |
| 398 | /* If there's no minibuffer frame to use, create one. */ |
| 399 | kb->Vdefault_minibuffer_frame = |
| 400 | call1 (intern ("make-initial-minibuffer-frame"), display); |
| 401 | UNGCPRO; |
| 402 | } |
| 403 | |
| 404 | mini_window = XFRAME (kb->Vdefault_minibuffer_frame)->minibuffer_window; |
| 405 | } |
| 406 | |
| 407 | f->minibuffer_window = mini_window; |
| 408 | |
| 409 | /* Make the chosen minibuffer window display the proper minibuffer, |
| 410 | unless it is already showing a minibuffer. */ |
| 411 | if (NILP (Fmemq (XWINDOW (mini_window)->buffer, Vminibuffer_list))) |
| 412 | Fset_window_buffer (mini_window, |
| 413 | (NILP (Vminibuffer_list) |
| 414 | ? get_minibuffer (0) |
| 415 | : Fcar (Vminibuffer_list))); |
| 416 | return f; |
| 417 | } |
| 418 | |
| 419 | /* Make a frame containing only a minibuffer window. */ |
| 420 | |
| 421 | struct frame * |
| 422 | make_minibuffer_frame () |
| 423 | { |
| 424 | /* First make a frame containing just a root window, no minibuffer. */ |
| 425 | |
| 426 | register struct frame *f = make_frame (0); |
| 427 | register Lisp_Object mini_window; |
| 428 | register Lisp_Object frame; |
| 429 | |
| 430 | XSETFRAME (frame, f); |
| 431 | |
| 432 | f->auto_raise = 0; |
| 433 | f->auto_lower = 0; |
| 434 | f->no_split = 1; |
| 435 | f->wants_modeline = 0; |
| 436 | f->has_minibuffer = 1; |
| 437 | |
| 438 | /* Now label the root window as also being the minibuffer. |
| 439 | Avoid infinite looping on the window chain by marking next pointer |
| 440 | as nil. */ |
| 441 | |
| 442 | mini_window = f->minibuffer_window = f->root_window; |
| 443 | XWINDOW (mini_window)->mini_p = Qt; |
| 444 | XWINDOW (mini_window)->next = Qnil; |
| 445 | XWINDOW (mini_window)->prev = Qnil; |
| 446 | XWINDOW (mini_window)->frame = frame; |
| 447 | |
| 448 | /* Put the proper buffer in that window. */ |
| 449 | |
| 450 | Fset_window_buffer (mini_window, |
| 451 | (NILP (Vminibuffer_list) |
| 452 | ? get_minibuffer (0) |
| 453 | : Fcar (Vminibuffer_list))); |
| 454 | return f; |
| 455 | } |
| 456 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 457 | \f |
| 458 | /* Construct a frame that refers to the terminal (stdin and stdout). */ |
| 459 | |
| 460 | static int terminal_frame_count; |
| 461 | |
| 462 | struct frame * |
| 463 | make_terminal_frame () |
| 464 | { |
| 465 | register struct frame *f; |
| 466 | Lisp_Object frame; |
| 467 | char name[20]; |
| 468 | |
| 469 | #ifdef MULTI_KBOARD |
| 470 | if (!initial_kboard) |
| 471 | { |
| 472 | initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); |
| 473 | init_kboard (initial_kboard); |
| 474 | initial_kboard->next_kboard = all_kboards; |
| 475 | all_kboards = initial_kboard; |
| 476 | } |
| 477 | #endif |
| 478 | |
| 479 | /* The first call must initialize Vframe_list. */ |
| 480 | if (! (NILP (Vframe_list) || CONSP (Vframe_list))) |
| 481 | Vframe_list = Qnil; |
| 482 | |
| 483 | f = make_frame (1); |
| 484 | |
| 485 | XSETFRAME (frame, f); |
| 486 | Vframe_list = Fcons (frame, Vframe_list); |
| 487 | |
| 488 | terminal_frame_count++; |
| 489 | sprintf (name, "F%d", terminal_frame_count); |
| 490 | f->name = build_string (name); |
| 491 | |
| 492 | f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */ |
| 493 | f->async_visible = 1; /* Don't let visible be cleared later. */ |
| 494 | #ifdef MSDOS |
| 495 | f->output_data.x = &the_only_x_display; |
| 496 | if (!inhibit_window_system |
| 497 | && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame)) |
| 498 | || XFRAME (selected_frame)->output_method == output_msdos_raw)) |
| 499 | { |
| 500 | f->output_method = output_msdos_raw; |
| 501 | /* This initialization of foreground and background pixels is |
| 502 | only important for the initial frame created in temacs. If |
| 503 | we don't do that, we get black background and foreground in |
| 504 | the dumped Emacs because the_only_x_display is a static |
| 505 | variable, hence it is born all-zeroes, and zero is the code |
| 506 | for the black color. Other frames all inherit their pixels |
| 507 | from what's already in the_only_x_display. */ |
| 508 | if ((!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))) |
| 509 | && f->output_data.x->background_pixel == 0 |
| 510 | && f->output_data.x->foreground_pixel == 0) |
| 511 | { |
| 512 | f->output_data.x->background_pixel = FACE_TTY_DEFAULT_BG_COLOR; |
| 513 | f->output_data.x->foreground_pixel = FACE_TTY_DEFAULT_FG_COLOR; |
| 514 | } |
| 515 | } |
| 516 | else |
| 517 | f->output_method = output_termcap; |
| 518 | #else |
| 519 | #ifdef WINDOWSNT |
| 520 | f->output_method = output_termcap; |
| 521 | f->output_data.x = &tty_display; |
| 522 | #else |
| 523 | #ifdef MAC_OS8 |
| 524 | make_mac_terminal_frame (f); |
| 525 | #else |
| 526 | f->output_data.x = &tty_display; |
| 527 | #ifdef CANNOT_DUMP |
| 528 | FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR; |
| 529 | FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR; |
| 530 | #endif |
| 531 | #endif /* MAC_OS8 */ |
| 532 | #endif /* WINDOWSNT */ |
| 533 | #endif /* MSDOS */ |
| 534 | |
| 535 | if (!noninteractive) |
| 536 | init_frame_faces (f); |
| 537 | |
| 538 | return f; |
| 539 | } |
| 540 | |
| 541 | DEFUN ("make-terminal-frame", Fmake_terminal_frame, Smake_terminal_frame, |
| 542 | 1, 1, 0, |
| 543 | doc: /* Create an additional terminal frame. |
| 544 | You can create multiple frames on a text-only terminal in this way. |
| 545 | Only the selected terminal frame is actually displayed. |
| 546 | This function takes one argument, an alist specifying frame parameters. |
| 547 | In practice, generally you don't need to specify any parameters. |
| 548 | Note that changing the size of one terminal frame automatically affects all. */) |
| 549 | (parms) |
| 550 | Lisp_Object parms; |
| 551 | { |
| 552 | struct frame *f; |
| 553 | Lisp_Object frame, tem; |
| 554 | struct frame *sf = SELECTED_FRAME (); |
| 555 | |
| 556 | #ifdef MSDOS |
| 557 | if (sf->output_method != output_msdos_raw |
| 558 | && sf->output_method != output_termcap) |
| 559 | abort (); |
| 560 | #else /* not MSDOS */ |
| 561 | |
| 562 | #ifdef MAC_OS |
| 563 | if (sf->output_method != output_mac) |
| 564 | error ("Not running on a Macintosh screen; cannot make a new Macintosh frame"); |
| 565 | #else |
| 566 | if (sf->output_method != output_termcap) |
| 567 | error ("Not using an ASCII terminal now; cannot make a new ASCII frame"); |
| 568 | #endif |
| 569 | #endif /* not MSDOS */ |
| 570 | |
| 571 | f = make_terminal_frame (); |
| 572 | |
| 573 | change_frame_size (f, FRAME_HEIGHT (sf), |
| 574 | FRAME_WIDTH (sf), 0, 0, 0); |
| 575 | adjust_glyphs (f); |
| 576 | calculate_costs (f); |
| 577 | XSETFRAME (frame, f); |
| 578 | Fmodify_frame_parameters (frame, Vdefault_frame_alist); |
| 579 | Fmodify_frame_parameters (frame, parms); |
| 580 | |
| 581 | /* Make the frame face alist be frame-specific, so that each |
| 582 | frame could change its face definitions independently. */ |
| 583 | f->face_alist = Fcopy_alist (sf->face_alist); |
| 584 | /* Simple Fcopy_alist isn't enough, because we need the contents of |
| 585 | the vectors which are the CDRs of associations in face_alist to |
| 586 | be copied as well. */ |
| 587 | for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem)) |
| 588 | XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem)))); |
| 589 | return frame; |
| 590 | } |
| 591 | |
| 592 | \f |
| 593 | /* Perform the switch to frame FRAME. |
| 594 | |
| 595 | If FRAME is a switch-frame event `(switch-frame FRAME1)', use |
| 596 | FRAME1 as frame. |
| 597 | |
| 598 | If TRACK is non-zero and the frame that currently has the focus |
| 599 | redirects its focus to the selected frame, redirect that focused |
| 600 | frame's focus to FRAME instead. |
| 601 | |
| 602 | FOR_DELETION non-zero means that the selected frame is being |
| 603 | deleted, which includes the possibility that the frame's display |
| 604 | is dead. */ |
| 605 | |
| 606 | Lisp_Object |
| 607 | do_switch_frame (frame, track, for_deletion) |
| 608 | Lisp_Object frame; |
| 609 | int track, for_deletion; |
| 610 | { |
| 611 | struct frame *sf = SELECTED_FRAME (); |
| 612 | |
| 613 | /* If FRAME is a switch-frame event, extract the frame we should |
| 614 | switch to. */ |
| 615 | if (CONSP (frame) |
| 616 | && EQ (XCAR (frame), Qswitch_frame) |
| 617 | && CONSP (XCDR (frame))) |
| 618 | frame = XCAR (XCDR (frame)); |
| 619 | |
| 620 | /* This used to say CHECK_LIVE_FRAME, but apparently it's possible for |
| 621 | a switch-frame event to arrive after a frame is no longer live, |
| 622 | especially when deleting the initial frame during startup. */ |
| 623 | CHECK_FRAME (frame); |
| 624 | if (! FRAME_LIVE_P (XFRAME (frame))) |
| 625 | return Qnil; |
| 626 | |
| 627 | if (sf == XFRAME (frame)) |
| 628 | return frame; |
| 629 | |
| 630 | /* This is too greedy; it causes inappropriate focus redirection |
| 631 | that's hard to get rid of. */ |
| 632 | #if 0 |
| 633 | /* If a frame's focus has been redirected toward the currently |
| 634 | selected frame, we should change the redirection to point to the |
| 635 | newly selected frame. This means that if the focus is redirected |
| 636 | from a minibufferless frame to a surrogate minibuffer frame, we |
| 637 | can use `other-window' to switch between all the frames using |
| 638 | that minibuffer frame, and the focus redirection will follow us |
| 639 | around. */ |
| 640 | if (track) |
| 641 | { |
| 642 | Lisp_Object tail; |
| 643 | |
| 644 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) |
| 645 | { |
| 646 | Lisp_Object focus; |
| 647 | |
| 648 | if (!FRAMEP (XCAR (tail))) |
| 649 | abort (); |
| 650 | |
| 651 | focus = FRAME_FOCUS_FRAME (XFRAME (XCAR (tail))); |
| 652 | |
| 653 | if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ()) |
| 654 | Fredirect_frame_focus (XCAR (tail), frame); |
| 655 | } |
| 656 | } |
| 657 | #else /* ! 0 */ |
| 658 | /* Instead, apply it only to the frame we're pointing to. */ |
| 659 | #ifdef HAVE_WINDOW_SYSTEM |
| 660 | if (track && FRAME_WINDOW_P (XFRAME (frame))) |
| 661 | { |
| 662 | Lisp_Object focus, xfocus; |
| 663 | |
| 664 | xfocus = x_get_focus_frame (XFRAME (frame)); |
| 665 | if (FRAMEP (xfocus)) |
| 666 | { |
| 667 | focus = FRAME_FOCUS_FRAME (XFRAME (xfocus)); |
| 668 | if (FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ()) |
| 669 | Fredirect_frame_focus (xfocus, frame); |
| 670 | } |
| 671 | } |
| 672 | #endif /* HAVE_X_WINDOWS */ |
| 673 | #endif /* ! 0 */ |
| 674 | |
| 675 | if (!for_deletion && FRAME_HAS_MINIBUF_P (sf)) |
| 676 | resize_mini_window (XWINDOW (FRAME_MINIBUF_WINDOW (sf)), 1); |
| 677 | |
| 678 | selected_frame = frame; |
| 679 | if (! FRAME_MINIBUF_ONLY_P (XFRAME (selected_frame))) |
| 680 | last_nonminibuf_frame = XFRAME (selected_frame); |
| 681 | |
| 682 | Fselect_window (XFRAME (frame)->selected_window); |
| 683 | |
| 684 | #ifndef WINDOWSNT |
| 685 | /* Make sure to switch the tty color mode to that of the newly |
| 686 | selected frame. */ |
| 687 | sf = SELECTED_FRAME (); |
| 688 | if (FRAME_TERMCAP_P (sf)) |
| 689 | { |
| 690 | Lisp_Object color_mode_spec, color_mode; |
| 691 | |
| 692 | color_mode_spec = assq_no_quit (Qtty_color_mode, sf->param_alist); |
| 693 | if (CONSP (color_mode_spec)) |
| 694 | color_mode = XCDR (color_mode_spec); |
| 695 | else |
| 696 | color_mode = make_number (0); |
| 697 | set_tty_color_mode (sf, color_mode); |
| 698 | } |
| 699 | #endif /* !WINDOWSNT */ |
| 700 | |
| 701 | /* We want to make sure that the next event generates a frame-switch |
| 702 | event to the appropriate frame. This seems kludgy to me, but |
| 703 | before you take it out, make sure that evaluating something like |
| 704 | (select-window (frame-root-window (new-frame))) doesn't end up |
| 705 | with your typing being interpreted in the new frame instead of |
| 706 | the one you're actually typing in. */ |
| 707 | internal_last_event_frame = Qnil; |
| 708 | |
| 709 | return frame; |
| 710 | } |
| 711 | |
| 712 | DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e", |
| 713 | doc: /* Select the frame FRAME. |
| 714 | Subsequent editing commands apply to its selected window. |
| 715 | The selection of FRAME lasts until the next time the user does |
| 716 | something to select a different frame, or until the next time this |
| 717 | function is called. */) |
| 718 | (frame, no_enter) |
| 719 | Lisp_Object frame, no_enter; |
| 720 | { |
| 721 | return do_switch_frame (frame, 1, 0); |
| 722 | } |
| 723 | |
| 724 | |
| 725 | DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 2, "e", |
| 726 | doc: /* Handle a switch-frame event EVENT. |
| 727 | Switch-frame events are usually bound to this function. |
| 728 | A switch-frame event tells Emacs that the window manager has requested |
| 729 | that the user's events be directed to the frame mentioned in the event. |
| 730 | This function selects the selected window of the frame of EVENT. |
| 731 | |
| 732 | If EVENT is frame object, handle it as if it were a switch-frame event |
| 733 | to that frame. */) |
| 734 | (event, no_enter) |
| 735 | Lisp_Object event, no_enter; |
| 736 | { |
| 737 | /* Preserve prefix arg that the command loop just cleared. */ |
| 738 | current_kboard->Vprefix_arg = Vcurrent_prefix_arg; |
| 739 | call1 (Vrun_hooks, Qmouse_leave_buffer_hook); |
| 740 | return do_switch_frame (event, 0, 0); |
| 741 | } |
| 742 | |
| 743 | DEFUN ("ignore-event", Fignore_event, Signore_event, 0, 0, "", |
| 744 | doc: /* Do nothing, but preserve any prefix argument already specified. |
| 745 | This is a suitable binding for iconify-frame and make-frame-visible. */) |
| 746 | () |
| 747 | { |
| 748 | current_kboard->Vprefix_arg = Vcurrent_prefix_arg; |
| 749 | return Qnil; |
| 750 | } |
| 751 | |
| 752 | DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, |
| 753 | doc: /* Return the frame that is now selected. */) |
| 754 | () |
| 755 | { |
| 756 | return selected_frame; |
| 757 | } |
| 758 | \f |
| 759 | DEFUN ("window-frame", Fwindow_frame, Swindow_frame, 1, 1, 0, |
| 760 | doc: /* Return the frame object that window WINDOW is on. */) |
| 761 | (window) |
| 762 | Lisp_Object window; |
| 763 | { |
| 764 | CHECK_LIVE_WINDOW (window); |
| 765 | return XWINDOW (window)->frame; |
| 766 | } |
| 767 | |
| 768 | DEFUN ("frame-first-window", Fframe_first_window, Sframe_first_window, 0, 1, 0, |
| 769 | doc: /* Returns the topmost, leftmost window of FRAME. |
| 770 | If omitted, FRAME defaults to the currently selected frame. */) |
| 771 | (frame) |
| 772 | Lisp_Object frame; |
| 773 | { |
| 774 | Lisp_Object w; |
| 775 | |
| 776 | if (NILP (frame)) |
| 777 | w = SELECTED_FRAME ()->root_window; |
| 778 | else |
| 779 | { |
| 780 | CHECK_LIVE_FRAME (frame); |
| 781 | w = XFRAME (frame)->root_window; |
| 782 | } |
| 783 | while (NILP (XWINDOW (w)->buffer)) |
| 784 | { |
| 785 | if (! NILP (XWINDOW (w)->hchild)) |
| 786 | w = XWINDOW (w)->hchild; |
| 787 | else if (! NILP (XWINDOW (w)->vchild)) |
| 788 | w = XWINDOW (w)->vchild; |
| 789 | else |
| 790 | abort (); |
| 791 | } |
| 792 | return w; |
| 793 | } |
| 794 | |
| 795 | DEFUN ("active-minibuffer-window", Factive_minibuffer_window, |
| 796 | Sactive_minibuffer_window, 0, 0, 0, |
| 797 | doc: /* Return the currently active minibuffer window, or nil if none. */) |
| 798 | () |
| 799 | { |
| 800 | return minibuf_level ? minibuf_window : Qnil; |
| 801 | } |
| 802 | |
| 803 | DEFUN ("frame-root-window", Fframe_root_window, Sframe_root_window, 0, 1, 0, |
| 804 | doc: /* Returns the root-window of FRAME. |
| 805 | If omitted, FRAME defaults to the currently selected frame. */) |
| 806 | (frame) |
| 807 | Lisp_Object frame; |
| 808 | { |
| 809 | Lisp_Object window; |
| 810 | |
| 811 | if (NILP (frame)) |
| 812 | window = SELECTED_FRAME ()->root_window; |
| 813 | else |
| 814 | { |
| 815 | CHECK_LIVE_FRAME (frame); |
| 816 | window = XFRAME (frame)->root_window; |
| 817 | } |
| 818 | |
| 819 | return window; |
| 820 | } |
| 821 | |
| 822 | DEFUN ("frame-selected-window", Fframe_selected_window, |
| 823 | Sframe_selected_window, 0, 1, 0, |
| 824 | doc: /* Return the selected window of frame object FRAME. |
| 825 | If omitted, FRAME defaults to the currently selected frame. */) |
| 826 | (frame) |
| 827 | Lisp_Object frame; |
| 828 | { |
| 829 | Lisp_Object window; |
| 830 | |
| 831 | if (NILP (frame)) |
| 832 | window = SELECTED_FRAME ()->selected_window; |
| 833 | else |
| 834 | { |
| 835 | CHECK_LIVE_FRAME (frame); |
| 836 | window = XFRAME (frame)->selected_window; |
| 837 | } |
| 838 | |
| 839 | return window; |
| 840 | } |
| 841 | |
| 842 | DEFUN ("set-frame-selected-window", Fset_frame_selected_window, |
| 843 | Sset_frame_selected_window, 2, 2, 0, |
| 844 | doc: /* Set the selected window of frame object FRAME to WINDOW. |
| 845 | If FRAME is nil, the selected frame is used. |
| 846 | If FRAME is the selected frame, this makes WINDOW the selected window. */) |
| 847 | (frame, window) |
| 848 | Lisp_Object frame, window; |
| 849 | { |
| 850 | if (NILP (frame)) |
| 851 | frame = selected_frame; |
| 852 | |
| 853 | CHECK_LIVE_FRAME (frame); |
| 854 | CHECK_LIVE_WINDOW (window); |
| 855 | |
| 856 | if (! EQ (frame, WINDOW_FRAME (XWINDOW (window)))) |
| 857 | error ("In `set-frame-selected-window', WINDOW is not on FRAME"); |
| 858 | |
| 859 | if (EQ (frame, selected_frame)) |
| 860 | return Fselect_window (window); |
| 861 | |
| 862 | return XFRAME (frame)->selected_window = window; |
| 863 | } |
| 864 | \f |
| 865 | DEFUN ("frame-list", Fframe_list, Sframe_list, |
| 866 | 0, 0, 0, |
| 867 | doc: /* Return a list of all frames. */) |
| 868 | () |
| 869 | { |
| 870 | Lisp_Object frames; |
| 871 | frames = Fcopy_sequence (Vframe_list); |
| 872 | #ifdef HAVE_WINDOW_SYSTEM |
| 873 | if (FRAMEP (tip_frame)) |
| 874 | frames = Fdelq (tip_frame, frames); |
| 875 | #endif |
| 876 | return frames; |
| 877 | } |
| 878 | |
| 879 | /* Return the next frame in the frame list after FRAME. |
| 880 | If MINIBUF is nil, exclude minibuffer-only frames. |
| 881 | If MINIBUF is a window, include only its own frame |
| 882 | and any frame now using that window as the minibuffer. |
| 883 | If MINIBUF is `visible', include all visible frames. |
| 884 | If MINIBUF is 0, include all visible and iconified frames. |
| 885 | Otherwise, include all frames. */ |
| 886 | |
| 887 | Lisp_Object |
| 888 | next_frame (frame, minibuf) |
| 889 | Lisp_Object frame; |
| 890 | Lisp_Object minibuf; |
| 891 | { |
| 892 | Lisp_Object tail; |
| 893 | int passed = 0; |
| 894 | |
| 895 | /* There must always be at least one frame in Vframe_list. */ |
| 896 | if (! CONSP (Vframe_list)) |
| 897 | abort (); |
| 898 | |
| 899 | /* If this frame is dead, it won't be in Vframe_list, and we'll loop |
| 900 | forever. Forestall that. */ |
| 901 | CHECK_LIVE_FRAME (frame); |
| 902 | |
| 903 | while (1) |
| 904 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) |
| 905 | { |
| 906 | Lisp_Object f; |
| 907 | |
| 908 | f = XCAR (tail); |
| 909 | |
| 910 | if (passed |
| 911 | && FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) |
| 912 | { |
| 913 | /* Decide whether this frame is eligible to be returned. */ |
| 914 | |
| 915 | /* If we've looped all the way around without finding any |
| 916 | eligible frames, return the original frame. */ |
| 917 | if (EQ (f, frame)) |
| 918 | return f; |
| 919 | |
| 920 | /* Let minibuf decide if this frame is acceptable. */ |
| 921 | if (NILP (minibuf)) |
| 922 | { |
| 923 | if (! FRAME_MINIBUF_ONLY_P (XFRAME (f))) |
| 924 | return f; |
| 925 | } |
| 926 | else if (EQ (minibuf, Qvisible)) |
| 927 | { |
| 928 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); |
| 929 | if (FRAME_VISIBLE_P (XFRAME (f))) |
| 930 | return f; |
| 931 | } |
| 932 | else if (INTEGERP (minibuf) && XINT (minibuf) == 0) |
| 933 | { |
| 934 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); |
| 935 | if (FRAME_VISIBLE_P (XFRAME (f)) |
| 936 | || FRAME_ICONIFIED_P (XFRAME (f))) |
| 937 | return f; |
| 938 | } |
| 939 | else if (WINDOWP (minibuf)) |
| 940 | { |
| 941 | if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf) |
| 942 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f) |
| 943 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), |
| 944 | FRAME_FOCUS_FRAME (XFRAME (f)))) |
| 945 | return f; |
| 946 | } |
| 947 | else |
| 948 | return f; |
| 949 | } |
| 950 | |
| 951 | if (EQ (frame, f)) |
| 952 | passed++; |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | /* Return the previous frame in the frame list before FRAME. |
| 957 | If MINIBUF is nil, exclude minibuffer-only frames. |
| 958 | If MINIBUF is a window, include only its own frame |
| 959 | and any frame now using that window as the minibuffer. |
| 960 | If MINIBUF is `visible', include all visible frames. |
| 961 | If MINIBUF is 0, include all visible and iconified frames. |
| 962 | Otherwise, include all frames. */ |
| 963 | |
| 964 | Lisp_Object |
| 965 | prev_frame (frame, minibuf) |
| 966 | Lisp_Object frame; |
| 967 | Lisp_Object minibuf; |
| 968 | { |
| 969 | Lisp_Object tail; |
| 970 | Lisp_Object prev; |
| 971 | |
| 972 | /* There must always be at least one frame in Vframe_list. */ |
| 973 | if (! CONSP (Vframe_list)) |
| 974 | abort (); |
| 975 | |
| 976 | prev = Qnil; |
| 977 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) |
| 978 | { |
| 979 | Lisp_Object f; |
| 980 | |
| 981 | f = XCAR (tail); |
| 982 | if (!FRAMEP (f)) |
| 983 | abort (); |
| 984 | |
| 985 | if (EQ (frame, f) && !NILP (prev)) |
| 986 | return prev; |
| 987 | |
| 988 | if (FRAME_KBOARD (XFRAME (f)) == FRAME_KBOARD (XFRAME (frame))) |
| 989 | { |
| 990 | /* Decide whether this frame is eligible to be returned, |
| 991 | according to minibuf. */ |
| 992 | if (NILP (minibuf)) |
| 993 | { |
| 994 | if (! FRAME_MINIBUF_ONLY_P (XFRAME (f))) |
| 995 | prev = f; |
| 996 | } |
| 997 | else if (WINDOWP (minibuf)) |
| 998 | { |
| 999 | if (EQ (FRAME_MINIBUF_WINDOW (XFRAME (f)), minibuf) |
| 1000 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), f) |
| 1001 | || EQ (WINDOW_FRAME (XWINDOW (minibuf)), |
| 1002 | FRAME_FOCUS_FRAME (XFRAME (f)))) |
| 1003 | prev = f; |
| 1004 | } |
| 1005 | else if (EQ (minibuf, Qvisible)) |
| 1006 | { |
| 1007 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); |
| 1008 | if (FRAME_VISIBLE_P (XFRAME (f))) |
| 1009 | prev = f; |
| 1010 | } |
| 1011 | else if (XFASTINT (minibuf) == 0) |
| 1012 | { |
| 1013 | FRAME_SAMPLE_VISIBILITY (XFRAME (f)); |
| 1014 | if (FRAME_VISIBLE_P (XFRAME (f)) |
| 1015 | || FRAME_ICONIFIED_P (XFRAME (f))) |
| 1016 | prev = f; |
| 1017 | } |
| 1018 | else |
| 1019 | prev = f; |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | /* We've scanned the entire list. */ |
| 1024 | if (NILP (prev)) |
| 1025 | /* We went through the whole frame list without finding a single |
| 1026 | acceptable frame. Return the original frame. */ |
| 1027 | return frame; |
| 1028 | else |
| 1029 | /* There were no acceptable frames in the list before FRAME; otherwise, |
| 1030 | we would have returned directly from the loop. Since PREV is the last |
| 1031 | acceptable frame in the list, return it. */ |
| 1032 | return prev; |
| 1033 | } |
| 1034 | |
| 1035 | |
| 1036 | DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0, |
| 1037 | doc: /* Return the next frame in the frame list after FRAME. |
| 1038 | It considers only frames on the same terminal as FRAME. |
| 1039 | By default, skip minibuffer-only frames. |
| 1040 | If omitted, FRAME defaults to the selected frame. |
| 1041 | If optional argument MINIFRAME is nil, exclude minibuffer-only frames. |
| 1042 | If MINIFRAME is a window, include only its own frame |
| 1043 | and any frame now using that window as the minibuffer. |
| 1044 | If MINIFRAME is `visible', include all visible frames. |
| 1045 | If MINIFRAME is 0, include all visible and iconified frames. |
| 1046 | Otherwise, include all frames. */) |
| 1047 | (frame, miniframe) |
| 1048 | Lisp_Object frame, miniframe; |
| 1049 | { |
| 1050 | if (NILP (frame)) |
| 1051 | frame = selected_frame; |
| 1052 | |
| 1053 | CHECK_LIVE_FRAME (frame); |
| 1054 | return next_frame (frame, miniframe); |
| 1055 | } |
| 1056 | |
| 1057 | DEFUN ("previous-frame", Fprevious_frame, Sprevious_frame, 0, 2, 0, |
| 1058 | doc: /* Return the previous frame in the frame list before FRAME. |
| 1059 | It considers only frames on the same terminal as FRAME. |
| 1060 | By default, skip minibuffer-only frames. |
| 1061 | If omitted, FRAME defaults to the selected frame. |
| 1062 | If optional argument MINIFRAME is nil, exclude minibuffer-only frames. |
| 1063 | If MINIFRAME is a window, include only its own frame |
| 1064 | and any frame now using that window as the minibuffer. |
| 1065 | If MINIFRAME is `visible', include all visible frames. |
| 1066 | If MINIFRAME is 0, include all visible and iconified frames. |
| 1067 | Otherwise, include all frames. */) |
| 1068 | (frame, miniframe) |
| 1069 | Lisp_Object frame, miniframe; |
| 1070 | { |
| 1071 | if (NILP (frame)) |
| 1072 | frame = selected_frame; |
| 1073 | CHECK_LIVE_FRAME (frame); |
| 1074 | return prev_frame (frame, miniframe); |
| 1075 | } |
| 1076 | \f |
| 1077 | /* Return 1 if it is ok to delete frame F; |
| 1078 | 0 if all frames aside from F are invisible. |
| 1079 | (Exception: if F is the terminal frame, and we are using X, return 1.) */ |
| 1080 | |
| 1081 | int |
| 1082 | other_visible_frames (f) |
| 1083 | FRAME_PTR f; |
| 1084 | { |
| 1085 | /* We know the selected frame is visible, |
| 1086 | so if F is some other frame, it can't be the sole visible one. */ |
| 1087 | if (f == SELECTED_FRAME ()) |
| 1088 | { |
| 1089 | Lisp_Object frames; |
| 1090 | int count = 0; |
| 1091 | |
| 1092 | for (frames = Vframe_list; |
| 1093 | CONSP (frames); |
| 1094 | frames = XCDR (frames)) |
| 1095 | { |
| 1096 | Lisp_Object this; |
| 1097 | |
| 1098 | this = XCAR (frames); |
| 1099 | /* Verify that the frame's window still exists |
| 1100 | and we can still talk to it. And note any recent change |
| 1101 | in visibility. */ |
| 1102 | #ifdef HAVE_WINDOW_SYSTEM |
| 1103 | if (FRAME_WINDOW_P (XFRAME (this))) |
| 1104 | { |
| 1105 | x_sync (XFRAME (this)); |
| 1106 | FRAME_SAMPLE_VISIBILITY (XFRAME (this)); |
| 1107 | } |
| 1108 | #endif |
| 1109 | |
| 1110 | if (FRAME_VISIBLE_P (XFRAME (this)) |
| 1111 | || FRAME_ICONIFIED_P (XFRAME (this)) |
| 1112 | /* Allow deleting the terminal frame when at least |
| 1113 | one X frame exists! */ |
| 1114 | || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f))) |
| 1115 | count++; |
| 1116 | } |
| 1117 | return count > 1; |
| 1118 | } |
| 1119 | return 1; |
| 1120 | } |
| 1121 | |
| 1122 | DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0, 2, "", |
| 1123 | doc: /* Delete FRAME, permanently eliminating it from use. |
| 1124 | If omitted, FRAME defaults to the selected frame. |
| 1125 | A frame may not be deleted if its minibuffer is used by other frames. |
| 1126 | Normally, you may not delete a frame if all other frames are invisible, |
| 1127 | but if the second optional argument FORCE is non-nil, you may do so. |
| 1128 | |
| 1129 | This function runs `delete-frame-functions' before actually deleting the |
| 1130 | frame, unless the frame is a tooltip. |
| 1131 | The functions are run with one arg, the frame to be deleted. */) |
| 1132 | (frame, force) |
| 1133 | Lisp_Object frame, force; |
| 1134 | { |
| 1135 | struct frame *f; |
| 1136 | struct frame *sf = SELECTED_FRAME (); |
| 1137 | int minibuffer_selected; |
| 1138 | |
| 1139 | if (EQ (frame, Qnil)) |
| 1140 | { |
| 1141 | f = sf; |
| 1142 | XSETFRAME (frame, f); |
| 1143 | } |
| 1144 | else |
| 1145 | { |
| 1146 | CHECK_FRAME (frame); |
| 1147 | f = XFRAME (frame); |
| 1148 | } |
| 1149 | |
| 1150 | if (! FRAME_LIVE_P (f)) |
| 1151 | return Qnil; |
| 1152 | |
| 1153 | if (NILP (force) && !other_visible_frames (f) |
| 1154 | #ifdef MAC_OS8 |
| 1155 | /* Terminal frame deleted before any other visible frames are |
| 1156 | created. */ |
| 1157 | && strcmp (SDATA (f->name), "F1") != 0 |
| 1158 | #endif |
| 1159 | ) |
| 1160 | error ("Attempt to delete the sole visible or iconified frame"); |
| 1161 | |
| 1162 | #if 0 |
| 1163 | /* This is a nice idea, but x_connection_closed needs to be able |
| 1164 | to delete the last frame, if it is gone. */ |
| 1165 | if (NILP (XCDR (Vframe_list))) |
| 1166 | error ("Attempt to delete the only frame"); |
| 1167 | #endif |
| 1168 | |
| 1169 | /* Does this frame have a minibuffer, and is it the surrogate |
| 1170 | minibuffer for any other frame? */ |
| 1171 | if (FRAME_HAS_MINIBUF_P (XFRAME (frame))) |
| 1172 | { |
| 1173 | Lisp_Object frames; |
| 1174 | |
| 1175 | for (frames = Vframe_list; |
| 1176 | CONSP (frames); |
| 1177 | frames = XCDR (frames)) |
| 1178 | { |
| 1179 | Lisp_Object this; |
| 1180 | this = XCAR (frames); |
| 1181 | |
| 1182 | if (! EQ (this, frame) |
| 1183 | && EQ (frame, |
| 1184 | WINDOW_FRAME (XWINDOW |
| 1185 | (FRAME_MINIBUF_WINDOW (XFRAME (this)))))) |
| 1186 | error ("Attempt to delete a surrogate minibuffer frame"); |
| 1187 | } |
| 1188 | } |
| 1189 | |
| 1190 | /* Run `delete-frame-functions' unless frame is a tooltip. */ |
| 1191 | if (!NILP (Vrun_hooks) |
| 1192 | && NILP (Fframe_parameter (frame, intern ("tooltip")))) |
| 1193 | { |
| 1194 | Lisp_Object args[2]; |
| 1195 | args[0] = intern ("delete-frame-functions"); |
| 1196 | args[1] = frame; |
| 1197 | Frun_hook_with_args (2, args); |
| 1198 | } |
| 1199 | |
| 1200 | minibuffer_selected = EQ (minibuf_window, selected_window); |
| 1201 | |
| 1202 | /* Don't let the frame remain selected. */ |
| 1203 | if (f == sf) |
| 1204 | { |
| 1205 | Lisp_Object tail, frame1; |
| 1206 | |
| 1207 | /* Look for another visible frame on the same terminal. */ |
| 1208 | frame1 = next_frame (frame, Qvisible); |
| 1209 | |
| 1210 | /* If there is none, find *some* other frame. */ |
| 1211 | if (NILP (frame1) || EQ (frame1, frame)) |
| 1212 | { |
| 1213 | FOR_EACH_FRAME (tail, frame1) |
| 1214 | { |
| 1215 | if (! EQ (frame, frame1)) |
| 1216 | break; |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | do_switch_frame (frame1, 0, 1); |
| 1221 | sf = SELECTED_FRAME (); |
| 1222 | } |
| 1223 | |
| 1224 | /* Don't allow minibuf_window to remain on a deleted frame. */ |
| 1225 | if (EQ (f->minibuffer_window, minibuf_window)) |
| 1226 | { |
| 1227 | Fset_window_buffer (sf->minibuffer_window, |
| 1228 | XWINDOW (minibuf_window)->buffer); |
| 1229 | minibuf_window = sf->minibuffer_window; |
| 1230 | |
| 1231 | /* If the dying minibuffer window was selected, |
| 1232 | select the new one. */ |
| 1233 | if (minibuffer_selected) |
| 1234 | Fselect_window (minibuf_window); |
| 1235 | } |
| 1236 | |
| 1237 | /* Don't let echo_area_window to remain on a deleted frame. */ |
| 1238 | if (EQ (f->minibuffer_window, echo_area_window)) |
| 1239 | echo_area_window = sf->minibuffer_window; |
| 1240 | |
| 1241 | /* Clear any X selections for this frame. */ |
| 1242 | #ifdef HAVE_X_WINDOWS |
| 1243 | if (FRAME_X_P (f)) |
| 1244 | x_clear_frame_selections (f); |
| 1245 | #endif |
| 1246 | |
| 1247 | /* Free glyphs. |
| 1248 | This function must be called before the window tree of the |
| 1249 | frame is deleted because windows contain dynamically allocated |
| 1250 | memory. */ |
| 1251 | free_glyphs (f); |
| 1252 | |
| 1253 | /* Mark all the windows that used to be on FRAME as deleted, and then |
| 1254 | remove the reference to them. */ |
| 1255 | delete_all_subwindows (XWINDOW (f->root_window)); |
| 1256 | f->root_window = Qnil; |
| 1257 | |
| 1258 | Vframe_list = Fdelq (frame, Vframe_list); |
| 1259 | FRAME_SET_VISIBLE (f, 0); |
| 1260 | |
| 1261 | if (f->namebuf) |
| 1262 | xfree (f->namebuf); |
| 1263 | if (FRAME_INSERT_COST (f)) |
| 1264 | xfree (FRAME_INSERT_COST (f)); |
| 1265 | if (FRAME_DELETEN_COST (f)) |
| 1266 | xfree (FRAME_DELETEN_COST (f)); |
| 1267 | if (FRAME_INSERTN_COST (f)) |
| 1268 | xfree (FRAME_INSERTN_COST (f)); |
| 1269 | if (FRAME_DELETE_COST (f)) |
| 1270 | xfree (FRAME_DELETE_COST (f)); |
| 1271 | if (FRAME_MESSAGE_BUF (f)) |
| 1272 | xfree (FRAME_MESSAGE_BUF (f)); |
| 1273 | |
| 1274 | /* Since some events are handled at the interrupt level, we may get |
| 1275 | an event for f at any time; if we zero out the frame's display |
| 1276 | now, then we may trip up the event-handling code. Instead, we'll |
| 1277 | promise that the display of the frame must be valid until we have |
| 1278 | called the window-system-dependent frame destruction routine. */ |
| 1279 | |
| 1280 | /* I think this should be done with a hook. */ |
| 1281 | #ifdef HAVE_WINDOW_SYSTEM |
| 1282 | if (FRAME_WINDOW_P (f)) |
| 1283 | x_destroy_window (f); |
| 1284 | #endif |
| 1285 | |
| 1286 | f->output_data.nothing = 0; |
| 1287 | |
| 1288 | /* If we've deleted the last_nonminibuf_frame, then try to find |
| 1289 | another one. */ |
| 1290 | if (f == last_nonminibuf_frame) |
| 1291 | { |
| 1292 | Lisp_Object frames; |
| 1293 | |
| 1294 | last_nonminibuf_frame = 0; |
| 1295 | |
| 1296 | for (frames = Vframe_list; |
| 1297 | CONSP (frames); |
| 1298 | frames = XCDR (frames)) |
| 1299 | { |
| 1300 | f = XFRAME (XCAR (frames)); |
| 1301 | if (!FRAME_MINIBUF_ONLY_P (f)) |
| 1302 | { |
| 1303 | last_nonminibuf_frame = f; |
| 1304 | break; |
| 1305 | } |
| 1306 | } |
| 1307 | } |
| 1308 | |
| 1309 | /* If we've deleted this keyboard's default_minibuffer_frame, try to |
| 1310 | find another one. Prefer minibuffer-only frames, but also notice |
| 1311 | frames with other windows. */ |
| 1312 | if (EQ (frame, FRAME_KBOARD (f)->Vdefault_minibuffer_frame)) |
| 1313 | { |
| 1314 | Lisp_Object frames; |
| 1315 | |
| 1316 | /* The last frame we saw with a minibuffer, minibuffer-only or not. */ |
| 1317 | Lisp_Object frame_with_minibuf; |
| 1318 | /* Some frame we found on the same kboard, or nil if there are none. */ |
| 1319 | Lisp_Object frame_on_same_kboard; |
| 1320 | |
| 1321 | frame_on_same_kboard = Qnil; |
| 1322 | frame_with_minibuf = Qnil; |
| 1323 | |
| 1324 | for (frames = Vframe_list; |
| 1325 | CONSP (frames); |
| 1326 | frames = XCDR (frames)) |
| 1327 | { |
| 1328 | Lisp_Object this; |
| 1329 | struct frame *f1; |
| 1330 | |
| 1331 | this = XCAR (frames); |
| 1332 | if (!FRAMEP (this)) |
| 1333 | abort (); |
| 1334 | f1 = XFRAME (this); |
| 1335 | |
| 1336 | /* Consider only frames on the same kboard |
| 1337 | and only those with minibuffers. */ |
| 1338 | if (FRAME_KBOARD (f) == FRAME_KBOARD (f1) |
| 1339 | && FRAME_HAS_MINIBUF_P (f1)) |
| 1340 | { |
| 1341 | frame_with_minibuf = this; |
| 1342 | if (FRAME_MINIBUF_ONLY_P (f1)) |
| 1343 | break; |
| 1344 | } |
| 1345 | |
| 1346 | if (FRAME_KBOARD (f) == FRAME_KBOARD (f1)) |
| 1347 | frame_on_same_kboard = this; |
| 1348 | } |
| 1349 | |
| 1350 | if (!NILP (frame_on_same_kboard)) |
| 1351 | { |
| 1352 | /* We know that there must be some frame with a minibuffer out |
| 1353 | there. If this were not true, all of the frames present |
| 1354 | would have to be minibufferless, which implies that at some |
| 1355 | point their minibuffer frames must have been deleted, but |
| 1356 | that is prohibited at the top; you can't delete surrogate |
| 1357 | minibuffer frames. */ |
| 1358 | if (NILP (frame_with_minibuf)) |
| 1359 | abort (); |
| 1360 | |
| 1361 | FRAME_KBOARD (f)->Vdefault_minibuffer_frame = frame_with_minibuf; |
| 1362 | } |
| 1363 | else |
| 1364 | /* No frames left on this kboard--say no minibuffer either. */ |
| 1365 | FRAME_KBOARD (f)->Vdefault_minibuffer_frame = Qnil; |
| 1366 | } |
| 1367 | |
| 1368 | /* Cause frame titles to update--necessary if we now have just one frame. */ |
| 1369 | update_mode_lines = 1; |
| 1370 | |
| 1371 | return Qnil; |
| 1372 | } |
| 1373 | \f |
| 1374 | /* Return mouse position in character cell units. */ |
| 1375 | |
| 1376 | DEFUN ("mouse-position", Fmouse_position, Smouse_position, 0, 0, 0, |
| 1377 | doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. |
| 1378 | The position is given in character cells, where (0, 0) is the |
| 1379 | upper-left corner. |
| 1380 | If Emacs is running on a mouseless terminal or hasn't been programmed |
| 1381 | to read the mouse position, it returns the selected frame for FRAME |
| 1382 | and nil for X and Y. |
| 1383 | If `mouse-position-function' is non-nil, `mouse-position' calls it, |
| 1384 | passing the normal return value to that function as an argument, |
| 1385 | and returns whatever that function returns. */) |
| 1386 | () |
| 1387 | { |
| 1388 | FRAME_PTR f; |
| 1389 | Lisp_Object lispy_dummy; |
| 1390 | enum scroll_bar_part party_dummy; |
| 1391 | Lisp_Object x, y, retval; |
| 1392 | int col, row; |
| 1393 | unsigned long long_dummy; |
| 1394 | struct gcpro gcpro1; |
| 1395 | |
| 1396 | f = SELECTED_FRAME (); |
| 1397 | x = y = Qnil; |
| 1398 | |
| 1399 | #ifdef HAVE_MOUSE |
| 1400 | /* It's okay for the hook to refrain from storing anything. */ |
| 1401 | if (mouse_position_hook) |
| 1402 | (*mouse_position_hook) (&f, -1, |
| 1403 | &lispy_dummy, &party_dummy, |
| 1404 | &x, &y, |
| 1405 | &long_dummy); |
| 1406 | if (! NILP (x)) |
| 1407 | { |
| 1408 | col = XINT (x); |
| 1409 | row = XINT (y); |
| 1410 | pixel_to_glyph_coords (f, col, row, &col, &row, NULL, 1); |
| 1411 | XSETINT (x, col); |
| 1412 | XSETINT (y, row); |
| 1413 | } |
| 1414 | #endif |
| 1415 | XSETFRAME (lispy_dummy, f); |
| 1416 | retval = Fcons (lispy_dummy, Fcons (x, y)); |
| 1417 | GCPRO1 (retval); |
| 1418 | if (!NILP (Vmouse_position_function)) |
| 1419 | retval = call1 (Vmouse_position_function, retval); |
| 1420 | RETURN_UNGCPRO (retval); |
| 1421 | } |
| 1422 | |
| 1423 | DEFUN ("mouse-pixel-position", Fmouse_pixel_position, |
| 1424 | Smouse_pixel_position, 0, 0, 0, |
| 1425 | doc: /* Return a list (FRAME X . Y) giving the current mouse frame and position. |
| 1426 | The position is given in pixel units, where (0, 0) is the |
| 1427 | upper-left corner. |
| 1428 | If Emacs is running on a mouseless terminal or hasn't been programmed |
| 1429 | to read the mouse position, it returns the selected frame for FRAME |
| 1430 | and nil for X and Y. */) |
| 1431 | () |
| 1432 | { |
| 1433 | FRAME_PTR f; |
| 1434 | Lisp_Object lispy_dummy; |
| 1435 | enum scroll_bar_part party_dummy; |
| 1436 | Lisp_Object x, y; |
| 1437 | unsigned long long_dummy; |
| 1438 | |
| 1439 | f = SELECTED_FRAME (); |
| 1440 | x = y = Qnil; |
| 1441 | |
| 1442 | #ifdef HAVE_MOUSE |
| 1443 | /* It's okay for the hook to refrain from storing anything. */ |
| 1444 | if (mouse_position_hook) |
| 1445 | (*mouse_position_hook) (&f, -1, |
| 1446 | &lispy_dummy, &party_dummy, |
| 1447 | &x, &y, |
| 1448 | &long_dummy); |
| 1449 | #endif |
| 1450 | XSETFRAME (lispy_dummy, f); |
| 1451 | return Fcons (lispy_dummy, Fcons (x, y)); |
| 1452 | } |
| 1453 | |
| 1454 | DEFUN ("set-mouse-position", Fset_mouse_position, Sset_mouse_position, 3, 3, 0, |
| 1455 | doc: /* Move the mouse pointer to the center of character cell (X,Y) in FRAME. |
| 1456 | Coordinates are relative to the frame, not a window, |
| 1457 | so the coordinates of the top left character in the frame |
| 1458 | may be nonzero due to left-hand scroll bars or the menu bar. |
| 1459 | |
| 1460 | This function is a no-op for an X frame that is not visible. |
| 1461 | If you have just created a frame, you must wait for it to become visible |
| 1462 | before calling this function on it, like this. |
| 1463 | (while (not (frame-visible-p frame)) (sleep-for .5)) */) |
| 1464 | (frame, x, y) |
| 1465 | Lisp_Object frame, x, y; |
| 1466 | { |
| 1467 | CHECK_LIVE_FRAME (frame); |
| 1468 | CHECK_NUMBER (x); |
| 1469 | CHECK_NUMBER (y); |
| 1470 | |
| 1471 | /* I think this should be done with a hook. */ |
| 1472 | #ifdef HAVE_WINDOW_SYSTEM |
| 1473 | if (FRAME_WINDOW_P (XFRAME (frame))) |
| 1474 | /* Warping the mouse will cause enternotify and focus events. */ |
| 1475 | x_set_mouse_position (XFRAME (frame), XINT (x), XINT (y)); |
| 1476 | #else |
| 1477 | #if defined (MSDOS) && defined (HAVE_MOUSE) |
| 1478 | if (FRAME_MSDOS_P (XFRAME (frame))) |
| 1479 | { |
| 1480 | Fselect_frame (frame, Qnil); |
| 1481 | mouse_moveto (XINT (x), XINT (y)); |
| 1482 | } |
| 1483 | #endif |
| 1484 | #endif |
| 1485 | |
| 1486 | return Qnil; |
| 1487 | } |
| 1488 | |
| 1489 | DEFUN ("set-mouse-pixel-position", Fset_mouse_pixel_position, |
| 1490 | Sset_mouse_pixel_position, 3, 3, 0, |
| 1491 | doc: /* Move the mouse pointer to pixel position (X,Y) in FRAME. |
| 1492 | Note, this is a no-op for an X frame that is not visible. |
| 1493 | If you have just created a frame, you must wait for it to become visible |
| 1494 | before calling this function on it, like this. |
| 1495 | (while (not (frame-visible-p frame)) (sleep-for .5)) */) |
| 1496 | (frame, x, y) |
| 1497 | Lisp_Object frame, x, y; |
| 1498 | { |
| 1499 | CHECK_LIVE_FRAME (frame); |
| 1500 | CHECK_NUMBER (x); |
| 1501 | CHECK_NUMBER (y); |
| 1502 | |
| 1503 | /* I think this should be done with a hook. */ |
| 1504 | #ifdef HAVE_WINDOW_SYSTEM |
| 1505 | if (FRAME_WINDOW_P (XFRAME (frame))) |
| 1506 | /* Warping the mouse will cause enternotify and focus events. */ |
| 1507 | x_set_mouse_pixel_position (XFRAME (frame), XINT (x), XINT (y)); |
| 1508 | #else |
| 1509 | #if defined (MSDOS) && defined (HAVE_MOUSE) |
| 1510 | if (FRAME_MSDOS_P (XFRAME (frame))) |
| 1511 | { |
| 1512 | Fselect_frame (frame, Qnil); |
| 1513 | mouse_moveto (XINT (x), XINT (y)); |
| 1514 | } |
| 1515 | #endif |
| 1516 | #endif |
| 1517 | |
| 1518 | return Qnil; |
| 1519 | } |
| 1520 | \f |
| 1521 | static void make_frame_visible_1 P_ ((Lisp_Object)); |
| 1522 | |
| 1523 | DEFUN ("make-frame-visible", Fmake_frame_visible, Smake_frame_visible, |
| 1524 | 0, 1, "", |
| 1525 | doc: /* Make the frame FRAME visible (assuming it is an X window). |
| 1526 | If omitted, FRAME defaults to the currently selected frame. */) |
| 1527 | (frame) |
| 1528 | Lisp_Object frame; |
| 1529 | { |
| 1530 | if (NILP (frame)) |
| 1531 | frame = selected_frame; |
| 1532 | |
| 1533 | CHECK_LIVE_FRAME (frame); |
| 1534 | |
| 1535 | /* I think this should be done with a hook. */ |
| 1536 | #ifdef HAVE_WINDOW_SYSTEM |
| 1537 | if (FRAME_WINDOW_P (XFRAME (frame))) |
| 1538 | { |
| 1539 | FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); |
| 1540 | x_make_frame_visible (XFRAME (frame)); |
| 1541 | } |
| 1542 | #endif |
| 1543 | |
| 1544 | make_frame_visible_1 (XFRAME (frame)->root_window); |
| 1545 | |
| 1546 | /* Make menu bar update for the Buffers and Frames menus. */ |
| 1547 | windows_or_buffers_changed++; |
| 1548 | |
| 1549 | return frame; |
| 1550 | } |
| 1551 | |
| 1552 | /* Update the display_time slot of the buffers shown in WINDOW |
| 1553 | and all its descendents. */ |
| 1554 | |
| 1555 | static void |
| 1556 | make_frame_visible_1 (window) |
| 1557 | Lisp_Object window; |
| 1558 | { |
| 1559 | struct window *w; |
| 1560 | |
| 1561 | for (;!NILP (window); window = w->next) |
| 1562 | { |
| 1563 | w = XWINDOW (window); |
| 1564 | |
| 1565 | if (!NILP (w->buffer)) |
| 1566 | XBUFFER (w->buffer)->display_time = Fcurrent_time (); |
| 1567 | |
| 1568 | if (!NILP (w->vchild)) |
| 1569 | make_frame_visible_1 (w->vchild); |
| 1570 | if (!NILP (w->hchild)) |
| 1571 | make_frame_visible_1 (w->hchild); |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | DEFUN ("make-frame-invisible", Fmake_frame_invisible, Smake_frame_invisible, |
| 1576 | 0, 2, "", |
| 1577 | doc: /* Make the frame FRAME invisible (assuming it is an X window). |
| 1578 | If omitted, FRAME defaults to the currently selected frame. |
| 1579 | Normally you may not make FRAME invisible if all other frames are invisible, |
| 1580 | but if the second optional argument FORCE is non-nil, you may do so. */) |
| 1581 | (frame, force) |
| 1582 | Lisp_Object frame, force; |
| 1583 | { |
| 1584 | if (NILP (frame)) |
| 1585 | frame = selected_frame; |
| 1586 | |
| 1587 | CHECK_LIVE_FRAME (frame); |
| 1588 | |
| 1589 | if (NILP (force) && !other_visible_frames (XFRAME (frame))) |
| 1590 | error ("Attempt to make invisible the sole visible or iconified frame"); |
| 1591 | |
| 1592 | #if 0 /* This isn't logically necessary, and it can do GC. */ |
| 1593 | /* Don't let the frame remain selected. */ |
| 1594 | if (EQ (frame, selected_frame)) |
| 1595 | do_switch_frame (next_frame (frame, Qt), 0, 0) |
| 1596 | #endif |
| 1597 | |
| 1598 | /* Don't allow minibuf_window to remain on a deleted frame. */ |
| 1599 | if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) |
| 1600 | { |
| 1601 | struct frame *sf = XFRAME (selected_frame); |
| 1602 | Fset_window_buffer (sf->minibuffer_window, |
| 1603 | XWINDOW (minibuf_window)->buffer); |
| 1604 | minibuf_window = sf->minibuffer_window; |
| 1605 | } |
| 1606 | |
| 1607 | /* I think this should be done with a hook. */ |
| 1608 | #ifdef HAVE_WINDOW_SYSTEM |
| 1609 | if (FRAME_WINDOW_P (XFRAME (frame))) |
| 1610 | x_make_frame_invisible (XFRAME (frame)); |
| 1611 | #endif |
| 1612 | |
| 1613 | /* Make menu bar update for the Buffers and Frames menus. */ |
| 1614 | windows_or_buffers_changed++; |
| 1615 | |
| 1616 | return Qnil; |
| 1617 | } |
| 1618 | |
| 1619 | DEFUN ("iconify-frame", Ficonify_frame, Siconify_frame, |
| 1620 | 0, 1, "", |
| 1621 | doc: /* Make the frame FRAME into an icon. |
| 1622 | If omitted, FRAME defaults to the currently selected frame. */) |
| 1623 | (frame) |
| 1624 | Lisp_Object frame; |
| 1625 | { |
| 1626 | if (NILP (frame)) |
| 1627 | frame = selected_frame; |
| 1628 | |
| 1629 | CHECK_LIVE_FRAME (frame); |
| 1630 | |
| 1631 | #if 0 /* This isn't logically necessary, and it can do GC. */ |
| 1632 | /* Don't let the frame remain selected. */ |
| 1633 | if (EQ (frame, selected_frame)) |
| 1634 | Fhandle_switch_frame (next_frame (frame, Qt), Qnil); |
| 1635 | #endif |
| 1636 | |
| 1637 | /* Don't allow minibuf_window to remain on a deleted frame. */ |
| 1638 | if (EQ (XFRAME (frame)->minibuffer_window, minibuf_window)) |
| 1639 | { |
| 1640 | struct frame *sf = XFRAME (selected_frame); |
| 1641 | Fset_window_buffer (sf->minibuffer_window, |
| 1642 | XWINDOW (minibuf_window)->buffer); |
| 1643 | minibuf_window = sf->minibuffer_window; |
| 1644 | } |
| 1645 | |
| 1646 | /* I think this should be done with a hook. */ |
| 1647 | #ifdef HAVE_WINDOW_SYSTEM |
| 1648 | if (FRAME_WINDOW_P (XFRAME (frame))) |
| 1649 | x_iconify_frame (XFRAME (frame)); |
| 1650 | #endif |
| 1651 | |
| 1652 | /* Make menu bar update for the Buffers and Frames menus. */ |
| 1653 | windows_or_buffers_changed++; |
| 1654 | |
| 1655 | return Qnil; |
| 1656 | } |
| 1657 | |
| 1658 | DEFUN ("frame-visible-p", Fframe_visible_p, Sframe_visible_p, |
| 1659 | 1, 1, 0, |
| 1660 | doc: /* Return t if FRAME is now \"visible\" (actually in use for display). |
| 1661 | A frame that is not \"visible\" is not updated and, if it works through |
| 1662 | a window system, it may not show at all. |
| 1663 | Return the symbol `icon' if frame is visible only as an icon. */) |
| 1664 | (frame) |
| 1665 | Lisp_Object frame; |
| 1666 | { |
| 1667 | CHECK_LIVE_FRAME (frame); |
| 1668 | |
| 1669 | FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); |
| 1670 | |
| 1671 | if (FRAME_VISIBLE_P (XFRAME (frame))) |
| 1672 | return Qt; |
| 1673 | if (FRAME_ICONIFIED_P (XFRAME (frame))) |
| 1674 | return Qicon; |
| 1675 | return Qnil; |
| 1676 | } |
| 1677 | |
| 1678 | DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list, |
| 1679 | 0, 0, 0, |
| 1680 | doc: /* Return a list of all frames now \"visible\" (being updated). */) |
| 1681 | () |
| 1682 | { |
| 1683 | Lisp_Object tail, frame; |
| 1684 | struct frame *f; |
| 1685 | Lisp_Object value; |
| 1686 | |
| 1687 | value = Qnil; |
| 1688 | for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) |
| 1689 | { |
| 1690 | frame = XCAR (tail); |
| 1691 | if (!FRAMEP (frame)) |
| 1692 | continue; |
| 1693 | f = XFRAME (frame); |
| 1694 | if (FRAME_VISIBLE_P (f)) |
| 1695 | value = Fcons (frame, value); |
| 1696 | } |
| 1697 | return value; |
| 1698 | } |
| 1699 | |
| 1700 | |
| 1701 | DEFUN ("raise-frame", Fraise_frame, Sraise_frame, 0, 1, "", |
| 1702 | doc: /* Bring FRAME to the front, so it occludes any frames it overlaps. |
| 1703 | If FRAME is invisible, make it visible. |
| 1704 | If you don't specify a frame, the selected frame is used. |
| 1705 | If Emacs is displaying on an ordinary terminal or some other device which |
| 1706 | doesn't support multiple overlapping frames, this function does nothing. */) |
| 1707 | (frame) |
| 1708 | Lisp_Object frame; |
| 1709 | { |
| 1710 | if (NILP (frame)) |
| 1711 | frame = selected_frame; |
| 1712 | |
| 1713 | CHECK_LIVE_FRAME (frame); |
| 1714 | |
| 1715 | /* Do like the documentation says. */ |
| 1716 | Fmake_frame_visible (frame); |
| 1717 | |
| 1718 | if (frame_raise_lower_hook) |
| 1719 | (*frame_raise_lower_hook) (XFRAME (frame), 1); |
| 1720 | |
| 1721 | return Qnil; |
| 1722 | } |
| 1723 | |
| 1724 | /* Should we have a corresponding function called Flower_Power? */ |
| 1725 | DEFUN ("lower-frame", Flower_frame, Slower_frame, 0, 1, "", |
| 1726 | doc: /* Send FRAME to the back, so it is occluded by any frames that overlap it. |
| 1727 | If you don't specify a frame, the selected frame is used. |
| 1728 | If Emacs is displaying on an ordinary terminal or some other device which |
| 1729 | doesn't support multiple overlapping frames, this function does nothing. */) |
| 1730 | (frame) |
| 1731 | Lisp_Object frame; |
| 1732 | { |
| 1733 | if (NILP (frame)) |
| 1734 | frame = selected_frame; |
| 1735 | |
| 1736 | CHECK_LIVE_FRAME (frame); |
| 1737 | |
| 1738 | if (frame_raise_lower_hook) |
| 1739 | (*frame_raise_lower_hook) (XFRAME (frame), 0); |
| 1740 | |
| 1741 | return Qnil; |
| 1742 | } |
| 1743 | |
| 1744 | \f |
| 1745 | DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus, |
| 1746 | 1, 2, 0, |
| 1747 | doc: /* Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME. |
| 1748 | In other words, switch-frame events caused by events in FRAME will |
| 1749 | request a switch to FOCUS-FRAME, and `last-event-frame' will be |
| 1750 | FOCUS-FRAME after reading an event typed at FRAME. |
| 1751 | |
| 1752 | If FOCUS-FRAME is omitted or nil, any existing redirection is |
| 1753 | cancelled, and the frame again receives its own keystrokes. |
| 1754 | |
| 1755 | Focus redirection is useful for temporarily redirecting keystrokes to |
| 1756 | a surrogate minibuffer frame when a frame doesn't have its own |
| 1757 | minibuffer window. |
| 1758 | |
| 1759 | A frame's focus redirection can be changed by select-frame. If frame |
| 1760 | FOO is selected, and then a different frame BAR is selected, any |
| 1761 | frames redirecting their focus to FOO are shifted to redirect their |
| 1762 | focus to BAR. This allows focus redirection to work properly when the |
| 1763 | user switches from one frame to another using `select-window'. |
| 1764 | |
| 1765 | This means that a frame whose focus is redirected to itself is treated |
| 1766 | differently from a frame whose focus is redirected to nil; the former |
| 1767 | is affected by select-frame, while the latter is not. |
| 1768 | |
| 1769 | The redirection lasts until `redirect-frame-focus' is called to change it. */) |
| 1770 | (frame, focus_frame) |
| 1771 | Lisp_Object frame, focus_frame; |
| 1772 | { |
| 1773 | /* Note that we don't check for a live frame here. It's reasonable |
| 1774 | to redirect the focus of a frame you're about to delete, if you |
| 1775 | know what other frame should receive those keystrokes. */ |
| 1776 | CHECK_FRAME (frame); |
| 1777 | |
| 1778 | if (! NILP (focus_frame)) |
| 1779 | CHECK_LIVE_FRAME (focus_frame); |
| 1780 | |
| 1781 | XFRAME (frame)->focus_frame = focus_frame; |
| 1782 | |
| 1783 | if (frame_rehighlight_hook) |
| 1784 | (*frame_rehighlight_hook) (XFRAME (frame)); |
| 1785 | |
| 1786 | return Qnil; |
| 1787 | } |
| 1788 | |
| 1789 | |
| 1790 | DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, |
| 1791 | doc: /* Return the frame to which FRAME's keystrokes are currently being sent. |
| 1792 | This returns nil if FRAME's focus is not redirected. |
| 1793 | See `redirect-frame-focus'. */) |
| 1794 | (frame) |
| 1795 | Lisp_Object frame; |
| 1796 | { |
| 1797 | CHECK_LIVE_FRAME (frame); |
| 1798 | |
| 1799 | return FRAME_FOCUS_FRAME (XFRAME (frame)); |
| 1800 | } |
| 1801 | |
| 1802 | |
| 1803 | \f |
| 1804 | /* Return the value of frame parameter PROP in frame FRAME. */ |
| 1805 | |
| 1806 | Lisp_Object |
| 1807 | get_frame_param (frame, prop) |
| 1808 | register struct frame *frame; |
| 1809 | Lisp_Object prop; |
| 1810 | { |
| 1811 | register Lisp_Object tem; |
| 1812 | |
| 1813 | tem = Fassq (prop, frame->param_alist); |
| 1814 | if (EQ (tem, Qnil)) |
| 1815 | return tem; |
| 1816 | return Fcdr (tem); |
| 1817 | } |
| 1818 | |
| 1819 | /* Return the buffer-predicate of the selected frame. */ |
| 1820 | |
| 1821 | Lisp_Object |
| 1822 | frame_buffer_predicate (frame) |
| 1823 | Lisp_Object frame; |
| 1824 | { |
| 1825 | return XFRAME (frame)->buffer_predicate; |
| 1826 | } |
| 1827 | |
| 1828 | /* Return the buffer-list of the selected frame. */ |
| 1829 | |
| 1830 | Lisp_Object |
| 1831 | frame_buffer_list (frame) |
| 1832 | Lisp_Object frame; |
| 1833 | { |
| 1834 | return XFRAME (frame)->buffer_list; |
| 1835 | } |
| 1836 | |
| 1837 | /* Set the buffer-list of the selected frame. */ |
| 1838 | |
| 1839 | void |
| 1840 | set_frame_buffer_list (frame, list) |
| 1841 | Lisp_Object frame, list; |
| 1842 | { |
| 1843 | XFRAME (frame)->buffer_list = list; |
| 1844 | } |
| 1845 | |
| 1846 | /* Discard BUFFER from the buffer-list of each frame. */ |
| 1847 | |
| 1848 | void |
| 1849 | frames_discard_buffer (buffer) |
| 1850 | Lisp_Object buffer; |
| 1851 | { |
| 1852 | Lisp_Object frame, tail; |
| 1853 | |
| 1854 | FOR_EACH_FRAME (tail, frame) |
| 1855 | { |
| 1856 | XFRAME (frame)->buffer_list |
| 1857 | = Fdelq (buffer, XFRAME (frame)->buffer_list); |
| 1858 | } |
| 1859 | } |
| 1860 | |
| 1861 | /* Modify the alist in *ALISTPTR to associate PROP with VAL. |
| 1862 | If the alist already has an element for PROP, we change it. */ |
| 1863 | |
| 1864 | void |
| 1865 | store_in_alist (alistptr, prop, val) |
| 1866 | Lisp_Object *alistptr, val; |
| 1867 | Lisp_Object prop; |
| 1868 | { |
| 1869 | register Lisp_Object tem; |
| 1870 | |
| 1871 | tem = Fassq (prop, *alistptr); |
| 1872 | if (EQ (tem, Qnil)) |
| 1873 | *alistptr = Fcons (Fcons (prop, val), *alistptr); |
| 1874 | else |
| 1875 | Fsetcdr (tem, val); |
| 1876 | } |
| 1877 | |
| 1878 | static int |
| 1879 | frame_name_fnn_p (str, len) |
| 1880 | char *str; |
| 1881 | int len; |
| 1882 | { |
| 1883 | if (len > 1 && str[0] == 'F') |
| 1884 | { |
| 1885 | char *end_ptr; |
| 1886 | |
| 1887 | strtol (str + 1, &end_ptr, 10); |
| 1888 | |
| 1889 | if (end_ptr == str + len) |
| 1890 | return 1; |
| 1891 | } |
| 1892 | return 0; |
| 1893 | } |
| 1894 | |
| 1895 | /* Set the name of the terminal frame. Also used by MSDOS frames. |
| 1896 | Modeled after x_set_name which is used for WINDOW frames. */ |
| 1897 | |
| 1898 | void |
| 1899 | set_term_frame_name (f, name) |
| 1900 | struct frame *f; |
| 1901 | Lisp_Object name; |
| 1902 | { |
| 1903 | f->explicit_name = ! NILP (name); |
| 1904 | |
| 1905 | /* If NAME is nil, set the name to F<num>. */ |
| 1906 | if (NILP (name)) |
| 1907 | { |
| 1908 | char namebuf[20]; |
| 1909 | |
| 1910 | /* Check for no change needed in this very common case |
| 1911 | before we do any consing. */ |
| 1912 | if (frame_name_fnn_p (SDATA (f->name), |
| 1913 | SBYTES (f->name))) |
| 1914 | return; |
| 1915 | |
| 1916 | terminal_frame_count++; |
| 1917 | sprintf (namebuf, "F%d", terminal_frame_count); |
| 1918 | name = build_string (namebuf); |
| 1919 | } |
| 1920 | else |
| 1921 | { |
| 1922 | CHECK_STRING (name); |
| 1923 | |
| 1924 | /* Don't change the name if it's already NAME. */ |
| 1925 | if (! NILP (Fstring_equal (name, f->name))) |
| 1926 | return; |
| 1927 | |
| 1928 | /* Don't allow the user to set the frame name to F<num>, so it |
| 1929 | doesn't clash with the names we generate for terminal frames. */ |
| 1930 | if (frame_name_fnn_p (SDATA (name), SBYTES (name))) |
| 1931 | error ("Frame names of the form F<num> are usurped by Emacs"); |
| 1932 | } |
| 1933 | |
| 1934 | f->name = name; |
| 1935 | update_mode_lines = 1; |
| 1936 | } |
| 1937 | |
| 1938 | void |
| 1939 | store_frame_param (f, prop, val) |
| 1940 | struct frame *f; |
| 1941 | Lisp_Object prop, val; |
| 1942 | { |
| 1943 | register Lisp_Object old_alist_elt; |
| 1944 | |
| 1945 | /* The buffer-alist parameter is stored in a special place and is |
| 1946 | not in the alist. */ |
| 1947 | if (EQ (prop, Qbuffer_list)) |
| 1948 | { |
| 1949 | f->buffer_list = val; |
| 1950 | return; |
| 1951 | } |
| 1952 | |
| 1953 | /* If PROP is a symbol which is supposed to have frame-local values, |
| 1954 | and it is set up based on this frame, switch to the global |
| 1955 | binding. That way, we can create or alter the frame-local binding |
| 1956 | without messing up the symbol's status. */ |
| 1957 | if (SYMBOLP (prop)) |
| 1958 | { |
| 1959 | Lisp_Object valcontents; |
| 1960 | valcontents = SYMBOL_VALUE (prop); |
| 1961 | if ((BUFFER_LOCAL_VALUEP (valcontents) |
| 1962 | || SOME_BUFFER_LOCAL_VALUEP (valcontents)) |
| 1963 | && XBUFFER_LOCAL_VALUE (valcontents)->check_frame |
| 1964 | && XFRAME (XBUFFER_LOCAL_VALUE (valcontents)->frame) == f) |
| 1965 | swap_in_global_binding (prop); |
| 1966 | } |
| 1967 | |
| 1968 | #ifndef WINDOWSNT |
| 1969 | /* The tty color mode needs to be set before the frame's parameter |
| 1970 | alist is updated with the new value, because set_tty_color_mode |
| 1971 | wants to look at the old mode. */ |
| 1972 | if (FRAME_TERMCAP_P (f) && EQ (prop, Qtty_color_mode)) |
| 1973 | set_tty_color_mode (f, val); |
| 1974 | #endif |
| 1975 | |
| 1976 | /* Update the frame parameter alist. */ |
| 1977 | old_alist_elt = Fassq (prop, f->param_alist); |
| 1978 | if (EQ (old_alist_elt, Qnil)) |
| 1979 | f->param_alist = Fcons (Fcons (prop, val), f->param_alist); |
| 1980 | else |
| 1981 | Fsetcdr (old_alist_elt, val); |
| 1982 | |
| 1983 | /* Update some other special parameters in their special places |
| 1984 | in addition to the alist. */ |
| 1985 | |
| 1986 | if (EQ (prop, Qbuffer_predicate)) |
| 1987 | f->buffer_predicate = val; |
| 1988 | |
| 1989 | if (! FRAME_WINDOW_P (f)) |
| 1990 | { |
| 1991 | if (EQ (prop, Qmenu_bar_lines)) |
| 1992 | set_menu_bar_lines (f, val, make_number (FRAME_MENU_BAR_LINES (f))); |
| 1993 | else if (EQ (prop, Qname)) |
| 1994 | set_term_frame_name (f, val); |
| 1995 | } |
| 1996 | |
| 1997 | if (EQ (prop, Qminibuffer) && WINDOWP (val)) |
| 1998 | { |
| 1999 | if (! MINI_WINDOW_P (XWINDOW (val))) |
| 2000 | error ("Surrogate minibuffer windows must be minibuffer windows."); |
| 2001 | |
| 2002 | if ((FRAME_HAS_MINIBUF_P (f) || FRAME_MINIBUF_ONLY_P (f)) |
| 2003 | && !EQ (val, f->minibuffer_window)) |
| 2004 | error ("Can't change the surrogate minibuffer of a frame with its own minibuffer"); |
| 2005 | |
| 2006 | /* Install the chosen minibuffer window, with proper buffer. */ |
| 2007 | f->minibuffer_window = val; |
| 2008 | } |
| 2009 | } |
| 2010 | |
| 2011 | DEFUN ("frame-parameters", Fframe_parameters, Sframe_parameters, 0, 1, 0, |
| 2012 | doc: /* Return the parameters-alist of frame FRAME. |
| 2013 | It is a list of elements of the form (PARM . VALUE), where PARM is a symbol. |
| 2014 | The meaningful PARMs depend on the kind of frame. |
| 2015 | If FRAME is omitted, return information on the currently selected frame. */) |
| 2016 | (frame) |
| 2017 | Lisp_Object frame; |
| 2018 | { |
| 2019 | Lisp_Object alist; |
| 2020 | FRAME_PTR f; |
| 2021 | int height, width; |
| 2022 | struct gcpro gcpro1; |
| 2023 | |
| 2024 | if (NILP (frame)) |
| 2025 | frame = selected_frame; |
| 2026 | |
| 2027 | CHECK_FRAME (frame); |
| 2028 | f = XFRAME (frame); |
| 2029 | |
| 2030 | if (!FRAME_LIVE_P (f)) |
| 2031 | return Qnil; |
| 2032 | |
| 2033 | alist = Fcopy_alist (f->param_alist); |
| 2034 | GCPRO1 (alist); |
| 2035 | |
| 2036 | if (!FRAME_WINDOW_P (f)) |
| 2037 | { |
| 2038 | int fg = FRAME_FOREGROUND_PIXEL (f); |
| 2039 | int bg = FRAME_BACKGROUND_PIXEL (f); |
| 2040 | Lisp_Object elt; |
| 2041 | |
| 2042 | /* If the frame's parameter alist says the colors are |
| 2043 | unspecified and reversed, take the frame's background pixel |
| 2044 | for foreground and vice versa. */ |
| 2045 | elt = Fassq (Qforeground_color, alist); |
| 2046 | if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt))) |
| 2047 | { |
| 2048 | if (strncmp (SDATA (XCDR (elt)), |
| 2049 | unspecified_bg, |
| 2050 | SCHARS (XCDR (elt))) == 0) |
| 2051 | store_in_alist (&alist, Qforeground_color, tty_color_name (f, bg)); |
| 2052 | else if (strncmp (SDATA (XCDR (elt)), |
| 2053 | unspecified_fg, |
| 2054 | SCHARS (XCDR (elt))) == 0) |
| 2055 | store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg)); |
| 2056 | } |
| 2057 | else |
| 2058 | store_in_alist (&alist, Qforeground_color, tty_color_name (f, fg)); |
| 2059 | elt = Fassq (Qbackground_color, alist); |
| 2060 | if (!NILP (elt) && CONSP (elt) && STRINGP (XCDR (elt))) |
| 2061 | { |
| 2062 | if (strncmp (SDATA (XCDR (elt)), |
| 2063 | unspecified_fg, |
| 2064 | SCHARS (XCDR (elt))) == 0) |
| 2065 | store_in_alist (&alist, Qbackground_color, tty_color_name (f, fg)); |
| 2066 | else if (strncmp (SDATA (XCDR (elt)), |
| 2067 | unspecified_bg, |
| 2068 | SCHARS (XCDR (elt))) == 0) |
| 2069 | store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg)); |
| 2070 | } |
| 2071 | else |
| 2072 | store_in_alist (&alist, Qbackground_color, tty_color_name (f, bg)); |
| 2073 | store_in_alist (&alist, intern ("font"), |
| 2074 | build_string (FRAME_MSDOS_P (f) |
| 2075 | ? "ms-dos" |
| 2076 | : FRAME_W32_P (f) ? "w32term" |
| 2077 | :"tty")); |
| 2078 | } |
| 2079 | store_in_alist (&alist, Qname, f->name); |
| 2080 | height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f)); |
| 2081 | store_in_alist (&alist, Qheight, make_number (height)); |
| 2082 | width = (FRAME_NEW_WIDTH (f) ? FRAME_NEW_WIDTH (f) : FRAME_WIDTH (f)); |
| 2083 | store_in_alist (&alist, Qwidth, make_number (width)); |
| 2084 | store_in_alist (&alist, Qmodeline, (FRAME_WANTS_MODELINE_P (f) ? Qt : Qnil)); |
| 2085 | store_in_alist (&alist, Qminibuffer, |
| 2086 | (! FRAME_HAS_MINIBUF_P (f) ? Qnil |
| 2087 | : FRAME_MINIBUF_ONLY_P (f) ? Qonly |
| 2088 | : FRAME_MINIBUF_WINDOW (f))); |
| 2089 | store_in_alist (&alist, Qunsplittable, (FRAME_NO_SPLIT_P (f) ? Qt : Qnil)); |
| 2090 | store_in_alist (&alist, Qbuffer_list, frame_buffer_list (frame)); |
| 2091 | |
| 2092 | /* I think this should be done with a hook. */ |
| 2093 | #ifdef HAVE_WINDOW_SYSTEM |
| 2094 | if (FRAME_WINDOW_P (f)) |
| 2095 | x_report_frame_params (f, &alist); |
| 2096 | else |
| 2097 | #endif |
| 2098 | { |
| 2099 | /* This ought to be correct in f->param_alist for an X frame. */ |
| 2100 | Lisp_Object lines; |
| 2101 | XSETFASTINT (lines, FRAME_MENU_BAR_LINES (f)); |
| 2102 | store_in_alist (&alist, Qmenu_bar_lines, lines); |
| 2103 | } |
| 2104 | |
| 2105 | UNGCPRO; |
| 2106 | return alist; |
| 2107 | } |
| 2108 | |
| 2109 | |
| 2110 | DEFUN ("frame-parameter", Fframe_parameter, Sframe_parameter, 2, 2, 0, |
| 2111 | doc: /* Return FRAME's value for parameter PARAMETER. |
| 2112 | If FRAME is nil, describe the currently selected frame. */) |
| 2113 | (frame, parameter) |
| 2114 | Lisp_Object frame, parameter; |
| 2115 | { |
| 2116 | struct frame *f; |
| 2117 | Lisp_Object value; |
| 2118 | |
| 2119 | if (NILP (frame)) |
| 2120 | frame = selected_frame; |
| 2121 | else |
| 2122 | CHECK_FRAME (frame); |
| 2123 | CHECK_SYMBOL (parameter); |
| 2124 | |
| 2125 | f = XFRAME (frame); |
| 2126 | value = Qnil; |
| 2127 | |
| 2128 | if (FRAME_LIVE_P (f)) |
| 2129 | { |
| 2130 | /* Avoid consing in frequent cases. */ |
| 2131 | if (EQ (parameter, Qname)) |
| 2132 | value = f->name; |
| 2133 | #ifdef HAVE_X_WINDOWS |
| 2134 | else if (EQ (parameter, Qdisplay) && FRAME_X_P (f)) |
| 2135 | value = XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element); |
| 2136 | #endif /* HAVE_X_WINDOWS */ |
| 2137 | else if (EQ (parameter, Qbackground_color) |
| 2138 | || EQ (parameter, Qforeground_color)) |
| 2139 | { |
| 2140 | value = Fassq (parameter, f->param_alist); |
| 2141 | if (CONSP (value)) |
| 2142 | { |
| 2143 | value = XCDR (value); |
| 2144 | /* Fframe_parameters puts the actual fg/bg color names, |
| 2145 | even if f->param_alist says otherwise. This is |
| 2146 | important when param_alist's notion of colors is |
| 2147 | "unspecified". We need to do the same here. */ |
| 2148 | if (STRINGP (value) && !FRAME_WINDOW_P (f)) |
| 2149 | { |
| 2150 | const char *color_name; |
| 2151 | EMACS_INT csz; |
| 2152 | |
| 2153 | if (EQ (parameter, Qbackground_color)) |
| 2154 | { |
| 2155 | color_name = SDATA (value); |
| 2156 | csz = SCHARS (value); |
| 2157 | if (strncmp (color_name, unspecified_bg, csz) == 0) |
| 2158 | value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)); |
| 2159 | else if (strncmp (color_name, unspecified_fg, csz) == 0) |
| 2160 | value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)); |
| 2161 | } |
| 2162 | else if (EQ (parameter, Qforeground_color)) |
| 2163 | { |
| 2164 | color_name = SDATA (value); |
| 2165 | csz = SCHARS (value); |
| 2166 | if (strncmp (color_name, unspecified_fg, csz) == 0) |
| 2167 | value = tty_color_name (f, FRAME_FOREGROUND_PIXEL (f)); |
| 2168 | else if (strncmp (color_name, unspecified_bg, csz) == 0) |
| 2169 | value = tty_color_name (f, FRAME_BACKGROUND_PIXEL (f)); |
| 2170 | } |
| 2171 | } |
| 2172 | } |
| 2173 | else |
| 2174 | value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); |
| 2175 | } |
| 2176 | else if (EQ (parameter, Qdisplay_type) |
| 2177 | || EQ (parameter, Qbackground_mode)) |
| 2178 | value = Fcdr (Fassq (parameter, f->param_alist)); |
| 2179 | else |
| 2180 | value = Fcdr (Fassq (parameter, Fframe_parameters (frame))); |
| 2181 | } |
| 2182 | |
| 2183 | return value; |
| 2184 | } |
| 2185 | |
| 2186 | |
| 2187 | DEFUN ("modify-frame-parameters", Fmodify_frame_parameters, |
| 2188 | Smodify_frame_parameters, 2, 2, 0, |
| 2189 | doc: /* Modify the parameters of frame FRAME according to ALIST. |
| 2190 | If FRAME is nil, it defaults to the selected frame. |
| 2191 | ALIST is an alist of parameters to change and their new values. |
| 2192 | Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol. |
| 2193 | The meaningful PARMs depend on the kind of frame. |
| 2194 | Undefined PARMs are ignored, but stored in the frame's parameter list |
| 2195 | so that `frame-parameters' will return them. |
| 2196 | |
| 2197 | The value of frame parameter FOO can also be accessed |
| 2198 | as a frame-local binding for the variable FOO, if you have |
| 2199 | enabled such bindings for that variable with `make-variable-frame-local'. */) |
| 2200 | (frame, alist) |
| 2201 | Lisp_Object frame, alist; |
| 2202 | { |
| 2203 | FRAME_PTR f; |
| 2204 | register Lisp_Object tail, prop, val; |
| 2205 | int count = SPECPDL_INDEX (); |
| 2206 | |
| 2207 | /* Bind this to t to inhibit initialization of the default face from |
| 2208 | X resources in face-set-after-frame-default. If we don't inhibit |
| 2209 | this, modifying the `font' frame parameter, for example, while |
| 2210 | there is a `default.attributeFont' X resource, won't work, |
| 2211 | because `default's font is reset to the value of the X resource |
| 2212 | and that resets the `font' frame parameter. */ |
| 2213 | specbind (Qinhibit_default_face_x_resources, Qt); |
| 2214 | |
| 2215 | if (EQ (frame, Qnil)) |
| 2216 | frame = selected_frame; |
| 2217 | CHECK_LIVE_FRAME (frame); |
| 2218 | f = XFRAME (frame); |
| 2219 | |
| 2220 | /* I think this should be done with a hook. */ |
| 2221 | #ifdef HAVE_WINDOW_SYSTEM |
| 2222 | if (FRAME_WINDOW_P (f)) |
| 2223 | x_set_frame_parameters (f, alist); |
| 2224 | else |
| 2225 | #endif |
| 2226 | #ifdef MSDOS |
| 2227 | if (FRAME_MSDOS_P (f)) |
| 2228 | IT_set_frame_parameters (f, alist); |
| 2229 | else |
| 2230 | #endif |
| 2231 | |
| 2232 | { |
| 2233 | int length = XINT (Flength (alist)); |
| 2234 | int i; |
| 2235 | Lisp_Object *parms |
| 2236 | = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); |
| 2237 | Lisp_Object *values |
| 2238 | = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); |
| 2239 | |
| 2240 | /* Extract parm names and values into those vectors. */ |
| 2241 | |
| 2242 | i = 0; |
| 2243 | for (tail = alist; CONSP (tail); tail = Fcdr (tail)) |
| 2244 | { |
| 2245 | Lisp_Object elt; |
| 2246 | |
| 2247 | elt = Fcar (tail); |
| 2248 | parms[i] = Fcar (elt); |
| 2249 | values[i] = Fcdr (elt); |
| 2250 | i++; |
| 2251 | } |
| 2252 | |
| 2253 | /* Now process them in reverse of specified order. */ |
| 2254 | for (i--; i >= 0; i--) |
| 2255 | { |
| 2256 | prop = parms[i]; |
| 2257 | val = values[i]; |
| 2258 | store_frame_param (f, prop, val); |
| 2259 | } |
| 2260 | } |
| 2261 | |
| 2262 | return unbind_to (count, Qnil); |
| 2263 | } |
| 2264 | \f |
| 2265 | DEFUN ("frame-char-height", Fframe_char_height, Sframe_char_height, |
| 2266 | 0, 1, 0, |
| 2267 | doc: /* Height in pixels of a line in the font in frame FRAME. |
| 2268 | If FRAME is omitted, the selected frame is used. |
| 2269 | For a terminal frame, the value is always 1. */) |
| 2270 | (frame) |
| 2271 | Lisp_Object frame; |
| 2272 | { |
| 2273 | struct frame *f; |
| 2274 | |
| 2275 | if (NILP (frame)) |
| 2276 | frame = selected_frame; |
| 2277 | CHECK_FRAME (frame); |
| 2278 | f = XFRAME (frame); |
| 2279 | |
| 2280 | #ifdef HAVE_WINDOW_SYSTEM |
| 2281 | if (FRAME_WINDOW_P (f)) |
| 2282 | return make_number (x_char_height (f)); |
| 2283 | else |
| 2284 | #endif |
| 2285 | return make_number (1); |
| 2286 | } |
| 2287 | |
| 2288 | |
| 2289 | DEFUN ("frame-char-width", Fframe_char_width, Sframe_char_width, |
| 2290 | 0, 1, 0, |
| 2291 | doc: /* Width in pixels of characters in the font in frame FRAME. |
| 2292 | If FRAME is omitted, the selected frame is used. |
| 2293 | The width is the same for all characters, because |
| 2294 | currently Emacs supports only fixed-width fonts. |
| 2295 | For a terminal screen, the value is always 1. */) |
| 2296 | (frame) |
| 2297 | Lisp_Object frame; |
| 2298 | { |
| 2299 | struct frame *f; |
| 2300 | |
| 2301 | if (NILP (frame)) |
| 2302 | frame = selected_frame; |
| 2303 | CHECK_FRAME (frame); |
| 2304 | f = XFRAME (frame); |
| 2305 | |
| 2306 | #ifdef HAVE_WINDOW_SYSTEM |
| 2307 | if (FRAME_WINDOW_P (f)) |
| 2308 | return make_number (x_char_width (f)); |
| 2309 | else |
| 2310 | #endif |
| 2311 | return make_number (1); |
| 2312 | } |
| 2313 | |
| 2314 | DEFUN ("frame-pixel-height", Fframe_pixel_height, |
| 2315 | Sframe_pixel_height, 0, 1, 0, |
| 2316 | doc: /* Return a FRAME's height in pixels. |
| 2317 | This counts only the height available for text lines, |
| 2318 | not menu bars on window-system Emacs frames. |
| 2319 | For a terminal frame, the result really gives the height in characters. |
| 2320 | If FRAME is omitted, the selected frame is used. */) |
| 2321 | (frame) |
| 2322 | Lisp_Object frame; |
| 2323 | { |
| 2324 | struct frame *f; |
| 2325 | |
| 2326 | if (NILP (frame)) |
| 2327 | frame = selected_frame; |
| 2328 | CHECK_FRAME (frame); |
| 2329 | f = XFRAME (frame); |
| 2330 | |
| 2331 | #ifdef HAVE_WINDOW_SYSTEM |
| 2332 | if (FRAME_WINDOW_P (f)) |
| 2333 | return make_number (x_pixel_height (f)); |
| 2334 | else |
| 2335 | #endif |
| 2336 | return make_number (FRAME_HEIGHT (f)); |
| 2337 | } |
| 2338 | |
| 2339 | DEFUN ("frame-pixel-width", Fframe_pixel_width, |
| 2340 | Sframe_pixel_width, 0, 1, 0, |
| 2341 | doc: /* Return FRAME's width in pixels. |
| 2342 | For a terminal frame, the result really gives the width in characters. |
| 2343 | If FRAME is omitted, the selected frame is used. */) |
| 2344 | (frame) |
| 2345 | Lisp_Object frame; |
| 2346 | { |
| 2347 | struct frame *f; |
| 2348 | |
| 2349 | if (NILP (frame)) |
| 2350 | frame = selected_frame; |
| 2351 | CHECK_FRAME (frame); |
| 2352 | f = XFRAME (frame); |
| 2353 | |
| 2354 | #ifdef HAVE_WINDOW_SYSTEM |
| 2355 | if (FRAME_WINDOW_P (f)) |
| 2356 | return make_number (x_pixel_width (f)); |
| 2357 | else |
| 2358 | #endif |
| 2359 | return make_number (FRAME_WIDTH (f)); |
| 2360 | } |
| 2361 | \f |
| 2362 | DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 3, 0, |
| 2363 | doc: /* Specify that the frame FRAME has LINES lines. |
| 2364 | Optional third arg non-nil means that redisplay should use LINES lines |
| 2365 | but that the idea of the actual height of the frame should not be changed. */) |
| 2366 | (frame, lines, pretend) |
| 2367 | Lisp_Object frame, lines, pretend; |
| 2368 | { |
| 2369 | register struct frame *f; |
| 2370 | |
| 2371 | CHECK_NUMBER (lines); |
| 2372 | if (NILP (frame)) |
| 2373 | frame = selected_frame; |
| 2374 | CHECK_LIVE_FRAME (frame); |
| 2375 | f = XFRAME (frame); |
| 2376 | |
| 2377 | /* I think this should be done with a hook. */ |
| 2378 | #ifdef HAVE_WINDOW_SYSTEM |
| 2379 | if (FRAME_WINDOW_P (f)) |
| 2380 | { |
| 2381 | if (XINT (lines) != f->height) |
| 2382 | x_set_window_size (f, 1, f->width, XINT (lines)); |
| 2383 | do_pending_window_change (0); |
| 2384 | } |
| 2385 | else |
| 2386 | #endif |
| 2387 | change_frame_size (f, XINT (lines), 0, !NILP (pretend), 0, 0); |
| 2388 | return Qnil; |
| 2389 | } |
| 2390 | |
| 2391 | DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 3, 0, |
| 2392 | doc: /* Specify that the frame FRAME has COLS columns. |
| 2393 | Optional third arg non-nil means that redisplay should use COLS columns |
| 2394 | but that the idea of the actual width of the frame should not be changed. */) |
| 2395 | (frame, cols, pretend) |
| 2396 | Lisp_Object frame, cols, pretend; |
| 2397 | { |
| 2398 | register struct frame *f; |
| 2399 | CHECK_NUMBER (cols); |
| 2400 | if (NILP (frame)) |
| 2401 | frame = selected_frame; |
| 2402 | CHECK_LIVE_FRAME (frame); |
| 2403 | f = XFRAME (frame); |
| 2404 | |
| 2405 | /* I think this should be done with a hook. */ |
| 2406 | #ifdef HAVE_WINDOW_SYSTEM |
| 2407 | if (FRAME_WINDOW_P (f)) |
| 2408 | { |
| 2409 | if (XINT (cols) != f->width) |
| 2410 | x_set_window_size (f, 1, XINT (cols), f->height); |
| 2411 | do_pending_window_change (0); |
| 2412 | } |
| 2413 | else |
| 2414 | #endif |
| 2415 | change_frame_size (f, 0, XINT (cols), !NILP (pretend), 0, 0); |
| 2416 | return Qnil; |
| 2417 | } |
| 2418 | |
| 2419 | DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 3, 0, |
| 2420 | doc: /* Sets size of FRAME to COLS by ROWS, measured in characters. */) |
| 2421 | (frame, cols, rows) |
| 2422 | Lisp_Object frame, cols, rows; |
| 2423 | { |
| 2424 | register struct frame *f; |
| 2425 | |
| 2426 | CHECK_LIVE_FRAME (frame); |
| 2427 | CHECK_NUMBER (cols); |
| 2428 | CHECK_NUMBER (rows); |
| 2429 | f = XFRAME (frame); |
| 2430 | |
| 2431 | /* I think this should be done with a hook. */ |
| 2432 | #ifdef HAVE_WINDOW_SYSTEM |
| 2433 | if (FRAME_WINDOW_P (f)) |
| 2434 | { |
| 2435 | if (XINT (rows) != f->height || XINT (cols) != f->width |
| 2436 | || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f)) |
| 2437 | x_set_window_size (f, 1, XINT (cols), XINT (rows)); |
| 2438 | do_pending_window_change (0); |
| 2439 | } |
| 2440 | else |
| 2441 | #endif |
| 2442 | change_frame_size (f, XINT (rows), XINT (cols), 0, 0, 0); |
| 2443 | |
| 2444 | return Qnil; |
| 2445 | } |
| 2446 | |
| 2447 | DEFUN ("set-frame-position", Fset_frame_position, |
| 2448 | Sset_frame_position, 3, 3, 0, |
| 2449 | doc: /* Sets position of FRAME in pixels to XOFFSET by YOFFSET. |
| 2450 | This is actually the position of the upper left corner of the frame. |
| 2451 | Negative values for XOFFSET or YOFFSET are interpreted relative to |
| 2452 | the rightmost or bottommost possible position (that stays within the screen). */) |
| 2453 | (frame, xoffset, yoffset) |
| 2454 | Lisp_Object frame, xoffset, yoffset; |
| 2455 | { |
| 2456 | register struct frame *f; |
| 2457 | |
| 2458 | CHECK_LIVE_FRAME (frame); |
| 2459 | CHECK_NUMBER (xoffset); |
| 2460 | CHECK_NUMBER (yoffset); |
| 2461 | f = XFRAME (frame); |
| 2462 | |
| 2463 | /* I think this should be done with a hook. */ |
| 2464 | #ifdef HAVE_WINDOW_SYSTEM |
| 2465 | if (FRAME_WINDOW_P (f)) |
| 2466 | x_set_offset (f, XINT (xoffset), XINT (yoffset), 1); |
| 2467 | #endif |
| 2468 | |
| 2469 | return Qt; |
| 2470 | } |
| 2471 | |
| 2472 | \f |
| 2473 | /*********************************************************************** |
| 2474 | Frame Parameters |
| 2475 | ***********************************************************************/ |
| 2476 | |
| 2477 | /* Connect the frame-parameter names for X frames |
| 2478 | to the ways of passing the parameter values to the window system. |
| 2479 | |
| 2480 | The name of a parameter, as a Lisp symbol, |
| 2481 | has an `x-frame-parameter' property which is an integer in Lisp |
| 2482 | that is an index in this table. */ |
| 2483 | |
| 2484 | struct frame_parm_table { |
| 2485 | char *name; |
| 2486 | Lisp_Object *variable; |
| 2487 | }; |
| 2488 | |
| 2489 | static struct frame_parm_table frame_parms[] = |
| 2490 | { |
| 2491 | {"auto-raise", &Qauto_raise}, |
| 2492 | {"auto-lower", &Qauto_lower}, |
| 2493 | {"background-color", 0}, |
| 2494 | {"border-color", &Qborder_color}, |
| 2495 | {"border-width", &Qborder_width}, |
| 2496 | {"cursor-color", &Qcursor_color}, |
| 2497 | {"cursor-type", &Qcursor_type}, |
| 2498 | {"font", 0}, |
| 2499 | {"foreground-color", 0}, |
| 2500 | {"icon-name", &Qicon_name}, |
| 2501 | {"icon-type", &Qicon_type}, |
| 2502 | {"internal-border-width", &Qinternal_border_width}, |
| 2503 | {"menu-bar-lines", &Qmenu_bar_lines}, |
| 2504 | {"mouse-color", &Qmouse_color}, |
| 2505 | {"name", &Qname}, |
| 2506 | {"scroll-bar-width", &Qscroll_bar_width}, |
| 2507 | {"title", &Qtitle}, |
| 2508 | {"unsplittable", &Qunsplittable}, |
| 2509 | {"vertical-scroll-bars", &Qvertical_scroll_bars}, |
| 2510 | {"visibility", &Qvisibility}, |
| 2511 | {"tool-bar-lines", &Qtool_bar_lines}, |
| 2512 | {"scroll-bar-foreground", &Qscroll_bar_foreground}, |
| 2513 | {"scroll-bar-background", &Qscroll_bar_background}, |
| 2514 | {"screen-gamma", &Qscreen_gamma}, |
| 2515 | {"line-spacing", &Qline_spacing}, |
| 2516 | {"left-fringe", &Qleft_fringe}, |
| 2517 | {"right-fringe", &Qright_fringe}, |
| 2518 | {"wait-for-wm", &Qwait_for_wm}, |
| 2519 | {"fullscreen", &Qfullscreen}, |
| 2520 | }; |
| 2521 | |
| 2522 | #ifdef HAVE_WINDOW_SYSTEM |
| 2523 | |
| 2524 | extern Lisp_Object Qbox; |
| 2525 | extern Lisp_Object Qtop; |
| 2526 | |
| 2527 | /* Calculate fullscreen size. Return in *TOP_POS and *LEFT_POS the |
| 2528 | wanted positions of the WM window (not emacs window). |
| 2529 | Return in *WIDTH and *HEIGHT the wanted width and height of Emacs |
| 2530 | window (FRAME_X_WINDOW). |
| 2531 | */ |
| 2532 | |
| 2533 | void |
| 2534 | x_fullscreen_adjust (f, width, height, top_pos, left_pos) |
| 2535 | struct frame *f; |
| 2536 | int *width; |
| 2537 | int *height; |
| 2538 | int *top_pos; |
| 2539 | int *left_pos; |
| 2540 | { |
| 2541 | int newwidth = f->width, newheight = f->height; |
| 2542 | |
| 2543 | *top_pos = FRAME_X_OUTPUT (f)->top_pos; |
| 2544 | *left_pos = FRAME_X_OUTPUT (f)->left_pos; |
| 2545 | |
| 2546 | if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_HEIGHT) |
| 2547 | { |
| 2548 | int ph; |
| 2549 | |
| 2550 | ph = FRAME_X_DISPLAY_INFO (f)->height; |
| 2551 | newheight = PIXEL_TO_CHAR_HEIGHT (f, ph); |
| 2552 | ph = CHAR_TO_PIXEL_HEIGHT (f, newheight) |
| 2553 | - FRAME_X_OUTPUT (f)->y_pixels_diff; |
| 2554 | newheight = PIXEL_TO_CHAR_HEIGHT (f, ph); |
| 2555 | *top_pos = 0; |
| 2556 | } |
| 2557 | |
| 2558 | if (FRAME_X_OUTPUT (f)->want_fullscreen & FULLSCREEN_WIDTH) |
| 2559 | { |
| 2560 | int pw; |
| 2561 | |
| 2562 | pw = FRAME_X_DISPLAY_INFO (f)->width; |
| 2563 | newwidth = PIXEL_TO_CHAR_WIDTH (f, pw); |
| 2564 | pw = CHAR_TO_PIXEL_WIDTH (f, newwidth) |
| 2565 | - FRAME_X_OUTPUT (f)->x_pixels_diff; |
| 2566 | newwidth = PIXEL_TO_CHAR_WIDTH (f, pw); |
| 2567 | *left_pos = 0; |
| 2568 | } |
| 2569 | |
| 2570 | *width = newwidth; |
| 2571 | *height = newheight; |
| 2572 | } |
| 2573 | |
| 2574 | |
| 2575 | /* Really try to move where we want to be in case of fullscreen. Some WMs |
| 2576 | moves the window where we tell them. Some (mwm, twm) moves the outer |
| 2577 | window manager window there instead. |
| 2578 | Try to compensate for those WM here. */ |
| 2579 | |
| 2580 | static void |
| 2581 | x_fullscreen_move (f, new_top, new_left) |
| 2582 | struct frame *f; |
| 2583 | int new_top; |
| 2584 | int new_left; |
| 2585 | { |
| 2586 | if (new_top != FRAME_X_OUTPUT (f)->top_pos |
| 2587 | || new_left != FRAME_X_OUTPUT (f)->left_pos) |
| 2588 | { |
| 2589 | int move_x = new_left; |
| 2590 | int move_y = new_top; |
| 2591 | |
| 2592 | #ifdef HAVE_X_WINDOWS |
| 2593 | move_x += FRAME_X_OUTPUT (f)->x_pixels_outer_diff; |
| 2594 | move_y += FRAME_X_OUTPUT (f)->y_pixels_outer_diff; |
| 2595 | #endif |
| 2596 | |
| 2597 | FRAME_X_OUTPUT (f)->want_fullscreen |= FULLSCREEN_MOVE_WAIT; |
| 2598 | x_set_offset (f, move_x, move_y, 1); |
| 2599 | } |
| 2600 | } |
| 2601 | |
| 2602 | /* Change the parameters of frame F as specified by ALIST. |
| 2603 | If a parameter is not specially recognized, do nothing special; |
| 2604 | otherwise call the `x_set_...' function for that parameter. |
| 2605 | Except for certain geometry properties, always call store_frame_param |
| 2606 | to store the new value in the parameter alist. */ |
| 2607 | |
| 2608 | void |
| 2609 | x_set_frame_parameters (f, alist) |
| 2610 | FRAME_PTR f; |
| 2611 | Lisp_Object alist; |
| 2612 | { |
| 2613 | Lisp_Object tail; |
| 2614 | |
| 2615 | /* If both of these parameters are present, it's more efficient to |
| 2616 | set them both at once. So we wait until we've looked at the |
| 2617 | entire list before we set them. */ |
| 2618 | int width, height; |
| 2619 | |
| 2620 | /* Same here. */ |
| 2621 | Lisp_Object left, top; |
| 2622 | |
| 2623 | /* Same with these. */ |
| 2624 | Lisp_Object icon_left, icon_top; |
| 2625 | |
| 2626 | /* Record in these vectors all the parms specified. */ |
| 2627 | Lisp_Object *parms; |
| 2628 | Lisp_Object *values; |
| 2629 | int i, p; |
| 2630 | int left_no_change = 0, top_no_change = 0; |
| 2631 | int icon_left_no_change = 0, icon_top_no_change = 0; |
| 2632 | int fullscreen_is_being_set = 0; |
| 2633 | |
| 2634 | struct gcpro gcpro1, gcpro2; |
| 2635 | |
| 2636 | i = 0; |
| 2637 | for (tail = alist; CONSP (tail); tail = Fcdr (tail)) |
| 2638 | i++; |
| 2639 | |
| 2640 | parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object)); |
| 2641 | values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object)); |
| 2642 | |
| 2643 | /* Extract parm names and values into those vectors. */ |
| 2644 | |
| 2645 | i = 0; |
| 2646 | for (tail = alist; CONSP (tail); tail = Fcdr (tail)) |
| 2647 | { |
| 2648 | Lisp_Object elt; |
| 2649 | |
| 2650 | elt = Fcar (tail); |
| 2651 | parms[i] = Fcar (elt); |
| 2652 | values[i] = Fcdr (elt); |
| 2653 | i++; |
| 2654 | } |
| 2655 | /* TAIL and ALIST are not used again below here. */ |
| 2656 | alist = tail = Qnil; |
| 2657 | |
| 2658 | GCPRO2 (*parms, *values); |
| 2659 | gcpro1.nvars = i; |
| 2660 | gcpro2.nvars = i; |
| 2661 | |
| 2662 | /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP, |
| 2663 | because their values appear in VALUES and strings are not valid. */ |
| 2664 | top = left = Qunbound; |
| 2665 | icon_left = icon_top = Qunbound; |
| 2666 | |
| 2667 | /* Provide default values for HEIGHT and WIDTH. */ |
| 2668 | if (FRAME_NEW_WIDTH (f)) |
| 2669 | width = FRAME_NEW_WIDTH (f); |
| 2670 | else |
| 2671 | width = FRAME_WIDTH (f); |
| 2672 | |
| 2673 | if (FRAME_NEW_HEIGHT (f)) |
| 2674 | height = FRAME_NEW_HEIGHT (f); |
| 2675 | else |
| 2676 | height = FRAME_HEIGHT (f); |
| 2677 | |
| 2678 | /* Process foreground_color and background_color before anything else. |
| 2679 | They are independent of other properties, but other properties (e.g., |
| 2680 | cursor_color) are dependent upon them. */ |
| 2681 | /* Process default font as well, since fringe widths depends on it. */ |
| 2682 | /* Also, process fullscreen, width and height depend upon that */ |
| 2683 | for (p = 0; p < i; p++) |
| 2684 | { |
| 2685 | Lisp_Object prop, val; |
| 2686 | |
| 2687 | prop = parms[p]; |
| 2688 | val = values[p]; |
| 2689 | if (EQ (prop, Qforeground_color) |
| 2690 | || EQ (prop, Qbackground_color) |
| 2691 | || EQ (prop, Qfont) |
| 2692 | || EQ (prop, Qfullscreen)) |
| 2693 | { |
| 2694 | register Lisp_Object param_index, old_value; |
| 2695 | |
| 2696 | old_value = get_frame_param (f, prop); |
| 2697 | fullscreen_is_being_set |= EQ (prop, Qfullscreen); |
| 2698 | |
| 2699 | if (NILP (Fequal (val, old_value))) |
| 2700 | { |
| 2701 | store_frame_param (f, prop, val); |
| 2702 | |
| 2703 | param_index = Fget (prop, Qx_frame_parameter); |
| 2704 | if (NATNUMP (param_index) |
| 2705 | && (XFASTINT (param_index) |
| 2706 | < sizeof (frame_parms)/sizeof (frame_parms[0])) |
| 2707 | && rif->frame_parm_handlers[XINT (param_index)]) |
| 2708 | (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); |
| 2709 | } |
| 2710 | } |
| 2711 | } |
| 2712 | |
| 2713 | /* Now process them in reverse of specified order. */ |
| 2714 | for (i--; i >= 0; i--) |
| 2715 | { |
| 2716 | Lisp_Object prop, val; |
| 2717 | |
| 2718 | prop = parms[i]; |
| 2719 | val = values[i]; |
| 2720 | |
| 2721 | if (EQ (prop, Qwidth) && NUMBERP (val)) |
| 2722 | width = XFASTINT (val); |
| 2723 | else if (EQ (prop, Qheight) && NUMBERP (val)) |
| 2724 | height = XFASTINT (val); |
| 2725 | else if (EQ (prop, Qtop)) |
| 2726 | top = val; |
| 2727 | else if (EQ (prop, Qleft)) |
| 2728 | left = val; |
| 2729 | else if (EQ (prop, Qicon_top)) |
| 2730 | icon_top = val; |
| 2731 | else if (EQ (prop, Qicon_left)) |
| 2732 | icon_left = val; |
| 2733 | else if (EQ (prop, Qforeground_color) |
| 2734 | || EQ (prop, Qbackground_color) |
| 2735 | || EQ (prop, Qfont) |
| 2736 | || EQ (prop, Qfullscreen)) |
| 2737 | /* Processed above. */ |
| 2738 | continue; |
| 2739 | else |
| 2740 | { |
| 2741 | register Lisp_Object param_index, old_value; |
| 2742 | |
| 2743 | old_value = get_frame_param (f, prop); |
| 2744 | |
| 2745 | store_frame_param (f, prop, val); |
| 2746 | |
| 2747 | param_index = Fget (prop, Qx_frame_parameter); |
| 2748 | if (NATNUMP (param_index) |
| 2749 | && (XFASTINT (param_index) |
| 2750 | < sizeof (frame_parms)/sizeof (frame_parms[0])) |
| 2751 | && rif->frame_parm_handlers[XINT (param_index)]) |
| 2752 | (*(rif->frame_parm_handlers[XINT (param_index)])) (f, val, old_value); |
| 2753 | } |
| 2754 | } |
| 2755 | |
| 2756 | /* Don't die if just one of these was set. */ |
| 2757 | if (EQ (left, Qunbound)) |
| 2758 | { |
| 2759 | left_no_change = 1; |
| 2760 | if (FRAME_X_OUTPUT (f)->left_pos < 0) |
| 2761 | left = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->left_pos), Qnil)); |
| 2762 | else |
| 2763 | XSETINT (left, FRAME_X_OUTPUT (f)->left_pos); |
| 2764 | } |
| 2765 | if (EQ (top, Qunbound)) |
| 2766 | { |
| 2767 | top_no_change = 1; |
| 2768 | if (FRAME_X_OUTPUT (f)->top_pos < 0) |
| 2769 | top = Fcons (Qplus, Fcons (make_number (FRAME_X_OUTPUT (f)->top_pos), Qnil)); |
| 2770 | else |
| 2771 | XSETINT (top, FRAME_X_OUTPUT (f)->top_pos); |
| 2772 | } |
| 2773 | |
| 2774 | /* If one of the icon positions was not set, preserve or default it. */ |
| 2775 | if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left)) |
| 2776 | { |
| 2777 | icon_left_no_change = 1; |
| 2778 | icon_left = Fcdr (Fassq (Qicon_left, f->param_alist)); |
| 2779 | if (NILP (icon_left)) |
| 2780 | XSETINT (icon_left, 0); |
| 2781 | } |
| 2782 | if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top)) |
| 2783 | { |
| 2784 | icon_top_no_change = 1; |
| 2785 | icon_top = Fcdr (Fassq (Qicon_top, f->param_alist)); |
| 2786 | if (NILP (icon_top)) |
| 2787 | XSETINT (icon_top, 0); |
| 2788 | } |
| 2789 | |
| 2790 | #ifndef HAVE_CARBON |
| 2791 | /* MAC_TODO: fullscreen */ |
| 2792 | if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set) |
| 2793 | { |
| 2794 | /* If the frame is visible already and the fullscreen parameter is |
| 2795 | being set, it is too late to set WM manager hints to specify |
| 2796 | size and position. |
| 2797 | Here we first get the width, height and position that applies to |
| 2798 | fullscreen. We then move the frame to the appropriate |
| 2799 | position. Resize of the frame is taken care of in the code after |
| 2800 | this if-statement. */ |
| 2801 | int new_left, new_top; |
| 2802 | |
| 2803 | x_fullscreen_adjust (f, &width, &height, &new_top, &new_left); |
| 2804 | x_fullscreen_move (f, new_top, new_left); |
| 2805 | } |
| 2806 | #endif |
| 2807 | |
| 2808 | /* Don't set these parameters unless they've been explicitly |
| 2809 | specified. The window might be mapped or resized while we're in |
| 2810 | this function, and we don't want to override that unless the lisp |
| 2811 | code has asked for it. |
| 2812 | |
| 2813 | Don't set these parameters unless they actually differ from the |
| 2814 | window's current parameters; the window may not actually exist |
| 2815 | yet. */ |
| 2816 | { |
| 2817 | Lisp_Object frame; |
| 2818 | |
| 2819 | check_frame_size (f, &height, &width); |
| 2820 | |
| 2821 | XSETFRAME (frame, f); |
| 2822 | |
| 2823 | if (width != FRAME_WIDTH (f) |
| 2824 | || height != FRAME_HEIGHT (f) |
| 2825 | || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f)) |
| 2826 | Fset_frame_size (frame, make_number (width), make_number (height)); |
| 2827 | |
| 2828 | if ((!NILP (left) || !NILP (top)) |
| 2829 | && ! (left_no_change && top_no_change) |
| 2830 | && ! (NUMBERP (left) && XINT (left) == FRAME_X_OUTPUT (f)->left_pos |
| 2831 | && NUMBERP (top) && XINT (top) == FRAME_X_OUTPUT (f)->top_pos)) |
| 2832 | { |
| 2833 | int leftpos = 0; |
| 2834 | int toppos = 0; |
| 2835 | |
| 2836 | /* Record the signs. */ |
| 2837 | FRAME_X_OUTPUT (f)->size_hint_flags &= ~ (XNegative | YNegative); |
| 2838 | if (EQ (left, Qminus)) |
| 2839 | FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative; |
| 2840 | else if (INTEGERP (left)) |
| 2841 | { |
| 2842 | leftpos = XINT (left); |
| 2843 | if (leftpos < 0) |
| 2844 | FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative; |
| 2845 | } |
| 2846 | else if (CONSP (left) && EQ (XCAR (left), Qminus) |
| 2847 | && CONSP (XCDR (left)) |
| 2848 | && INTEGERP (XCAR (XCDR (left)))) |
| 2849 | { |
| 2850 | leftpos = - XINT (XCAR (XCDR (left))); |
| 2851 | FRAME_X_OUTPUT (f)->size_hint_flags |= XNegative; |
| 2852 | } |
| 2853 | else if (CONSP (left) && EQ (XCAR (left), Qplus) |
| 2854 | && CONSP (XCDR (left)) |
| 2855 | && INTEGERP (XCAR (XCDR (left)))) |
| 2856 | { |
| 2857 | leftpos = XINT (XCAR (XCDR (left))); |
| 2858 | } |
| 2859 | |
| 2860 | if (EQ (top, Qminus)) |
| 2861 | FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative; |
| 2862 | else if (INTEGERP (top)) |
| 2863 | { |
| 2864 | toppos = XINT (top); |
| 2865 | if (toppos < 0) |
| 2866 | FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative; |
| 2867 | } |
| 2868 | else if (CONSP (top) && EQ (XCAR (top), Qminus) |
| 2869 | && CONSP (XCDR (top)) |
| 2870 | && INTEGERP (XCAR (XCDR (top)))) |
| 2871 | { |
| 2872 | toppos = - XINT (XCAR (XCDR (top))); |
| 2873 | FRAME_X_OUTPUT (f)->size_hint_flags |= YNegative; |
| 2874 | } |
| 2875 | else if (CONSP (top) && EQ (XCAR (top), Qplus) |
| 2876 | && CONSP (XCDR (top)) |
| 2877 | && INTEGERP (XCAR (XCDR (top)))) |
| 2878 | { |
| 2879 | toppos = XINT (XCAR (XCDR (top))); |
| 2880 | } |
| 2881 | |
| 2882 | |
| 2883 | /* Store the numeric value of the position. */ |
| 2884 | FRAME_X_OUTPUT (f)->top_pos = toppos; |
| 2885 | FRAME_X_OUTPUT (f)->left_pos = leftpos; |
| 2886 | |
| 2887 | FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity; |
| 2888 | |
| 2889 | /* Actually set that position, and convert to absolute. */ |
| 2890 | x_set_offset (f, leftpos, toppos, -1); |
| 2891 | } |
| 2892 | |
| 2893 | if ((!NILP (icon_left) || !NILP (icon_top)) |
| 2894 | && ! (icon_left_no_change && icon_top_no_change)) |
| 2895 | x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top)); |
| 2896 | } |
| 2897 | |
| 2898 | UNGCPRO; |
| 2899 | } |
| 2900 | |
| 2901 | |
| 2902 | /* Insert a description of internally-recorded parameters of frame X |
| 2903 | into the parameter alist *ALISTPTR that is to be given to the user. |
| 2904 | Only parameters that are specific to the X window system |
| 2905 | and whose values are not correctly recorded in the frame's |
| 2906 | param_alist need to be considered here. */ |
| 2907 | |
| 2908 | void |
| 2909 | x_report_frame_params (f, alistptr) |
| 2910 | struct frame *f; |
| 2911 | Lisp_Object *alistptr; |
| 2912 | { |
| 2913 | char buf[16]; |
| 2914 | Lisp_Object tem; |
| 2915 | |
| 2916 | /* Represent negative positions (off the top or left screen edge) |
| 2917 | in a way that Fmodify_frame_parameters will understand correctly. */ |
| 2918 | XSETINT (tem, FRAME_X_OUTPUT (f)->left_pos); |
| 2919 | if (FRAME_X_OUTPUT (f)->left_pos >= 0) |
| 2920 | store_in_alist (alistptr, Qleft, tem); |
| 2921 | else |
| 2922 | store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil))); |
| 2923 | |
| 2924 | XSETINT (tem, FRAME_X_OUTPUT (f)->top_pos); |
| 2925 | if (FRAME_X_OUTPUT (f)->top_pos >= 0) |
| 2926 | store_in_alist (alistptr, Qtop, tem); |
| 2927 | else |
| 2928 | store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil))); |
| 2929 | |
| 2930 | store_in_alist (alistptr, Qborder_width, |
| 2931 | make_number (FRAME_X_OUTPUT (f)->border_width)); |
| 2932 | store_in_alist (alistptr, Qinternal_border_width, |
| 2933 | make_number (FRAME_X_OUTPUT (f)->internal_border_width)); |
| 2934 | store_in_alist (alistptr, Qleft_fringe, |
| 2935 | make_number (FRAME_X_OUTPUT (f)->left_fringe_width)); |
| 2936 | store_in_alist (alistptr, Qright_fringe, |
| 2937 | make_number (FRAME_X_OUTPUT (f)->right_fringe_width)); |
| 2938 | store_in_alist (alistptr, Qscroll_bar_width, |
| 2939 | (! FRAME_HAS_VERTICAL_SCROLL_BARS (f) |
| 2940 | ? make_number (0) |
| 2941 | : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0 |
| 2942 | ? make_number (FRAME_SCROLL_BAR_PIXEL_WIDTH (f)) |
| 2943 | /* nil means "use default width" |
| 2944 | for non-toolkit scroll bar. |
| 2945 | ruler-mode.el depends on this. */ |
| 2946 | : Qnil)); |
| 2947 | sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f)); |
| 2948 | store_in_alist (alistptr, Qwindow_id, |
| 2949 | build_string (buf)); |
| 2950 | #ifdef HAVE_X_WINDOWS |
| 2951 | #ifdef USE_X_TOOLKIT |
| 2952 | /* Tooltip frame may not have this widget. */ |
| 2953 | if (FRAME_X_OUTPUT (f)->widget) |
| 2954 | #endif |
| 2955 | sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f)); |
| 2956 | store_in_alist (alistptr, Qouter_window_id, |
| 2957 | build_string (buf)); |
| 2958 | #endif |
| 2959 | store_in_alist (alistptr, Qicon_name, f->icon_name); |
| 2960 | FRAME_SAMPLE_VISIBILITY (f); |
| 2961 | store_in_alist (alistptr, Qvisibility, |
| 2962 | (FRAME_VISIBLE_P (f) ? Qt |
| 2963 | : FRAME_ICONIFIED_P (f) ? Qicon : Qnil)); |
| 2964 | store_in_alist (alistptr, Qdisplay, |
| 2965 | XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element)); |
| 2966 | |
| 2967 | if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window) |
| 2968 | tem = Qnil; |
| 2969 | else |
| 2970 | XSETFASTINT (tem, FRAME_X_OUTPUT (f)->parent_desc); |
| 2971 | store_in_alist (alistptr, Qparent_id, tem); |
| 2972 | } |
| 2973 | |
| 2974 | |
| 2975 | /* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is |
| 2976 | the previous value of that parameter, NEW_VALUE is the new value. */ |
| 2977 | |
| 2978 | void |
| 2979 | x_set_fullscreen (f, new_value, old_value) |
| 2980 | struct frame *f; |
| 2981 | Lisp_Object new_value, old_value; |
| 2982 | { |
| 2983 | #ifndef HAVE_CARBON |
| 2984 | if (NILP (new_value)) |
| 2985 | FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_NONE; |
| 2986 | else if (EQ (new_value, Qfullboth)) |
| 2987 | FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_BOTH; |
| 2988 | else if (EQ (new_value, Qfullwidth)) |
| 2989 | FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_WIDTH; |
| 2990 | else if (EQ (new_value, Qfullheight)) |
| 2991 | FRAME_X_OUTPUT (f)->want_fullscreen = FULLSCREEN_HEIGHT; |
| 2992 | #endif |
| 2993 | } |
| 2994 | |
| 2995 | |
| 2996 | /* Change the `line-spacing' frame parameter of frame F. OLD_VALUE is |
| 2997 | the previous value of that parameter, NEW_VALUE is the new value. */ |
| 2998 | |
| 2999 | void |
| 3000 | x_set_line_spacing (f, new_value, old_value) |
| 3001 | struct frame *f; |
| 3002 | Lisp_Object new_value, old_value; |
| 3003 | { |
| 3004 | if (NILP (new_value)) |
| 3005 | f->extra_line_spacing = 0; |
| 3006 | else if (NATNUMP (new_value)) |
| 3007 | f->extra_line_spacing = XFASTINT (new_value); |
| 3008 | else |
| 3009 | Fsignal (Qerror, Fcons (build_string ("Invalid line-spacing"), |
| 3010 | Fcons (new_value, Qnil))); |
| 3011 | if (FRAME_VISIBLE_P (f)) |
| 3012 | redraw_frame (f); |
| 3013 | } |
| 3014 | |
| 3015 | |
| 3016 | /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is |
| 3017 | the previous value of that parameter, NEW_VALUE is the new value. */ |
| 3018 | |
| 3019 | void |
| 3020 | x_set_screen_gamma (f, new_value, old_value) |
| 3021 | struct frame *f; |
| 3022 | Lisp_Object new_value, old_value; |
| 3023 | { |
| 3024 | if (NILP (new_value)) |
| 3025 | f->gamma = 0; |
| 3026 | else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0) |
| 3027 | /* The value 0.4545 is the normal viewing gamma. */ |
| 3028 | f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value)); |
| 3029 | else |
| 3030 | Fsignal (Qerror, Fcons (build_string ("Invalid screen-gamma"), |
| 3031 | Fcons (new_value, Qnil))); |
| 3032 | |
| 3033 | clear_face_cache (0); |
| 3034 | } |
| 3035 | |
| 3036 | |
| 3037 | void |
| 3038 | x_set_font (f, arg, oldval) |
| 3039 | struct frame *f; |
| 3040 | Lisp_Object arg, oldval; |
| 3041 | { |
| 3042 | Lisp_Object result; |
| 3043 | Lisp_Object fontset_name; |
| 3044 | Lisp_Object frame; |
| 3045 | int old_fontset = FRAME_FONTSET(f); |
| 3046 | |
| 3047 | CHECK_STRING (arg); |
| 3048 | |
| 3049 | fontset_name = Fquery_fontset (arg, Qnil); |
| 3050 | |
| 3051 | BLOCK_INPUT; |
| 3052 | result = (STRINGP (fontset_name) |
| 3053 | ? x_new_fontset (f, SDATA (fontset_name)) |
| 3054 | : x_new_font (f, SDATA (arg))); |
| 3055 | UNBLOCK_INPUT; |
| 3056 | |
| 3057 | if (EQ (result, Qnil)) |
| 3058 | error ("Font `%s' is not defined", SDATA (arg)); |
| 3059 | else if (EQ (result, Qt)) |
| 3060 | error ("The characters of the given font have varying widths"); |
| 3061 | else if (STRINGP (result)) |
| 3062 | { |
| 3063 | if (STRINGP (fontset_name)) |
| 3064 | { |
| 3065 | /* Fontset names are built from ASCII font names, so the |
| 3066 | names may be equal despite there was a change. */ |
| 3067 | if (old_fontset == FRAME_FONTSET (f)) |
| 3068 | return; |
| 3069 | } |
| 3070 | else if (!NILP (Fequal (result, oldval))) |
| 3071 | return; |
| 3072 | |
| 3073 | store_frame_param (f, Qfont, result); |
| 3074 | recompute_basic_faces (f); |
| 3075 | } |
| 3076 | else |
| 3077 | abort (); |
| 3078 | |
| 3079 | do_pending_window_change (0); |
| 3080 | |
| 3081 | /* Don't call `face-set-after-frame-default' when faces haven't been |
| 3082 | initialized yet. This is the case when called from |
| 3083 | Fx_create_frame. In that case, the X widget or window doesn't |
| 3084 | exist either, and we can end up in x_report_frame_params with a |
| 3085 | null widget which gives a segfault. */ |
| 3086 | if (FRAME_FACE_CACHE (f)) |
| 3087 | { |
| 3088 | XSETFRAME (frame, f); |
| 3089 | call1 (Qface_set_after_frame_default, frame); |
| 3090 | } |
| 3091 | } |
| 3092 | |
| 3093 | |
| 3094 | void |
| 3095 | x_set_fringe_width (f, new_value, old_value) |
| 3096 | struct frame *f; |
| 3097 | Lisp_Object new_value, old_value; |
| 3098 | { |
| 3099 | compute_fringe_widths (f, 1); |
| 3100 | } |
| 3101 | |
| 3102 | void |
| 3103 | x_set_border_width (f, arg, oldval) |
| 3104 | struct frame *f; |
| 3105 | Lisp_Object arg, oldval; |
| 3106 | { |
| 3107 | CHECK_NUMBER (arg); |
| 3108 | |
| 3109 | if (XINT (arg) == FRAME_X_OUTPUT (f)->border_width) |
| 3110 | return; |
| 3111 | |
| 3112 | #ifndef HAVE_CARBON |
| 3113 | if (FRAME_X_WINDOW (f) != 0) |
| 3114 | error ("Cannot change the border width of a window"); |
| 3115 | #endif /* MAC_TODO */ |
| 3116 | |
| 3117 | FRAME_X_OUTPUT (f)->border_width = XINT (arg); |
| 3118 | } |
| 3119 | |
| 3120 | void |
| 3121 | x_set_internal_border_width (f, arg, oldval) |
| 3122 | struct frame *f; |
| 3123 | Lisp_Object arg, oldval; |
| 3124 | { |
| 3125 | int old = FRAME_X_OUTPUT (f)->internal_border_width; |
| 3126 | |
| 3127 | CHECK_NUMBER (arg); |
| 3128 | FRAME_X_OUTPUT (f)->internal_border_width = XINT (arg); |
| 3129 | if (FRAME_X_OUTPUT (f)->internal_border_width < 0) |
| 3130 | FRAME_X_OUTPUT (f)->internal_border_width = 0; |
| 3131 | |
| 3132 | #ifdef USE_X_TOOLKIT |
| 3133 | if (FRAME_X_OUTPUT (f)->edit_widget) |
| 3134 | widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget); |
| 3135 | #endif |
| 3136 | |
| 3137 | if (FRAME_X_OUTPUT (f)->internal_border_width == old) |
| 3138 | return; |
| 3139 | |
| 3140 | if (FRAME_X_WINDOW (f) != 0) |
| 3141 | { |
| 3142 | x_set_window_size (f, 0, f->width, f->height); |
| 3143 | SET_FRAME_GARBAGED (f); |
| 3144 | do_pending_window_change (0); |
| 3145 | } |
| 3146 | else |
| 3147 | SET_FRAME_GARBAGED (f); |
| 3148 | } |
| 3149 | |
| 3150 | void |
| 3151 | x_set_visibility (f, value, oldval) |
| 3152 | struct frame *f; |
| 3153 | Lisp_Object value, oldval; |
| 3154 | { |
| 3155 | Lisp_Object frame; |
| 3156 | XSETFRAME (frame, f); |
| 3157 | |
| 3158 | if (NILP (value)) |
| 3159 | Fmake_frame_invisible (frame, Qt); |
| 3160 | else if (EQ (value, Qicon)) |
| 3161 | Ficonify_frame (frame); |
| 3162 | else |
| 3163 | Fmake_frame_visible (frame); |
| 3164 | } |
| 3165 | |
| 3166 | void |
| 3167 | x_set_autoraise (f, arg, oldval) |
| 3168 | struct frame *f; |
| 3169 | Lisp_Object arg, oldval; |
| 3170 | { |
| 3171 | f->auto_raise = !EQ (Qnil, arg); |
| 3172 | } |
| 3173 | |
| 3174 | void |
| 3175 | x_set_autolower (f, arg, oldval) |
| 3176 | struct frame *f; |
| 3177 | Lisp_Object arg, oldval; |
| 3178 | { |
| 3179 | f->auto_lower = !EQ (Qnil, arg); |
| 3180 | } |
| 3181 | |
| 3182 | void |
| 3183 | x_set_unsplittable (f, arg, oldval) |
| 3184 | struct frame *f; |
| 3185 | Lisp_Object arg, oldval; |
| 3186 | { |
| 3187 | f->no_split = !NILP (arg); |
| 3188 | } |
| 3189 | |
| 3190 | void |
| 3191 | x_set_vertical_scroll_bars (f, arg, oldval) |
| 3192 | struct frame *f; |
| 3193 | Lisp_Object arg, oldval; |
| 3194 | { |
| 3195 | if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f)) |
| 3196 | || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) |
| 3197 | || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
| 3198 | || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f))) |
| 3199 | { |
| 3200 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) |
| 3201 | = (NILP (arg) |
| 3202 | ? vertical_scroll_bar_none |
| 3203 | : EQ (Qleft, arg) |
| 3204 | ? vertical_scroll_bar_left |
| 3205 | : EQ (Qright, arg) |
| 3206 | ? vertical_scroll_bar_right |
| 3207 | #ifdef HAVE_NTGUI |
| 3208 | /* MS-Windows has scroll bars on the right by default. */ |
| 3209 | : vertical_scroll_bar_right |
| 3210 | #else |
| 3211 | : vertical_scroll_bar_left |
| 3212 | #endif |
| 3213 | ); |
| 3214 | |
| 3215 | /* We set this parameter before creating the X window for the |
| 3216 | frame, so we can get the geometry right from the start. |
| 3217 | However, if the window hasn't been created yet, we shouldn't |
| 3218 | call x_set_window_size. */ |
| 3219 | if (FRAME_X_WINDOW (f)) |
| 3220 | x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); |
| 3221 | do_pending_window_change (0); |
| 3222 | } |
| 3223 | } |
| 3224 | |
| 3225 | void |
| 3226 | x_set_scroll_bar_width (f, arg, oldval) |
| 3227 | struct frame *f; |
| 3228 | Lisp_Object arg, oldval; |
| 3229 | { |
| 3230 | int wid = FONT_WIDTH (FRAME_FONT (f)); |
| 3231 | |
| 3232 | if (NILP (arg)) |
| 3233 | { |
| 3234 | x_set_scroll_bar_default_width (f); |
| 3235 | |
| 3236 | if (FRAME_X_WINDOW (f)) |
| 3237 | x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); |
| 3238 | do_pending_window_change (0); |
| 3239 | } |
| 3240 | else if (INTEGERP (arg) && XINT (arg) > 0 |
| 3241 | && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f)) |
| 3242 | { |
| 3243 | if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM) |
| 3244 | XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1); |
| 3245 | |
| 3246 | FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg); |
| 3247 | FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid; |
| 3248 | if (FRAME_X_WINDOW (f)) |
| 3249 | x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); |
| 3250 | do_pending_window_change (0); |
| 3251 | } |
| 3252 | |
| 3253 | change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0); |
| 3254 | XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0; |
| 3255 | XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; |
| 3256 | } |
| 3257 | |
| 3258 | |
| 3259 | |
| 3260 | /* Return non-nil if frame F wants a bitmap icon. */ |
| 3261 | |
| 3262 | Lisp_Object |
| 3263 | x_icon_type (f) |
| 3264 | FRAME_PTR f; |
| 3265 | { |
| 3266 | Lisp_Object tem; |
| 3267 | |
| 3268 | tem = assq_no_quit (Qicon_type, f->param_alist); |
| 3269 | if (CONSP (tem)) |
| 3270 | return XCDR (tem); |
| 3271 | else |
| 3272 | return Qnil; |
| 3273 | } |
| 3274 | |
| 3275 | \f |
| 3276 | /* Subroutines of creating an X frame. */ |
| 3277 | |
| 3278 | /* Make sure that Vx_resource_name is set to a reasonable value. |
| 3279 | Fix it up, or set it to `emacs' if it is too hopeless. */ |
| 3280 | |
| 3281 | void |
| 3282 | validate_x_resource_name () |
| 3283 | { |
| 3284 | int len = 0; |
| 3285 | /* Number of valid characters in the resource name. */ |
| 3286 | int good_count = 0; |
| 3287 | /* Number of invalid characters in the resource name. */ |
| 3288 | int bad_count = 0; |
| 3289 | Lisp_Object new; |
| 3290 | int i; |
| 3291 | |
| 3292 | if (!STRINGP (Vx_resource_class)) |
| 3293 | Vx_resource_class = build_string (EMACS_CLASS); |
| 3294 | |
| 3295 | if (STRINGP (Vx_resource_name)) |
| 3296 | { |
| 3297 | unsigned char *p = SDATA (Vx_resource_name); |
| 3298 | int i; |
| 3299 | |
| 3300 | len = SBYTES (Vx_resource_name); |
| 3301 | |
| 3302 | /* Only letters, digits, - and _ are valid in resource names. |
| 3303 | Count the valid characters and count the invalid ones. */ |
| 3304 | for (i = 0; i < len; i++) |
| 3305 | { |
| 3306 | int c = p[i]; |
| 3307 | if (! ((c >= 'a' && c <= 'z') |
| 3308 | || (c >= 'A' && c <= 'Z') |
| 3309 | || (c >= '0' && c <= '9') |
| 3310 | || c == '-' || c == '_')) |
| 3311 | bad_count++; |
| 3312 | else |
| 3313 | good_count++; |
| 3314 | } |
| 3315 | } |
| 3316 | else |
| 3317 | /* Not a string => completely invalid. */ |
| 3318 | bad_count = 5, good_count = 0; |
| 3319 | |
| 3320 | /* If name is valid already, return. */ |
| 3321 | if (bad_count == 0) |
| 3322 | return; |
| 3323 | |
| 3324 | /* If name is entirely invalid, or nearly so, use `emacs'. */ |
| 3325 | if (good_count == 0 |
| 3326 | || (good_count == 1 && bad_count > 0)) |
| 3327 | { |
| 3328 | Vx_resource_name = build_string ("emacs"); |
| 3329 | return; |
| 3330 | } |
| 3331 | |
| 3332 | /* Name is partly valid. Copy it and replace the invalid characters |
| 3333 | with underscores. */ |
| 3334 | |
| 3335 | Vx_resource_name = new = Fcopy_sequence (Vx_resource_name); |
| 3336 | |
| 3337 | for (i = 0; i < len; i++) |
| 3338 | { |
| 3339 | int c = SREF (new, i); |
| 3340 | if (! ((c >= 'a' && c <= 'z') |
| 3341 | || (c >= 'A' && c <= 'Z') |
| 3342 | || (c >= '0' && c <= '9') |
| 3343 | || c == '-' || c == '_')) |
| 3344 | SSET (new, i, '_'); |
| 3345 | } |
| 3346 | } |
| 3347 | |
| 3348 | |
| 3349 | extern char *x_get_string_resource P_ ((XrmDatabase, char *, char *)); |
| 3350 | extern Display_Info *check_x_display_info P_ ((Lisp_Object)); |
| 3351 | |
| 3352 | |
| 3353 | /* Get specified attribute from resource database RDB. |
| 3354 | See Fx_get_resource below for other parameters. */ |
| 3355 | |
| 3356 | static Lisp_Object |
| 3357 | xrdb_get_resource (rdb, attribute, class, component, subclass) |
| 3358 | XrmDatabase rdb; |
| 3359 | Lisp_Object attribute, class, component, subclass; |
| 3360 | { |
| 3361 | register char *value; |
| 3362 | char *name_key; |
| 3363 | char *class_key; |
| 3364 | |
| 3365 | CHECK_STRING (attribute); |
| 3366 | CHECK_STRING (class); |
| 3367 | |
| 3368 | if (!NILP (component)) |
| 3369 | CHECK_STRING (component); |
| 3370 | if (!NILP (subclass)) |
| 3371 | CHECK_STRING (subclass); |
| 3372 | if (NILP (component) != NILP (subclass)) |
| 3373 | error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither"); |
| 3374 | |
| 3375 | validate_x_resource_name (); |
| 3376 | |
| 3377 | /* Allocate space for the components, the dots which separate them, |
| 3378 | and the final '\0'. Make them big enough for the worst case. */ |
| 3379 | name_key = (char *) alloca (SBYTES (Vx_resource_name) |
| 3380 | + (STRINGP (component) |
| 3381 | ? SBYTES (component) : 0) |
| 3382 | + SBYTES (attribute) |
| 3383 | + 3); |
| 3384 | |
| 3385 | class_key = (char *) alloca (SBYTES (Vx_resource_class) |
| 3386 | + SBYTES (class) |
| 3387 | + (STRINGP (subclass) |
| 3388 | ? SBYTES (subclass) : 0) |
| 3389 | + 3); |
| 3390 | |
| 3391 | /* Start with emacs.FRAMENAME for the name (the specific one) |
| 3392 | and with `Emacs' for the class key (the general one). */ |
| 3393 | strcpy (name_key, SDATA (Vx_resource_name)); |
| 3394 | strcpy (class_key, SDATA (Vx_resource_class)); |
| 3395 | |
| 3396 | strcat (class_key, "."); |
| 3397 | strcat (class_key, SDATA (class)); |
| 3398 | |
| 3399 | if (!NILP (component)) |
| 3400 | { |
| 3401 | strcat (class_key, "."); |
| 3402 | strcat (class_key, SDATA (subclass)); |
| 3403 | |
| 3404 | strcat (name_key, "."); |
| 3405 | strcat (name_key, SDATA (component)); |
| 3406 | } |
| 3407 | |
| 3408 | strcat (name_key, "."); |
| 3409 | strcat (name_key, SDATA (attribute)); |
| 3410 | |
| 3411 | value = x_get_string_resource (rdb, name_key, class_key); |
| 3412 | |
| 3413 | if (value != (char *) 0) |
| 3414 | return build_string (value); |
| 3415 | else |
| 3416 | return Qnil; |
| 3417 | } |
| 3418 | |
| 3419 | |
| 3420 | DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0, |
| 3421 | doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database. |
| 3422 | This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the |
| 3423 | class, where INSTANCE is the name under which Emacs was invoked, or |
| 3424 | the name specified by the `-name' or `-rn' command-line arguments. |
| 3425 | |
| 3426 | The optional arguments COMPONENT and SUBCLASS add to the key and the |
| 3427 | class, respectively. You must specify both of them or neither. |
| 3428 | If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE' |
| 3429 | and the class is `Emacs.CLASS.SUBCLASS'. */) |
| 3430 | (attribute, class, component, subclass) |
| 3431 | Lisp_Object attribute, class, component, subclass; |
| 3432 | { |
| 3433 | #ifdef HAVE_X_WINDOWS |
| 3434 | check_x (); |
| 3435 | #endif |
| 3436 | |
| 3437 | return xrdb_get_resource (check_x_display_info (Qnil)->xrdb, |
| 3438 | attribute, class, component, subclass); |
| 3439 | } |
| 3440 | |
| 3441 | /* Get an X resource, like Fx_get_resource, but for display DPYINFO. */ |
| 3442 | |
| 3443 | Lisp_Object |
| 3444 | display_x_get_resource (dpyinfo, attribute, class, component, subclass) |
| 3445 | struct x_display_info *dpyinfo; |
| 3446 | Lisp_Object attribute, class, component, subclass; |
| 3447 | { |
| 3448 | return xrdb_get_resource (dpyinfo->xrdb, |
| 3449 | attribute, class, component, subclass); |
| 3450 | } |
| 3451 | |
| 3452 | /* Used when C code wants a resource value. */ |
| 3453 | |
| 3454 | char * |
| 3455 | x_get_resource_string (attribute, class) |
| 3456 | char *attribute, *class; |
| 3457 | { |
| 3458 | char *name_key; |
| 3459 | char *class_key; |
| 3460 | struct frame *sf = SELECTED_FRAME (); |
| 3461 | |
| 3462 | /* Allocate space for the components, the dots which separate them, |
| 3463 | and the final '\0'. */ |
| 3464 | name_key = (char *) alloca (SBYTES (Vinvocation_name) |
| 3465 | + strlen (attribute) + 2); |
| 3466 | class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) |
| 3467 | + strlen (class) + 2); |
| 3468 | |
| 3469 | sprintf (name_key, "%s.%s", SDATA (Vinvocation_name), attribute); |
| 3470 | sprintf (class_key, "%s.%s", EMACS_CLASS, class); |
| 3471 | |
| 3472 | return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb, |
| 3473 | name_key, class_key); |
| 3474 | } |
| 3475 | |
| 3476 | |
| 3477 | /* Return the value of parameter PARAM. |
| 3478 | |
| 3479 | First search ALIST, then Vdefault_frame_alist, then the X defaults |
| 3480 | database, using ATTRIBUTE as the attribute name and CLASS as its class. |
| 3481 | |
| 3482 | Convert the resource to the type specified by desired_type. |
| 3483 | |
| 3484 | If no default is specified, return Qunbound. If you call |
| 3485 | x_get_arg, make sure you deal with Qunbound in a reasonable way, |
| 3486 | and don't let it get stored in any Lisp-visible variables! */ |
| 3487 | |
| 3488 | Lisp_Object |
| 3489 | x_get_arg (dpyinfo, alist, param, attribute, class, type) |
| 3490 | Display_Info *dpyinfo; |
| 3491 | Lisp_Object alist, param; |
| 3492 | char *attribute; |
| 3493 | char *class; |
| 3494 | enum resource_types type; |
| 3495 | { |
| 3496 | register Lisp_Object tem; |
| 3497 | |
| 3498 | tem = Fassq (param, alist); |
| 3499 | if (EQ (tem, Qnil)) |
| 3500 | tem = Fassq (param, Vdefault_frame_alist); |
| 3501 | if (EQ (tem, Qnil)) |
| 3502 | { |
| 3503 | if (attribute) |
| 3504 | { |
| 3505 | tem = display_x_get_resource (dpyinfo, |
| 3506 | build_string (attribute), |
| 3507 | build_string (class), |
| 3508 | Qnil, Qnil); |
| 3509 | |
| 3510 | if (NILP (tem)) |
| 3511 | return Qunbound; |
| 3512 | |
| 3513 | switch (type) |
| 3514 | { |
| 3515 | case RES_TYPE_NUMBER: |
| 3516 | return make_number (atoi (SDATA (tem))); |
| 3517 | |
| 3518 | case RES_TYPE_FLOAT: |
| 3519 | return make_float (atof (SDATA (tem))); |
| 3520 | |
| 3521 | case RES_TYPE_BOOLEAN: |
| 3522 | tem = Fdowncase (tem); |
| 3523 | if (!strcmp (SDATA (tem), "on") |
| 3524 | || !strcmp (SDATA (tem), "true")) |
| 3525 | return Qt; |
| 3526 | else |
| 3527 | return Qnil; |
| 3528 | |
| 3529 | case RES_TYPE_STRING: |
| 3530 | return tem; |
| 3531 | |
| 3532 | case RES_TYPE_SYMBOL: |
| 3533 | /* As a special case, we map the values `true' and `on' |
| 3534 | to Qt, and `false' and `off' to Qnil. */ |
| 3535 | { |
| 3536 | Lisp_Object lower; |
| 3537 | lower = Fdowncase (tem); |
| 3538 | if (!strcmp (SDATA (lower), "on") |
| 3539 | || !strcmp (SDATA (lower), "true")) |
| 3540 | return Qt; |
| 3541 | else if (!strcmp (SDATA (lower), "off") |
| 3542 | || !strcmp (SDATA (lower), "false")) |
| 3543 | return Qnil; |
| 3544 | else |
| 3545 | return Fintern (tem, Qnil); |
| 3546 | } |
| 3547 | |
| 3548 | default: |
| 3549 | abort (); |
| 3550 | } |
| 3551 | } |
| 3552 | else |
| 3553 | return Qunbound; |
| 3554 | } |
| 3555 | return Fcdr (tem); |
| 3556 | } |
| 3557 | |
| 3558 | Lisp_Object |
| 3559 | x_frame_get_arg (f, alist, param, attribute, class, type) |
| 3560 | struct frame *f; |
| 3561 | Lisp_Object alist, param; |
| 3562 | char *attribute; |
| 3563 | char *class; |
| 3564 | enum resource_types type; |
| 3565 | { |
| 3566 | return x_get_arg (FRAME_X_DISPLAY_INFO (f), |
| 3567 | alist, param, attribute, class, type); |
| 3568 | } |
| 3569 | |
| 3570 | /* Like x_frame_get_arg, but also record the value in f->param_alist. */ |
| 3571 | |
| 3572 | Lisp_Object |
| 3573 | x_frame_get_and_record_arg (f, alist, param, attribute, class, type) |
| 3574 | struct frame *f; |
| 3575 | Lisp_Object alist, param; |
| 3576 | char *attribute; |
| 3577 | char *class; |
| 3578 | enum resource_types type; |
| 3579 | { |
| 3580 | Lisp_Object value; |
| 3581 | |
| 3582 | value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param, |
| 3583 | attribute, class, type); |
| 3584 | if (! NILP (value)) |
| 3585 | store_frame_param (f, param, value); |
| 3586 | |
| 3587 | return value; |
| 3588 | } |
| 3589 | |
| 3590 | |
| 3591 | /* Record in frame F the specified or default value according to ALIST |
| 3592 | of the parameter named PROP (a Lisp symbol). |
| 3593 | If no value is specified for PROP, look for an X default for XPROP |
| 3594 | on the frame named NAME. |
| 3595 | If that is not found either, use the value DEFLT. */ |
| 3596 | |
| 3597 | Lisp_Object |
| 3598 | x_default_parameter (f, alist, prop, deflt, xprop, xclass, type) |
| 3599 | struct frame *f; |
| 3600 | Lisp_Object alist; |
| 3601 | Lisp_Object prop; |
| 3602 | Lisp_Object deflt; |
| 3603 | char *xprop; |
| 3604 | char *xclass; |
| 3605 | enum resource_types type; |
| 3606 | { |
| 3607 | Lisp_Object tem; |
| 3608 | |
| 3609 | tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type); |
| 3610 | if (EQ (tem, Qunbound)) |
| 3611 | tem = deflt; |
| 3612 | x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil)); |
| 3613 | return tem; |
| 3614 | } |
| 3615 | |
| 3616 | |
| 3617 | |
| 3618 | \f |
| 3619 | DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0, |
| 3620 | doc: /* Parse an X-style geometry string STRING. |
| 3621 | Returns an alist of the form ((top . TOP), (left . LEFT) ... ). |
| 3622 | The properties returned may include `top', `left', `height', and `width'. |
| 3623 | The value of `left' or `top' may be an integer, |
| 3624 | or a list (+ N) meaning N pixels relative to top/left corner, |
| 3625 | or a list (- N) meaning -N pixels relative to bottom/right corner. */) |
| 3626 | (string) |
| 3627 | Lisp_Object string; |
| 3628 | { |
| 3629 | int geometry, x, y; |
| 3630 | unsigned int width, height; |
| 3631 | Lisp_Object result; |
| 3632 | |
| 3633 | CHECK_STRING (string); |
| 3634 | |
| 3635 | geometry = XParseGeometry ((char *) SDATA (string), |
| 3636 | &x, &y, &width, &height); |
| 3637 | |
| 3638 | #if 0 |
| 3639 | if (!!(geometry & XValue) != !!(geometry & YValue)) |
| 3640 | error ("Must specify both x and y position, or neither"); |
| 3641 | #endif |
| 3642 | |
| 3643 | result = Qnil; |
| 3644 | if (geometry & XValue) |
| 3645 | { |
| 3646 | Lisp_Object element; |
| 3647 | |
| 3648 | if (x >= 0 && (geometry & XNegative)) |
| 3649 | element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil))); |
| 3650 | else if (x < 0 && ! (geometry & XNegative)) |
| 3651 | element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil))); |
| 3652 | else |
| 3653 | element = Fcons (Qleft, make_number (x)); |
| 3654 | result = Fcons (element, result); |
| 3655 | } |
| 3656 | |
| 3657 | if (geometry & YValue) |
| 3658 | { |
| 3659 | Lisp_Object element; |
| 3660 | |
| 3661 | if (y >= 0 && (geometry & YNegative)) |
| 3662 | element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil))); |
| 3663 | else if (y < 0 && ! (geometry & YNegative)) |
| 3664 | element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil))); |
| 3665 | else |
| 3666 | element = Fcons (Qtop, make_number (y)); |
| 3667 | result = Fcons (element, result); |
| 3668 | } |
| 3669 | |
| 3670 | if (geometry & WidthValue) |
| 3671 | result = Fcons (Fcons (Qwidth, make_number (width)), result); |
| 3672 | if (geometry & HeightValue) |
| 3673 | result = Fcons (Fcons (Qheight, make_number (height)), result); |
| 3674 | |
| 3675 | return result; |
| 3676 | } |
| 3677 | |
| 3678 | /* Calculate the desired size and position of frame F. |
| 3679 | Return the flags saying which aspects were specified. |
| 3680 | |
| 3681 | Also set the win_gravity and size_hint_flags of F. |
| 3682 | |
| 3683 | Adjust height for toolbar if TOOLBAR_P is 1. |
| 3684 | |
| 3685 | This function does not make the coordinates positive. */ |
| 3686 | |
| 3687 | #define DEFAULT_ROWS 40 |
| 3688 | #define DEFAULT_COLS 80 |
| 3689 | |
| 3690 | int |
| 3691 | x_figure_window_size (f, parms, toolbar_p) |
| 3692 | struct frame *f; |
| 3693 | Lisp_Object parms; |
| 3694 | int toolbar_p; |
| 3695 | { |
| 3696 | register Lisp_Object tem0, tem1, tem2; |
| 3697 | long window_prompting = 0; |
| 3698 | Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 3699 | |
| 3700 | /* Default values if we fall through. |
| 3701 | Actually, if that happens we should get |
| 3702 | window manager prompting. */ |
| 3703 | SET_FRAME_WIDTH (f, DEFAULT_COLS); |
| 3704 | f->height = DEFAULT_ROWS; |
| 3705 | /* Window managers expect that if program-specified |
| 3706 | positions are not (0,0), they're intentional, not defaults. */ |
| 3707 | FRAME_X_OUTPUT (f)->top_pos = 0; |
| 3708 | FRAME_X_OUTPUT (f)->left_pos = 0; |
| 3709 | |
| 3710 | /* Ensure that old new_width and new_height will not override the |
| 3711 | values set here. */ |
| 3712 | /* ++KFS: This was specific to W32, but seems ok for all platforms */ |
| 3713 | FRAME_NEW_WIDTH (f) = 0; |
| 3714 | FRAME_NEW_HEIGHT (f) = 0; |
| 3715 | |
| 3716 | tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER); |
| 3717 | tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER); |
| 3718 | tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER); |
| 3719 | if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound)) |
| 3720 | { |
| 3721 | if (!EQ (tem0, Qunbound)) |
| 3722 | { |
| 3723 | CHECK_NUMBER (tem0); |
| 3724 | f->height = XINT (tem0); |
| 3725 | } |
| 3726 | if (!EQ (tem1, Qunbound)) |
| 3727 | { |
| 3728 | CHECK_NUMBER (tem1); |
| 3729 | SET_FRAME_WIDTH (f, XINT (tem1)); |
| 3730 | } |
| 3731 | if (!NILP (tem2) && !EQ (tem2, Qunbound)) |
| 3732 | window_prompting |= USSize; |
| 3733 | else |
| 3734 | window_prompting |= PSize; |
| 3735 | } |
| 3736 | |
| 3737 | FRAME_X_OUTPUT (f)->vertical_scroll_bar_extra |
| 3738 | = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f) |
| 3739 | ? 0 |
| 3740 | #ifndef HAVE_X_WINDOWS |
| 3741 | /* +KFS: This was specific for W32 and MAC.. why? */ |
| 3742 | : FRAME_SCROLL_BAR_PIXEL_WIDTH (f) > 0 |
| 3743 | ? FRAME_SCROLL_BAR_PIXEL_WIDTH (f) |
| 3744 | #endif |
| 3745 | : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (FRAME_X_OUTPUT (f)->font))); |
| 3746 | |
| 3747 | /* This used to be done _before_ calling x_figure_window_size, but |
| 3748 | since the height is reset here, this was really a no-op. I |
| 3749 | assume that moving it here does what Gerd intended (although he |
| 3750 | no longer can remember what that was... ++KFS, 2003-03-25. */ |
| 3751 | |
| 3752 | /* Add the tool-bar height to the initial frame height so that the |
| 3753 | user gets a text display area of the size he specified with -g or |
| 3754 | via .Xdefaults. Later changes of the tool-bar height don't |
| 3755 | change the frame size. This is done so that users can create |
| 3756 | tall Emacs frames without having to guess how tall the tool-bar |
| 3757 | will get. */ |
| 3758 | if (toolbar_p && FRAME_TOOL_BAR_LINES (f)) |
| 3759 | { |
| 3760 | int margin, relief, bar_height; |
| 3761 | |
| 3762 | relief = (tool_bar_button_relief >= 0 |
| 3763 | ? tool_bar_button_relief |
| 3764 | : DEFAULT_TOOL_BAR_BUTTON_RELIEF); |
| 3765 | |
| 3766 | if (INTEGERP (Vtool_bar_button_margin) |
| 3767 | && XINT (Vtool_bar_button_margin) > 0) |
| 3768 | margin = XFASTINT (Vtool_bar_button_margin); |
| 3769 | else if (CONSP (Vtool_bar_button_margin) |
| 3770 | && INTEGERP (XCDR (Vtool_bar_button_margin)) |
| 3771 | && XINT (XCDR (Vtool_bar_button_margin)) > 0) |
| 3772 | margin = XFASTINT (XCDR (Vtool_bar_button_margin)); |
| 3773 | else |
| 3774 | margin = 0; |
| 3775 | |
| 3776 | bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; |
| 3777 | f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f); |
| 3778 | } |
| 3779 | |
| 3780 | compute_fringe_widths (f, 0); |
| 3781 | |
| 3782 | FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width); |
| 3783 | FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height); |
| 3784 | |
| 3785 | tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER); |
| 3786 | tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER); |
| 3787 | tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER); |
| 3788 | if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound)) |
| 3789 | { |
| 3790 | if (EQ (tem0, Qminus)) |
| 3791 | { |
| 3792 | FRAME_X_OUTPUT (f)->top_pos = 0; |
| 3793 | window_prompting |= YNegative; |
| 3794 | } |
| 3795 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus) |
| 3796 | && CONSP (XCDR (tem0)) |
| 3797 | && INTEGERP (XCAR (XCDR (tem0)))) |
| 3798 | { |
| 3799 | FRAME_X_OUTPUT (f)->top_pos = - XINT (XCAR (XCDR (tem0))); |
| 3800 | window_prompting |= YNegative; |
| 3801 | } |
| 3802 | else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus) |
| 3803 | && CONSP (XCDR (tem0)) |
| 3804 | && INTEGERP (XCAR (XCDR (tem0)))) |
| 3805 | { |
| 3806 | FRAME_X_OUTPUT (f)->top_pos = XINT (XCAR (XCDR (tem0))); |
| 3807 | } |
| 3808 | else if (EQ (tem0, Qunbound)) |
| 3809 | FRAME_X_OUTPUT (f)->top_pos = 0; |
| 3810 | else |
| 3811 | { |
| 3812 | CHECK_NUMBER (tem0); |
| 3813 | FRAME_X_OUTPUT (f)->top_pos = XINT (tem0); |
| 3814 | if (FRAME_X_OUTPUT (f)->top_pos < 0) |
| 3815 | window_prompting |= YNegative; |
| 3816 | } |
| 3817 | |
| 3818 | if (EQ (tem1, Qminus)) |
| 3819 | { |
| 3820 | FRAME_X_OUTPUT (f)->left_pos = 0; |
| 3821 | window_prompting |= XNegative; |
| 3822 | } |
| 3823 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus) |
| 3824 | && CONSP (XCDR (tem1)) |
| 3825 | && INTEGERP (XCAR (XCDR (tem1)))) |
| 3826 | { |
| 3827 | FRAME_X_OUTPUT (f)->left_pos = - XINT (XCAR (XCDR (tem1))); |
| 3828 | window_prompting |= XNegative; |
| 3829 | } |
| 3830 | else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus) |
| 3831 | && CONSP (XCDR (tem1)) |
| 3832 | && INTEGERP (XCAR (XCDR (tem1)))) |
| 3833 | { |
| 3834 | FRAME_X_OUTPUT (f)->left_pos = XINT (XCAR (XCDR (tem1))); |
| 3835 | } |
| 3836 | else if (EQ (tem1, Qunbound)) |
| 3837 | FRAME_X_OUTPUT (f)->left_pos = 0; |
| 3838 | else |
| 3839 | { |
| 3840 | CHECK_NUMBER (tem1); |
| 3841 | FRAME_X_OUTPUT (f)->left_pos = XINT (tem1); |
| 3842 | if (FRAME_X_OUTPUT (f)->left_pos < 0) |
| 3843 | window_prompting |= XNegative; |
| 3844 | } |
| 3845 | |
| 3846 | if (!NILP (tem2) && ! EQ (tem2, Qunbound)) |
| 3847 | window_prompting |= USPosition; |
| 3848 | else |
| 3849 | window_prompting |= PPosition; |
| 3850 | } |
| 3851 | |
| 3852 | if (FRAME_X_OUTPUT (f)->want_fullscreen != FULLSCREEN_NONE) |
| 3853 | { |
| 3854 | int left, top; |
| 3855 | int width, height; |
| 3856 | |
| 3857 | /* It takes both for some WM:s to place it where we want */ |
| 3858 | window_prompting = USPosition | PPosition; |
| 3859 | x_fullscreen_adjust (f, &width, &height, &top, &left); |
| 3860 | f->width = width; |
| 3861 | f->height = height; |
| 3862 | FRAME_X_OUTPUT (f)->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width); |
| 3863 | FRAME_X_OUTPUT (f)->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height); |
| 3864 | FRAME_X_OUTPUT (f)->left_pos = left; |
| 3865 | FRAME_X_OUTPUT (f)->top_pos = top; |
| 3866 | } |
| 3867 | |
| 3868 | if (window_prompting & XNegative) |
| 3869 | { |
| 3870 | if (window_prompting & YNegative) |
| 3871 | FRAME_X_OUTPUT (f)->win_gravity = SouthEastGravity; |
| 3872 | else |
| 3873 | FRAME_X_OUTPUT (f)->win_gravity = NorthEastGravity; |
| 3874 | } |
| 3875 | else |
| 3876 | { |
| 3877 | if (window_prompting & YNegative) |
| 3878 | FRAME_X_OUTPUT (f)->win_gravity = SouthWestGravity; |
| 3879 | else |
| 3880 | FRAME_X_OUTPUT (f)->win_gravity = NorthWestGravity; |
| 3881 | } |
| 3882 | |
| 3883 | FRAME_X_OUTPUT (f)->size_hint_flags = window_prompting; |
| 3884 | |
| 3885 | return window_prompting; |
| 3886 | } |
| 3887 | |
| 3888 | |
| 3889 | |
| 3890 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 3891 | |
| 3892 | |
| 3893 | \f |
| 3894 | /*********************************************************************** |
| 3895 | Initialization |
| 3896 | ***********************************************************************/ |
| 3897 | |
| 3898 | void |
| 3899 | syms_of_frame () |
| 3900 | { |
| 3901 | Qframep = intern ("framep"); |
| 3902 | staticpro (&Qframep); |
| 3903 | Qframe_live_p = intern ("frame-live-p"); |
| 3904 | staticpro (&Qframe_live_p); |
| 3905 | Qheight = intern ("height"); |
| 3906 | staticpro (&Qheight); |
| 3907 | Qicon = intern ("icon"); |
| 3908 | staticpro (&Qicon); |
| 3909 | Qminibuffer = intern ("minibuffer"); |
| 3910 | staticpro (&Qminibuffer); |
| 3911 | Qmodeline = intern ("modeline"); |
| 3912 | staticpro (&Qmodeline); |
| 3913 | Qonly = intern ("only"); |
| 3914 | staticpro (&Qonly); |
| 3915 | Qwidth = intern ("width"); |
| 3916 | staticpro (&Qwidth); |
| 3917 | Qgeometry = intern ("geometry"); |
| 3918 | staticpro (&Qgeometry); |
| 3919 | Qicon_left = intern ("icon-left"); |
| 3920 | staticpro (&Qicon_left); |
| 3921 | Qicon_top = intern ("icon-top"); |
| 3922 | staticpro (&Qicon_top); |
| 3923 | Qleft = intern ("left"); |
| 3924 | staticpro (&Qleft); |
| 3925 | Qright = intern ("right"); |
| 3926 | staticpro (&Qright); |
| 3927 | Quser_position = intern ("user-position"); |
| 3928 | staticpro (&Quser_position); |
| 3929 | Quser_size = intern ("user-size"); |
| 3930 | staticpro (&Quser_size); |
| 3931 | Qwindow_id = intern ("window-id"); |
| 3932 | staticpro (&Qwindow_id); |
| 3933 | #ifdef HAVE_X_WINDOWS |
| 3934 | Qouter_window_id = intern ("outer-window-id"); |
| 3935 | staticpro (&Qouter_window_id); |
| 3936 | #endif |
| 3937 | Qparent_id = intern ("parent-id"); |
| 3938 | staticpro (&Qparent_id); |
| 3939 | Qx = intern ("x"); |
| 3940 | staticpro (&Qx); |
| 3941 | Qw32 = intern ("w32"); |
| 3942 | staticpro (&Qw32); |
| 3943 | Qpc = intern ("pc"); |
| 3944 | staticpro (&Qpc); |
| 3945 | Qmac = intern ("mac"); |
| 3946 | staticpro (&Qmac); |
| 3947 | Qvisible = intern ("visible"); |
| 3948 | staticpro (&Qvisible); |
| 3949 | Qbuffer_predicate = intern ("buffer-predicate"); |
| 3950 | staticpro (&Qbuffer_predicate); |
| 3951 | Qbuffer_list = intern ("buffer-list"); |
| 3952 | staticpro (&Qbuffer_list); |
| 3953 | Qdisplay_type = intern ("display-type"); |
| 3954 | staticpro (&Qdisplay_type); |
| 3955 | Qbackground_mode = intern ("background-mode"); |
| 3956 | staticpro (&Qbackground_mode); |
| 3957 | Qtty_color_mode = intern ("tty-color-mode"); |
| 3958 | staticpro (&Qtty_color_mode); |
| 3959 | |
| 3960 | Qface_set_after_frame_default = intern ("face-set-after-frame-default"); |
| 3961 | staticpro (&Qface_set_after_frame_default); |
| 3962 | |
| 3963 | Qfullwidth = intern ("fullwidth"); |
| 3964 | staticpro (&Qfullwidth); |
| 3965 | Qfullheight = intern ("fullheight"); |
| 3966 | staticpro (&Qfullheight); |
| 3967 | Qfullboth = intern ("fullboth"); |
| 3968 | staticpro (&Qfullboth); |
| 3969 | Qx_resource_name = intern ("x-resource-name"); |
| 3970 | staticpro (&Qx_resource_name); |
| 3971 | |
| 3972 | Qx_frame_parameter = intern ("x-frame-parameter"); |
| 3973 | staticpro (&Qx_frame_parameter); |
| 3974 | |
| 3975 | { |
| 3976 | int i; |
| 3977 | |
| 3978 | for (i = 0; i < sizeof (frame_parms) / sizeof (frame_parms[0]); i++) |
| 3979 | { |
| 3980 | Lisp_Object v = intern (frame_parms[i].name); |
| 3981 | if (frame_parms[i].variable) |
| 3982 | { |
| 3983 | *frame_parms[i].variable = v; |
| 3984 | staticpro (frame_parms[i].variable); |
| 3985 | } |
| 3986 | Fput (v, Qx_frame_parameter, make_number (i)); |
| 3987 | } |
| 3988 | } |
| 3989 | |
| 3990 | DEFVAR_LISP ("x-resource-name", &Vx_resource_name, |
| 3991 | doc: /* The name Emacs uses to look up X resources. |
| 3992 | `x-get-resource' uses this as the first component of the instance name |
| 3993 | when requesting resource values. |
| 3994 | Emacs initially sets `x-resource-name' to the name under which Emacs |
| 3995 | was invoked, or to the value specified with the `-name' or `-rn' |
| 3996 | switches, if present. |
| 3997 | |
| 3998 | It may be useful to bind this variable locally around a call |
| 3999 | to `x-get-resource'. See also the variable `x-resource-class'. */); |
| 4000 | Vx_resource_name = Qnil; |
| 4001 | |
| 4002 | DEFVAR_LISP ("x-resource-class", &Vx_resource_class, |
| 4003 | doc: /* The class Emacs uses to look up X resources. |
| 4004 | `x-get-resource' uses this as the first component of the instance class |
| 4005 | when requesting resource values. |
| 4006 | |
| 4007 | Emacs initially sets `x-resource-class' to "Emacs". |
| 4008 | |
| 4009 | Setting this variable permanently is not a reasonable thing to do, |
| 4010 | but binding this variable locally around a call to `x-get-resource' |
| 4011 | is a reasonable practice. See also the variable `x-resource-name'. */); |
| 4012 | Vx_resource_class = build_string (EMACS_CLASS); |
| 4013 | |
| 4014 | DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist, |
| 4015 | doc: /* Alist of default values for frame creation. |
| 4016 | These may be set in your init file, like this: |
| 4017 | (setq default-frame-alist '((width . 80) (height . 55) (menu-bar-lines . 1)) |
| 4018 | These override values given in window system configuration data, |
| 4019 | including X Windows' defaults database. |
| 4020 | For values specific to the first Emacs frame, see `initial-frame-alist'. |
| 4021 | For values specific to the separate minibuffer frame, see |
| 4022 | `minibuffer-frame-alist'. |
| 4023 | The `menu-bar-lines' element of the list controls whether new frames |
| 4024 | have menu bars; `menu-bar-mode' works by altering this element. |
| 4025 | Setting this variable does not affect existing frames, only new ones. */); |
| 4026 | Vdefault_frame_alist = Qnil; |
| 4027 | |
| 4028 | Qinhibit_default_face_x_resources |
| 4029 | = intern ("inhibit-default-face-x-resources"); |
| 4030 | staticpro (&Qinhibit_default_face_x_resources); |
| 4031 | |
| 4032 | DEFVAR_LISP ("terminal-frame", &Vterminal_frame, |
| 4033 | doc: /* The initial frame-object, which represents Emacs's stdout. */); |
| 4034 | |
| 4035 | DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified, |
| 4036 | doc: /* Non-nil if all of emacs is iconified and frame updates are not needed. */); |
| 4037 | Vemacs_iconified = Qnil; |
| 4038 | |
| 4039 | DEFVAR_LISP ("mouse-position-function", &Vmouse_position_function, |
| 4040 | doc: /* If non-nil, function to transform normal value of `mouse-position'. |
| 4041 | `mouse-position' calls this function, passing its usual return value as |
| 4042 | argument, and returns whatever this function returns. |
| 4043 | This abnormal hook exists for the benefit of packages like `xt-mouse.el' |
| 4044 | which need to do mouse handling at the Lisp level. */); |
| 4045 | Vmouse_position_function = Qnil; |
| 4046 | |
| 4047 | DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight, |
| 4048 | doc: /* If non-nil, clickable text is highlighted when mouse is over it. |
| 4049 | If the value is an integer, highlighting is only shown after moving the |
| 4050 | mouse, while keyboard input turns off the highlight even when the mouse |
| 4051 | is over the clickable text. However, the mouse shape still indicates |
| 4052 | when the mouse is over clickable text. */); |
| 4053 | Vmouse_highlight = Qt; |
| 4054 | |
| 4055 | DEFVAR_LISP ("delete-frame-functions", &Vdelete_frame_functions, |
| 4056 | doc: /* Functions to be run before deleting a frame. |
| 4057 | The functions are run with one arg, the frame to be deleted. |
| 4058 | See `delete-frame'. */); |
| 4059 | Vdelete_frame_functions = Qnil; |
| 4060 | |
| 4061 | DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame, |
| 4062 | doc: /* Minibufferless frames use this frame's minibuffer. |
| 4063 | |
| 4064 | Emacs cannot create minibufferless frames unless this is set to an |
| 4065 | appropriate surrogate. |
| 4066 | |
| 4067 | Emacs consults this variable only when creating minibufferless |
| 4068 | frames; once the frame is created, it sticks with its assigned |
| 4069 | minibuffer, no matter what this variable is set to. This means that |
| 4070 | this variable doesn't necessarily say anything meaningful about the |
| 4071 | current set of frames, or where the minibuffer is currently being |
| 4072 | displayed. |
| 4073 | |
| 4074 | This variable is local to the current terminal and cannot be buffer-local. */); |
| 4075 | |
| 4076 | staticpro (&Vframe_list); |
| 4077 | |
| 4078 | defsubr (&Sactive_minibuffer_window); |
| 4079 | defsubr (&Sframep); |
| 4080 | defsubr (&Sframe_live_p); |
| 4081 | defsubr (&Smake_terminal_frame); |
| 4082 | defsubr (&Shandle_switch_frame); |
| 4083 | defsubr (&Signore_event); |
| 4084 | defsubr (&Sselect_frame); |
| 4085 | defsubr (&Sselected_frame); |
| 4086 | defsubr (&Swindow_frame); |
| 4087 | defsubr (&Sframe_root_window); |
| 4088 | defsubr (&Sframe_first_window); |
| 4089 | defsubr (&Sframe_selected_window); |
| 4090 | defsubr (&Sset_frame_selected_window); |
| 4091 | defsubr (&Sframe_list); |
| 4092 | defsubr (&Snext_frame); |
| 4093 | defsubr (&Sprevious_frame); |
| 4094 | defsubr (&Sdelete_frame); |
| 4095 | defsubr (&Smouse_position); |
| 4096 | defsubr (&Smouse_pixel_position); |
| 4097 | defsubr (&Sset_mouse_position); |
| 4098 | defsubr (&Sset_mouse_pixel_position); |
| 4099 | #if 0 |
| 4100 | defsubr (&Sframe_configuration); |
| 4101 | defsubr (&Srestore_frame_configuration); |
| 4102 | #endif |
| 4103 | defsubr (&Smake_frame_visible); |
| 4104 | defsubr (&Smake_frame_invisible); |
| 4105 | defsubr (&Siconify_frame); |
| 4106 | defsubr (&Sframe_visible_p); |
| 4107 | defsubr (&Svisible_frame_list); |
| 4108 | defsubr (&Sraise_frame); |
| 4109 | defsubr (&Slower_frame); |
| 4110 | defsubr (&Sredirect_frame_focus); |
| 4111 | defsubr (&Sframe_focus); |
| 4112 | defsubr (&Sframe_parameters); |
| 4113 | defsubr (&Sframe_parameter); |
| 4114 | defsubr (&Smodify_frame_parameters); |
| 4115 | defsubr (&Sframe_char_height); |
| 4116 | defsubr (&Sframe_char_width); |
| 4117 | defsubr (&Sframe_pixel_height); |
| 4118 | defsubr (&Sframe_pixel_width); |
| 4119 | defsubr (&Sset_frame_height); |
| 4120 | defsubr (&Sset_frame_width); |
| 4121 | defsubr (&Sset_frame_size); |
| 4122 | defsubr (&Sset_frame_position); |
| 4123 | |
| 4124 | #ifdef HAVE_WINDOW_SYSTEM |
| 4125 | defsubr (&Sx_get_resource); |
| 4126 | defsubr (&Sx_parse_geometry); |
| 4127 | #endif |
| 4128 | |
| 4129 | } |