X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/18b35e2c7a3ff95fb4a07e58c3f57c70c65c0701..34dc21db6e57ebbad81a196002fcd3cc557f096e:/lisp/frame.el diff --git a/lisp/frame.el b/lisp/frame.el index 87756f78f1..59e4d67b76 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1,9 +1,9 @@ ;;; frame.el --- multi-frame management independent of window systems -;; Copyright (C) 1993-1994, 1996-1997, 2000-2013 Free Software +;; Copyright (C) 1993-1994, 1996-1997, 2000-2014 Free Software ;; Foundation, Inc. -;; Maintainer: FSF +;; Maintainer: emacs-devel@gnu.org ;; Keywords: internal ;; Package: emacs @@ -120,6 +120,23 @@ appended when the minibuffer frame is created." (delete-frame frame t) ;; Gildea@x.org says it is ok to ask questions before terminating. (save-buffers-kill-emacs)))) + +(defun handle-focus-in (_event) + "Handle a focus-in event. +Focus-in events are usually bound to this function. +Focus-in events occur when a frame has focus, but a switch-frame event +is not generated. +This function runs the hook `focus-in-hook'." + (interactive "e") + (run-hooks 'focus-in-hook)) + +(defun handle-focus-out (_event) + "Handle a focus-out event. +Focus-out events are usually bound to this function. +Focus-out events occur when no frame has focus. +This function runs the hook `focus-out-hook'." + (interactive "e") + (run-hooks 'focus-out-hook)) ;;;; Arrangement of frames at startup @@ -193,6 +210,8 @@ appended when the minibuffer frame is created." (declare-function tool-bar-mode "tool-bar" (&optional arg)) +(defalias 'tool-bar-lines-needed 'tool-bar-height) + ;; startup.el calls this function after loading the user's init ;; file. Now default-frame-alist and initial-frame-alist contain ;; information to which we must react; do what needs to be done. @@ -521,10 +540,14 @@ is not considered (see `next-frame')." (defun window-system-for-display (display) "Return the window system for DISPLAY. Return nil if we don't know how to interpret DISPLAY." - (cl-loop for descriptor in display-format-alist - for pattern = (car descriptor) - for system = (cdr descriptor) - when (string-match-p pattern display) return system)) + ;; MS-Windows doesn't know how to create a GUI frame in a -nw session. + (if (and (eq system-type 'windows-nt) + (null (window-system))) + nil + (cl-loop for descriptor in display-format-alist + for pattern = (car descriptor) + for system = (cdr descriptor) + when (string-match-p pattern display) return system))) (defun make-frame-on-display (display &optional parameters) "Make a frame on display DISPLAY. @@ -1727,12 +1750,11 @@ command starts, by installing a pre-command hook." "Timer function of timer `blink-cursor-timer'." (internal-show-cursor nil (not (internal-show-cursor-p))) ;; Each blink is two calls to this function. - (when (memq window-system '(x ns w32)) - (setq blink-cursor-blinks-done (1+ blink-cursor-blinks-done)) - (when (and (> blink-cursor-blinks 0) - (<= (* 2 blink-cursor-blinks) blink-cursor-blinks-done)) - (blink-cursor-suspend) - (add-hook 'post-command-hook 'blink-cursor-check)))) + (setq blink-cursor-blinks-done (1+ blink-cursor-blinks-done)) + (when (and (> blink-cursor-blinks 0) + (<= (* 2 blink-cursor-blinks) blink-cursor-blinks-done)) + (blink-cursor-suspend) + (add-hook 'post-command-hook 'blink-cursor-check))) (defun blink-cursor-end () @@ -1747,15 +1769,14 @@ itself as a pre-command hook." (setq blink-cursor-timer nil))) (defun blink-cursor-suspend () - "Suspend cursor blinking on NS, X and W32. + "Suspend cursor blinking. This is called when no frame has focus and timers can be suspended. Timers are restarted by `blink-cursor-check', which is called when a frame receives focus." - (when (memq window-system '(x ns w32)) - (blink-cursor-end) - (when blink-cursor-idle-timer - (cancel-timer blink-cursor-idle-timer) - (setq blink-cursor-idle-timer nil)))) + (blink-cursor-end) + (when blink-cursor-idle-timer + (cancel-timer blink-cursor-idle-timer) + (setq blink-cursor-idle-timer nil))) (defun blink-cursor-check () "Check if cursor blinking shall be restarted. @@ -1789,13 +1810,15 @@ terminals, cursor blinking is controlled by the terminal." (if blink-cursor-idle-timer (cancel-timer blink-cursor-idle-timer)) (setq blink-cursor-idle-timer nil) (blink-cursor-end) + (remove-hook 'focus-in-hook #'blink-cursor-check) + (remove-hook 'focus-out-hook #'blink-cursor-suspend) (when blink-cursor-mode - ;; Hide the cursor. - ;;(internal-show-cursor nil nil) + (add-hook 'focus-in-hook #'blink-cursor-check) + (add-hook 'focus-out-hook #'blink-cursor-suspend) (setq blink-cursor-idle-timer (run-with-idle-timer blink-cursor-delay blink-cursor-delay - 'blink-cursor-start)))) + #'blink-cursor-start)))) ;; Frame maximization/fullscreen