comparison lisp/frame.el @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c42ec1d1cded
children e11d67e05968
comparison
equal deleted inserted replaced
283:fa3d41851a08 284:558f606b08ae
517 "Select the ARG'th different visible frame, and raise it. 517 "Select the ARG'th different visible frame, and raise it.
518 All frames are arranged in a cyclic order. 518 All frames are arranged in a cyclic order.
519 This command selects the frame ARG steps away in that order. 519 This command selects the frame ARG steps away in that order.
520 A negative ARG moves in the opposite order. 520 A negative ARG moves in the opposite order.
521 521
522 This command ignores the value of `focus-follows-mouse'." 522 This sets the window system focus, regardless of the value
523 of `focus-follows-mouse'."
523 (interactive "p") 524 (interactive "p")
524 (let ((frame (selected-frame)) 525 (let ((frame (selected-frame)))
525 (old-focus-follows-mouse focus-follows-mouse)
526 ;; Allow selecting another frame even when
527 ;; focus-follows-mouse is true.
528 (focus-follows-mouse nil))
529 (while (> arg 0) 526 (while (> arg 0)
530 (setq frame (next-frame frame 'visible-nomini)) 527 (setq frame (next-frame frame 'visible-nomini))
531 (setq arg (1- arg))) 528 (setq arg (1- arg)))
532 (while (< arg 0) 529 (while (< arg 0)
533 (setq frame (previous-frame frame 'visible-nomini)) 530 (setq frame (previous-frame frame 'visible-nomini))
534 (setq arg (1+ arg))) 531 (setq arg (1+ arg)))
535 (raise-frame frame) 532 (raise-frame frame)
536 (select-frame frame) 533 (focus-frame frame)
537 ;; Allow the focus change to be processed while
538 ;; focus-follows-mouse is nil.
539 (and old-focus-follows-mouse
540 (sit-for 0))
541 ;this is a bad idea; you should in general never warp the 534 ;this is a bad idea; you should in general never warp the
542 ;pointer unless the user asks for this. Furthermore, 535 ;pointer unless the user asks for this. Furthermore,
543 ;our version of `set-mouse-position' takes a window, 536 ;our version of `set-mouse-position' takes a window,
544 ;not a frame. 537 ;not a frame.
545 ;(set-mouse-position (selected-frame) (1- (frame-width)) 0) 538 ;(set-mouse-position (selected-frame) (1- (frame-width)) 0)
546 ;some weird FSFmacs randomness 539 ;some weird FSFmacs randomness
547 ;(if (fboundp 'unfocus-frame) 540 ;(if (fboundp 'unfocus-frame)
548 ; (unfocus-frame)))) 541 ; (unfocus-frame))))
549 )) 542 ))
550 543
551 ;; XEmacs-added utility functions 544 ;; XEmacs-added utility functions
545
546 (defmacro save-selected-frame (&rest body)
547 "Execute forms in BODY, then restore the selected frame.
548 The value returned is the value of the last form in BODY."
549 (let ((old-frame (gensym "ssf")))
550 `(let ((,old-frame (selected-frame)))
551 (unwind-protect
552 (progn ,@body)
553 (select-frame ,old-frame)))))
554
555 (defmacro with-selected-frame (frame &rest body)
556 "Execute forms in BODY with FRAME as the selected frame.
557 The value returned is the value of the last form in BODY."
558 `(save-selected-frame
559 (select-frame ,frame)
560 ,@body))
552 561
553 ; this is in C in FSFmacs 562 ; this is in C in FSFmacs
554 (defun frame-list () 563 (defun frame-list ()
555 "Return a list of all frames on all devices/consoles." 564 "Return a list of all frames on all devices/consoles."
556 ;; Lists are copies, so nconc is safe here. 565 ;; Lists are copies, so nconc is safe here.