D5037: KTextEditor: prevent accidental zooming
René J.V. Bertin
noreply at phabricator.kde.org
Mon Mar 13 17:27:28 UTC 2017
rjvbb created this revision.
rjvbb added a project: KTextEditor.
Restricted Application added subscribers: Frameworks, kwrite-devel.
Restricted Application added a project: Frameworks.
REVISION SUMMARY
KTextEditor::KateViewInternal::wheelEvent() implements text zoom in reaction to Ctrl+Wheel events, something Qt also implements or used to implement for QTextEdit and/or QTextBrowser.
Problems can occur with systems with a trackpad that use 2-finger scrolling and scroll inertia. These are subject to unexpected, accidental text zooming when the user holds presses the Ctrl key to trigger a shortcut (say, Ctrl-S to save the current document) before scroll coasting has stopped completely.
The end of coasting isn't always clear: scroll events may continue to come in with sub-threshold deltas, or when the view has already reached its extreme position and can scroll no further. This affects me much more frequently than I would like in applications like KDevelop and is especially annoying since there is no standard shortcut to return to 100% (no zoom).
Qt itself has a form of protection against this kind of annoyance on Mac and possibly other systems where inertial scrolling has better platform support than under X11.
This patch provides what I hope is a reasonably minimal implementation of a similar protection that ignores Control modifier changes that occur within a certain lapse of time after the start of a series of wheel events.
See also https://bugs.kde.org/show_bug.cgi?id=377562
TEST PLAN
This is stripped-down version of a proof of concept designed by Thomas Lübking and me and well tested on Linux and Mac:
https://github.com/RJVB/qtwheeltest/blob/master/wheeltest.cpp
the timing parameters have been tuned in a rather ad-hoc fashion; the lower threshold is probably just fine as it is but the higher threshold could possibly be set lower. It represents the time one would have to hold down the Ctrl key before wheel events again cause zooming after the protection has triggered. Any wheel event without the modifier key set will also reset the timer.
This is a patch that merits being tested in practice, not just reviewed in source code.
REPOSITORY
R39 KTextEditor
REVISION DETAIL
https://phabricator.kde.org/D5037
AFFECTED FILES
src/view/kateviewinternal.cpp
src/view/kateviewinternal.h
To: rjvbb, #ktexteditor
Cc: kwrite-devel, #ktexteditor, #frameworks, head7, cullmann, kfunk, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20170313/5e5d94aa/attachment-0001.html>
More information about the Kde-frameworks-devel
mailing list