diff --git a/app/main.cpp b/app/main.cpp index 9da3a6617..46787c2c9 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -169,6 +169,11 @@ int main(int argc, char **argv) filterDebugInputMask.setDescription(QStringLiteral("Show visual window indicators for calculated input mask.")); filterDebugInputMask.setFlags(QCommandLineOption::HiddenFromHelp); parser.addOption(filterDebugInputMask); + + QCommandLineOption filterDebugEventSinkMask(QStringList() << QStringLiteral("events-sink")); + filterDebugEventSinkMask.setDescription(QStringLiteral("Show visual indicators for areas of EventsSink.")); + filterDebugEventSinkMask.setFlags(QCommandLineOption::HiddenFromHelp); + parser.addOption(filterDebugEventSinkMask); //! END: Hidden options parser.process(app); diff --git a/containment/package/contents/ui/abilities/Debug.qml b/containment/package/contents/ui/abilities/Debug.qml index f9cc07050..b8c832c8d 100644 --- a/containment/package/contents/ui/abilities/Debug.qml +++ b/containment/package/contents/ui/abilities/Debug.qml @@ -24,6 +24,7 @@ import org.kde.latte.abilities.definition 0.1 as AbilityDefinition import org.kde.latte.abilities.host 0.1 as AbilityHost AbilityHost.Debug { + eventsSinkEnabled: Qt.application.arguments.indexOf("--events-sink")>=0 graphicsEnabled: Qt.application.arguments.indexOf("--graphics")>=0 inputMaskEnabled: Qt.application.arguments.indexOf("--input")>=0 layouterEnabled: Qt.application.arguments.indexOf("--layouter")>=0 diff --git a/containment/package/contents/ui/applet/EventsSink.qml b/containment/package/contents/ui/applet/EventsSink.qml new file mode 100644 index 000000000..07f665bdb --- /dev/null +++ b/containment/package/contents/ui/applet/EventsSink.qml @@ -0,0 +1,127 @@ +/* +* Copyright 2020 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.7 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.latte.core 0.2 as LatteCore + +Item { + property Item destination: null + + readonly property int headThickness: appletItem.metrics.margin.thickness + readonly property int tailThickness: destination ? destination.tailThicknessMargin : headThickness + readonly property int lengthPadding: { + if ( (root.panelAlignment === LatteCore.Types.Justify && appletItem.firstChildOfStartLayout) + || (root.panelAlignment === LatteCore.Types.Justify && appletItem.lastChildOfEndLayout) + || (root.panelAlignment !== LatteCore.Types.Justify && appletItem.firstChildOfMainLayout) + || (root.panelAlignment !== LatteCore.Types.Justify && appletItem.lastChildOfMainLayout)) { + //! Fitts Law on corners + return appletItem.lengthAppletFullMargin; + } + + return appletItem.lengthAppletPadding; + } + + readonly property bool active: parent ? parent.active : false + + Loader{ + anchors.fill: parent + active: appletItem.debug.eventsSinkEnabled && active + + sourceComponent: Rectangle { + anchors.fill: parent + color: "yellow" + opacity: 0.2 + visible: root.latteView && root.latteView.sink.destinationItem === destination + } + } + + EventsSinkOriginArea { + id: topArea + anchors.bottom: parent.top + anchors.bottomMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? destination.width + 2 * lengthPadding : destination.width + height: { + if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { + return lengthPadding; + } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { + return tailThickness; + } else { + return headThickness; + } + } + } + + EventsSinkOriginArea { + id: bottomArea + anchors.top: parent.bottom + anchors.topMargin: 1 + anchors.horizontalCenter: parent.horizontalCenter + + width: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? destination.width + 2 * lengthPadding : parent.width + height: { + if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { + return lengthPadding; + } else if (plasmoid.location === PlasmaCore.Types.BottomEdge) { + return tailThickness; + } else { + return headThickness; + } + } + } + + EventsSinkOriginArea { + id: leftArea + anchors.right: parent.left + anchors.rightMargin: 1 + anchors.verticalCenter: parent.verticalCenter + + height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? parent.height : destination.height + 2 * lengthPadding + width: { + if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { + return lengthPadding; + } else if (plasmoid.location === PlasmaCore.Types.LeftEdge) { + return tailThickness; + } else { + return headThickness; + } + } + } + + EventsSinkOriginArea { + id: rightArea + anchors.left: parent.right + anchors.leftMargin: 1 + anchors.verticalCenter: parent.verticalCenter + + height: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? parent.height : destination.height + 2 * lengthPadding + width: { + if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { + return lengthPadding; + } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { + return tailThickness; + } else { + return headThickness; + } + } + } +} diff --git a/containment/package/contents/ui/applet/EventsSinkOriginArea.qml b/containment/package/contents/ui/applet/EventsSinkOriginArea.qml new file mode 100644 index 000000000..e14d0069e --- /dev/null +++ b/containment/package/contents/ui/applet/EventsSinkOriginArea.qml @@ -0,0 +1,42 @@ +/* +* Copyright 2020 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.7 + +MouseArea { + id: __destinationArea + enabled: visible + hoverEnabled: true + visible: root.latteView && root.latteView.sink.originItem !== __destinationArea + + onEntered: { + root.latteView.sink.setSink(__destinationArea, destination) + } + + Loader{ + anchors.fill: parent + active: appletItem.debug.eventsSinkEnabled && active + + sourceComponent: Rectangle { + anchors.fill: parent + color: "red" + opacity: 0.2 + } + } +} diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index 99a9373d2..5924d78c6 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -473,6 +473,22 @@ Item{ ] } + //! EventsSink + + Loader { + id: eventsSinkLoader + anchors.fill: _wrapperContainer + active: (appletItem.lockZoom || !appletItem.parabolic.isEnabled || !appletItem.parabolicEffectIsSupported) + && !communicator.parabolicEffectIsSupported + && !isSeparator + && !isSpacer + + sourceComponent: EventsSink { + destination: _wrapperContainer + } + } + + //! InternalViewSplitter Loader{ anchors.fill: _wrapperContainer active: appletItem.isInternalViewSplitter && root.inConfigureAppletsMode diff --git a/declarativeimports/abilities/client/Debug.qml b/declarativeimports/abilities/client/Debug.qml index e2a8d6439..14d21cdf8 100644 --- a/declarativeimports/abilities/client/Debug.qml +++ b/declarativeimports/abilities/client/Debug.qml @@ -24,6 +24,7 @@ import org.kde.latte.abilities.definition 0.1 as AbilityDefinition AbilityDefinition.Debug { property Item bridge: null + eventsSinkEnabled: ref.debug.eventsSinkEnabled graphicsEnabled: ref.debug.graphicsEnabled inputMaskEnabled: ref.debug.inputMaskEnabled layouterEnabled: ref.debug.layouterEnabled diff --git a/declarativeimports/abilities/definition/Debug.qml b/declarativeimports/abilities/definition/Debug.qml index cb91c5e74..99c95f16b 100644 --- a/declarativeimports/abilities/definition/Debug.qml +++ b/declarativeimports/abilities/definition/Debug.qml @@ -20,6 +20,7 @@ import QtQuick 2.0 Item { + property bool eventsSinkEnabled: false property bool graphicsEnabled: false property bool inputMaskEnabled: false property bool layouterEnabled: false