Ignore stationary pointer hover in launcher
This commit is contained in:
@@ -20,6 +20,8 @@ Item {
|
|||||||
property int selectedIndex: 0
|
property int selectedIndex: 0
|
||||||
property bool cursorActive: true
|
property bool cursorActive: true
|
||||||
property bool hoverArmed: false
|
property bool hoverArmed: false
|
||||||
|
property real lastPointerX: -1
|
||||||
|
property real lastPointerY: -1
|
||||||
property var filteredEntries: []
|
property var filteredEntries: []
|
||||||
property int launchSerial: 0
|
property int launchSerial: 0
|
||||||
property int launchToplevelCount: 0
|
property int launchToplevelCount: 0
|
||||||
@@ -79,7 +81,7 @@ Item {
|
|||||||
root.filterText = payload.query || ""
|
root.filterText = payload.query || ""
|
||||||
root.selectedIndex = 0
|
root.selectedIndex = 0
|
||||||
root.cursorActive = true
|
root.cursorActive = true
|
||||||
root.hoverArmed = false
|
root.disarmHover()
|
||||||
root.rebuildDisplay()
|
root.rebuildDisplay()
|
||||||
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
|
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
|
||||||
}
|
}
|
||||||
@@ -130,6 +132,28 @@ Item {
|
|||||||
return LauncherSearch.entrySearchText(entry)
|
return LauncherSearch.entrySearchText(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disarmHover() {
|
||||||
|
root.hoverArmed = false
|
||||||
|
root.lastPointerX = -1
|
||||||
|
root.lastPointerY = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
function pointerMovedInCard(item, mouse) {
|
||||||
|
var point = item.mapToItem(card, mouse.x, mouse.y)
|
||||||
|
var moved = root.lastPointerX >= 0
|
||||||
|
&& (Math.abs(point.x - root.lastPointerX) > 1 || Math.abs(point.y - root.lastPointerY) > 1)
|
||||||
|
root.lastPointerX = point.x
|
||||||
|
root.lastPointerY = point.y
|
||||||
|
return moved
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectFromPointer(index, item, mouse) {
|
||||||
|
if (!root.pointerMovedInCard(item, mouse)) return
|
||||||
|
root.hoverArmed = true
|
||||||
|
root.cursorActive = true
|
||||||
|
root.selectedIndex = index
|
||||||
|
}
|
||||||
|
|
||||||
function isHiddenEntry(entry) {
|
function isHiddenEntry(entry) {
|
||||||
var id = String((entry && entry.id) || "")
|
var id = String((entry && entry.id) || "")
|
||||||
return root.configuredHiddenEntryIds[id] === true || root.desktopHiddenEntryIds[id] === true
|
return root.configuredHiddenEntryIds[id] === true || root.desktopHiddenEntryIds[id] === true
|
||||||
@@ -234,14 +258,14 @@ Item {
|
|||||||
root.filterText = nextFilter
|
root.filterText = nextFilter
|
||||||
root.selectedIndex = 0
|
root.selectedIndex = 0
|
||||||
root.cursorActive = true
|
root.cursorActive = true
|
||||||
root.hoverArmed = false
|
root.disarmHover()
|
||||||
root.rebuildDisplay()
|
root.rebuildDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
function select(delta) {
|
function select(delta) {
|
||||||
if (displayModel.count === 0) return
|
if (displayModel.count === 0) return
|
||||||
root.cursorActive = true
|
root.cursorActive = true
|
||||||
root.hoverArmed = false
|
root.disarmHover()
|
||||||
root.selectedIndex = (root.selectedIndex + delta + displayModel.count) % displayModel.count
|
root.selectedIndex = (root.selectedIndex + delta + displayModel.count) % displayModel.count
|
||||||
resultList.positionViewAtIndex(root.selectedIndex, ListView.Contain)
|
resultList.positionViewAtIndex(root.selectedIndex, ListView.Contain)
|
||||||
}
|
}
|
||||||
@@ -272,6 +296,7 @@ Item {
|
|||||||
root.deleteConfirmOpen = false
|
root.deleteConfirmOpen = false
|
||||||
root.deleteEntry = null
|
root.deleteEntry = null
|
||||||
deleteConfirm.selectedIndex = 1
|
deleteConfirm.selectedIndex = 1
|
||||||
|
root.disarmHover()
|
||||||
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
|
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +488,7 @@ Item {
|
|||||||
} else if (event.key === Qt.Key_Home) {
|
} else if (event.key === Qt.Key_Home) {
|
||||||
if (displayModel.count > 0) {
|
if (displayModel.count > 0) {
|
||||||
root.cursorActive = true
|
root.cursorActive = true
|
||||||
root.hoverArmed = false
|
root.disarmHover()
|
||||||
root.selectedIndex = 0
|
root.selectedIndex = 0
|
||||||
resultList.positionViewAtIndex(root.selectedIndex, ListView.Contain)
|
resultList.positionViewAtIndex(root.selectedIndex, ListView.Contain)
|
||||||
}
|
}
|
||||||
@@ -471,7 +496,7 @@ Item {
|
|||||||
} else if (event.key === Qt.Key_End) {
|
} else if (event.key === Qt.Key_End) {
|
||||||
if (displayModel.count > 0) {
|
if (displayModel.count > 0) {
|
||||||
root.cursorActive = true
|
root.cursorActive = true
|
||||||
root.hoverArmed = false
|
root.disarmHover()
|
||||||
root.selectedIndex = displayModel.count - 1
|
root.selectedIndex = displayModel.count - 1
|
||||||
resultList.positionViewAtIndex(root.selectedIndex, ListView.Contain)
|
resultList.positionViewAtIndex(root.selectedIndex, ListView.Contain)
|
||||||
}
|
}
|
||||||
@@ -611,9 +636,7 @@ Item {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onPositionChanged: function(mouse) {
|
onPositionChanged: function(mouse) {
|
||||||
root.hoverArmed = true
|
root.selectFromPointer(row.index, row, mouse)
|
||||||
root.cursorActive = true
|
|
||||||
root.selectedIndex = row.index
|
|
||||||
}
|
}
|
||||||
onContainsMouseChanged: if (containsMouse && root.hoverArmed) {
|
onContainsMouseChanged: if (containsMouse && root.hoverArmed) {
|
||||||
root.cursorActive = true
|
root.cursorActive = true
|
||||||
|
|||||||
@@ -69,9 +69,21 @@ const directMatches = search.sortedEntries(entries, 'obs').map(row => search.ent
|
|||||||
assertEqual(directMatches[0], 'OBS Studio', 'direct app-name matching still works')
|
assertEqual(directMatches[0], 'OBS Studio', 'direct app-name matching still works')
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
/function select\(delta\)[\s\S]*root\.hoverArmed = false[\s\S]*root\.selectedIndex =/.test(launcherQml),
|
/function select\(delta\)[\s\S]*root\.disarmHover\(\)[\s\S]*root\.selectedIndex =/.test(launcherQml),
|
||||||
'launcher keyboard navigation disarms stale hover before moving selection'
|
'launcher keyboard navigation disarms stale hover before moving selection'
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
|
/function pointerMovedInCard\(item, mouse\)[\s\S]*item\.mapToItem\(card, mouse\.x, mouse\.y\)/.test(launcherQml),
|
||||||
|
'launcher compares pointer movement in card coordinates'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
/function selectFromPointer\(index, item, mouse\)[\s\S]*pointerMovedInCard\(item, mouse\)[\s\S]*root\.selectedIndex = index/.test(launcherQml),
|
||||||
|
'launcher only selects from pointer after real movement'
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
/onPositionChanged: function\(mouse\) \{\s*root\.selectFromPointer\(row\.index, row, mouse\)\s*\}/.test(launcherQml),
|
||||||
|
'launcher row hover routes through pointer movement gate'
|
||||||
|
)
|
||||||
|
|
||||||
const confirmDeleteMatch = launcherQml.match(/function confirmDelete\(\) \{([\s\S]*?)\n \}/)
|
const confirmDeleteMatch = launcherQml.match(/function confirmDelete\(\) \{([\s\S]*?)\n \}/)
|
||||||
assert(confirmDeleteMatch, 'launcher confirmDelete function exists')
|
assert(confirmDeleteMatch, 'launcher confirmDelete function exists')
|
||||||
|
|||||||
Reference in New Issue
Block a user