diff options
author | Martin Rudalics <rudalics@gmx.at> | 2017-04-11 12:37:26 +0200 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2017-04-11 12:37:26 +0200 |
commit | ea6c880aa68bcc8f0e388ecbd8c552392488b38f (patch) | |
tree | c4da212b292347d6668dc6283f8444fc795f6e2c /lisp/frame.el | |
parent | 0eef8e9af7707b7bd01243033b9a48cb74fb8672 (diff) | |
download | emacs-ea6c880aa68bcc8f0e388ecbd8c552392488b38f.tar.gz |
Frame movement, focus and hook related changes
New hook `move-frame-functions'. Run `focus-in-hook'
after switching to frame that gets focus. Don't run
XMoveWindow for GTK.
* lisp/frame.el (handle-move-frame, frame-size-changed-p): New
functions.
* src/frame.c (do_switch_frame): Simplify code.
(Fhandle_switch_frame): Switch frame before running
`handle-focus-in'.
(Vfocus_in_hook, Vfocus_out_hook): Clarify doc-strings.
(Vmove_frame_functions): New hook variable.
* src/keyboard.c (kbd_buffer_get_event): Handle
MOVE_FRAME_EVENT. Handle SELECT_WINDOW_EVENT separately.
(head_table): Add Qmove_frame entry.
(syms_of_keyboard): Add Qmove_frame.
(keys_of_keyboard): Define key for `move-frame'.
* src/termhooks.h (event_kind): Add MOVE_FRAME_EVENT.
* src/w32term.c (w32_read_socket): Create MOVE_FRAME_EVENT.
* src/window.c (run_window_size_change_functions): Record size of
FRAME's minibuffer window too.
* src/xterm.c (handle_one_xevent): Create MOVE_FRAME_EVENT.
(x_set_offset): For GTK call gtk_widget_move instead of
XMoveWindow.
Diffstat (limited to 'lisp/frame.el')
-rw-r--r-- | lisp/frame.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lisp/frame.el b/lisp/frame.el index 0a35b715b3d..4768b5be002 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -144,6 +144,13 @@ Focus-out events occur when no frame has focus. This function runs the hook `focus-out-hook'." (interactive "e") (run-hooks 'focus-out-hook)) + +(defun handle-move-frame (event) + "Handle a move-frame event. +This function runs the abnormal hook `move-frame-functions'." + (interactive "e") + (let ((frame (posn-window (event-start event)))) + (run-hook-with-args 'move-frame-functions frame))) ;;;; Arrangement of frames at startup @@ -1483,6 +1490,29 @@ keys and their meanings." for frames = (cdr (assq 'frames attributes)) if (memq frame frames) return attributes)) +(defun frame-size-changed-p (&optional frame) + "Return non-nil when the size of FRAME has changed. +More precisely, return non-nil when the inner width or height of +FRAME has changed since `window-size-change-functions' was run +for FRAME." + (let* ((frame (window-normalize-frame frame)) + (root (frame-root-window frame)) + (mini (minibuffer-window frame)) + (mini-height-before-size-change 0) + (mini-height 0)) + ;; FRAME's minibuffer window counts iff it's on FRAME and FRAME is + ;; not a minibuffer-only frame. + (when (and (eq (window-frame mini) frame) (not (eq mini root))) + (setq mini-height-before-size-change + (window-pixel-height-before-size-change mini)) + (setq mini-height (window-pixel-height mini))) + ;; Return non-nil when either the width of the root or the sum of + ;; the heights of root and minibuffer window changed. + (or (/= (window-pixel-width-before-size-change root) + (window-pixel-width root)) + (/= (+ (window-pixel-height-before-size-change root) + mini-height-before-size-change) + (+ (window-pixel-height root) mini-height))))) ;;;; Frame/display capabilities. |