From: Martin Rudalics Date: Fri, 2 Jul 2021 08:55:42 +0000 (+0200) Subject: New frame parameter 'drag-with-tab-line' (Bug#49247) X-Git-Tag: emacs-28.0.90~1983 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f449890508e8d52cc2029a34e55bfdb63c431c4b;p=emacs.git New frame parameter 'drag-with-tab-line' (Bug#49247) The new frame parameter 'drag-with-tab-line' allows to move frames by dragging their topmost windows' tab line with the mouse thus achieving a behavior similar to that provided by the 'drag-with-header-line' parameter. * lisp/mouse.el (mouse-drag-tab-line): New function. (mouse-drag-frame-resize, mouse-drag-frame-move) ([tab-line down-mouse-1]): Handle tab line dragging in various keymaps. * doc/lispref/frames.texi (Mouse Dragging Parameters): Describe new parameter 'drag-with-tab-line'. * etc/NEWS: Add entry for 'drag-with-tab-line'. --- diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index a9d20c543da..25706befc8d 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -2023,8 +2023,8 @@ the @sc{cdr} of the cell is either @code{t} or @code{top-only}. The parameters described below provide support for resizing a frame by dragging its internal borders with the mouse. They also allow moving a -frame with the mouse by dragging the header line of its topmost or the -mode line of its bottommost window. +frame with the mouse by dragging the header or tab line of its topmost +or the mode line of its bottommost window. These parameters are mostly useful for child frames (@pxref{Child Frames}) that come without window manager decorations. If necessary, @@ -2041,6 +2041,11 @@ borders, if present, with the mouse. If non-@code{nil}, the frame can be moved with the mouse by dragging the header line of its topmost window. +@vindex drag-with-tab-line@r{, a frame parameter} +@item drag-with-tab-line +If non-@code{nil}, the frame can be moved with the mouse by dragging the +tab line of its topmost window. + @vindex drag-with-mode-line@r{, a frame parameter} @item drag-with-mode-line If non-@code{nil}, the frame can be moved with the mouse by dragging the diff --git a/etc/NEWS b/etc/NEWS index 605c4d228fc..5b04278e3aa 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -319,6 +319,10 @@ Meta characters to Emacs, e.g., send "ESC x" when the user types emulators by using the new input-meta-mode with the special value 'encoded' with these terminal emulators. ++++ +** New frame parameter 'drag-with-tab-line'. +This parameter, similar to 'drag-with-header-line', allows moving frames +by dragging the tab lines of their topmost windows with the mouse. * Editing Changes in Emacs 28.1 diff --git a/lisp/mouse.el b/lisp/mouse.el index d0064eecfc7..ab260d4ed49 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -550,6 +550,18 @@ the frame instead." (when (frame-parameter frame 'drag-with-header-line) (mouse-drag-frame-move start-event)))))) +(defun mouse-drag-tab-line (start-event) + "Drag frame with tab line in its topmost window. +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)) + (let ((frame (window-frame window))) + (when (frame-parameter frame 'drag-with-tab-line) + (mouse-drag-frame-move start-event)))))) + (defun mouse-drag-vertical-line (start-event) "Change the width of a window by dragging on a vertical line. START-EVENT is the starting mouse event of the drag action." @@ -678,6 +690,7 @@ frame with the mouse." ;; 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 ;; prefix. @@ -904,6 +917,7 @@ frame with the mouse." ;; 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 ;; prefix. @@ -2908,6 +2922,7 @@ is copied instead of being cut." ;; versions. (global-set-key [header-line down-mouse-1] 'mouse-drag-header-line) (global-set-key [header-line mouse-1] 'mouse-select-window) +(global-set-key [tab-line down-mouse-1] 'mouse-drag-tab-line) (global-set-key [tab-line mouse-1] 'mouse-select-window) ;; (global-set-key [mode-line drag-mouse-1] 'mouse-select-window) (global-set-key [mode-line down-mouse-1] 'mouse-drag-mode-line)