Skip to content

Commit 62ed09f

Browse files
authored
Made horizontal wheel scrolling work with Custom Command (#2074)
Previously, only the vertical wheel scrolling worked, which might not be ideal with a touchpad. A confession: My concern wasn't the touchpad ;) I made this patch as a workaround for a regression about Wayland, because of which, Qt's vertical and horizontal wheel events are swapped under special circumstances. However, the end result is independent of that regression.
1 parent 2bbc017 commit 62ed09f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

plugin-customcommand/custombutton.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ CustomButton::~CustomButton() = default;
7676

7777
void CustomButton::wheelEvent(QWheelEvent *event)
7878
{
79-
int y = event->angleDelta().y();
80-
emit wheelScrolled(y);
79+
QPoint anglePoint = event->angleDelta();
80+
bool horizontal(qAbs(event->angleDelta().x()) > qAbs(anglePoint.y()));
81+
int delta = horizontal ? anglePoint.x() : anglePoint.y();
82+
emit wheelScrolled(delta);
8183
event->accept();
8284
}
8385

plugin-customcommand/lxqtcustomcommand.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ void LXQtCustomCommand::updateButton() {
214214
mButton->updateWidth();
215215
}
216216

217-
void LXQtCustomCommand::handleWheelScrolled(int yDelta)
217+
void LXQtCustomCommand::handleWheelScrolled(int delta)
218218
{
219-
if (yDelta > 0 && !mWheelUp.isEmpty())
219+
if (delta > 0 && !mWheelUp.isEmpty())
220220
runDetached(mWheelUp);
221-
else if (yDelta < 0 && !mWheelDown.isEmpty())
221+
else if (delta < 0 && !mWheelDown.isEmpty())
222222
runDetached(mWheelDown);
223223
}
224224

plugin-customcommand/lxqtcustomcommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected slots:
5656
private slots:
5757
void handleClick();
5858
void handleFinished(int exitCode, QProcess::ExitStatus exitStatus);
59-
void handleWheelScrolled(int yDelta);
59+
void handleWheelScrolled(int delta);
6060
void updateButton();
6161
void runCommand();
6262
void runDetached(QString command);

0 commit comments

Comments
 (0)