Commit b1b3193d authored by Konrad Materka's avatar Konrad Materka
Browse files

[applets/systemtray] Fix click outside of applet

This solves the problem when the user clicks the padding around the applet or its label. The event is now correctly redirected to the applet.
This fixes both the left button and the middle click.

BUG: 426646
FIXED-IN: 5.21
parent fbb18131
......@@ -36,8 +36,17 @@ AbstractItem {
active: systemTrayState.activeApplet !== applet
onClicked: {
if (applet && mouse.button === Qt.LeftButton) {
applet.expanded = true;
if (!applet) {
return
}
//forward click event to the applet
if (mouse.button === Qt.LeftButton || mouse.button === Qt.MidButton) {
const mouseArea = findMouseArea(applet.compactRepresentationItem)
if (mouseArea) {
mouseArea.clicked(mouse)
} else if (mouse.button === Qt.LeftButton) {//falback
applet.expanded = true
}
}
}
onPressed: {
......@@ -50,6 +59,38 @@ AbstractItem {
plasmoid.nativeInterface.showPlasmoidMenu(applet, 0, plasmoidContainer.inHiddenLayout ? applet.height : 0);
}
}
onWheel: {
if (!applet) {
return
}
//forward wheel event to the applet
const mouseArea = findMouseArea(applet.compactRepresentationItem)
if (mouseArea) {
mouseArea.wheel(wheel)
}
}
//some heuristics to find MouseArea
function findMouseArea(item) {
if (!item) {
return null
}
if (item instanceof MouseArea) {
return item
}
for (var i = 0; i < item.children.length; i++) {
const child = item.children[i]
if (child instanceof MouseArea && child.enabled) {
//check if MouseArea covers the entire item
if (child.anchors.fill === item || (child.x === 0 && child.y === 0 && child.height === item.height && child.width === item.width)) {
return child
}
}
}
return null
}
//This is to make preloading effective, minimizes the scene changes
function preloadFullRepresentationItem(fullRepresentationItem) {
......
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