Skip to content

Commit f266ab2

Browse files
committed
fix: mask off by a couple of pixels when panel de-floats
1 parent 495578c commit f266ab2

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

package/contents/ui/code/utils.js

+14
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,17 @@ function editProperty(object, path, value) {
534534
current[lastKey] = value
535535
}
536536
}
537+
538+
// https://stackoverflow.com/questions/28507619/how-to-create-delay-function-in-qml
539+
function delay(interval, callback, parentItem) {
540+
let timer = Qt.createQmlObject("import QtQuick; Timer {}", parentItem);
541+
timer.interval = interval;
542+
timer.repeat = false;
543+
timer.triggered.connect(callback);
544+
timer.triggered.connect(function release() {
545+
timer.triggered.disconnect(callback);
546+
timer.triggered.disconnect(release);
547+
timer.destroy();
548+
});
549+
timer.start();
550+
}

package/contents/ui/main.qml

+15-4
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ PlasmoidItem {
199199

200200
onFloatignessChanged: {
201201
updateMasks()
202+
// fixes the mask getting stuck a couple of pixels off for some reason
203+
if (main.floatigness === 1 || main.floatigness === 0) {
204+
Utils.delay(10, () => {
205+
updateMasks()
206+
activatePlasmoidCycle()
207+
}, main)
208+
}
202209
}
203210

204211
function getColor(colorCfg, targetIndex, parentColor, itemType, kirigamiColorItem) {
@@ -1140,13 +1147,13 @@ PlasmoidItem {
11401147
property real moveX: {
11411148
const edge = main.plasmaVersion.isLowerThan("6.2.0") ? PlasmaCore.Types.LeftEdge : PlasmaCore.Types.RightEdge
11421149
const m = horizontal ? 0 : (panelElement?.floating && plasmoid.location === edge ? 16 : 0)
1143-
return floatigness > 0 ? 8 : m
1150+
return floatigness > 0 ? (8*floatigness) : m
11441151
}
11451152

11461153
property real moveY: {
11471154
const edge = main.plasmaVersion.isLowerThan("6.2.0") ? PlasmaCore.Types.TopEdge : PlasmaCore.Types.BottomEdge
11481155
const m = horizontal ? (panelElement?.floating && plasmoid.location === edge ? 16 : 0) : 0
1149-
return floatigness > 0 ? 8 : m
1156+
return floatigness > 0 ? (8*floatigness) : m
11501157
}
11511158

11521159
onVisibleChanged: {
@@ -1514,12 +1521,16 @@ PlasmoidItem {
15141521
// to avoid plasma crash when changing its location
15151522
tempActivationTimer.restart()
15161523
} else {
1517-
Plasmoid.activated()
1518-
Plasmoid.activated()
1524+
activatePlasmoidCycle()
15191525
bindPlasmoidStatus()
15201526
}
15211527
}
15221528

1529+
function activatePlasmoidCycle() {
1530+
Plasmoid.activated()
1531+
Plasmoid.activated()
1532+
}
1533+
15231534
// https://github.com/olib14/pinpanel/blob/2d126f0f3ac3e35a725f05b0060a3dd5c924cbe7/package/contents/ui/main.qml#L58 ♥
15241535
Item {
15251536
onWindowChanged: (window) => {

0 commit comments

Comments
 (0)