Created
February 2, 2023 21:56
-
-
Save M4he/9b2b3ba75af658a721afe1381a9cc733 to your computer and use it in GitHub Desktop.
PCManFM-Qt patch for disabling smooth-scrolling to fix scrolling behavior on touchpad devices, until https://github.com/lxqt/libfm-qt/pull/875 lands in packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- src/folderview.cpp.orig 2023-02-02 22:54:09.780036423 +0100 | |
+++ src/folderview.cpp 2023-02-02 22:50:06.284034359 +0100 | |
@@ -1592,9 +1592,6 @@ | |
return true; | |
} | |
} | |
- // row-by-row scrolling when Shift is pressed | |
- if((QApplication::keyboardModifiers() & Qt::ShiftModifier) | |
- && (mode == CompactMode || mode == DetailedListMode)) // other modes have smooth scroling | |
{ | |
QScrollBar *sbar = (mode == CompactMode ? view->horizontalScrollBar() | |
: view->verticalScrollBar()); | |
@@ -1629,54 +1626,6 @@ | |
return true; | |
} | |
} | |
- // This is to fix #85: Scrolling doesn't work in compact view | |
- // Actually, I think it's the bug of Qt, not ours. | |
- // When in compact mode, only the horizontal scroll bar is used and the vertical one is hidden. | |
- // So, when a user scroll his mouse wheel, it's reasonable to scroll the horizontal scollbar. | |
- // Qt does not implement such a simple feature, unfortunately. | |
- // We do it by forwarding the scroll event in the viewport to the horizontal scrollbar. | |
- // FIXME: if someday Qt supports this, we have to disable the workaround. | |
- else if(mode == CompactMode) { | |
-#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) | |
- QScrollBar* scroll = view->horizontalScrollBar(); | |
- if(scroll) { | |
- QApplication::sendEvent(scroll, event); | |
- return true; | |
- } | |
-#else | |
- return false; // the problem with horizontal wheel scrolling from inside view is fixed in Qt 5.14 | |
-#endif | |
- } | |
- // Smooth Scrolling | |
- // Some tricks are adapted from <https://github.com/zhou13/qsmoothscrollarea>. | |
- else if(mode != DetailedListMode | |
- && event->spontaneous() | |
- && static_cast<QWheelEvent*>(event)->source() == Qt::MouseEventNotSynthesized | |
- && !(QApplication::keyboardModifiers() & Qt::AltModifier)) { | |
- if(QScrollBar* vbar = view->verticalScrollBar()) { | |
- // keep track of the wheel event for smooth scrolling | |
- int delta = static_cast<QWheelEvent*>(event)->angleDelta().y(); | |
- if(QApplication::keyboardModifiers() & Qt::ShiftModifier) { | |
- delta /= QApplication::wheelScrollLines(); // row-by-row scrolling | |
- } | |
- if((delta > 0 && vbar->value() == vbar->minimum()) || (delta < 0 && vbar->value() == vbar->maximum())) { | |
- break; // the scrollbar can't move | |
- } | |
- | |
- if(!smoothScrollTimer_) { | |
- smoothScrollTimer_ = new QTimer(); | |
- connect(smoothScrollTimer_, &QTimer::timeout, this, &FolderView::scrollSmoothly); | |
- } | |
- | |
- // set the data for smooth scrolling | |
- scrollData data; | |
- data.delta = delta; | |
- data.leftFrames = scrollAnimFrames; | |
- queuedScrollSteps_.append(data); | |
- smoothScrollTimer_->start(1000 / SCROLL_FRAMES_PER_SEC); | |
- return true; | |
- } | |
- } | |
break; | |
default: | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a quick rundown on how to apply this on Debian 11 for reference: