| 1 | ;;; frame.el --- multi-frame management independent of window systems |
| 2 | |
| 3 | ;; Copyright (C) 1993-1994, 1996-1997, 2000-2014 Free Software Foundation, Inc. |
| 4 | |
| 5 | ;; Maintainer: emacs-devel@gnu.org |
| 6 | ;; Keywords: internal |
| 7 | ;; Package: emacs |
| 8 | |
| 9 | ;; This file is part of GNU Emacs. |
| 10 | |
| 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
| 12 | ;; it under the terms of the GNU General Public License as published by |
| 13 | ;; the Free Software Foundation, either version 3 of the License, or |
| 14 | ;; (at your option) any later version. |
| 15 | |
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, |
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | ;; GNU General Public License for more details. |
| 20 | |
| 21 | ;; You should have received a copy of the GNU General Public License |
| 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
| 23 | |
| 24 | ;;; Commentary: |
| 25 | |
| 26 | ;;; Code: |
| 27 | |
| 28 | (defvar frame-creation-function-alist |
| 29 | (list (cons nil |
| 30 | (if (fboundp 'tty-create-frame-with-faces) |
| 31 | 'tty-create-frame-with-faces |
| 32 | (lambda (_parameters) |
| 33 | (error "Can't create multiple frames without a window system"))))) |
| 34 | "Alist of window-system dependent functions to call to create a new frame. |
| 35 | The window system startup file should add its frame creation |
| 36 | function to this list, which should take an alist of parameters |
| 37 | as its argument.") |
| 38 | |
| 39 | (defvar window-system-default-frame-alist nil |
| 40 | "Window-system dependent default frame parameters. |
| 41 | The value should be an alist of elements (WINDOW-SYSTEM . ALIST), |
| 42 | where WINDOW-SYSTEM is a window system symbol (see `window-system') |
| 43 | and ALIST is a frame parameter alist like `default-frame-alist'. |
| 44 | Then, for frames on WINDOW-SYSTEM, any parameters specified in |
| 45 | ALIST supersede the corresponding parameters specified in |
| 46 | `default-frame-alist'.") |
| 47 | |
| 48 | (defvar display-format-alist nil |
| 49 | "Alist of patterns to decode display names. |
| 50 | The car of each entry is a regular expression matching a display |
| 51 | name string. The cdr is a symbol giving the window-system that |
| 52 | handles the corresponding kind of display.") |
| 53 | |
| 54 | ;; The initial value given here used to ask for a minibuffer. |
| 55 | ;; But that's not necessary, because the default is to have one. |
| 56 | ;; By not specifying it here, we let an X resource specify it. |
| 57 | (defcustom initial-frame-alist nil |
| 58 | "Alist of parameters for the initial X window frame. |
| 59 | You can set this in your init file; for example, |
| 60 | |
| 61 | (setq initial-frame-alist |
| 62 | '((top . 1) (left . 1) (width . 80) (height . 55))) |
| 63 | |
| 64 | Parameters specified here supersede the values given in |
| 65 | `default-frame-alist'. |
| 66 | |
| 67 | If the value calls for a frame without a minibuffer, and you have |
| 68 | not created a minibuffer frame on your own, a minibuffer frame is |
| 69 | created according to `minibuffer-frame-alist'. |
| 70 | |
| 71 | You can specify geometry-related options for just the initial |
| 72 | frame by setting this variable in your init file; however, they |
| 73 | won't take effect until Emacs reads your init file, which happens |
| 74 | after creating the initial frame. If you want the initial frame |
| 75 | to have the proper geometry as soon as it appears, you need to |
| 76 | use this three-step process: |
| 77 | * Specify X resources to give the geometry you want. |
| 78 | * Set `default-frame-alist' to override these options so that they |
| 79 | don't affect subsequent frames. |
| 80 | * Set `initial-frame-alist' in a way that matches the X resources, |
| 81 | to override what you put in `default-frame-alist'." |
| 82 | :type '(repeat (cons :format "%v" |
| 83 | (symbol :tag "Parameter") |
| 84 | (sexp :tag "Value"))) |
| 85 | :group 'frames) |
| 86 | |
| 87 | (defcustom minibuffer-frame-alist '((width . 80) (height . 2)) |
| 88 | "Alist of parameters for the initial minibuffer frame. |
| 89 | This is the minibuffer frame created if `initial-frame-alist' |
| 90 | calls for a frame without a minibuffer. The parameters specified |
| 91 | here supersede those given in `default-frame-alist', for the |
| 92 | initial minibuffer frame. |
| 93 | |
| 94 | You can set this in your init file; for example, |
| 95 | |
| 96 | (setq minibuffer-frame-alist |
| 97 | '((top . 1) (left . 1) (width . 80) (height . 2))) |
| 98 | |
| 99 | It is not necessary to include (minibuffer . only); that is |
| 100 | appended when the minibuffer frame is created." |
| 101 | :type '(repeat (cons :format "%v" |
| 102 | (symbol :tag "Parameter") |
| 103 | (sexp :tag "Value"))) |
| 104 | :group 'frames) |
| 105 | |
| 106 | (defun handle-delete-frame (event) |
| 107 | "Handle delete-frame events from the X server." |
| 108 | (interactive "e") |
| 109 | (let ((frame (posn-window (event-start event))) |
| 110 | (i 0) |
| 111 | (tail (frame-list))) |
| 112 | (while tail |
| 113 | (and (frame-visible-p (car tail)) |
| 114 | (not (eq (car tail) frame)) |
| 115 | (setq i (1+ i))) |
| 116 | (setq tail (cdr tail))) |
| 117 | (if (> i 0) |
| 118 | (delete-frame frame t) |
| 119 | ;; Gildea@x.org says it is ok to ask questions before terminating. |
| 120 | (save-buffers-kill-emacs)))) |
| 121 | |
| 122 | (defun handle-focus-in (_event) |
| 123 | "Handle a focus-in event. |
| 124 | Focus-in events are usually bound to this function. |
| 125 | Focus-in events occur when a frame has focus, but a switch-frame event |
| 126 | is not generated. |
| 127 | This function runs the hook `focus-in-hook'." |
| 128 | (interactive "e") |
| 129 | (run-hooks 'focus-in-hook)) |
| 130 | |
| 131 | (defun handle-focus-out (_event) |
| 132 | "Handle a focus-out event. |
| 133 | Focus-out events are usually bound to this function. |
| 134 | Focus-out events occur when no frame has focus. |
| 135 | This function runs the hook `focus-out-hook'." |
| 136 | (interactive "e") |
| 137 | (run-hooks 'focus-out-hook)) |
| 138 | \f |
| 139 | ;;;; Arrangement of frames at startup |
| 140 | |
| 141 | ;; 1) Load the window system startup file from the lisp library and read the |
| 142 | ;; high-priority arguments (-q and the like). The window system startup |
| 143 | ;; file should create any frames specified in the window system defaults. |
| 144 | ;; |
| 145 | ;; 2) If no frames have been opened, we open an initial text frame. |
| 146 | ;; |
| 147 | ;; 3) Once the init file is done, we apply any newly set parameters |
| 148 | ;; in initial-frame-alist to the frame. |
| 149 | |
| 150 | ;; If we create the initial frame, this is it. |
| 151 | (defvar frame-initial-frame nil) |
| 152 | |
| 153 | ;; Record the parameters used in frame-initialize to make the initial frame. |
| 154 | (defvar frame-initial-frame-alist) |
| 155 | |
| 156 | (defvar frame-initial-geometry-arguments nil) |
| 157 | |
| 158 | ;; startup.el calls this function before loading the user's init |
| 159 | ;; file - if there is no frame with a minibuffer open now, create |
| 160 | ;; one to display messages while loading the init file. |
| 161 | (defun frame-initialize () |
| 162 | "Create an initial frame if necessary." |
| 163 | ;; Are we actually running under a window system at all? |
| 164 | (if (and initial-window-system |
| 165 | (not noninteractive) |
| 166 | (not (eq initial-window-system 'pc))) |
| 167 | (progn |
| 168 | ;; If there is no frame with a minibuffer besides the terminal |
| 169 | ;; frame, then we need to create the opening frame. Make sure |
| 170 | ;; it has a minibuffer, but let initial-frame-alist omit the |
| 171 | ;; minibuffer spec. |
| 172 | (or (delq terminal-frame (minibuffer-frame-list)) |
| 173 | (progn |
| 174 | (setq frame-initial-frame-alist |
| 175 | (append initial-frame-alist default-frame-alist nil)) |
| 176 | (or (assq 'horizontal-scroll-bars frame-initial-frame-alist) |
| 177 | (setq frame-initial-frame-alist |
| 178 | (cons '(horizontal-scroll-bars . t) |
| 179 | frame-initial-frame-alist))) |
| 180 | (setq frame-initial-frame-alist |
| 181 | (cons (cons 'window-system initial-window-system) |
| 182 | frame-initial-frame-alist)) |
| 183 | (setq default-minibuffer-frame |
| 184 | (setq frame-initial-frame |
| 185 | (make-frame frame-initial-frame-alist))) |
| 186 | ;; Delete any specifications for window geometry parameters |
| 187 | ;; so that we won't reapply them in frame-notice-user-settings. |
| 188 | ;; It would be wrong to reapply them then, |
| 189 | ;; because that would override explicit user resizing. |
| 190 | (setq initial-frame-alist |
| 191 | (frame-remove-geometry-params initial-frame-alist)))) |
| 192 | ;; Copy the environment of the Emacs process into the new frame. |
| 193 | (set-frame-parameter frame-initial-frame 'environment |
| 194 | (frame-parameter terminal-frame 'environment)) |
| 195 | ;; At this point, we know that we have a frame open, so we |
| 196 | ;; can delete the terminal frame. |
| 197 | (delete-frame terminal-frame) |
| 198 | (setq terminal-frame nil)))) |
| 199 | |
| 200 | (defvar frame-notice-user-settings t |
| 201 | "Non-nil means function `frame-notice-user-settings' wasn't run yet.") |
| 202 | |
| 203 | (declare-function tool-bar-mode "tool-bar" (&optional arg)) |
| 204 | |
| 205 | (defalias 'tool-bar-lines-needed 'tool-bar-height) |
| 206 | |
| 207 | ;; startup.el calls this function after loading the user's init |
| 208 | ;; file. Now default-frame-alist and initial-frame-alist contain |
| 209 | ;; information to which we must react; do what needs to be done. |
| 210 | (defun frame-notice-user-settings () |
| 211 | "Act on user's init file settings of frame parameters. |
| 212 | React to settings of `initial-frame-alist', |
| 213 | `window-system-default-frame-alist' and `default-frame-alist' |
| 214 | there (in decreasing order of priority)." |
| 215 | ;; Creating and deleting frames may shift the selected frame around, |
| 216 | ;; and thus the current buffer. Protect against that. We don't |
| 217 | ;; want to use save-excursion here, because that may also try to set |
| 218 | ;; the buffer of the selected window, which fails when the selected |
| 219 | ;; window is the minibuffer. |
| 220 | (let ((old-buffer (current-buffer)) |
| 221 | (window-system-frame-alist |
| 222 | (cdr (assq initial-window-system |
| 223 | window-system-default-frame-alist)))) |
| 224 | |
| 225 | (when (and frame-notice-user-settings |
| 226 | (null frame-initial-frame)) |
| 227 | ;; This case happens when we don't have a window system, and |
| 228 | ;; also for MS-DOS frames. |
| 229 | (let ((parms (frame-parameters))) |
| 230 | ;; Don't change the frame names. |
| 231 | (setq parms (delq (assq 'name parms) parms)) |
| 232 | ;; Can't modify the minibuffer parameter, so don't try. |
| 233 | (setq parms (delq (assq 'minibuffer parms) parms)) |
| 234 | (modify-frame-parameters |
| 235 | nil |
| 236 | (if initial-window-system |
| 237 | parms |
| 238 | ;; initial-frame-alist and default-frame-alist were already |
| 239 | ;; applied in pc-win.el. |
| 240 | (append initial-frame-alist window-system-frame-alist |
| 241 | default-frame-alist parms nil))) |
| 242 | (if (null initial-window-system) ;; MS-DOS does this differently in pc-win.el |
| 243 | (let ((newparms (frame-parameters)) |
| 244 | (frame (selected-frame))) |
| 245 | (tty-handle-reverse-video frame newparms) |
| 246 | ;; If we changed the background color, we need to update |
| 247 | ;; the background-mode parameter, and maybe some faces, |
| 248 | ;; too. |
| 249 | (when (assq 'background-color newparms) |
| 250 | (unless (or (assq 'background-mode initial-frame-alist) |
| 251 | (assq 'background-mode default-frame-alist)) |
| 252 | (frame-set-background-mode frame)) |
| 253 | (face-set-after-frame-default frame)))))) |
| 254 | |
| 255 | ;; If the initial frame is still around, apply initial-frame-alist |
| 256 | ;; and default-frame-alist to it. |
| 257 | (when (frame-live-p frame-initial-frame) |
| 258 | |
| 259 | ;; When tool-bar has been switched off, correct the frame size |
| 260 | ;; by the lines added in x-create-frame for the tool-bar and |
| 261 | ;; switch `tool-bar-mode' off. |
| 262 | (when (display-graphic-p) |
| 263 | (let ((tool-bar-lines (or (assq 'tool-bar-lines initial-frame-alist) |
| 264 | (assq 'tool-bar-lines window-system-frame-alist) |
| 265 | (assq 'tool-bar-lines default-frame-alist)))) |
| 266 | (when (and tool-bar-originally-present |
| 267 | (or (null tool-bar-lines) |
| 268 | (null (cdr tool-bar-lines)) |
| 269 | (eq 0 (cdr tool-bar-lines)))) |
| 270 | (let* ((char-height (frame-char-height frame-initial-frame)) |
| 271 | (image-height tool-bar-images-pixel-height) |
| 272 | (margin (cond ((and (consp tool-bar-button-margin) |
| 273 | (integerp (cdr tool-bar-button-margin)) |
| 274 | (> tool-bar-button-margin 0)) |
| 275 | (cdr tool-bar-button-margin)) |
| 276 | ((and (integerp tool-bar-button-margin) |
| 277 | (> tool-bar-button-margin 0)) |
| 278 | tool-bar-button-margin) |
| 279 | (t 0))) |
| 280 | (relief (if (and (integerp tool-bar-button-relief) |
| 281 | (> tool-bar-button-relief 0)) |
| 282 | tool-bar-button-relief 3)) |
| 283 | (lines (/ (+ image-height |
| 284 | (* 2 margin) |
| 285 | (* 2 relief) |
| 286 | (1- char-height)) |
| 287 | char-height)) |
| 288 | (height (frame-parameter frame-initial-frame 'height)) |
| 289 | (newparms (list (cons 'height (- height lines)))) |
| 290 | (initial-top (cdr (assq 'top |
| 291 | frame-initial-geometry-arguments))) |
| 292 | (top (frame-parameter frame-initial-frame 'top))) |
| 293 | (when (and (consp initial-top) (eq '- (car initial-top))) |
| 294 | (let ((adjusted-top |
| 295 | (cond ((and (consp top) |
| 296 | (eq '+ (car top))) |
| 297 | (list '+ |
| 298 | (+ (cadr top) |
| 299 | (* lines char-height)))) |
| 300 | ((and (consp top) |
| 301 | (eq '- (car top))) |
| 302 | (list '- |
| 303 | (- (cadr top) |
| 304 | (* lines char-height)))) |
| 305 | (t (+ top (* lines char-height)))))) |
| 306 | (setq newparms |
| 307 | (append newparms |
| 308 | `((top . ,adjusted-top)) |
| 309 | nil)))) |
| 310 | (modify-frame-parameters frame-initial-frame newparms) |
| 311 | (tool-bar-mode -1))))) |
| 312 | |
| 313 | ;; The initial frame we create above always has a minibuffer. |
| 314 | ;; If the user wants to remove it, or make it a minibuffer-only |
| 315 | ;; frame, then we'll have to delete the current frame and make a |
| 316 | ;; new one; you can't remove or add a root window to/from an |
| 317 | ;; existing frame. |
| 318 | ;; |
| 319 | ;; NOTE: default-frame-alist was nil when we created the |
| 320 | ;; existing frame. We need to explicitly include |
| 321 | ;; default-frame-alist in the parameters of the screen we |
| 322 | ;; create here, so that its new value, gleaned from the user's |
| 323 | ;; init file, will be applied to the existing screen. |
| 324 | (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist) |
| 325 | (assq 'minibuffer window-system-frame-alist) |
| 326 | (assq 'minibuffer default-frame-alist) |
| 327 | '(minibuffer . t))) |
| 328 | t)) |
| 329 | ;; Create the new frame. |
| 330 | (let (parms new) |
| 331 | ;; MS-Windows needs this to avoid inflooping below. |
| 332 | (if (eq system-type 'windows-nt) |
| 333 | (sit-for 0 t)) |
| 334 | ;; If the frame isn't visible yet, wait till it is. |
| 335 | ;; If the user has to position the window, |
| 336 | ;; Emacs doesn't know its real position until |
| 337 | ;; the frame is seen to be visible. |
| 338 | (while (not (cdr (assq 'visibility |
| 339 | (frame-parameters frame-initial-frame)))) |
| 340 | (sleep-for 1)) |
| 341 | (setq parms (frame-parameters frame-initial-frame)) |
| 342 | |
| 343 | ;; Get rid of `name' unless it was specified explicitly before. |
| 344 | (or (assq 'name frame-initial-frame-alist) |
| 345 | (setq parms (delq (assq 'name parms) parms))) |
| 346 | ;; An explicit parent-id is a request to XEmbed the frame. |
| 347 | (or (assq 'parent-id frame-initial-frame-alist) |
| 348 | (setq parms (delq (assq 'parent-id parms) parms))) |
| 349 | |
| 350 | (setq parms (append initial-frame-alist |
| 351 | window-system-frame-alist |
| 352 | default-frame-alist |
| 353 | parms |
| 354 | nil)) |
| 355 | |
| 356 | ;; Get rid of `reverse', because that was handled |
| 357 | ;; when we first made the frame. |
| 358 | (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms))) |
| 359 | |
| 360 | (if (assq 'height frame-initial-geometry-arguments) |
| 361 | (setq parms (assq-delete-all 'height parms))) |
| 362 | (if (assq 'width frame-initial-geometry-arguments) |
| 363 | (setq parms (assq-delete-all 'width parms))) |
| 364 | (if (assq 'left frame-initial-geometry-arguments) |
| 365 | (setq parms (assq-delete-all 'left parms))) |
| 366 | (if (assq 'top frame-initial-geometry-arguments) |
| 367 | (setq parms (assq-delete-all 'top parms))) |
| 368 | (setq new |
| 369 | (make-frame |
| 370 | ;; Use the geometry args that created the existing |
| 371 | ;; frame, rather than the parms we get for it. |
| 372 | (append frame-initial-geometry-arguments |
| 373 | '((user-size . t) (user-position . t)) |
| 374 | parms))) |
| 375 | ;; The initial frame, which we are about to delete, may be |
| 376 | ;; the only frame with a minibuffer. If it is, create a |
| 377 | ;; new one. |
| 378 | (or (delq frame-initial-frame (minibuffer-frame-list)) |
| 379 | (make-initial-minibuffer-frame nil)) |
| 380 | |
| 381 | ;; If the initial frame is serving as a surrogate |
| 382 | ;; minibuffer frame for any frames, we need to wean them |
| 383 | ;; onto a new frame. The default-minibuffer-frame |
| 384 | ;; variable must be handled similarly. |
| 385 | (let ((users-of-initial |
| 386 | (filtered-frame-list |
| 387 | (lambda (frame) |
| 388 | (and (not (eq frame frame-initial-frame)) |
| 389 | (eq (window-frame |
| 390 | (minibuffer-window frame)) |
| 391 | frame-initial-frame)))))) |
| 392 | (if (or users-of-initial |
| 393 | (eq default-minibuffer-frame frame-initial-frame)) |
| 394 | |
| 395 | ;; Choose an appropriate frame. Prefer frames which |
| 396 | ;; are only minibuffers. |
| 397 | (let* ((new-surrogate |
| 398 | (car |
| 399 | (or (filtered-frame-list |
| 400 | (lambda (frame) |
| 401 | (eq (cdr (assq 'minibuffer |
| 402 | (frame-parameters frame))) |
| 403 | 'only))) |
| 404 | (minibuffer-frame-list)))) |
| 405 | (new-minibuffer (minibuffer-window new-surrogate))) |
| 406 | |
| 407 | (if (eq default-minibuffer-frame frame-initial-frame) |
| 408 | (setq default-minibuffer-frame new-surrogate)) |
| 409 | |
| 410 | ;; Wean the frames using frame-initial-frame as |
| 411 | ;; their minibuffer frame. |
| 412 | (dolist (frame users-of-initial) |
| 413 | (modify-frame-parameters |
| 414 | frame (list (cons 'minibuffer new-minibuffer))))))) |
| 415 | |
| 416 | ;; Redirect events enqueued at this frame to the new frame. |
| 417 | ;; Is this a good idea? |
| 418 | (redirect-frame-focus frame-initial-frame new) |
| 419 | |
| 420 | ;; Finally, get rid of the old frame. |
| 421 | (delete-frame frame-initial-frame t)) |
| 422 | |
| 423 | ;; Otherwise, we don't need all that rigmarole; just apply |
| 424 | ;; the new parameters. |
| 425 | (let (newparms allparms tail) |
| 426 | (setq allparms (append initial-frame-alist |
| 427 | window-system-frame-alist |
| 428 | default-frame-alist nil)) |
| 429 | (if (assq 'height frame-initial-geometry-arguments) |
| 430 | (setq allparms (assq-delete-all 'height allparms))) |
| 431 | (if (assq 'width frame-initial-geometry-arguments) |
| 432 | (setq allparms (assq-delete-all 'width allparms))) |
| 433 | (if (assq 'left frame-initial-geometry-arguments) |
| 434 | (setq allparms (assq-delete-all 'left allparms))) |
| 435 | (if (assq 'top frame-initial-geometry-arguments) |
| 436 | (setq allparms (assq-delete-all 'top allparms))) |
| 437 | (setq tail allparms) |
| 438 | ;; Find just the parms that have changed since we first |
| 439 | ;; made this frame. Those are the ones actually set by |
| 440 | ;; the init file. For those parms whose values we already knew |
| 441 | ;; (such as those spec'd by command line options) |
| 442 | ;; it is undesirable to specify the parm again |
| 443 | ;; once the user has seen the frame and been able to alter it |
| 444 | ;; manually. |
| 445 | (let (newval oldval) |
| 446 | (dolist (entry tail) |
| 447 | (setq oldval (assq (car entry) frame-initial-frame-alist)) |
| 448 | (setq newval (cdr (assq (car entry) allparms))) |
| 449 | (or (and oldval (eq (cdr oldval) newval)) |
| 450 | (setq newparms |
| 451 | (cons (cons (car entry) newval) newparms))))) |
| 452 | (setq newparms (nreverse newparms)) |
| 453 | |
| 454 | (let ((new-bg (assq 'background-color newparms))) |
| 455 | ;; If the `background-color' parameter is changed, apply |
| 456 | ;; it first, then make sure that the `background-mode' |
| 457 | ;; parameter and other faces are updated, before applying |
| 458 | ;; the other parameters. |
| 459 | (when new-bg |
| 460 | (modify-frame-parameters frame-initial-frame |
| 461 | (list new-bg)) |
| 462 | (unless (assq 'background-mode newparms) |
| 463 | (frame-set-background-mode frame-initial-frame)) |
| 464 | (face-set-after-frame-default frame-initial-frame) |
| 465 | (setq newparms (delq new-bg newparms))) |
| 466 | (modify-frame-parameters frame-initial-frame newparms))))) |
| 467 | |
| 468 | ;; Restore the original buffer. |
| 469 | (set-buffer old-buffer) |
| 470 | |
| 471 | ;; Make sure the initial frame can be GC'd if it is ever deleted. |
| 472 | ;; Make sure frame-notice-user-settings does nothing if called twice. |
| 473 | (setq frame-notice-user-settings nil) |
| 474 | (setq frame-initial-frame nil))) |
| 475 | |
| 476 | (defun make-initial-minibuffer-frame (display) |
| 477 | (let ((parms (append minibuffer-frame-alist '((minibuffer . only))))) |
| 478 | (if display |
| 479 | (make-frame-on-display display parms) |
| 480 | (make-frame parms)))) |
| 481 | |
| 482 | ;;;; Creation of additional frames, and other frame miscellanea |
| 483 | |
| 484 | (defun modify-all-frames-parameters (alist) |
| 485 | "Modify all current and future frames' parameters according to ALIST. |
| 486 | This changes `default-frame-alist' and possibly `initial-frame-alist'. |
| 487 | Furthermore, this function removes all parameters in ALIST from |
| 488 | `window-system-default-frame-alist'. |
| 489 | See help of `modify-frame-parameters' for more information." |
| 490 | (dolist (frame (frame-list)) |
| 491 | (modify-frame-parameters frame alist)) |
| 492 | |
| 493 | (dolist (pair alist) ;; conses to add/replace |
| 494 | ;; initial-frame-alist needs setting only when |
| 495 | ;; frame-notice-user-settings is true. |
| 496 | (and frame-notice-user-settings |
| 497 | (setq initial-frame-alist |
| 498 | (assq-delete-all (car pair) initial-frame-alist))) |
| 499 | (setq default-frame-alist |
| 500 | (assq-delete-all (car pair) default-frame-alist)) |
| 501 | ;; Remove any similar settings from the window-system specific |
| 502 | ;; parameters---they would override default-frame-alist. |
| 503 | (dolist (w window-system-default-frame-alist) |
| 504 | (setcdr w (assq-delete-all (car pair) (cdr w))))) |
| 505 | |
| 506 | (and frame-notice-user-settings |
| 507 | (setq initial-frame-alist (append initial-frame-alist alist))) |
| 508 | (setq default-frame-alist (append default-frame-alist alist))) |
| 509 | |
| 510 | (defun get-other-frame () |
| 511 | "Return some frame other than the current frame. |
| 512 | Create one if necessary. Note that the minibuffer frame, if separate, |
| 513 | is not considered (see `next-frame')." |
| 514 | (if (equal (next-frame) (selected-frame)) (make-frame) (next-frame))) |
| 515 | |
| 516 | (defun next-multiframe-window () |
| 517 | "Select the next window, regardless of which frame it is on." |
| 518 | (interactive) |
| 519 | (select-window (next-window (selected-window) |
| 520 | (> (minibuffer-depth) 0) |
| 521 | 0)) |
| 522 | (select-frame-set-input-focus (selected-frame))) |
| 523 | |
| 524 | (defun previous-multiframe-window () |
| 525 | "Select the previous window, regardless of which frame it is on." |
| 526 | (interactive) |
| 527 | (select-window (previous-window (selected-window) |
| 528 | (> (minibuffer-depth) 0) |
| 529 | 0)) |
| 530 | (select-frame-set-input-focus (selected-frame))) |
| 531 | |
| 532 | (defun window-system-for-display (display) |
| 533 | "Return the window system for DISPLAY. |
| 534 | Return nil if we don't know how to interpret DISPLAY." |
| 535 | ;; MS-Windows doesn't know how to create a GUI frame in a -nw session. |
| 536 | (if (and (eq system-type 'windows-nt) |
| 537 | (null (window-system))) |
| 538 | nil |
| 539 | (labels ((loop (list) |
| 540 | (let* ((descriptor (car list)) |
| 541 | (pattern (car descriptor)) |
| 542 | (system (cdr descriptor))) |
| 543 | (if (string-match-p pattern display) |
| 544 | system |
| 545 | (loop (cdr list)))))) |
| 546 | (loop display-format-alist)))) |
| 547 | |
| 548 | (defun make-frame-on-display (display &optional parameters) |
| 549 | "Make a frame on display DISPLAY. |
| 550 | The optional argument PARAMETERS specifies additional frame parameters." |
| 551 | (interactive "sMake frame on display: ") |
| 552 | (make-frame (cons (cons 'display display) parameters))) |
| 553 | |
| 554 | (declare-function x-close-connection "xfns.c" (terminal)) |
| 555 | |
| 556 | (defun close-display-connection (display) |
| 557 | "Close the connection to a display, deleting all its associated frames. |
| 558 | For DISPLAY, specify either a frame or a display name (a string). |
| 559 | If DISPLAY is nil, that stands for the selected frame's display." |
| 560 | (interactive |
| 561 | (list |
| 562 | (let* ((default (frame-parameter nil 'display)) |
| 563 | (display (completing-read |
| 564 | (format "Close display (default %s): " default) |
| 565 | (delete-dups |
| 566 | (mapcar (lambda (frame) |
| 567 | (frame-parameter frame 'display)) |
| 568 | (frame-list))) |
| 569 | nil t nil nil |
| 570 | default))) |
| 571 | (if (zerop (length display)) default display)))) |
| 572 | (let ((frames (delq nil |
| 573 | (mapcar (lambda (frame) |
| 574 | (if (equal display |
| 575 | (frame-parameter frame 'display)) |
| 576 | frame)) |
| 577 | (frame-list))))) |
| 578 | (if (and (consp frames) |
| 579 | (not (y-or-n-p (if (cdr frames) |
| 580 | (format "Delete %s frames? " (length frames)) |
| 581 | (format "Delete %s ? " (car frames)))))) |
| 582 | (error "Abort!") |
| 583 | (mapc 'delete-frame frames) |
| 584 | (x-close-connection display)))) |
| 585 | |
| 586 | (defun make-frame-command () |
| 587 | "Make a new frame, on the same terminal as the selected frame. |
| 588 | If the terminal is a text-only terminal, this also selects the |
| 589 | new frame." |
| 590 | (interactive) |
| 591 | (if (display-graphic-p) |
| 592 | (make-frame) |
| 593 | (select-frame (make-frame)))) |
| 594 | |
| 595 | (defvar before-make-frame-hook nil |
| 596 | "Functions to run before a frame is created.") |
| 597 | |
| 598 | (defvar after-make-frame-functions nil |
| 599 | "Functions to run after a frame is created. |
| 600 | The functions are run with one arg, the newly created frame.") |
| 601 | |
| 602 | (defvar after-setting-font-hook nil |
| 603 | "Functions to run after a frame's font has been changed.") |
| 604 | |
| 605 | ;; Alias, kept temporarily. |
| 606 | (define-obsolete-function-alias 'new-frame 'make-frame "22.1") |
| 607 | |
| 608 | (defvar frame-inherited-parameters '() |
| 609 | "Parameters `make-frame' copies from the `selected-frame' to the new frame.") |
| 610 | |
| 611 | (defvar x-display-name) |
| 612 | |
| 613 | (defun make-frame (&optional parameters) |
| 614 | "Return a newly created frame displaying the current buffer. |
| 615 | Optional argument PARAMETERS is an alist of frame parameters for |
| 616 | the new frame. Each element of PARAMETERS should have the |
| 617 | form (NAME . VALUE), for example: |
| 618 | |
| 619 | (name . STRING) The frame should be named STRING. |
| 620 | |
| 621 | (width . NUMBER) The frame should be NUMBER characters in width. |
| 622 | (height . NUMBER) The frame should be NUMBER text lines high. |
| 623 | |
| 624 | You cannot specify either `width' or `height', you must specify |
| 625 | neither or both. |
| 626 | |
| 627 | (minibuffer . t) The frame should have a minibuffer. |
| 628 | (minibuffer . nil) The frame should have no minibuffer. |
| 629 | (minibuffer . only) The frame should contain only a minibuffer. |
| 630 | (minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window. |
| 631 | |
| 632 | (window-system . nil) The frame should be displayed on a terminal device. |
| 633 | (window-system . x) The frame should be displayed in an X window. |
| 634 | |
| 635 | (display . \":0\") The frame should appear on display :0. |
| 636 | |
| 637 | (terminal . TERMINAL) The frame should use the terminal object TERMINAL. |
| 638 | |
| 639 | In addition, any parameter specified in `default-frame-alist', |
| 640 | but not present in PARAMETERS, is applied. |
| 641 | |
| 642 | Before creating the frame (via `frame-creation-function-alist'), |
| 643 | this function runs the hook `before-make-frame-hook'. After |
| 644 | creating the frame, it runs the hook `after-make-frame-functions' |
| 645 | with one arg, the newly created frame. |
| 646 | |
| 647 | If a display parameter is supplied and a window-system is not, |
| 648 | guess the window-system from the display. |
| 649 | |
| 650 | On graphical displays, this function does not itself make the new |
| 651 | frame the selected frame. However, the window system may select |
| 652 | the new frame according to its own rules." |
| 653 | (interactive) |
| 654 | (let* ((display (cdr (assq 'display parameters))) |
| 655 | (w (cond |
| 656 | ((assq 'terminal parameters) |
| 657 | (let ((type (terminal-live-p (cdr (assq 'terminal parameters))))) |
| 658 | (cond |
| 659 | ((eq type t) nil) |
| 660 | ((eq type nil) (error "Terminal %s does not exist" |
| 661 | (cdr (assq 'terminal parameters)))) |
| 662 | (t type)))) |
| 663 | ((assq 'window-system parameters) |
| 664 | (cdr (assq 'window-system parameters))) |
| 665 | (display |
| 666 | (or (window-system-for-display display) |
| 667 | (error "Don't know how to interpret display %S" |
| 668 | display))) |
| 669 | (t window-system))) |
| 670 | (frame-creation-function (cdr (assq w frame-creation-function-alist))) |
| 671 | (oldframe (selected-frame)) |
| 672 | (params parameters) |
| 673 | frame) |
| 674 | (unless frame-creation-function |
| 675 | (error "Don't know how to create a frame on window system %s" w)) |
| 676 | |
| 677 | (unless (get w 'window-system-initialized) |
| 678 | (funcall (cdr (assq w window-system-initialization-alist)) display) |
| 679 | (setq x-display-name display) |
| 680 | (put w 'window-system-initialized t)) |
| 681 | |
| 682 | ;; Add parameters from `window-system-default-frame-alist'. |
| 683 | (dolist (p (cdr (assq w window-system-default-frame-alist))) |
| 684 | (unless (assq (car p) params) |
| 685 | (push p params))) |
| 686 | ;; Add parameters from `default-frame-alist'. |
| 687 | (dolist (p default-frame-alist) |
| 688 | (unless (assq (car p) params) |
| 689 | (push p params))) |
| 690 | ;; Now make the frame. |
| 691 | (run-hooks 'before-make-frame-hook) |
| 692 | (setq frame (funcall frame-creation-function params)) |
| 693 | (normal-erase-is-backspace-setup-frame frame) |
| 694 | ;; Inherit the original frame's parameters. |
| 695 | (dolist (param frame-inherited-parameters) |
| 696 | (unless (assq param parameters) ;Overridden by explicit parameters. |
| 697 | (let ((val (frame-parameter oldframe param))) |
| 698 | (when val (set-frame-parameter frame param val))))) |
| 699 | (run-hook-with-args 'after-make-frame-functions frame) |
| 700 | frame)) |
| 701 | |
| 702 | (defun filtered-frame-list (predicate) |
| 703 | "Return a list of all live frames which satisfy PREDICATE." |
| 704 | (let* ((frames (frame-list)) |
| 705 | (list frames)) |
| 706 | (while (consp frames) |
| 707 | (unless (funcall predicate (car frames)) |
| 708 | (setcar frames nil)) |
| 709 | (setq frames (cdr frames))) |
| 710 | (delq nil list))) |
| 711 | |
| 712 | (defun minibuffer-frame-list () |
| 713 | "Return a list of all frames with their own minibuffers." |
| 714 | (filtered-frame-list |
| 715 | (lambda (frame) |
| 716 | (eq frame (window-frame (minibuffer-window frame)))))) |
| 717 | |
| 718 | ;; Used to be called `terminal-id' in termdev.el. |
| 719 | (defun get-device-terminal (device) |
| 720 | "Return the terminal corresponding to DEVICE. |
| 721 | DEVICE can be a terminal, a frame, nil (meaning the selected frame's terminal), |
| 722 | the name of an X display device (HOST.SERVER.SCREEN) or a tty device file." |
| 723 | (cond |
| 724 | ((or (null device) (framep device)) |
| 725 | (frame-terminal device)) |
| 726 | ((stringp device) |
| 727 | (let ((f (car (filtered-frame-list |
| 728 | (lambda (frame) |
| 729 | (or (equal (frame-parameter frame 'display) device) |
| 730 | (equal (frame-parameter frame 'tty) device))))))) |
| 731 | (or f (error "Display %s does not exist" device)) |
| 732 | (frame-terminal f))) |
| 733 | ((terminal-live-p device) device) |
| 734 | (t |
| 735 | (error "Invalid argument %s in `get-device-terminal'" device)))) |
| 736 | |
| 737 | (defun frames-on-display-list (&optional device) |
| 738 | "Return a list of all frames on DEVICE. |
| 739 | |
| 740 | DEVICE should be a terminal, a frame, |
| 741 | or a name of an X display or tty (a string of the form |
| 742 | HOST:SERVER.SCREEN). |
| 743 | |
| 744 | If DEVICE is omitted or nil, it defaults to the selected |
| 745 | frame's terminal device." |
| 746 | (let* ((terminal (get-device-terminal device)) |
| 747 | (func #'(lambda (frame) |
| 748 | (eq (frame-terminal frame) terminal)))) |
| 749 | (filtered-frame-list func))) |
| 750 | |
| 751 | (defun framep-on-display (&optional terminal) |
| 752 | "Return the type of frames on TERMINAL. |
| 753 | TERMINAL may be a terminal id, a display name or a frame. If it |
| 754 | is a frame, its type is returned. If TERMINAL is omitted or nil, |
| 755 | it defaults to the selected frame's terminal device. All frames |
| 756 | on a given display are of the same type." |
| 757 | (or (terminal-live-p terminal) |
| 758 | (framep terminal) |
| 759 | (framep (car (frames-on-display-list terminal))))) |
| 760 | |
| 761 | (defun frame-remove-geometry-params (param-list) |
| 762 | "Return the parameter list PARAM-LIST, but with geometry specs removed. |
| 763 | This deletes all bindings in PARAM-LIST for `top', `left', `width', |
| 764 | `height', `user-size' and `user-position' parameters. |
| 765 | Emacs uses this to avoid overriding explicit moves and resizings from |
| 766 | the user during startup." |
| 767 | (setq param-list (cons nil param-list)) |
| 768 | (let ((tail param-list)) |
| 769 | (while (consp (cdr tail)) |
| 770 | (if (and (consp (car (cdr tail))) |
| 771 | (memq (car (car (cdr tail))) |
| 772 | '(height width top left user-position user-size))) |
| 773 | (progn |
| 774 | (setq frame-initial-geometry-arguments |
| 775 | (cons (car (cdr tail)) frame-initial-geometry-arguments)) |
| 776 | (setcdr tail (cdr (cdr tail)))) |
| 777 | (setq tail (cdr tail))))) |
| 778 | (setq frame-initial-geometry-arguments |
| 779 | (nreverse frame-initial-geometry-arguments)) |
| 780 | (cdr param-list)) |
| 781 | |
| 782 | (declare-function x-focus-frame "frame.c" (frame)) |
| 783 | |
| 784 | (defun select-frame-set-input-focus (frame &optional norecord) |
| 785 | "Select FRAME, raise it, and set input focus, if possible. |
| 786 | If `mouse-autoselect-window' is non-nil, also move mouse pointer |
| 787 | to FRAME's selected window. Otherwise, if `focus-follows-mouse' |
| 788 | is non-nil, move mouse cursor to FRAME. |
| 789 | |
| 790 | Optional argument NORECORD means to neither change the order of |
| 791 | recently selected windows nor the buffer list." |
| 792 | (select-frame frame norecord) |
| 793 | (raise-frame frame) |
| 794 | ;; Ensure, if possible, that FRAME gets input focus. |
| 795 | (when (memq (window-system frame) '(x w32 ns)) |
| 796 | (x-focus-frame frame)) |
| 797 | ;; Move mouse cursor if necessary. |
| 798 | (cond |
| 799 | (mouse-autoselect-window |
| 800 | (let ((edges (window-inside-edges (frame-selected-window frame)))) |
| 801 | ;; Move mouse cursor into FRAME's selected window to avoid that |
| 802 | ;; Emacs mouse-autoselects another window. |
| 803 | (set-mouse-position frame (nth 2 edges) (nth 1 edges)))) |
| 804 | (focus-follows-mouse |
| 805 | ;; Move mouse cursor into FRAME to avoid that another frame gets |
| 806 | ;; selected by the window manager. |
| 807 | (set-mouse-position frame (1- (frame-width frame)) 0)))) |
| 808 | |
| 809 | (defun other-frame (arg) |
| 810 | "Select the ARGth different visible frame on current display, and raise it. |
| 811 | All frames are arranged in a cyclic order. |
| 812 | This command selects the frame ARG steps away in that order. |
| 813 | A negative ARG moves in the opposite order. |
| 814 | |
| 815 | To make this command work properly, you must tell Emacs |
| 816 | how the system (or the window manager) generally handles |
| 817 | focus-switching between windows. If moving the mouse onto a window |
| 818 | selects it (gives it focus), set `focus-follows-mouse' to t. |
| 819 | Otherwise, that variable should be nil." |
| 820 | (interactive "p") |
| 821 | (let ((frame (selected-frame))) |
| 822 | (while (> arg 0) |
| 823 | (setq frame (next-frame frame)) |
| 824 | (while (not (eq (frame-visible-p frame) t)) |
| 825 | (setq frame (next-frame frame))) |
| 826 | (setq arg (1- arg))) |
| 827 | (while (< arg 0) |
| 828 | (setq frame (previous-frame frame)) |
| 829 | (while (not (eq (frame-visible-p frame) t)) |
| 830 | (setq frame (previous-frame frame))) |
| 831 | (setq arg (1+ arg))) |
| 832 | (select-frame-set-input-focus frame))) |
| 833 | |
| 834 | (defun iconify-or-deiconify-frame () |
| 835 | "Iconify the selected frame, or deiconify if it's currently an icon." |
| 836 | (interactive) |
| 837 | (if (eq (cdr (assq 'visibility (frame-parameters))) t) |
| 838 | (iconify-frame) |
| 839 | (make-frame-visible))) |
| 840 | |
| 841 | (defun suspend-frame () |
| 842 | "Do whatever is right to suspend the current frame. |
| 843 | Calls `suspend-emacs' if invoked from the controlling tty device, |
| 844 | `suspend-tty' from a secondary tty device, and |
| 845 | `iconify-or-deiconify-frame' from an X frame." |
| 846 | (interactive) |
| 847 | (let ((type (framep (selected-frame)))) |
| 848 | (cond |
| 849 | ((memq type '(x ns w32)) (iconify-or-deiconify-frame)) |
| 850 | ((eq type t) |
| 851 | (if (controlling-tty-p) |
| 852 | (suspend-emacs) |
| 853 | (suspend-tty))) |
| 854 | (t (suspend-emacs))))) |
| 855 | |
| 856 | (defun make-frame-names-alist () |
| 857 | ;; Only consider the frames on the same display. |
| 858 | (let* ((current-frame (selected-frame)) |
| 859 | (falist |
| 860 | (cons |
| 861 | (cons (frame-parameter current-frame 'name) current-frame) nil)) |
| 862 | (frame (next-frame nil 0))) |
| 863 | (while (not (eq frame current-frame)) |
| 864 | (progn |
| 865 | (push (cons (frame-parameter frame 'name) frame) falist) |
| 866 | (setq frame (next-frame frame 0)))) |
| 867 | falist)) |
| 868 | |
| 869 | (defvar frame-name-history nil) |
| 870 | (defun select-frame-by-name (name) |
| 871 | "Select the frame on the current terminal whose name is NAME and raise it. |
| 872 | If there is no frame by that name, signal an error." |
| 873 | (interactive |
| 874 | (let* ((frame-names-alist (make-frame-names-alist)) |
| 875 | (default (car (car frame-names-alist))) |
| 876 | (input (completing-read |
| 877 | (format "Select Frame (default %s): " default) |
| 878 | frame-names-alist nil t nil 'frame-name-history))) |
| 879 | (if (= (length input) 0) |
| 880 | (list default) |
| 881 | (list input)))) |
| 882 | (let* ((frame-names-alist (make-frame-names-alist)) |
| 883 | (frame (cdr (assoc name frame-names-alist)))) |
| 884 | (if frame |
| 885 | (select-frame-set-input-focus frame) |
| 886 | (error "There is no frame named `%s'" name)))) |
| 887 | |
| 888 | \f |
| 889 | ;;;; Background mode. |
| 890 | |
| 891 | (defcustom frame-background-mode nil |
| 892 | "The brightness of the background. |
| 893 | Set this to the symbol `dark' if your background color is dark, |
| 894 | `light' if your background is light, or nil (automatic by default) |
| 895 | if you want Emacs to examine the brightness for you. |
| 896 | |
| 897 | If you change this without using customize, you should use |
| 898 | `frame-set-background-mode' to update existing frames; |
| 899 | e.g. (mapc 'frame-set-background-mode (frame-list))." |
| 900 | :group 'faces |
| 901 | :set #'(lambda (var value) |
| 902 | (set-default var value) |
| 903 | (mapc 'frame-set-background-mode (frame-list))) |
| 904 | :initialize 'custom-initialize-changed |
| 905 | :type '(choice (const dark) |
| 906 | (const light) |
| 907 | (const :tag "automatic" nil))) |
| 908 | |
| 909 | (declare-function x-get-resource "frame.c" |
| 910 | (attribute class &optional component subclass)) |
| 911 | |
| 912 | ;; Only used if window-system is not null. |
| 913 | (declare-function x-display-grayscale-p "xfns.c" (&optional terminal)) |
| 914 | |
| 915 | (defvar inhibit-frame-set-background-mode nil) |
| 916 | |
| 917 | (defun frame-set-background-mode (frame &optional keep-face-specs) |
| 918 | "Set up display-dependent faces on FRAME. |
| 919 | Display-dependent faces are those which have different definitions |
| 920 | according to the `background-mode' and `display-type' frame parameters. |
| 921 | |
| 922 | If optional arg KEEP-FACE-SPECS is non-nil, don't recalculate |
| 923 | face specs for the new background mode." |
| 924 | (unless inhibit-frame-set-background-mode |
| 925 | (let* ((frame-default-bg-mode (frame-terminal-default-bg-mode frame)) |
| 926 | (bg-color (frame-parameter frame 'background-color)) |
| 927 | (tty-type (tty-type frame)) |
| 928 | (default-bg-mode |
| 929 | (if (or (window-system frame) |
| 930 | (and tty-type |
| 931 | (string-match "^\\(xterm\\|\\rxvt\\|dtterm\\|eterm\\)" |
| 932 | tty-type))) |
| 933 | 'light |
| 934 | 'dark)) |
| 935 | (non-default-bg-mode (if (eq default-bg-mode 'light) 'dark 'light)) |
| 936 | (bg-mode |
| 937 | (cond (frame-default-bg-mode) |
| 938 | ((equal bg-color "unspecified-fg") ; inverted colors |
| 939 | non-default-bg-mode) |
| 940 | ((not (color-values bg-color frame)) |
| 941 | default-bg-mode) |
| 942 | ((>= (apply '+ (color-values bg-color frame)) |
| 943 | ;; Just looking at the screen, colors whose |
| 944 | ;; values add up to .6 of the white total |
| 945 | ;; still look dark to me. |
| 946 | (* (apply '+ (color-values "white" frame)) .6)) |
| 947 | 'light) |
| 948 | (t 'dark))) |
| 949 | (display-type |
| 950 | (cond ((null (window-system frame)) |
| 951 | (if (tty-display-color-p frame) 'color 'mono)) |
| 952 | ((display-color-p frame) |
| 953 | 'color) |
| 954 | ((x-display-grayscale-p frame) |
| 955 | 'grayscale) |
| 956 | (t 'mono))) |
| 957 | (old-bg-mode |
| 958 | (frame-parameter frame 'background-mode)) |
| 959 | (old-display-type |
| 960 | (frame-parameter frame 'display-type))) |
| 961 | |
| 962 | (unless (and (eq bg-mode old-bg-mode) (eq display-type old-display-type)) |
| 963 | (let ((locally-modified-faces nil) |
| 964 | ;; Prevent face-spec-recalc from calling this function |
| 965 | ;; again, resulting in a loop (bug#911). |
| 966 | (inhibit-frame-set-background-mode t) |
| 967 | (params (list (cons 'background-mode bg-mode) |
| 968 | (cons 'display-type display-type)))) |
| 969 | (if keep-face-specs |
| 970 | (modify-frame-parameters frame params) |
| 971 | ;; If we are recomputing face specs, first collect a list |
| 972 | ;; of faces that don't match their face-specs. These are |
| 973 | ;; the faces modified on FRAME, and we avoid changing them |
| 974 | ;; below. Use a negative list to avoid consing (we assume |
| 975 | ;; most faces are unmodified). |
| 976 | (dolist (face (face-list)) |
| 977 | (and (not (get face 'face-override-spec)) |
| 978 | (not (face-spec-match-p face |
| 979 | (face-user-default-spec face) |
| 980 | (selected-frame))) |
| 981 | (push face locally-modified-faces))) |
| 982 | ;; Now change to the new frame parameters |
| 983 | (modify-frame-parameters frame params) |
| 984 | ;; For all unmodified named faces, choose face specs |
| 985 | ;; matching the new frame parameters. |
| 986 | (dolist (face (face-list)) |
| 987 | (unless (memq face locally-modified-faces) |
| 988 | (face-spec-recalc face frame))))))))) |
| 989 | |
| 990 | (defun frame-terminal-default-bg-mode (frame) |
| 991 | "Return the default background mode of FRAME. |
| 992 | This checks the `frame-background-mode' variable, the X resource |
| 993 | named \"backgroundMode\" (if FRAME is an X frame), and finally |
| 994 | the `background-mode' terminal parameter." |
| 995 | (or frame-background-mode |
| 996 | (let ((bg-resource |
| 997 | (and (window-system frame) |
| 998 | (x-get-resource "backgroundMode" "BackgroundMode")))) |
| 999 | (if bg-resource |
| 1000 | (intern (downcase bg-resource)))) |
| 1001 | (terminal-parameter frame 'background-mode))) |
| 1002 | |
| 1003 | \f |
| 1004 | ;;;; Frame configurations |
| 1005 | |
| 1006 | (defun current-frame-configuration () |
| 1007 | "Return a list describing the positions and states of all frames. |
| 1008 | Its car is `frame-configuration'. |
| 1009 | Each element of the cdr is a list of the form (FRAME ALIST WINDOW-CONFIG), |
| 1010 | where |
| 1011 | FRAME is a frame object, |
| 1012 | ALIST is an association list specifying some of FRAME's parameters, and |
| 1013 | WINDOW-CONFIG is a window configuration object for FRAME." |
| 1014 | (cons 'frame-configuration |
| 1015 | (mapcar (lambda (frame) |
| 1016 | (list frame |
| 1017 | (frame-parameters frame) |
| 1018 | (current-window-configuration frame))) |
| 1019 | (frame-list)))) |
| 1020 | |
| 1021 | (defun set-frame-configuration (configuration &optional nodelete) |
| 1022 | "Restore the frames to the state described by CONFIGURATION. |
| 1023 | Each frame listed in CONFIGURATION has its position, size, window |
| 1024 | configuration, and other parameters set as specified in CONFIGURATION. |
| 1025 | However, this function does not restore deleted frames. |
| 1026 | |
| 1027 | Ordinarily, this function deletes all existing frames not |
| 1028 | listed in CONFIGURATION. But if optional second argument NODELETE |
| 1029 | is given and non-nil, the unwanted frames are iconified instead." |
| 1030 | (or (frame-configuration-p configuration) |
| 1031 | (signal 'wrong-type-argument |
| 1032 | (list 'frame-configuration-p configuration))) |
| 1033 | (let ((config-alist (cdr configuration)) |
| 1034 | frames-to-delete) |
| 1035 | (dolist (frame (frame-list)) |
| 1036 | (let ((parameters (assq frame config-alist))) |
| 1037 | (if parameters |
| 1038 | (progn |
| 1039 | (modify-frame-parameters |
| 1040 | frame |
| 1041 | ;; Since we can't set a frame's minibuffer status, |
| 1042 | ;; we might as well omit the parameter altogether. |
| 1043 | (let* ((parms (nth 1 parameters)) |
| 1044 | (mini (assq 'minibuffer parms)) |
| 1045 | (name (assq 'name parms)) |
| 1046 | (explicit-name (cdr (assq 'explicit-name parms)))) |
| 1047 | (when mini (setq parms (delq mini parms))) |
| 1048 | ;; Leave name in iff it was set explicitly. |
| 1049 | ;; This should fix the behavior reported in |
| 1050 | ;; http://lists.gnu.org/archive/html/emacs-devel/2007-08/msg01632.html |
| 1051 | (when (and name (not explicit-name)) |
| 1052 | (setq parms (delq name parms))) |
| 1053 | parms)) |
| 1054 | (set-window-configuration (nth 2 parameters))) |
| 1055 | (setq frames-to-delete (cons frame frames-to-delete))))) |
| 1056 | (mapc (if nodelete |
| 1057 | ;; Note: making frames invisible here was tried |
| 1058 | ;; but led to some strange behavior--each time the frame |
| 1059 | ;; was made visible again, the window manager asked afresh |
| 1060 | ;; for where to put it. |
| 1061 | 'iconify-frame |
| 1062 | 'delete-frame) |
| 1063 | frames-to-delete))) |
| 1064 | \f |
| 1065 | ;;;; Convenience functions for accessing and interactively changing |
| 1066 | ;;;; frame parameters. |
| 1067 | |
| 1068 | (defun frame-height (&optional frame) |
| 1069 | "Return number of lines available for display on FRAME. |
| 1070 | If FRAME is omitted, describe the currently selected frame. |
| 1071 | Exactly what is included in the return value depends on the |
| 1072 | window-system and toolkit in use - see `frame-pixel-height' for |
| 1073 | more details. The lines are in units of the default font height. |
| 1074 | |
| 1075 | The result is roughly related to the frame pixel height via |
| 1076 | height in pixels = height in lines * `frame-char-height'. |
| 1077 | However, this is only approximate, and is complicated e.g. by the |
| 1078 | fact that individual window lines and menu bar lines can have |
| 1079 | differing font heights." |
| 1080 | (cdr (assq 'height (frame-parameters frame)))) |
| 1081 | |
| 1082 | (defun frame-width (&optional frame) |
| 1083 | "Return number of columns available for display on FRAME. |
| 1084 | If FRAME is omitted, describe the currently selected frame." |
| 1085 | (cdr (assq 'width (frame-parameters frame)))) |
| 1086 | |
| 1087 | (declare-function x-list-fonts "xfaces.c" |
| 1088 | (pattern &optional face frame maximum width)) |
| 1089 | |
| 1090 | (define-obsolete-function-alias 'set-default-font 'set-frame-font "23.1") |
| 1091 | |
| 1092 | (defun set-frame-font (font &optional keep-size frames) |
| 1093 | "Set the default font to FONT. |
| 1094 | When called interactively, prompt for the name of a font, and use |
| 1095 | that font on the selected frame. When called from Lisp, FONT |
| 1096 | should be a font name (a string), a font object, font entity, or |
| 1097 | font spec. |
| 1098 | |
| 1099 | If KEEP-SIZE is nil, keep the number of frame lines and columns |
| 1100 | fixed. If KEEP-SIZE is non-nil (or with a prefix argument), try |
| 1101 | to keep the current frame size fixed (in pixels) by adjusting the |
| 1102 | number of lines and columns. |
| 1103 | |
| 1104 | If FRAMES is nil, apply the font to the selected frame only. |
| 1105 | If FRAMES is non-nil, it should be a list of frames to act upon, |
| 1106 | or t meaning all existing graphical frames. |
| 1107 | Also, if FRAMES is non-nil, alter the user's Customization settings |
| 1108 | as though the font-related attributes of the `default' face had been |
| 1109 | \"set in this session\", so that the font is applied to future frames." |
| 1110 | (interactive |
| 1111 | (let* ((completion-ignore-case t) |
| 1112 | (font (completing-read "Font name: " |
| 1113 | ;; x-list-fonts will fail with an error |
| 1114 | ;; if this frame doesn't support fonts. |
| 1115 | (x-list-fonts "*" nil (selected-frame)) |
| 1116 | nil nil nil nil |
| 1117 | (frame-parameter nil 'font)))) |
| 1118 | (list font current-prefix-arg nil))) |
| 1119 | (when (or (stringp font) (fontp font)) |
| 1120 | (let* ((this-frame (selected-frame)) |
| 1121 | ;; FRAMES nil means affect the selected frame. |
| 1122 | (frame-list (cond ((null frames) |
| 1123 | (list this-frame)) |
| 1124 | ((eq frames t) |
| 1125 | (frame-list)) |
| 1126 | (t frames))) |
| 1127 | height width) |
| 1128 | (dolist (f frame-list) |
| 1129 | (when (display-multi-font-p f) |
| 1130 | (if keep-size |
| 1131 | (setq height (* (frame-parameter f 'height) |
| 1132 | (frame-char-height f)) |
| 1133 | width (* (frame-parameter f 'width) |
| 1134 | (frame-char-width f)))) |
| 1135 | ;; When set-face-attribute is called for :font, Emacs |
| 1136 | ;; guesses the best font according to other face attributes |
| 1137 | ;; (:width, :weight, etc.) so reset them too (Bug#2476). |
| 1138 | (set-face-attribute 'default f |
| 1139 | :width 'normal :weight 'normal |
| 1140 | :slant 'normal :font font) |
| 1141 | (if keep-size |
| 1142 | (modify-frame-parameters |
| 1143 | f |
| 1144 | (list (cons 'height (round height (frame-char-height f))) |
| 1145 | (cons 'width (round width (frame-char-width f)))))))) |
| 1146 | (when frames |
| 1147 | ;; Alter the user's Custom setting of the `default' face, but |
| 1148 | ;; only for font-related attributes. |
| 1149 | (let ((specs (cadr (assq 'user (get 'default 'theme-face)))) |
| 1150 | (attrs '(:family :foundry :slant :weight :height :width)) |
| 1151 | (new-specs nil)) |
| 1152 | (if (null specs) (setq specs '((t nil)))) |
| 1153 | (dolist (spec specs) |
| 1154 | ;; Each SPEC has the form (DISPLAY ATTRIBUTE-PLIST) |
| 1155 | (let ((display (nth 0 spec)) |
| 1156 | (plist (copy-tree (nth 1 spec)))) |
| 1157 | ;; Alter only DISPLAY conditions matching this frame. |
| 1158 | (when (or (memq display '(t default)) |
| 1159 | (face-spec-set-match-display display this-frame)) |
| 1160 | (dolist (attr attrs) |
| 1161 | (setq plist (plist-put plist attr |
| 1162 | (face-attribute 'default attr))))) |
| 1163 | (push (list display plist) new-specs))) |
| 1164 | (setq new-specs (nreverse new-specs)) |
| 1165 | (put 'default 'customized-face new-specs) |
| 1166 | (custom-push-theme 'theme-face 'default 'user 'set new-specs) |
| 1167 | (put 'default 'face-modified nil)))) |
| 1168 | (run-hooks 'after-setting-font-hook 'after-setting-font-hooks))) |
| 1169 | |
| 1170 | (defun set-frame-parameter (frame parameter value) |
| 1171 | "Set frame parameter PARAMETER to VALUE on FRAME. |
| 1172 | If FRAME is nil, it defaults to the selected frame. |
| 1173 | See `modify-frame-parameters'." |
| 1174 | (modify-frame-parameters frame (list (cons parameter value)))) |
| 1175 | |
| 1176 | (defun set-background-color (color-name) |
| 1177 | "Set the background color of the selected frame to COLOR-NAME. |
| 1178 | When called interactively, prompt for the name of the color to use. |
| 1179 | To get the frame's current background color, use `frame-parameters'." |
| 1180 | (interactive (list (read-color "Background color: "))) |
| 1181 | (modify-frame-parameters (selected-frame) |
| 1182 | (list (cons 'background-color color-name))) |
| 1183 | (or window-system |
| 1184 | (face-set-after-frame-default (selected-frame)))) |
| 1185 | |
| 1186 | (defun set-foreground-color (color-name) |
| 1187 | "Set the foreground color of the selected frame to COLOR-NAME. |
| 1188 | When called interactively, prompt for the name of the color to use. |
| 1189 | To get the frame's current foreground color, use `frame-parameters'." |
| 1190 | (interactive (list (read-color "Foreground color: "))) |
| 1191 | (modify-frame-parameters (selected-frame) |
| 1192 | (list (cons 'foreground-color color-name))) |
| 1193 | (or window-system |
| 1194 | (face-set-after-frame-default (selected-frame)))) |
| 1195 | |
| 1196 | (defun set-cursor-color (color-name) |
| 1197 | "Set the text cursor color of the selected frame to COLOR-NAME. |
| 1198 | When called interactively, prompt for the name of the color to use. |
| 1199 | This works by setting the `cursor-color' frame parameter on the |
| 1200 | selected frame. |
| 1201 | |
| 1202 | You can also set the text cursor color, for all frames, by |
| 1203 | customizing the `cursor' face." |
| 1204 | (interactive (list (read-color "Cursor color: "))) |
| 1205 | (modify-frame-parameters (selected-frame) |
| 1206 | (list (cons 'cursor-color color-name)))) |
| 1207 | |
| 1208 | (defun set-mouse-color (color-name) |
| 1209 | "Set the color of the mouse pointer of the selected frame to COLOR-NAME. |
| 1210 | When called interactively, prompt for the name of the color to use. |
| 1211 | To get the frame's current mouse color, use `frame-parameters'." |
| 1212 | (interactive (list (read-color "Mouse color: "))) |
| 1213 | (modify-frame-parameters (selected-frame) |
| 1214 | (list (cons 'mouse-color |
| 1215 | (or color-name |
| 1216 | (cdr (assq 'mouse-color |
| 1217 | (frame-parameters)))))))) |
| 1218 | |
| 1219 | (defun set-border-color (color-name) |
| 1220 | "Set the color of the border of the selected frame to COLOR-NAME. |
| 1221 | When called interactively, prompt for the name of the color to use. |
| 1222 | To get the frame's current border color, use `frame-parameters'." |
| 1223 | (interactive (list (read-color "Border color: "))) |
| 1224 | (modify-frame-parameters (selected-frame) |
| 1225 | (list (cons 'border-color color-name)))) |
| 1226 | |
| 1227 | (define-minor-mode auto-raise-mode |
| 1228 | "Toggle whether or not selected frames should auto-raise. |
| 1229 | With a prefix argument ARG, enable Auto Raise mode if ARG is |
| 1230 | positive, and disable it otherwise. If called from Lisp, enable |
| 1231 | the mode if ARG is omitted or nil. |
| 1232 | |
| 1233 | Auto Raise mode does nothing under most window managers, which |
| 1234 | switch focus on mouse clicks. It only has an effect if your |
| 1235 | window manager switches focus on mouse movement (in which case |
| 1236 | you should also change `focus-follows-mouse' to t). Then, |
| 1237 | enabling Auto Raise mode causes any graphical Emacs frame which |
| 1238 | acquires focus to be automatically raised. |
| 1239 | |
| 1240 | Note that this minor mode controls Emacs's own auto-raise |
| 1241 | feature. Window managers that switch focus on mouse movement |
| 1242 | often have their own auto-raise feature." |
| 1243 | :variable (frame-parameter nil 'auto-raise) |
| 1244 | (if (frame-parameter nil 'auto-raise) |
| 1245 | (raise-frame))) |
| 1246 | |
| 1247 | (define-minor-mode auto-lower-mode |
| 1248 | "Toggle whether or not the selected frame should auto-lower. |
| 1249 | With a prefix argument ARG, enable Auto Lower mode if ARG is |
| 1250 | positive, and disable it otherwise. If called from Lisp, enable |
| 1251 | the mode if ARG is omitted or nil. |
| 1252 | |
| 1253 | Auto Lower mode does nothing under most window managers, which |
| 1254 | switch focus on mouse clicks. It only has an effect if your |
| 1255 | window manager switches focus on mouse movement (in which case |
| 1256 | you should also change `focus-follows-mouse' to t). Then, |
| 1257 | enabling Auto Lower Mode causes any graphical Emacs frame which |
| 1258 | loses focus to be automatically lowered. |
| 1259 | |
| 1260 | Note that this minor mode controls Emacs's own auto-lower |
| 1261 | feature. Window managers that switch focus on mouse movement |
| 1262 | often have their own features for raising or lowering frames." |
| 1263 | :variable (frame-parameter nil 'auto-lower)) |
| 1264 | |
| 1265 | (defun set-frame-name (name) |
| 1266 | "Set the name of the selected frame to NAME. |
| 1267 | When called interactively, prompt for the name of the frame. |
| 1268 | On text terminals, the frame name is displayed on the mode line. |
| 1269 | On graphical displays, it is displayed on the frame's title bar." |
| 1270 | (interactive "sFrame name: ") |
| 1271 | (modify-frame-parameters (selected-frame) |
| 1272 | (list (cons 'name name)))) |
| 1273 | |
| 1274 | (defun frame-current-scroll-bars (&optional frame) |
| 1275 | "Return the current scroll-bar settings in frame FRAME. |
| 1276 | Value is a cons (VERTICAL . HORIZ0NTAL) where VERTICAL specifies the |
| 1277 | current location of the vertical scroll-bars (left, right, or nil), |
| 1278 | and HORIZONTAL specifies the current location of the horizontal scroll |
| 1279 | bars (top, bottom, or nil)." |
| 1280 | (let ((vert (frame-parameter frame 'vertical-scroll-bars)) |
| 1281 | (hor nil)) |
| 1282 | (unless (memq vert '(left right nil)) |
| 1283 | (setq vert default-frame-scroll-bars)) |
| 1284 | (cons vert hor))) |
| 1285 | |
| 1286 | (defun frame-monitor-attributes (&optional frame) |
| 1287 | "Return the attributes of the physical monitor dominating FRAME. |
| 1288 | If FRAME is omitted, describe the currently selected frame. |
| 1289 | |
| 1290 | A frame is dominated by a physical monitor when either the |
| 1291 | largest area of the frame resides in the monitor, or the monitor |
| 1292 | is the closest to the frame if the frame does not intersect any |
| 1293 | physical monitors. |
| 1294 | |
| 1295 | See `display-monitor-attributes-list' for the list of attribute |
| 1296 | keys and their meanings." |
| 1297 | (or frame (setq frame (selected-frame))) |
| 1298 | (labels ((loop (list) |
| 1299 | (let* ((attributes (car list)) |
| 1300 | (frames (cdr (assq 'frames attributes)))) |
| 1301 | (if (memq frame frames) |
| 1302 | attributes |
| 1303 | (loop (cdr list)))))) |
| 1304 | (loop (display-monitor-attributes-list frame)))) |
| 1305 | |
| 1306 | \f |
| 1307 | ;;;; Frame/display capabilities. |
| 1308 | |
| 1309 | (declare-function msdos-mouse-p "dosfns.c") |
| 1310 | |
| 1311 | (defun display-mouse-p (&optional display) |
| 1312 | "Return non-nil if DISPLAY has a mouse available. |
| 1313 | DISPLAY can be a display name, a frame, or nil (meaning the selected |
| 1314 | frame's display)." |
| 1315 | (let ((frame-type (framep-on-display display))) |
| 1316 | (cond |
| 1317 | ((eq frame-type 'pc) |
| 1318 | (msdos-mouse-p)) |
| 1319 | ((eq frame-type 'w32) |
| 1320 | (with-no-warnings |
| 1321 | (> w32-num-mouse-buttons 0))) |
| 1322 | ((memq frame-type '(x ns)) |
| 1323 | t) ;; We assume X and NeXTstep *always* have a pointing device |
| 1324 | (t |
| 1325 | (or (and (featurep 'xt-mouse) |
| 1326 | xterm-mouse-mode) |
| 1327 | ;; t-mouse is distributed with the GPM package. It doesn't have |
| 1328 | ;; a toggle. |
| 1329 | (featurep 't-mouse) |
| 1330 | ;; No way to check whether a w32 console has a mouse, assume |
| 1331 | ;; it always does. |
| 1332 | (boundp 'w32-use-full-screen-buffer)))))) |
| 1333 | |
| 1334 | (defun display-popup-menus-p (&optional display) |
| 1335 | "Return non-nil if popup menus are supported on DISPLAY. |
| 1336 | DISPLAY can be a display name, a frame, or nil (meaning the selected |
| 1337 | frame's display). |
| 1338 | Support for popup menus requires that the mouse be available." |
| 1339 | (display-mouse-p display)) |
| 1340 | |
| 1341 | (defun display-graphic-p (&optional display) |
| 1342 | "Return non-nil if DISPLAY is a graphic display. |
| 1343 | Graphical displays are those which are capable of displaying several |
| 1344 | frames and several different fonts at once. This is true for displays |
| 1345 | that use a window system such as X, and false for text-only terminals. |
| 1346 | DISPLAY can be a display name, a frame, or nil (meaning the selected |
| 1347 | frame's display)." |
| 1348 | (not (null (memq (framep-on-display display) '(x w32 ns))))) |
| 1349 | |
| 1350 | (defun display-images-p (&optional display) |
| 1351 | "Return non-nil if DISPLAY can display images. |
| 1352 | |
| 1353 | DISPLAY can be a display name, a frame, or nil (meaning the selected |
| 1354 | frame's display)." |
| 1355 | (and (display-graphic-p display) |
| 1356 | (fboundp 'image-mask-p) |
| 1357 | (fboundp 'image-size))) |
| 1358 | |
| 1359 | (defalias 'display-multi-frame-p 'display-graphic-p) |
| 1360 | (defalias 'display-multi-font-p 'display-graphic-p) |
| 1361 | |
| 1362 | (defun display-selections-p (&optional display) |
| 1363 | "Return non-nil if DISPLAY supports selections. |
| 1364 | A selection is a way to transfer text or other data between programs |
| 1365 | via special system buffers called `selection' or `clipboard'. |
| 1366 | DISPLAY can be a display name, a frame, or nil (meaning the selected |
| 1367 | frame's display)." |
| 1368 | (let ((frame-type (framep-on-display display))) |
| 1369 | (cond |
| 1370 | ((eq frame-type 'pc) |
| 1371 | ;; MS-DOG frames support selections when Emacs runs inside |
| 1372 | ;; the Windows' DOS Box. |
| 1373 | (with-no-warnings |
| 1374 | (not (null dos-windows-version)))) |
| 1375 | ((memq frame-type '(x w32 ns)) |
| 1376 | t) |
| 1377 | (t |
| 1378 | nil)))) |
| 1379 | |
| 1380 | (declare-function x-display-screens "xfns.c" (&optional terminal)) |
| 1381 | |
| 1382 | (defun display-screens (&optional display) |
| 1383 | "Return the number of screens associated with DISPLAY. |
| 1384 | If DISPLAY is omitted or nil, it defaults to the selected frame's display." |
| 1385 | (let ((frame-type (framep-on-display display))) |
| 1386 | (cond |
| 1387 | ((memq frame-type '(x w32 ns)) |
| 1388 | (x-display-screens display)) |
| 1389 | (t |
| 1390 | 1)))) |
| 1391 | |
| 1392 | (declare-function x-display-pixel-height "xfns.c" (&optional terminal)) |
| 1393 | |
| 1394 | (defun display-pixel-height (&optional display) |
| 1395 | "Return the height of DISPLAY's screen in pixels. |
| 1396 | If DISPLAY is omitted or nil, it defaults to the selected frame's display. |
| 1397 | |
| 1398 | For character terminals, each character counts as a single pixel. |
| 1399 | |
| 1400 | For graphical terminals, note that on \"multi-monitor\" setups this |
| 1401 | refers to the pixel height for all physical monitors associated |
| 1402 | with DISPLAY. To get information for each physical monitor, use |
| 1403 | `display-monitor-attributes-list'." |
| 1404 | (let ((frame-type (framep-on-display display))) |
| 1405 | (cond |
| 1406 | ((memq frame-type '(x w32 ns)) |
| 1407 | (x-display-pixel-height display)) |
| 1408 | (t |
| 1409 | (frame-height (if (framep display) display (selected-frame))))))) |
| 1410 | |
| 1411 | (declare-function x-display-pixel-width "xfns.c" (&optional terminal)) |
| 1412 | |
| 1413 | (defun display-pixel-width (&optional display) |
| 1414 | "Return the width of DISPLAY's screen in pixels. |
| 1415 | If DISPLAY is omitted or nil, it defaults to the selected frame's display. |
| 1416 | |
| 1417 | For character terminals, each character counts as a single pixel. |
| 1418 | |
| 1419 | For graphical terminals, note that on \"multi-monitor\" setups this |
| 1420 | refers to the pixel width for all physical monitors associated |
| 1421 | with DISPLAY. To get information for each physical monitor, use |
| 1422 | `display-monitor-attributes-list'." |
| 1423 | (let ((frame-type (framep-on-display display))) |
| 1424 | (cond |
| 1425 | ((memq frame-type '(x w32 ns)) |
| 1426 | (x-display-pixel-width display)) |
| 1427 | (t |
| 1428 | (frame-width (if (framep display) display (selected-frame))))))) |
| 1429 | |
| 1430 | (defcustom display-mm-dimensions-alist nil |
| 1431 | "Alist for specifying screen dimensions in millimeters. |
| 1432 | The functions `display-mm-height' and `display-mm-width' consult |
| 1433 | this list before asking the system. |
| 1434 | |
| 1435 | Each element has the form (DISPLAY . (WIDTH . HEIGHT)), e.g. |
| 1436 | \(\":0.0\" . (287 . 215)). |
| 1437 | |
| 1438 | If `display' is t, it specifies dimensions for all graphical displays |
| 1439 | not explicitly specified." |
| 1440 | :version "22.1" |
| 1441 | :type '(alist :key-type (choice (string :tag "Display name") |
| 1442 | (const :tag "Default" t)) |
| 1443 | :value-type (cons :tag "Dimensions" |
| 1444 | (integer :tag "Width") |
| 1445 | (integer :tag "Height"))) |
| 1446 | :group 'frames) |
| 1447 | |
| 1448 | (declare-function x-display-mm-height "xfns.c" (&optional terminal)) |
| 1449 | |
| 1450 | (defun display-mm-height (&optional display) |
| 1451 | "Return the height of DISPLAY's screen in millimeters. |
| 1452 | If the information is unavailable, this function returns nil. |
| 1453 | If DISPLAY is omitted or nil, it defaults to the selected frame's display. |
| 1454 | |
| 1455 | You can override what the system thinks the result should be by |
| 1456 | adding an entry to `display-mm-dimensions-alist'. |
| 1457 | |
| 1458 | For graphical terminals, note that on \"multi-monitor\" setups this |
| 1459 | refers to the height in millimeters for all physical monitors |
| 1460 | associated with DISPLAY. To get information for each physical |
| 1461 | monitor, use `display-monitor-attributes-list'." |
| 1462 | (and (memq (framep-on-display display) '(x w32 ns)) |
| 1463 | (or (cddr (assoc (or display (frame-parameter nil 'display)) |
| 1464 | display-mm-dimensions-alist)) |
| 1465 | (cddr (assoc t display-mm-dimensions-alist)) |
| 1466 | (x-display-mm-height display)))) |
| 1467 | |
| 1468 | (declare-function x-display-mm-width "xfns.c" (&optional terminal)) |
| 1469 | |
| 1470 | (defun display-mm-width (&optional display) |
| 1471 | "Return the width of DISPLAY's screen in millimeters. |
| 1472 | If the information is unavailable, this function returns nil. |
| 1473 | If DISPLAY is omitted or nil, it defaults to the selected frame's display. |
| 1474 | |
| 1475 | You can override what the system thinks the result should be by |
| 1476 | adding an entry to `display-mm-dimensions-alist'. |
| 1477 | |
| 1478 | For graphical terminals, note that on \"multi-monitor\" setups this |
| 1479 | refers to the width in millimeters for all physical monitors |
| 1480 | associated with DISPLAY. To get information for each physical |
| 1481 | monitor, use `display-monitor-attributes-list'." |
| 1482 | (and (memq (framep-on-display display) '(x w32 ns)) |
| 1483 | (or (cadr (assoc (or display (frame-parameter nil 'display)) |
| 1484 | display-mm-dimensions-alist)) |
| 1485 | (cadr (assoc t display-mm-dimensions-alist)) |
| 1486 | (x-display-mm-width display)))) |
| 1487 | |
| 1488 | (declare-function x-display-backing-store "xfns.c" (&optional terminal)) |
| 1489 | |
| 1490 | ;; In NS port, the return value may be `buffered', `retained', or |
| 1491 | ;; `non-retained'. See src/nsfns.m. |
| 1492 | (defun display-backing-store (&optional display) |
| 1493 | "Return the backing store capability of DISPLAY's screen. |
| 1494 | The value may be `always', `when-mapped', `not-useful', or nil if |
| 1495 | the question is inapplicable to a certain kind of display. |
| 1496 | If DISPLAY is omitted or nil, it defaults to the selected frame's display." |
| 1497 | (let ((frame-type (framep-on-display display))) |
| 1498 | (cond |
| 1499 | ((memq frame-type '(x w32 ns)) |
| 1500 | (x-display-backing-store display)) |
| 1501 | (t |
| 1502 | 'not-useful)))) |
| 1503 | |
| 1504 | (declare-function x-display-save-under "xfns.c" (&optional terminal)) |
| 1505 | |
| 1506 | (defun display-save-under (&optional display) |
| 1507 | "Return non-nil if DISPLAY's screen supports the SaveUnder feature. |
| 1508 | If DISPLAY is omitted or nil, it defaults to the selected frame's display." |
| 1509 | (let ((frame-type (framep-on-display display))) |
| 1510 | (cond |
| 1511 | ((memq frame-type '(x w32 ns)) |
| 1512 | (x-display-save-under display)) |
| 1513 | (t |
| 1514 | 'not-useful)))) |
| 1515 | |
| 1516 | (declare-function x-display-planes "xfns.c" (&optional terminal)) |
| 1517 | |
| 1518 | (defun display-planes (&optional display) |
| 1519 | "Return the number of planes supported by DISPLAY. |
| 1520 | If DISPLAY is omitted or nil, it defaults to the selected frame's display." |
| 1521 | (let ((frame-type (framep-on-display display))) |
| 1522 | (cond |
| 1523 | ((memq frame-type '(x w32 ns)) |
| 1524 | (x-display-planes display)) |
| 1525 | ((eq frame-type 'pc) |
| 1526 | 4) |
| 1527 | (t |
| 1528 | (truncate (log (length (tty-color-alist)) 2)))))) |
| 1529 | |
| 1530 | (declare-function x-display-color-cells "xfns.c" (&optional terminal)) |
| 1531 | |
| 1532 | (defun display-color-cells (&optional display) |
| 1533 | "Return the number of color cells supported by DISPLAY. |
| 1534 | If DISPLAY is omitted or nil, it defaults to the selected frame's display." |
| 1535 | (let ((frame-type (framep-on-display display))) |
| 1536 | (cond |
| 1537 | ((memq frame-type '(x w32 ns)) |
| 1538 | (x-display-color-cells display)) |
| 1539 | ((eq frame-type 'pc) |
| 1540 | 16) |
| 1541 | (t |
| 1542 | (tty-display-color-cells display))))) |
| 1543 | |
| 1544 | (declare-function x-display-visual-class "xfns.c" (&optional terminal)) |
| 1545 | |
| 1546 | (defun display-visual-class (&optional display) |
| 1547 | "Return the visual class of DISPLAY. |
| 1548 | The value is one of the symbols `static-gray', `gray-scale', |
| 1549 | `static-color', `pseudo-color', `true-color', or `direct-color'. |
| 1550 | If DISPLAY is omitted or nil, it defaults to the selected frame's display." |
| 1551 | (let ((frame-type (framep-on-display display))) |
| 1552 | (cond |
| 1553 | ((memq frame-type '(x w32 ns)) |
| 1554 | (x-display-visual-class display)) |
| 1555 | ((and (memq frame-type '(pc t)) |
| 1556 | (tty-display-color-p display)) |
| 1557 | 'static-color) |
| 1558 | (t |
| 1559 | 'static-gray)))) |
| 1560 | |
| 1561 | (declare-function x-display-monitor-attributes-list "xfns.c" |
| 1562 | (&optional terminal)) |
| 1563 | (declare-function w32-display-monitor-attributes-list "w32fns.c" |
| 1564 | (&optional display)) |
| 1565 | (declare-function ns-display-monitor-attributes-list "nsfns.m" |
| 1566 | (&optional terminal)) |
| 1567 | |
| 1568 | (defun display-monitor-attributes-list (&optional display) |
| 1569 | "Return a list of physical monitor attributes on DISPLAY. |
| 1570 | Each element of the list represents the attributes of each |
| 1571 | physical monitor. The first element corresponds to the primary |
| 1572 | monitor. |
| 1573 | |
| 1574 | Attributes for a physical monitor is represented as an alist of |
| 1575 | attribute keys and values as follows: |
| 1576 | |
| 1577 | geometry -- Position and size in pixels in the form of |
| 1578 | (X Y WIDTH HEIGHT) |
| 1579 | workarea -- Position and size of the workarea in pixels in the |
| 1580 | form of (X Y WIDTH HEIGHT) |
| 1581 | mm-size -- Width and height in millimeters in the form of |
| 1582 | (WIDTH HEIGHT) |
| 1583 | frames -- List of frames dominated by the physical monitor |
| 1584 | name (*) -- Name of the physical monitor as a string |
| 1585 | |
| 1586 | where X, Y, WIDTH, and HEIGHT are integers. Keys labeled |
| 1587 | with (*) are optional. |
| 1588 | |
| 1589 | A frame is dominated by a physical monitor when either the |
| 1590 | largest area of the frame resides in the monitor, or the monitor |
| 1591 | is the closest to the frame if the frame does not intersect any |
| 1592 | physical monitors. Every non-tip frame (including invisible one) |
| 1593 | in a graphical display is dominated by exactly one physical |
| 1594 | monitor at a time, though it can span multiple (or no) physical |
| 1595 | monitors. |
| 1596 | If DISPLAY is omitted or nil, it defaults to the selected frame's display." |
| 1597 | (let ((frame-type (framep-on-display display))) |
| 1598 | (cond |
| 1599 | ((eq frame-type 'x) |
| 1600 | (x-display-monitor-attributes-list display)) |
| 1601 | ((eq frame-type 'w32) |
| 1602 | (w32-display-monitor-attributes-list display)) |
| 1603 | ((eq frame-type 'ns) |
| 1604 | (ns-display-monitor-attributes-list display)) |
| 1605 | (t |
| 1606 | (let ((geometry (list 0 0 (display-pixel-width display) |
| 1607 | (display-pixel-height display)))) |
| 1608 | `(((geometry . ,geometry) |
| 1609 | (workarea . ,geometry) |
| 1610 | (mm-size . (,(display-mm-width display) |
| 1611 | ,(display-mm-height display))) |
| 1612 | (frames . ,(frames-on-display-list display))))))))) |
| 1613 | |
| 1614 | \f |
| 1615 | ;;;; Frame geometry values |
| 1616 | |
| 1617 | (defun frame-geom-value-cons (type value &optional frame) |
| 1618 | "Return equivalent geometry value for FRAME as a cons with car `+'. |
| 1619 | A geometry value equivalent to VALUE for FRAME is returned, |
| 1620 | where the value is a cons with car `+', not numeric. |
| 1621 | TYPE is the car of the original geometry spec (TYPE . VALUE). |
| 1622 | It is `top' or `left', depending on which edge VALUE is related to. |
| 1623 | VALUE is the cdr of a frame geometry spec: (left/top . VALUE). |
| 1624 | If VALUE is a number, then it is converted to a cons value, perhaps |
| 1625 | relative to the opposite frame edge from that in the original spec. |
| 1626 | FRAME defaults to the selected frame. |
| 1627 | |
| 1628 | Examples (measures in pixels) - |
| 1629 | Assuming display height/width=1024, frame height/width=600: |
| 1630 | 300 inside display edge: 300 => (+ 300) |
| 1631 | (+ 300) => (+ 300) |
| 1632 | 300 inside opposite display edge: (- 300) => (+ 124) |
| 1633 | -300 => (+ 124) |
| 1634 | 300 beyond display edge |
| 1635 | (= 724 inside opposite display edge): (+ -300) => (+ -300) |
| 1636 | 300 beyond display edge |
| 1637 | (= 724 inside opposite display edge): (- -300) => (+ 724) |
| 1638 | |
| 1639 | In the 3rd, 4th, and 6th examples, the returned value is relative to |
| 1640 | the opposite frame edge from the edge indicated in the input spec." |
| 1641 | (cond ((and (consp value) (eq '+ (car value))) ; e.g. (+ 300), (+ -300) |
| 1642 | value) |
| 1643 | ((natnump value) (list '+ value)) ; e.g. 300 => (+ 300) |
| 1644 | (t ; e.g. -300, (- 300), (- -300) |
| 1645 | (list '+ (- (if (eq 'left type) ; => (+ 124), (+ 124), (+ 724) |
| 1646 | (x-display-pixel-width) |
| 1647 | (x-display-pixel-height)) |
| 1648 | (if (integerp value) (- value) (cadr value)) |
| 1649 | (if (eq 'left type) |
| 1650 | (frame-pixel-width frame) |
| 1651 | (frame-pixel-height frame))))))) |
| 1652 | |
| 1653 | (defun frame-geom-spec-cons (spec &optional frame) |
| 1654 | "Return equivalent geometry spec for FRAME as a cons with car `+'. |
| 1655 | A geometry specification equivalent to SPEC for FRAME is returned, |
| 1656 | where the value is a cons with car `+', not numeric. |
| 1657 | SPEC is a frame geometry spec: (left . VALUE) or (top . VALUE). |
| 1658 | If VALUE is a number, then it is converted to a cons value, perhaps |
| 1659 | relative to the opposite frame edge from that in the original spec. |
| 1660 | FRAME defaults to the selected frame. |
| 1661 | |
| 1662 | Examples (measures in pixels) - |
| 1663 | Assuming display height=1024, frame height=600: |
| 1664 | top 300 below display top: (top . 300) => (top + 300) |
| 1665 | (top + 300) => (top + 300) |
| 1666 | bottom 300 above display bottom: (top - 300) => (top + 124) |
| 1667 | (top . -300) => (top + 124) |
| 1668 | top 300 above display top |
| 1669 | (= bottom 724 above display bottom): (top + -300) => (top + -300) |
| 1670 | bottom 300 below display bottom |
| 1671 | (= top 724 below display top): (top - -300) => (top + 724) |
| 1672 | |
| 1673 | In the 3rd, 4th, and 6th examples, the returned value is relative to |
| 1674 | the opposite frame edge from the edge indicated in the input spec." |
| 1675 | (cons (car spec) (frame-geom-value-cons (car spec) (cdr spec) frame))) |
| 1676 | \f |
| 1677 | |
| 1678 | (defun delete-other-frames (&optional frame) |
| 1679 | "Delete all frames on the current terminal, except FRAME. |
| 1680 | If FRAME uses another frame's minibuffer, the minibuffer frame is |
| 1681 | left untouched. FRAME nil or omitted means use the selected frame." |
| 1682 | (interactive) |
| 1683 | (unless frame |
| 1684 | (setq frame (selected-frame))) |
| 1685 | (let* ((mini-frame (window-frame (minibuffer-window frame))) |
| 1686 | (frames (delq mini-frame (delq frame (frame-list))))) |
| 1687 | ;; Only consider frames on the same terminal. |
| 1688 | (dolist (frame (prog1 frames (setq frames nil))) |
| 1689 | (if (eq (frame-terminal) (frame-terminal frame)) |
| 1690 | (push frame frames))) |
| 1691 | ;; Delete mon-minibuffer-only frames first, because `delete-frame' |
| 1692 | ;; signals an error when trying to delete a mini-frame that's |
| 1693 | ;; still in use by another frame. |
| 1694 | (dolist (frame frames) |
| 1695 | (unless (eq (frame-parameter frame 'minibuffer) 'only) |
| 1696 | (delete-frame frame))) |
| 1697 | ;; Delete minibuffer-only frames. |
| 1698 | (dolist (frame frames) |
| 1699 | (when (eq (frame-parameter frame 'minibuffer) 'only) |
| 1700 | (delete-frame frame))))) |
| 1701 | |
| 1702 | ;; miscellaneous obsolescence declarations |
| 1703 | (define-obsolete-variable-alias 'delete-frame-hook |
| 1704 | 'delete-frame-functions "22.1") |
| 1705 | |
| 1706 | \f |
| 1707 | ;; Blinking cursor |
| 1708 | |
| 1709 | (defgroup cursor nil |
| 1710 | "Displaying text cursors." |
| 1711 | :version "21.1" |
| 1712 | :group 'frames) |
| 1713 | |
| 1714 | (defcustom blink-cursor-delay 0.5 |
| 1715 | "Seconds of idle time after which cursor starts to blink." |
| 1716 | :type 'number |
| 1717 | :group 'cursor) |
| 1718 | |
| 1719 | (defcustom blink-cursor-interval 0.5 |
| 1720 | "Length of cursor blink interval in seconds." |
| 1721 | :type 'number |
| 1722 | :group 'cursor) |
| 1723 | |
| 1724 | (defcustom blink-cursor-blinks 10 |
| 1725 | "How many times to blink before using a solid cursor on NS, X, and MS-Windows. |
| 1726 | Use 0 or negative value to blink forever." |
| 1727 | :version "24.4" |
| 1728 | :type 'integer |
| 1729 | :group 'cursor) |
| 1730 | |
| 1731 | (defvar blink-cursor-blinks-done 1 |
| 1732 | "Number of blinks done since we started blinking on NS, X, and MS-Windows.") |
| 1733 | |
| 1734 | (defvar blink-cursor-idle-timer nil |
| 1735 | "Timer started after `blink-cursor-delay' seconds of Emacs idle time. |
| 1736 | The function `blink-cursor-start' is called when the timer fires.") |
| 1737 | |
| 1738 | (defvar blink-cursor-timer nil |
| 1739 | "Timer started from `blink-cursor-start'. |
| 1740 | This timer calls `blink-cursor-timer-function' every |
| 1741 | `blink-cursor-interval' seconds.") |
| 1742 | |
| 1743 | (defun blink-cursor-start () |
| 1744 | "Timer function called from the timer `blink-cursor-idle-timer'. |
| 1745 | This starts the timer `blink-cursor-timer', which makes the cursor blink |
| 1746 | if appropriate. It also arranges to cancel that timer when the next |
| 1747 | command starts, by installing a pre-command hook." |
| 1748 | (when (null blink-cursor-timer) |
| 1749 | ;; Set up the timer first, so that if this signals an error, |
| 1750 | ;; blink-cursor-end is not added to pre-command-hook. |
| 1751 | (setq blink-cursor-blinks-done 1) |
| 1752 | (setq blink-cursor-timer |
| 1753 | (run-with-timer blink-cursor-interval blink-cursor-interval |
| 1754 | 'blink-cursor-timer-function)) |
| 1755 | (add-hook 'pre-command-hook 'blink-cursor-end) |
| 1756 | (internal-show-cursor nil nil))) |
| 1757 | |
| 1758 | (defun blink-cursor-timer-function () |
| 1759 | "Timer function of timer `blink-cursor-timer'." |
| 1760 | (internal-show-cursor nil (not (internal-show-cursor-p))) |
| 1761 | ;; Each blink is two calls to this function. |
| 1762 | (setq blink-cursor-blinks-done (1+ blink-cursor-blinks-done)) |
| 1763 | (when (and (> blink-cursor-blinks 0) |
| 1764 | (<= (* 2 blink-cursor-blinks) blink-cursor-blinks-done)) |
| 1765 | (blink-cursor-suspend) |
| 1766 | (add-hook 'post-command-hook 'blink-cursor-check))) |
| 1767 | |
| 1768 | |
| 1769 | (defun blink-cursor-end () |
| 1770 | "Stop cursor blinking. |
| 1771 | This is installed as a pre-command hook by `blink-cursor-start'. |
| 1772 | When run, it cancels the timer `blink-cursor-timer' and removes |
| 1773 | itself as a pre-command hook." |
| 1774 | (remove-hook 'pre-command-hook 'blink-cursor-end) |
| 1775 | (internal-show-cursor nil t) |
| 1776 | (when blink-cursor-timer |
| 1777 | (cancel-timer blink-cursor-timer) |
| 1778 | (setq blink-cursor-timer nil))) |
| 1779 | |
| 1780 | (defun blink-cursor-suspend () |
| 1781 | "Suspend cursor blinking. |
| 1782 | This is called when no frame has focus and timers can be suspended. |
| 1783 | Timers are restarted by `blink-cursor-check', which is called when a |
| 1784 | frame receives focus." |
| 1785 | (blink-cursor-end) |
| 1786 | (when blink-cursor-idle-timer |
| 1787 | (cancel-timer blink-cursor-idle-timer) |
| 1788 | (setq blink-cursor-idle-timer nil))) |
| 1789 | |
| 1790 | (defun blink-cursor-check () |
| 1791 | "Check if cursor blinking shall be restarted. |
| 1792 | This is done when a frame gets focus. Blink timers may be stopped by |
| 1793 | `blink-cursor-suspend'." |
| 1794 | (when (and blink-cursor-mode |
| 1795 | (not blink-cursor-idle-timer)) |
| 1796 | (remove-hook 'post-command-hook 'blink-cursor-check) |
| 1797 | (setq blink-cursor-idle-timer |
| 1798 | (run-with-idle-timer blink-cursor-delay |
| 1799 | blink-cursor-delay |
| 1800 | 'blink-cursor-start)))) |
| 1801 | |
| 1802 | (define-obsolete-variable-alias 'blink-cursor 'blink-cursor-mode "22.1") |
| 1803 | |
| 1804 | (define-minor-mode blink-cursor-mode |
| 1805 | "Toggle cursor blinking (Blink Cursor mode). |
| 1806 | With a prefix argument ARG, enable Blink Cursor mode if ARG is |
| 1807 | positive, and disable it otherwise. If called from Lisp, enable |
| 1808 | the mode if ARG is omitted or nil. |
| 1809 | |
| 1810 | If the value of `blink-cursor-blinks' is positive (10 by default), |
| 1811 | the cursor stops blinking after that number of blinks, if Emacs |
| 1812 | gets no input during that time. |
| 1813 | |
| 1814 | See also `blink-cursor-interval' and `blink-cursor-delay'. |
| 1815 | |
| 1816 | This command is effective only on graphical frames. On text-only |
| 1817 | terminals, cursor blinking is controlled by the terminal." |
| 1818 | :init-value (not (or noninteractive |
| 1819 | no-blinking-cursor |
| 1820 | (eq system-type 'ms-dos) |
| 1821 | (not (memq window-system '(x w32 ns))))) |
| 1822 | :initialize 'custom-initialize-delay |
| 1823 | :group 'cursor |
| 1824 | :global t |
| 1825 | (blink-cursor-suspend) |
| 1826 | (remove-hook 'focus-in-hook #'blink-cursor-check) |
| 1827 | (remove-hook 'focus-out-hook #'blink-cursor-suspend) |
| 1828 | (when blink-cursor-mode |
| 1829 | (add-hook 'focus-in-hook #'blink-cursor-check) |
| 1830 | (add-hook 'focus-out-hook #'blink-cursor-suspend) |
| 1831 | (setq blink-cursor-idle-timer |
| 1832 | (run-with-idle-timer blink-cursor-delay |
| 1833 | blink-cursor-delay |
| 1834 | #'blink-cursor-start)))) |
| 1835 | |
| 1836 | \f |
| 1837 | ;; Frame maximization/fullscreen |
| 1838 | |
| 1839 | (defun toggle-frame-maximized () |
| 1840 | "Toggle maximization state of the selected frame. |
| 1841 | Maximize the selected frame or un-maximize if it is already maximized. |
| 1842 | Respect window manager screen decorations. |
| 1843 | If the frame is in fullscreen mode, don't change its mode, |
| 1844 | just toggle the temporary frame parameter `maximized', |
| 1845 | so the frame will go to the right maximization state |
| 1846 | after disabling fullscreen mode. |
| 1847 | See also `toggle-frame-fullscreen'." |
| 1848 | (interactive) |
| 1849 | (if (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth)) |
| 1850 | (modify-frame-parameters |
| 1851 | nil |
| 1852 | `((maximized |
| 1853 | . ,(unless (eq (frame-parameter nil 'maximized) 'maximized) |
| 1854 | 'maximized)))) |
| 1855 | (modify-frame-parameters |
| 1856 | nil |
| 1857 | `((fullscreen |
| 1858 | . ,(unless (eq (frame-parameter nil 'fullscreen) 'maximized) |
| 1859 | 'maximized)))))) |
| 1860 | |
| 1861 | (defun toggle-frame-fullscreen () |
| 1862 | "Toggle fullscreen mode of the selected frame. |
| 1863 | Enable fullscreen mode of the selected frame or disable if it is |
| 1864 | already fullscreen. Ignore window manager screen decorations. |
| 1865 | When turning on fullscreen mode, remember the previous value of the |
| 1866 | maximization state in the temporary frame parameter `maximized'. |
| 1867 | Restore the maximization state when turning off fullscreen mode. |
| 1868 | See also `toggle-frame-maximized'." |
| 1869 | (interactive) |
| 1870 | (modify-frame-parameters |
| 1871 | nil |
| 1872 | `((maximized |
| 1873 | . ,(unless (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth)) |
| 1874 | (frame-parameter nil 'fullscreen))) |
| 1875 | (fullscreen |
| 1876 | . ,(if (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth)) |
| 1877 | (if (eq (frame-parameter nil 'maximized) 'maximized) |
| 1878 | 'maximized) |
| 1879 | 'fullscreen))))) |
| 1880 | |
| 1881 | \f |
| 1882 | ;;;; Key bindings |
| 1883 | |
| 1884 | (define-key ctl-x-5-map "2" 'make-frame-command) |
| 1885 | (define-key ctl-x-5-map "1" 'delete-other-frames) |
| 1886 | (define-key ctl-x-5-map "0" 'delete-frame) |
| 1887 | (define-key ctl-x-5-map "o" 'other-frame) |
| 1888 | (define-key global-map [f11] 'toggle-frame-fullscreen) |
| 1889 | (define-key global-map [(meta f10)] 'toggle-frame-maximized) |
| 1890 | (define-key esc-map [f10] 'toggle-frame-maximized) |
| 1891 | |
| 1892 | \f |
| 1893 | ;; Misc. |
| 1894 | |
| 1895 | ;; Only marked as obsolete in 24.3. |
| 1896 | (define-obsolete-variable-alias 'automatic-hscrolling |
| 1897 | 'auto-hscroll-mode "22.1") |
| 1898 | |
| 1899 | (make-variable-buffer-local 'show-trailing-whitespace) |
| 1900 | |
| 1901 | ;; Defined in dispnew.c. |
| 1902 | (make-obsolete-variable |
| 1903 | 'window-system-version "it does not give useful information." "24.3") |
| 1904 | |
| 1905 | (provide 'frame) |
| 1906 | |
| 1907 | ;;; frame.el ends here |