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