From: Mark Levedahl Date: Sat, 6 Jul 2024 15:08:32 +0000 (-0400) Subject: gitk: update win32 scrolling for Tk 8.6 / TIP 171 X-Git-Tag: v2.51.0-rc0~47^2~1^2~3 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=61c74d062bd9fd35c6f9a17b488abce88d560566;p=thirdparty%2Fgit.git 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 --- 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 {allcanvs yview scroll [scrollval %D] units} bindall break - bind $ctext {$ctext yview scroll [scrollval %D] units} - bind $ctext {$ctext xview scroll [scrollval %D] units} - bind $cflist {$cflist yview scroll [scrollval %D] units} + bind $ctext {$ctext yview scroll [scrollval %D 2] units} + bind $ctext {$ctext xview scroll [scrollval %D 2] units} + bind $cflist {$cflist yview scroll [scrollval %D 2] units} bind $cflist 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 {selcanvline %W %x %y} + + #Mouse / touchpad scrolling if {[tk windowingsystem] == "win32"} { - bind . { windows_mousewheel_redirector %W %X %Y %D } - bind $ctext { windows_mousewheel_redirector %W %X %Y %D ; break } + set scroll_D0 120 + bind_mousewheel } elseif {[tk windowingsystem] == "x11"} { bindall "allcanvs yview scroll -5 units" bindall "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