aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Levedahl <mlevedahl@gmail.com>2024-07-06 11:08:32 -0400
committerMark Levedahl <mlevedahl@gmail.com>2025-07-16 23:01:51 -0400
commit61c74d062bd9fd35c6f9a17b488abce88d560566 (patch)
treeef70d0c13de6f78d57c698adbd6bd9b687edbb86
parent429bbf449c4ce43330e16422070080c314f8b8c4 (diff)
downloadgit-61c74d062bd9fd35c6f9a17b488abce88d560566.tar.gz
gitk: update win32 scrolling for Tk 8.6 / TIP 171
gitk on win32 binds windows_mousewheel_redirector to all MouseWheel events in the main window. This proc determines the widget under the cursor, then determines what scroll command to give, possibly none, and issues scroll commands to the widget. The top panes get only vertical scroll events, as does the lower right Patch/Tree pane. All others get both vertical and horizontal events. These are all hard coded at +/- five lines. We now have common MouseWheel event bindings that follow user preferences for the scrolling amount, bind for only the five main display widgets, and leave the other gui elements untouched. Let's use this instead. With the scrolling preference set at 5, the users should not notice much, if any, difference. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
-rwxr-xr-xgitk32
1 files changed, 8 insertions, 24 deletions
diff --git a/gitk b/gitk
index 56eb1ec4e6..124e39c519 100755
--- a/gitk
+++ b/gitk
@@ -2268,9 +2268,9 @@ proc bind_mousewheel {} {
global canv cflist ctext
bindall <MouseWheel> {allcanvs yview scroll [scrollval %D] units}
bindall <Shift-MouseWheel> break
- bind $ctext <MouseWheel> {$ctext yview scroll [scrollval %D] units}
- bind $ctext <Shift-MouseWheel> {$ctext xview scroll [scrollval %D] units}
- bind $cflist <MouseWheel> {$cflist yview scroll [scrollval %D] units}
+ bind $ctext <MouseWheel> {$ctext yview scroll [scrollval %D 2] units}
+ bind $ctext <Shift-MouseWheel> {$ctext xview scroll [scrollval %D 2] units}
+ bind $cflist <MouseWheel> {$cflist yview scroll [scrollval %D 2] units}
bind $cflist <Shift-MouseWheel> break
}
@@ -2293,6 +2293,7 @@ proc makewindow {} {
global fprogitem fprogcoord lastprogupdate progupdatepending
global rprogitem rprogcoord rownumsel numcommits
global worddiff
+ global scroll_D0
# The "mc" arguments here are purely so that xgettext
# sees the following string as needing to be translated
@@ -2709,10 +2710,11 @@ proc makewindow {} {
pack .ctop -fill both -expand 1
bindall <1> {selcanvline %W %x %y}
- #bindall <B1-Motion> {selcanvline %W %x %y}
+
+ #Mouse / touchpad scrolling
if {[tk windowingsystem] == "win32"} {
- bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
- bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D ; break }
+ set scroll_D0 120
+ bind_mousewheel
} elseif {[tk windowingsystem] == "x11"} {
bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
@@ -2873,24 +2875,6 @@ proc makewindow {} {
$diff_menu configure -tearoff 0
}
-# Windows sends all mouse wheel events to the current focused window, not
-# the one where the mouse hovers, so bind those events here and redirect
-# to the correct window
-proc windows_mousewheel_redirector {W X Y D} {
- global canv canv2 canv3
- set w [winfo containing -displayof $W $X $Y]
- if {$w ne ""} {
- set u [expr {$D < 0 ? 5 : -5}]
- if {$w == $canv || $w == $canv2 || $w == $canv3} {
- allcanvs yview scroll $u units
- } else {
- catch {
- $w yview scroll $u units
- }
- }
- }
-}
-
# Update row number label when selectedline changes
proc selectedline_change {n1 n2 op} {
global selectedline rownumsel