Commit 7f1c5184 authored by Nate Graham's avatar Nate Graham
Browse files

applets/taskmanager: make it harder to accidentally start a drag

Right now there is code to reduce the liklihood of accidental drags, but
it suffers from two issues that reduce its effectiveness:
- It doesn't internally check for all the parameters used to signify
  that the mouse is pressed, just one which serves as a proxy for the
  rest. As a result, if they get out of sync it's possible for a drag
  to begin even when the mouse isn't pressed.
- It has a distance threshold before starting a drag that defaults to
  10px, but can be overridden in config files to be much less. And 10px
  is quite small anyway.

This commit fixes those issues by checking for all press-based
paremeters when determining whether to start a drag, and and ensuring
that the drag threshold never falls below 1/2 of the icon size no
matter what it's set to in the config file.

BUG: 402376
FIXED-IN: 5.26
parent 5307ac20
Pipeline #228186 passed with stage
in 2 minutes and 47 seconds
......@@ -230,7 +230,12 @@ MouseArea {
onPositionChanged: {
// mouse.button is always 0 here, hence checking with mouse.buttons
if (pressX != -1 && mouse.buttons == Qt.LeftButton && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
if (pressed
&& pressX != -1
&& pressY != -1
&& mouse.buttons == Qt.LeftButton
&& dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)
) {
tasks.dragSource = task;
dragHelper.startDrag(task, model.MimeType, model.MimeData,
model.LauncherUrlWithoutIcon, model.decoration);
......@@ -42,7 +42,9 @@ void DragHelper::setDragIconSize(int size)
bool DragHelper::isDrag(int oldX, int oldY, int newX, int newY) const
return ((QPoint(oldX, oldY) - QPoint(newX, newY)).manhattanLength() >= QApplication::startDragDistance());
// Don't let drag threshold fall below 1/2 of icon size, to make accidental
// drags less likely.
return ((QPoint(oldX, oldY) - QPoint(newX, newY)).manhattanLength() >= std::max(QApplication::startDragDistance(), m_dragIconSize / 2));
void DragHelper::startDrag(QQuickItem *item, const QString &mimeType, const QVariant &mimeData, const QUrl &url, const QIcon &icon)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment