summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-07-26 09:06:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-07-26 09:06:10 (GMT)
commitf97059c69925b78f7f7e291b86fa2089f58291a6 (patch)
treeb11459ac908a6938f6fcb19aca40367ec98986cd
parentfda72faf1d67dd4016bf6842a6448943bd324707 (diff)
downloadtk-f97059c69925b78f7f7e291b86fa2089f58291a6.zip
tk-f97059c69925b78f7f7e291b86fa2089f58291a6.tar.gz
tk-f97059c69925b78f7f7e291b86fa2089f58291a6.tar.bz2
Further experiment: Bring scalefactor back to 120 (as it was for win32)
-rw-r--r--doc/event.n4
-rw-r--r--generic/tkBind.c4
-rw-r--r--generic/tkEvent.c2
-rw-r--r--generic/tkPointer.c3
-rw-r--r--library/demos/cscroll.tcl8
-rw-r--r--library/listbox.tcl8
-rw-r--r--library/scrlbar.tcl8
-rw-r--r--library/text.tcl8
-rw-r--r--library/ttk/utils.tcl35
-rw-r--r--macosx/tkMacOSXMouseEvent.c14
-rw-r--r--tests/scrollbar.test4
-rw-r--r--win/tkWinX.c4
12 files changed, 44 insertions, 58 deletions
diff --git a/doc/event.n b/doc/event.n
index be42fa5..5109794 100644
--- a/doc/event.n
+++ b/doc/event.n
@@ -119,8 +119,8 @@ for the event. Only valid for virtual events. Corresponds to the
for the \fBMouseWheel\fR event. The \fIdelta\fR refers to the
direction and magnitude the mouse wheel was rotated. Note the value
is not a screen distance but are units of motion in the mouse wheel.
-Typically these values are multiples of 40. For example, 40 should
-scroll the text widget up 4 lines and \-80 would scroll the text
+Typically these values are multiples of 120. For example, 120 should
+scroll the text widget up 4 lines and \-240 would scroll the text
widget down 8 lines. Of course, other widgets may define different
behaviors for mouse wheel motion. This field corresponds to the
\fB%D\fR substitution for binding scripts.
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 03e4a2b..45e07be 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -1996,7 +1996,7 @@ ExpandPercents(
if (flags & BUTTON) {
number = eventPtr->xbutton.button;
if (number >= Button8) {
- number += (Button4 - Button8);
+ number -= (Button8 - Button4);
}
goto doNumber;
}
@@ -4239,7 +4239,7 @@ GetPatternObj(
} else {
int button = patPtr->detail.button;
if (button >= Button8) {
- button += (Button4 - Button8);
+ button -= (Button8 - Button4);
}
Tcl_AppendPrintfToObj(patternObj, "%d", button);
}
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index dd77c2b..39d9d4b 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -594,7 +594,7 @@ UpdateButtonEventState(
#if defined(_WIN32) || defined(MAC_OSX_TK)
eventPtr->xkey.nbytes = 0;
#endif
- eventPtr->xkey.keycode = (eventPtr->xbutton.button & 1) ? 40 : -40;
+ eventPtr->xkey.keycode = (eventPtr->xbutton.button & 1) ? 120 : -120;
if (eventPtr->xkey.keycode > Button5) {
eventPtr->xkey.state |= ShiftMask;
}
diff --git a/generic/tkPointer.c b/generic/tkPointer.c
index af5e311..57680c3 100644
--- a/generic/tkPointer.c
+++ b/generic/tkPointer.c
@@ -226,8 +226,7 @@ Tk_UpdatePointer(
XPoint pos;
XEvent event;
int changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS;
- int type, b;
- int mask;
+ int type, b, mask;
pos.x = x;
pos.y = y;
diff --git a/library/demos/cscroll.tcl b/library/demos/cscroll.tcl
index 24d5f89..c709668 100644
--- a/library/demos/cscroll.tcl
+++ b/library/demos/cscroll.tcl
@@ -59,16 +59,16 @@ $c bind all <1> "scrollButton $c"
bind $c <2> "$c scan mark %x %y"
bind $c <B2-Motion> "$c scan dragto %x %y"
bind $c <MouseWheel> {
- %W yview scroll [expr {-(%D / 40)}] units
+ %W yview scroll [expr {-((%D+60) / 120)}] units
}
bind $c <Option-MouseWheel> {
- %W yview scroll [expr {-(%D / 4)}] units
+ %W yview scroll [expr {-((%D+6) / 12)}] units
}
bind $c <Shift-MouseWheel> {
- %W xview scroll [expr {-(%D / 40)}] units
+ %W xview scroll [expr {-((%D+60) / 120)}] units
}
bind $c <Shift-Option-MouseWheel> {
- %W xview scroll [expr {-(%D / 4)}] units
+ %W xview scroll [expr {-((%D+6) / 12)}] units
}
proc scrollEnter canvas {
diff --git a/library/listbox.tcl b/library/listbox.tcl
index fd10fe4..ffd7def 100644
--- a/library/listbox.tcl
+++ b/library/listbox.tcl
@@ -177,16 +177,16 @@ bind Listbox <B2-Motion> {
}
bind Listbox <MouseWheel> {
- %W yview scroll [expr {-(%D / 40)}] units
+ %W yview scroll [expr {-((%D+60) / 120)}] units
}
bind Listbox <Option-MouseWheel> {
- %W yview scroll [expr {-(%D / 4)}] units
+ %W yview scroll [expr {-((%D+6) / 12)}] units
}
bind Listbox <Shift-MouseWheel> {
- %W xview scroll [expr {-(%D / 40)}] units
+ %W xview scroll [expr {-((%D+60) / 120)}] units
}
bind Listbox <Shift-Option-MouseWheel> {
- %W xview scroll [expr {-(%D / 4)}] units
+ %W xview scroll [expr {-((%D+6) / 12)}] units
}
diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl
index 93ded56..dae11ae 100644
--- a/library/scrlbar.tcl
+++ b/library/scrlbar.tcl
@@ -130,16 +130,16 @@ bind Scrollbar <<LineEnd>> {
}
bind Scrollbar <MouseWheel> {
- tk::ScrollByUnits %W v [expr {-(%D / 40)}]
+ tk::ScrollByUnits %W v [expr {-((%D+60) / 120)}]
}
bind Scrollbar <Option-MouseWheel> {
- tk::ScrollByUnits %W v [expr {-(%D / 4)}]
+ tk::ScrollByUnits %W v [expr {-((%D+6) / 12)}]
}
bind Scrollbar <Shift-MouseWheel> {
- tk::ScrollByUnits %W h [expr {-(%D / 40)}]
+ tk::ScrollByUnits %W h [expr {-((%D+60) / 120)}]
}
bind Scrollbar <Shift-Option-MouseWheel> {
- tk::ScrollByUnits %W h [expr {-(%D / 4)}]
+ tk::ScrollByUnits %W h [expr {-((%D+6) / 12)}]
}
# tk::ScrollButtonDown --
diff --git a/library/text.tcl b/library/text.tcl
index 9d635de..72da6ff 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -428,16 +428,16 @@ bind Text <B2-Motion> {
set ::tk::Priv(prevPos) {}
bind Text <MouseWheel> {
- %W yview scroll [expr {-(%D)}] pixels
+ %W yview scroll [expr {-((%D+1)/3)}] pixels
}
bind Text <Option-MouseWheel> {
- %W yview scroll [expr {-10 * (%D)}] pixels
+ %W yview scroll [expr {-4 * (%D)}] pixels
}
bind Text <Shift-MouseWheel> {
- %W xview scroll [expr {-(%D)}] pixels
+ %W xview scroll [expr {-((%D+1)/3)}] pixels
}
bind Text <Shift-Option-MouseWheel> {
- %W xview scroll [expr {-10 * (%D)}] pixels
+ %W xview scroll [expr {-4 * (%D)}] pixels
}
# ::tk::TextClosestGap --
diff --git a/library/ttk/utils.tcl b/library/ttk/utils.tcl
index 140e061..ad36927 100644
--- a/library/ttk/utils.tcl
+++ b/library/ttk/utils.tcl
@@ -285,7 +285,8 @@ proc ttk::copyBindings {from to} {
#
proc ttk::bindMouseWheel {bindtag callback} {
- bind $bindtag <MouseWheel> [append callback { [expr {-(%D/40)}]}]
+ bind $bindtag <MouseWheel> [append callback { [expr {-((%D+60)/120)}]}]
+ bind $bindtag <Option-MouseWheel> [append callback { [expr {-((%D+6)/12)}]}]
}
## Mousewheel bindings for standard scrollable widgets.
@@ -296,29 +297,13 @@ proc ttk::bindMouseWheel {bindtag callback} {
# standard scrollbar protocol.
#
-switch -- [tk windowingsystem] {
- x11 {
- bind TtkScrollable <ButtonPress-4> { %W yview scroll -5 units }
- bind TtkScrollable <ButtonPress-5> { %W yview scroll 5 units }
- bind TtkScrollable <Shift-ButtonPress-4> { %W xview scroll -5 units }
- bind TtkScrollable <Shift-ButtonPress-5> { %W xview scroll 5 units }
- }
- win32 {
- bind TtkScrollable <MouseWheel> \
- { %W yview scroll [expr {-(%D/120)}] units }
- bind TtkScrollable <Shift-MouseWheel> \
- { %W xview scroll [expr {-(%D/120)}] units }
- }
- aqua {
- bind TtkScrollable <MouseWheel> \
- { %W yview scroll [expr {-(%D)}] units }
- bind TtkScrollable <Shift-MouseWheel> \
- { %W xview scroll [expr {-(%D)}] units }
- bind TtkScrollable <Option-MouseWheel> \
- { %W yview scroll [expr {-10*(%D)}] units }
- bind TtkScrollable <Shift-Option-MouseWheel> \
- { %W xview scroll [expr {-10*(%D)}] units }
- }
-}
+bind TtkScrollable <MouseWheel> \
+{ %W yview scroll [expr {-((%D+60)/120)}] units }
+bind TtkScrollable <Option-MouseWheel> \
+{ %W yview scroll [expr {-((%D+6)/12)}] units }
+bind TtkScrollable <Shift-MouseWheel> \
+{ %W xview scroll [expr {-((%D+60)/120)}] units }
+bind TtkScrollable <Shift-Option-MouseWheel> \
+{ %W xview scroll [expr {-((%D+6)/12)}] units }
#*EOF*
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index ed67bae..92d2daf 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -267,21 +267,23 @@ enum {
xEvent.xany.display = Tk_Display(tkwin);
xEvent.xany.window = Tk_WindowId(tkwin);
- delta = [theEvent deltaY] * 40;
+ delta = [theEvent deltaY] * 120;
if (delta != 0.0) {
- coarseDelta = (delta > -40.0 && delta < 40.0) ?
- (signbit(delta) ? -40 : 40 : lround(delta);
+ coarseDelta = (delta > -120.0 && delta < 120.0) ?
+ (signbit(delta) ? -120 : 120 : lround(delta);
xEvent.xbutton.state = state;
xEvent.xkey.keycode = coarseDelta;
+ xEvent.xkey.nbytes = 0;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
}
- delta = [theEvent deltaX] * 40;
+ delta = [theEvent deltaX] * 120;
if (delta != 0.0) {
- coarseDelta = (delta > -40.0 && delta < 40.0) ?
- (signbit(delta) ? -40 : 40) : lround(delta);
+ coarseDelta = (delta > -120.0 && delta < 120.0) ?
+ (signbit(delta) ? -120 : 120) : lround(delta);
xEvent.xbutton.state = state | ShiftMask;
xEvent.xkey.keycode = coarseDelta;
+ xEvent.xkey.nbytes = 0;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL);
}
diff --git a/tests/scrollbar.test b/tests/scrollbar.test
index d235656..e6e6bdd 100644
--- a/tests/scrollbar.test
+++ b/tests/scrollbar.test
@@ -693,7 +693,7 @@ test scrollbar-10.1 {<MouseWheel> event on scrollbar} -setup {
pack [scrollbar .s -command {.t yview}] -fill y -expand 1 -side left
update
focus -force .s
- event generate .s <MouseWheel> -delta -150
+ event generate .s <MouseWheel> -delta -120
after 200 {set eventprocessed 1} ; vwait eventprocessed
.t index @0,0
} -cleanup {
@@ -708,7 +708,7 @@ test scrollbar-10.2 {<MouseWheel> event on scrollbar} -setup {
pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top
update
focus -force .s
- event generate .s <Shift-MouseWheel> -delta -150
+ event generate .s <Shift-MouseWheel> -delta -120
after 200 {set eventprocessed 1} ; vwait eventprocessed
.t index @0,0
} -cleanup {
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 8127eef..9d474ac 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -1142,7 +1142,7 @@ GenerateXEvent(
event.type = MouseWheelEvent;
event.xany.send_event = -1;
event.xkey.nbytes = 0;
- event.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA / 3;
+ event.xkey.keycode = tsdPtr->vWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
tsdPtr->vWheelAcc = tsdPtr->vWheelAcc % WHEEL_DELTA;
break;
}
@@ -1175,7 +1175,7 @@ GenerateXEvent(
event.xany.send_event = -1;
event.xkey.nbytes = 0;
event.xkey.state |= ShiftMask;
- event.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA / 3;
+ event.xkey.keycode = tsdPtr->hWheelAcc / WHEEL_DELTA * WHEEL_DELTA;
tsdPtr->hWheelAcc = tsdPtr->hWheelAcc % WHEEL_DELTA;
break;
}