From 0462db66fb0bc7be3aec0541aa0876c6c884a4cd Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Mon, 10 Feb 2025 10:58:05 +0100 Subject: [PATCH] Implement tab line dragging with mouse (Bug#76084) * lisp/mouse.el (mouse-drag-line): Allow tab line dragging if there's a window above. Consider tab line height when calculating 'position'. Add 'tab-line' binding to transient map. (mouse-drag-tab-line): Have it drag the tab line only (and not the entire frame) when the tab line is between two windows. (cherry picked from commit efa9b97b454d2bf56d50fb4ef37e8378bb2e4b2a) --- lisp/mouse.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lisp/mouse.el b/lisp/mouse.el index cbf206d0d93..03dfc03341c 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -828,7 +828,7 @@ must be one of the symbols `header', `mode', or `vertical'." ;; Decide on whether we are allowed to track at all and whose ;; window's edge we drag. (cond - ((eq line 'header) + ((memq line '(header tab)) ;; Drag bottom edge of window above the header line. (setq window (window-in-direction 'above window t))) ((eq line 'mode)) @@ -887,10 +887,13 @@ must be one of the symbols `header', `mode', or `vertical'." (when (window-live-p posn-window) ;; Add top edge of `posn-window' to `position'. (setq position (+ (window-pixel-top posn-window) position)) - ;; If necessary, add height of header line to `position' + ;; If necessary, add height of header and tab line to + ;; `position'. (when (memq (posn-area start) '(nil left-fringe right-fringe left-margin right-margin)) - (setq position (+ (window-header-line-height posn-window) position)))) + (setq position (+ (window-header-line-height posn-window) + (window-tab-line-height posn-window) + position)))) ;; When the cursor overshoots after shrinking a window to its ;; minimum size and the dragging direction changes, have the ;; cursor first catch up with the window edge. @@ -931,6 +934,7 @@ must be one of the symbols `header', `mode', or `vertical'." ;; with a mode-line, header-line or vertical-line prefix ... (define-key map [mode-line] map) (define-key map [header-line] map) + (define-key map [tab-line] map) (define-key map [vertical-line] map) ;; ... and some maybe even with a right- or bottom-divider ;; or left- or right-margin prefix ... @@ -1019,8 +1023,9 @@ START-EVENT is the starting mouse event of the drag action." (interactive "e") (let* ((start (event-start start-event)) (window (posn-window start))) - (when (and (window-live-p window) - (window-at-side-p window 'top)) + (if (and (window-live-p window) + (not (window-at-side-p window 'top))) + (mouse-drag-line start-event 'tab) (let ((frame (window-frame window))) (when (frame-parameter frame 'drag-with-tab-line) (mouse-drag-frame-move start-event)))))) -- 2.39.5