]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement tab line dragging with mouse (Bug#76084)
authorMartin Rudalics <rudalics@gmx.at>
Mon, 10 Feb 2025 09:58:05 +0000 (10:58 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 10 Feb 2025 20:57:20 +0000 (21:57 +0100)
* 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

index cbf206d0d93451ad8cfecabb11adb5fd4fb8cd41..03dfc03341c07a0e9770949bf41677b9af412117 100644 (file)
@@ -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))))))