aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2021-08-18 20:52:32 +0300
committerJuri Linkov2021-08-18 20:52:32 +0300
commitad9c57f54ae3eea9e5b2fe9264e9edb8b2ed1857 (patch)
tree757b9cc38da6901fe3ce86e3151784c65c14618d
parent56d567acb6eae72352e39acf4f206f7cb3195900 (diff)
downloademacs-ad9c57f54ae3eea9e5b2fe9264e9edb8b2ed1857.tar.gz
emacs-ad9c57f54ae3eea9e5b2fe9264e9edb8b2ed1857.zip
Mouse wheel scrolling on the tab bar
* lisp/tab-bar.el (tab-bar-map): Bind mouse-4/wheel-up/wheel-left to tab-previous and mouse-5/wheel-down/wheel-right to tab-next. Bind S-mouse-4/wheel-up/wheel-left to tab-bar-move-tab-backward and S-mouse-5/wheel-down/wheel-right to tab-bar-move-tab. (tab-bar-move-tab-backward): New command. (tab-bar-move-repeat-map): Use tab-bar-move-tab-backward instead of lambda. * src/xterm.c (handle_one_xevent): Remove restriction to allow clicking mouse-4 and mouse-5.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/tab-bar.el27
-rw-r--r--src/xterm.c2
3 files changed, 26 insertions, 7 deletions
diff --git a/etc/NEWS b/etc/NEWS
index fb553e82ff2..c48e110f9a7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -751,7 +751,9 @@ of the next command to be displayed in a new frame.
751*** The tab bar now supports more mouse commands. 751*** The tab bar now supports more mouse commands.
752Clicking 'mouse-2' closes the tab, 'mouse-3' displays the context menu 752Clicking 'mouse-2' closes the tab, 'mouse-3' displays the context menu
753with items that operate on the clicked tab. Dragging the tab with 753with items that operate on the clicked tab. Dragging the tab with
754'mouse-1' moves it to another position on the tab bar. 754'mouse-1' moves it to another position on the tab bar. Mouse wheel
755scrolling switches to the previous/next tab, and holding the Shift key
756during scrolling moves the tab to the left/right.
755 757
756*** The key prefix 'C-x t t' displays next command buffer in a new tab. 758*** The key prefix 'C-x t t' displays next command buffer in a new tab.
757It's bound to the command 'other-tab-prefix' that requests the buffer 759It's bound to the command 'other-tab-prefix' that requests the buffer
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 68de770e060..ef7babb87b1 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -327,6 +327,20 @@ new frame when the global `tab-bar-mode' is enabled, by using
327 (define-key map [mouse-2] 'ignore) 327 (define-key map [mouse-2] 'ignore)
328 (define-key map [down-mouse-3] 'tab-bar-mouse-context-menu) 328 (define-key map [down-mouse-3] 'tab-bar-mouse-context-menu)
329 329
330 (define-key map [mouse-4] 'tab-previous)
331 (define-key map [mouse-5] 'tab-next)
332 (define-key map [wheel-up] 'tab-previous)
333 (define-key map [wheel-down] 'tab-next)
334 (define-key map [wheel-left] 'tab-previous)
335 (define-key map [wheel-right] 'tab-next)
336
337 (define-key map [S-mouse-4] 'tab-bar-move-tab-backward)
338 (define-key map [S-mouse-5] 'tab-bar-move-tab)
339 (define-key map [S-wheel-up] 'tab-bar-move-tab-backward)
340 (define-key map [S-wheel-down] 'tab-bar-move-tab)
341 (define-key map [S-wheel-left] 'tab-bar-move-tab-backward)
342 (define-key map [S-wheel-right] 'tab-bar-move-tab)
343
330 map) 344 map)
331 "Keymap for the commands used on the tab bar.") 345 "Keymap for the commands used on the tab bar.")
332 346
@@ -1055,6 +1069,12 @@ where argument addressing is absolute."
1055 (to-index (mod (+ from-index arg) (length tabs)))) 1069 (to-index (mod (+ from-index arg) (length tabs))))
1056 (tab-bar-move-tab-to (1+ to-index) (1+ from-index)))) 1070 (tab-bar-move-tab-to (1+ to-index) (1+ from-index))))
1057 1071
1072(defun tab-bar-move-tab-backward (&optional arg)
1073 "Move the current tab ARG positions to the left.
1074Like `tab-bar-move-tab', but moves in the opposite direction."
1075 (interactive "p")
1076 (tab-bar-move-tab (- (or arg 1))))
1077
1058(defun tab-bar-move-tab-to-frame (arg &optional from-frame from-index to-frame to-index) 1078(defun tab-bar-move-tab-to-frame (arg &optional from-frame from-index to-frame to-index)
1059 "Move tab from FROM-INDEX position to new position at TO-INDEX. 1079 "Move tab from FROM-INDEX position to new position at TO-INDEX.
1060FROM-INDEX defaults to the current tab index. 1080FROM-INDEX defaults to the current tab index.
@@ -2118,11 +2138,8 @@ Used in `repeat-mode'.")
2118 2138
2119(defvar tab-bar-move-repeat-map 2139(defvar tab-bar-move-repeat-map
2120 (let ((map (make-sparse-keymap))) 2140 (let ((map (make-sparse-keymap)))
2121 (define-key map "m" 'tab-move) 2141 (define-key map "m" 'tab-bar-move-tab)
2122 (define-key map "M" (lambda () 2142 (define-key map "M" 'tab-bar-move-tab-backward)
2123 (interactive)
2124 (setq repeat-map 'tab-bar-move-repeat-map)
2125 (tab-move -1)))
2126 map) 2143 map)
2127 "Keymap to repeat tab move key sequences `C-x t m m M'. 2144 "Keymap to repeat tab move key sequences `C-x t m m M'.
2128Used in `repeat-mode'.") 2145Used in `repeat-mode'.")
diff --git a/src/xterm.c b/src/xterm.c
index 80fa747b97d..57229d3d616 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9215,7 +9215,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
9215 window = window_from_coordinates (f, x, y, 0, true, true); 9215 window = window_from_coordinates (f, x, y, 0, true, true);
9216 tab_bar_p = EQ (window, f->tab_bar_window); 9216 tab_bar_p = EQ (window, f->tab_bar_window);
9217 9217
9218 if (tab_bar_p && event->xbutton.button < 4) 9218 if (tab_bar_p)
9219 tab_bar_key = handle_tab_bar_click 9219 tab_bar_key = handle_tab_bar_click
9220 (f, x, y, event->xbutton.type == ButtonPress, 9220 (f, x, y, event->xbutton.type == ButtonPress,
9221 x_x_to_emacs_modifiers (dpyinfo, event->xbutton.state)); 9221 x_x_to_emacs_modifiers (dpyinfo, event->xbutton.state));