Skip to content

Instantly share code, notes, and snippets.

@M4he
Created October 19, 2022 13:27
Show Gist options
  • Save M4he/4f6222e2524a15bca8a64ae9c2d09ea7 to your computer and use it in GitHub Desktop.
Save M4he/4f6222e2524a15bca8a64ae9c2d09ea7 to your computer and use it in GitHub Desktop.
PCManFM-Qt patch for making default scrolling slow (row-by-row) and only fast with Shift key (like Dolphin, the reverse of PCManFM-Qt's default behavior)
--- src/folderview.cpp.orig 2022-10-19 15:22:15.688067732 +0200
+++ src/folderview.cpp 2022-10-19 15:10:59.396065442 +0200
@@ -1592,8 +1592,8 @@
return true;
}
}
- // row-by-row scrolling when Shift is pressed
- if((QApplication::keyboardModifiers() & Qt::ShiftModifier)
+ // row-by-row scrolling when Shift is NOT pressed
+ if (!(QApplication::keyboardModifiers() & Qt::ShiftModifier)
&& (mode == CompactMode || mode == DetailedListMode)) // other modes have smooth scroling
{
QScrollBar *sbar = (mode == CompactMode ? view->horizontalScrollBar()
@@ -1656,7 +1656,7 @@
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) {
+ 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())) {
@M4he
Copy link
Author

M4he commented Oct 19, 2022

Here's a quick rundown on how to apply this on Debian 11 for reference:

# download the source code package
# (this will also automatically extract it in a subfolder)
apt source libfm-qt

# install necessary packages to compile libfm-qt
sudo apt build-dep libfm-qt

# enter the extracted source code directory (version number may differ)
cd libfm-qt-0.16.0/

# create a file using any editor (e.g. nano) and paste the patch into it
nano pcmanfm-qt_default_to_slow_scrolling.patch 

# apply the patch
patch -p0 < pcmanfm-qt_default_to_slow_scrolling.patch

# build the modified libfm-qt package
dpkg-buildpackage -rfakeroot -uc -b

# install the patched version (version numbers may differ)
sudo dpkg -i ../libfm-qt8_0.16.0-3_amd64.deb
sudo dpkg -i ../libfm-qt-l10n_0.16.0-3_all.deb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment