aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMartin Rudalics2017-04-11 12:37:26 +0200
committerMartin Rudalics2017-04-11 12:37:26 +0200
commitea6c880aa68bcc8f0e388ecbd8c552392488b38f (patch)
treec4da212b292347d6668dc6283f8444fc795f6e2c /lisp
parent0eef8e9af7707b7bd01243033b9a48cb74fb8672 (diff)
downloademacs-ea6c880aa68bcc8f0e388ecbd8c552392488b38f.tar.gz
emacs-ea6c880aa68bcc8f0e388ecbd8c552392488b38f.zip
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')
-rw-r--r--lisp/frame.el30
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.
144This function runs the hook `focus-out-hook'." 144This function runs the hook `focus-out-hook'."
145 (interactive "e") 145 (interactive "e")
146 (run-hooks 'focus-out-hook)) 146 (run-hooks 'focus-out-hook))
147
148(defun handle-move-frame (event)
149 "Handle a move-frame event.
150This function runs the abnormal hook `move-frame-functions'."
151 (interactive "e")
152 (let ((frame (posn-window (event-start event))))
153 (run-hook-with-args 'move-frame-functions frame)))
147 154
148;;;; Arrangement of frames at startup 155;;;; Arrangement of frames at startup
149 156
@@ -1483,6 +1490,29 @@ keys and their meanings."
1483 for frames = (cdr (assq 'frames attributes)) 1490 for frames = (cdr (assq 'frames attributes))
1484 if (memq frame frames) return attributes)) 1491 if (memq frame frames) return attributes))
1485 1492
1493(defun frame-size-changed-p (&optional frame)
1494 "Return non-nil when the size of FRAME has changed.
1495More precisely, return non-nil when the inner width or height of
1496FRAME has changed since `window-size-change-functions' was run
1497for FRAME."
1498 (let* ((frame (window-normalize-frame frame))
1499 (root (frame-root-window frame))
1500 (mini (minibuffer-window frame))
1501 (mini-height-before-size-change 0)
1502 (mini-height 0))
1503 ;; FRAME's minibuffer window counts iff it's on FRAME and FRAME is
1504 ;; not a minibuffer-only frame.
1505 (when (and (eq (window-frame mini) frame) (not (eq mini root)))
1506 (setq mini-height-before-size-change
1507 (window-pixel-height-before-size-change mini))
1508 (setq mini-height (window-pixel-height mini)))
1509 ;; Return non-nil when either the width of the root or the sum of
1510 ;; the heights of root and minibuffer window changed.
1511 (or (/= (window-pixel-width-before-size-change root)
1512 (window-pixel-width root))
1513 (/= (+ (window-pixel-height-before-size-change root)
1514 mini-height-before-size-change)
1515 (+ (window-pixel-height root) mini-height)))))
1486 1516
1487;;;; Frame/display capabilities. 1517;;;; Frame/display capabilities.
1488 1518