Skip to content

Commit 61c74d0

Browse files
committed
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 <[email protected]>
1 parent 429bbf4 commit 61c74d0

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

gitk

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,9 +2268,9 @@ proc bind_mousewheel {} {
22682268
global canv cflist ctext
22692269
bindall <MouseWheel> {allcanvs yview scroll [scrollval %D] units}
22702270
bindall <Shift-MouseWheel> break
2271-
bind $ctext <MouseWheel> {$ctext yview scroll [scrollval %D] units}
2272-
bind $ctext <Shift-MouseWheel> {$ctext xview scroll [scrollval %D] units}
2273-
bind $cflist <MouseWheel> {$cflist yview scroll [scrollval %D] units}
2271+
bind $ctext <MouseWheel> {$ctext yview scroll [scrollval %D 2] units}
2272+
bind $ctext <Shift-MouseWheel> {$ctext xview scroll [scrollval %D 2] units}
2273+
bind $cflist <MouseWheel> {$cflist yview scroll [scrollval %D 2] units}
22742274
bind $cflist <Shift-MouseWheel> break
22752275
}
22762276
@@ -2293,6 +2293,7 @@ proc makewindow {} {
22932293
global fprogitem fprogcoord lastprogupdate progupdatepending
22942294
global rprogitem rprogcoord rownumsel numcommits
22952295
global worddiff
2296+
global scroll_D0
22962297
22972298
# The "mc" arguments here are purely so that xgettext
22982299
# sees the following string as needing to be translated
@@ -2709,10 +2710,11 @@ proc makewindow {} {
27092710
27102711
pack .ctop -fill both -expand 1
27112712
bindall <1> {selcanvline %W %x %y}
2712-
#bindall <B1-Motion> {selcanvline %W %x %y}
2713+
2714+
#Mouse / touchpad scrolling
27132715
if {[tk windowingsystem] == "win32"} {
2714-
bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
2715-
bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D ; break }
2716+
set scroll_D0 120
2717+
bind_mousewheel
27162718
} elseif {[tk windowingsystem] == "x11"} {
27172719
bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
27182720
bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
@@ -2873,24 +2875,6 @@ proc makewindow {} {
28732875
$diff_menu configure -tearoff 0
28742876
}
28752877
2876-
# Windows sends all mouse wheel events to the current focused window, not
2877-
# the one where the mouse hovers, so bind those events here and redirect
2878-
# to the correct window
2879-
proc windows_mousewheel_redirector {W X Y D} {
2880-
global canv canv2 canv3
2881-
set w [winfo containing -displayof $W $X $Y]
2882-
if {$w ne ""} {
2883-
set u [expr {$D < 0 ? 5 : -5}]
2884-
if {$w == $canv || $w == $canv2 || $w == $canv3} {
2885-
allcanvs yview scroll $u units
2886-
} else {
2887-
catch {
2888-
$w yview scroll $u units
2889-
}
2890-
}
2891-
}
2892-
}
2893-
28942878
# Update row number label when selectedline changes
28952879
proc selectedline_change {n1 n2 op} {
28962880
global selectedline rownumsel

0 commit comments

Comments
 (0)