Commit 31bcd0ac authored by Eike Hein's avatar Eike Hein

Fix launching by touchscreen tap

Summary:
The mouse handling code relied on onPositionChanged to do setup work
prior to onPressed. This is never guaranteed, but it's is likely to
happen when using the mouse (since the pointer is usually moved from
a panel icon to a delegate elsewhere on screen). In a touchscreen
scenario, these odds reverse.

The lesson to take away: Never assume onPositionChanged has run
before onPressed.

BUG:366527

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10513
parent 840694cc
......@@ -359,12 +359,38 @@ FocusScope {
hoverEnabled: true
function updatePositionProperties(x, y) {
// Prevent hover event synthesis in QQuickWindow interfering
// with keyboard navigation by ignoring repeated events with
// identical coordinates. As the work done here would be re-
// dundant in any case, these are safe to ignore.
if (lastX == x && lastY == y) {
return;
}
lastX = x;
lastY = y;
var cPos = mapToItem(gridView.contentItem, x, y);
var item = gridView.itemAt(cPos.x, cPos.y);
if (!item) {
gridView.currentIndex = -1;
pressedItem = null;
} else {
gridView.currentIndex = item.itemIndex;
itemGrid.focus = (currentIndex != -1)
}
}
onPressed: {
mouse.accepted = true;
updatePositionProperties(mouse.x, mouse.y);
pressX = mouse.x;
pressY = mouse.y;
mouse.accepted = true;
if (mouse.button == Qt.RightButton) {
if (gridView.currentItem) {
if (gridView.currentItem.hasActionList) {
......@@ -400,27 +426,9 @@ FocusScope {
}
onPositionChanged: {
// Prevent hover event synthesis in QQuickWindow interfering
// with keyboard navigation by ignoring repeated events with
// identical coordinates. As the work done here would be re-
// dundant in any case, these are safe to ignore.
if (mouse.x == lastX && mouse.y == lastY) {
return;
}
lastX = mouse.x;
lastY = mouse.y;
var cPos = mapToItem(gridView.contentItem, mouse.x, mouse.y);
var item = gridView.itemAt(cPos.x, cPos.y);
if (!item) {
gridView.currentIndex = -1;
pressedItem = null;
} else {
gridView.currentIndex = item.itemIndex;
itemGrid.focus = (currentIndex != -1)
updatePositionProperties(mouse.x, mouse.y);
if (gridView.currentIndex != -1) {
if (dragEnabled && pressX != -1 && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) {
if ("pluginName" in item.m) {
dragHelper.startDrag(kicker, item.url, item.icon,
......
Markdown is supported
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