aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-01-30 15:06:47 +0000
committerGerd Moellmann2001-01-30 15:06:47 +0000
commit9688894d935927a3c98fbc0d1f16a865b602e176 (patch)
treef33037807d5aea50909eb2e5516ee73eb060dd9e
parentc3d761736c70e80156b4f38922d0c0d845af815c (diff)
downloademacs-9688894d935927a3c98fbc0d1f16a865b602e176.tar.gz
emacs-9688894d935927a3c98fbc0d1f16a865b602e176.zip
(frame-initialize): Create initial frame visible.
(frame-notice-user-settings): When tool-bar has been switched off, correct the frame size and sync too-bar-mode.
-rw-r--r--lisp/frame.el321
1 files changed, 176 insertions, 145 deletions
diff --git a/lisp/frame.el b/lisp/frame.el
index 93dcb36c124..b7f6492a396 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -181,8 +181,7 @@ Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
181 (or (delq terminal-frame (minibuffer-frame-list)) 181 (or (delq terminal-frame (minibuffer-frame-list))
182 (progn 182 (progn
183 (setq frame-initial-frame-alist 183 (setq frame-initial-frame-alist
184 (append initial-frame-alist default-frame-alist 184 (append initial-frame-alist default-frame-alist nil))
185 '((visibility . nil)) nil))
186 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist) 185 (or (assq 'horizontal-scroll-bars frame-initial-frame-alist)
187 (setq frame-initial-frame-alist 186 (setq frame-initial-frame-alist
188 (cons '(horizontal-scroll-bars . t) 187 (cons '(horizontal-scroll-bars . t)
@@ -233,8 +232,7 @@ React to settings of `default-frame-alist', `initial-frame-alist' there."
233 ;; Make tool-bar-mode and default-frame-alist consistent. Don't do 232 ;; Make tool-bar-mode and default-frame-alist consistent. Don't do
234 ;; it in batch mode since that would leave a tool-bar-lines 233 ;; it in batch mode since that would leave a tool-bar-lines
235 ;; parameter in default-frame-alist in a dumped Emacs, which is not 234 ;; parameter in default-frame-alist in a dumped Emacs, which is not
236 ;; what we want. For some reason, menu-bar-mode is not bound 235 ;; what we want.
237 ;; in this case, but tool-bar-mode is.
238 (when (and (boundp 'tool-bar-mode) 236 (when (and (boundp 'tool-bar-mode)
239 (not noninteractive)) 237 (not noninteractive))
240 (let ((default (assq 'tool-bar-lines default-frame-alist))) 238 (let ((default (assq 'tool-bar-lines default-frame-alist)))
@@ -285,150 +283,183 @@ React to settings of `default-frame-alist', `initial-frame-alist' there."
285 283
286 ;; If the initial frame is still around, apply initial-frame-alist 284 ;; If the initial frame is still around, apply initial-frame-alist
287 ;; and default-frame-alist to it. 285 ;; and default-frame-alist to it.
288 (if (frame-live-p frame-initial-frame) 286 (when (frame-live-p frame-initial-frame)
289 287
290 ;; The initial frame we create above always has a minibuffer. 288 ;; When tool-bar has been switched off, correct the frame size
291 ;; If the user wants to remove it, or make it a minibuffer-only 289 ;; by the lines added in x-create-frame for the tool-bar and
292 ;; frame, then we'll have to delete the current frame and make a 290 ;; switch `tool-bar-mode' off.
293 ;; new one; you can't remove or add a root window to/from an 291 (when (or (eq 0 (cdr (assq 'tool-bar-lines initial-frame-alist)))
294 ;; existing frame. 292 (eq 0 (cdr (assq 'tool-bar-lines default-frame-alist))))
295 ;; 293 (let* ((char-height (frame-char-height frame-initial-frame))
296 ;; NOTE: default-frame-alist was nil when we created the 294 (image-height 24)
297 ;; existing frame. We need to explicitly include 295 (margin (cond ((and (consp tool-bar-button-margin)
298 ;; default-frame-alist in the parameters of the screen we 296 (integerp (cdr tool-bar-button-margin))
299 ;; create here, so that its new value, gleaned from the user's 297 (> tool-bar-button-margin 0))
300 ;; .emacs file, will be applied to the existing screen. 298 (cdr tool-bar-button-margin))
301 (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist) 299 ((and (integerp tool-bar-button-margin)
300 (> tool-bar-button-margin 0))
301 tool-bar-button-margin)
302 (t 0)))
303 (relief (if (and (integerp tool-bar-button-relief)
304 (> tool-bar-button-relief 0))
305 tool-bar-button-relief 3))
306 (lines (/ (+ image-height
307 (* 2 margin)
308 (* 2 relief)
309 (1- char-height))
310 char-height))
311 (height (frame-parameter frame-initial-frame 'height)))
312 (modify-frame-parameters frame-initial-frame
313 (list (cons 'height (- height lines))))
314 (tool-bar-mode -1)))
315
316
317 ;; The initial frame we create above always has a minibuffer.
318 ;; If the user wants to remove it, or make it a minibuffer-only
319 ;; frame, then we'll have to delete the current frame and make a
320 ;; new one; you can't remove or add a root window to/from an
321 ;; existing frame.
322 ;;
323 ;; NOTE: default-frame-alist was nil when we created the
324 ;; existing frame. We need to explicitly include
325 ;; default-frame-alist in the parameters of the screen we
326 ;; create here, so that its new value, gleaned from the user's
327 ;; .emacs file, will be applied to the existing screen.
328 (when (not (eq (cdr (or (assq 'minibuffer initial-frame-alist)
302 (assq 'minibuffer default-frame-alist) 329 (assq 'minibuffer default-frame-alist)
303 '(minibuffer . t))) 330 '(minibuffer . t)))
304 t)) 331 t))
305 ;; Create the new frame. 332 ;; Create the new frame.
306 (let (parms new) 333 (let (parms new)
307 ;; If the frame isn't visible yet, wait till it is. 334 ;; If the frame isn't visible yet, wait till it is.
308 ;; If the user has to position the window, 335 ;; If the user has to position the window,
309 ;; Emacs doesn't know its real position until 336 ;; Emacs doesn't know its real position until
310 ;; the frame is seen to be visible. 337 ;; the frame is seen to be visible.
311 (while (not (cdr (assq 'visibility 338 (while (not (cdr (assq 'visibility
312 (frame-parameters frame-initial-frame)))) 339 (frame-parameters frame-initial-frame))))
313 (sleep-for 1)) 340 (sleep-for 1))
314 (setq parms (frame-parameters frame-initial-frame)) 341 (setq parms (frame-parameters frame-initial-frame))
315 ;; Get rid of `name' unless it was specified explicitly before. 342
316 (or (assq 'name frame-initial-frame-alist) 343 ;; Get rid of `name' unless it was specified explicitly before.
317 (setq parms (delq (assq 'name parms) parms))) 344 (or (assq 'name frame-initial-frame-alist)
318 (setq parms (append initial-frame-alist 345 (setq parms (delq (assq 'name parms) parms)))
319 default-frame-alist 346
320 parms 347 (setq parms (append initial-frame-alist
321 nil)) 348 default-frame-alist
322 ;; Get rid of `reverse', because that was handled 349 parms
323 ;; when we first made the frame. 350 nil))
324 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms))) 351
325 (if (assq 'height frame-initial-geometry-arguments) 352 ;; Get rid of `reverse', because that was handled
326 (setq parms (assq-delete-all 'height parms))) 353 ;; when we first made the frame.
327 (if (assq 'width frame-initial-geometry-arguments) 354 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms)))
328 (setq parms (assq-delete-all 'width parms))) 355
329 (if (assq 'left frame-initial-geometry-arguments) 356 (if (assq 'height frame-initial-geometry-arguments)
330 (setq parms (assq-delete-all 'left parms))) 357 (setq parms (assq-delete-all 'height parms)))
331 (if (assq 'top frame-initial-geometry-arguments) 358 (if (assq 'width frame-initial-geometry-arguments)
332 (setq parms (assq-delete-all 'top parms))) 359 (setq parms (assq-delete-all 'width parms)))
333 (setq new 360 (if (assq 'left frame-initial-geometry-arguments)
334 (make-frame 361 (setq parms (assq-delete-all 'left parms)))
335 ;; Use the geometry args that created the existing 362 (if (assq 'top frame-initial-geometry-arguments)
336 ;; frame, rather than the parms we get for it. 363 (setq parms (assq-delete-all 'top parms)))
337 (append frame-initial-geometry-arguments 364 (setq new
338 '((user-size . t) (user-position . t)) 365 (make-frame
339 parms))) 366 ;; Use the geometry args that created the existing
340 ;; The initial frame, which we are about to delete, may be 367 ;; frame, rather than the parms we get for it.
341 ;; the only frame with a minibuffer. If it is, create a 368 (append frame-initial-geometry-arguments
342 ;; new one. 369 '((user-size . t) (user-position . t))
343 (or (delq frame-initial-frame (minibuffer-frame-list)) 370 parms)))
344 (make-initial-minibuffer-frame nil)) 371 ;; The initial frame, which we are about to delete, may be
345 372 ;; the only frame with a minibuffer. If it is, create a
346 ;; If the initial frame is serving as a surrogate 373 ;; new one.
347 ;; minibuffer frame for any frames, we need to wean them 374 (or (delq frame-initial-frame (minibuffer-frame-list))
348 ;; onto a new frame. The default-minibuffer-frame 375 (make-initial-minibuffer-frame nil))
349 ;; variable must be handled similarly. 376
350 (let ((users-of-initial 377 ;; If the initial frame is serving as a surrogate
351 (filtered-frame-list 378 ;; minibuffer frame for any frames, we need to wean them
352 (function (lambda (frame) 379 ;; onto a new frame. The default-minibuffer-frame
353 (and (not (eq frame frame-initial-frame)) 380 ;; variable must be handled similarly.
354 (eq (window-frame 381 (let ((users-of-initial
355 (minibuffer-window frame)) 382 (filtered-frame-list
356 frame-initial-frame))))))) 383 (function (lambda (frame)
357 (if (or users-of-initial 384 (and (not (eq frame frame-initial-frame))
358 (eq default-minibuffer-frame frame-initial-frame)) 385 (eq (window-frame
359 386 (minibuffer-window frame))
360 ;; Choose an appropriate frame. Prefer frames which 387 frame-initial-frame)))))))
361 ;; are only minibuffers. 388 (if (or users-of-initial
362 (let* ((new-surrogate 389 (eq default-minibuffer-frame frame-initial-frame))
363 (car 390
364 (or (filtered-frame-list 391 ;; Choose an appropriate frame. Prefer frames which
365 (function 392 ;; are only minibuffers.
366 (lambda (frame) 393 (let* ((new-surrogate
367 (eq (cdr (assq 'minibuffer 394 (car
368 (frame-parameters frame))) 395 (or (filtered-frame-list
369 'only)))) 396 (function
370 (minibuffer-frame-list)))) 397 (lambda (frame)
371 (new-minibuffer (minibuffer-window new-surrogate))) 398 (eq (cdr (assq 'minibuffer
372 399 (frame-parameters frame)))
373 (if (eq default-minibuffer-frame frame-initial-frame) 400 'only))))
374 (setq default-minibuffer-frame new-surrogate)) 401 (minibuffer-frame-list))))
375 402 (new-minibuffer (minibuffer-window new-surrogate)))
376 ;; Wean the frames using frame-initial-frame as 403
377 ;; their minibuffer frame. 404 (if (eq default-minibuffer-frame frame-initial-frame)
378 (mapcar 405 (setq default-minibuffer-frame new-surrogate))
379 (function 406
380 (lambda (frame) 407 ;; Wean the frames using frame-initial-frame as
381 (modify-frame-parameters 408 ;; their minibuffer frame.
382 frame (list (cons 'minibuffer new-minibuffer))))) 409 (mapcar
383 users-of-initial)))) 410 (function
384 411 (lambda (frame)
385 ;; Redirect events enqueued at this frame to the new frame. 412 (modify-frame-parameters
386 ;; Is this a good idea? 413 frame (list (cons 'minibuffer new-minibuffer)))))
387 (redirect-frame-focus frame-initial-frame new) 414 users-of-initial))))
388 415
389 ;; Finally, get rid of the old frame. 416 ;; Redirect events enqueued at this frame to the new frame.
390 (delete-frame frame-initial-frame t)) 417 ;; Is this a good idea?
391 418 (redirect-frame-focus frame-initial-frame new)
392 ;; Otherwise, we don't need all that rigamarole; just apply 419
393 ;; the new parameters. 420 ;; Finally, get rid of the old frame.
394 (let (newparms allparms tail) 421 (delete-frame frame-initial-frame t))
395 (setq allparms (append initial-frame-alist 422
396 default-frame-alist nil)) 423 ;; Otherwise, we don't need all that rigamarole; just apply
397 (if (assq 'height frame-initial-geometry-arguments) 424 ;; the new parameters.
398 (setq allparms (assq-delete-all 'height allparms))) 425 (let (newparms allparms tail)
399 (if (assq 'width frame-initial-geometry-arguments) 426 (setq allparms (append initial-frame-alist
400 (setq allparms (assq-delete-all 'width allparms))) 427 default-frame-alist nil))
401 (if (assq 'left frame-initial-geometry-arguments) 428 (if (assq 'height frame-initial-geometry-arguments)
402 (setq allparms (assq-delete-all 'left allparms))) 429 (setq allparms (assq-delete-all 'height allparms)))
403 (if (assq 'top frame-initial-geometry-arguments) 430 (if (assq 'width frame-initial-geometry-arguments)
404 (setq allparms (assq-delete-all 'top allparms))) 431 (setq allparms (assq-delete-all 'width allparms)))
405 (setq tail allparms) 432 (if (assq 'left frame-initial-geometry-arguments)
406 ;; Find just the parms that have changed since we first 433 (setq allparms (assq-delete-all 'left allparms)))
407 ;; made this frame. Those are the ones actually set by 434 (if (assq 'top frame-initial-geometry-arguments)
408 ;; the init file. For those parms whose values we already knew 435 (setq allparms (assq-delete-all 'top allparms)))
409 ;; (such as those spec'd by command line options) 436 (setq tail allparms)
410 ;; it is undesirable to specify the parm again 437 ;; Find just the parms that have changed since we first
411 ;; once the user has seen the frame and been able to alter it 438 ;; made this frame. Those are the ones actually set by
412 ;; manually. 439 ;; the init file. For those parms whose values we already knew
413 (while tail 440 ;; (such as those spec'd by command line options)
414 (let (newval oldval) 441 ;; it is undesirable to specify the parm again
415 (setq oldval (assq (car (car tail)) 442 ;; once the user has seen the frame and been able to alter it
416 frame-initial-frame-alist)) 443 ;; manually.
417 (setq newval (cdr (assq (car (car tail)) allparms))) 444 (while tail
418 (or (and oldval (eq (cdr oldval) newval)) 445 (let (newval oldval)
419 (setq newparms 446 (setq oldval (assq (car (car tail))
420 (cons (cons (car (car tail)) newval) newparms)))) 447 frame-initial-frame-alist))
421 (setq tail (cdr tail))) 448 (setq newval (cdr (assq (car (car tail)) allparms)))
422 (setq newparms (nreverse newparms)) 449 (or (and oldval (eq (cdr oldval) newval))
423 (modify-frame-parameters frame-initial-frame 450 (setq newparms
424 newparms) 451 (cons (cons (car (car tail)) newval) newparms))))
425 ;; If we changed the background color, 452 (setq tail (cdr tail)))
426 ;; we need to update the background-mode parameter 453 (setq newparms (nreverse newparms))
427 ;; and maybe some faces too. 454 (modify-frame-parameters frame-initial-frame
428 (when (assq 'background-color newparms) 455 newparms)
429 (unless (assq 'background-mode newparms) 456 ;; If we changed the background color,
430 (frame-set-background-mode frame-initial-frame)) 457 ;; we need to update the background-mode parameter
431 (face-set-after-frame-default frame-initial-frame))))) 458 ;; and maybe some faces too.
459 (when (assq 'background-color newparms)
460 (unless (assq 'background-mode newparms)
461 (frame-set-background-mode frame-initial-frame))
462 (face-set-after-frame-default frame-initial-frame)))))
432 463
433 ;; Restore the original buffer. 464 ;; Restore the original buffer.
434 (set-buffer old-buffer) 465 (set-buffer old-buffer)