Fix panhelper effect

wilder/Plasma/6.2
Jacopo De Simoi 10 months ago
parent 5012e67258
commit 26a5dd2655
  1. 44
      src/plugins/panhelper/package/contents/code/main.js
  2. 17
      src/plugins/panhelper/package/metadata.desktop
  3. 9
      src/plugins/panhelper/package/metadata.json

@ -18,15 +18,28 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
/*global effect, effects, animate, animationTime, Effect*/
var panHelperEffect = {
duration: animationTime(250),
class panHelperEffect {
constructor() {
effect.configChanged.connect(this.loadConfig.bind(this));
loadConfig: function () {
effects.windowAdded.connect(this.manage.bind(this));
for (const window of effects.stackingOrder) {
this.manage(window);
}
this.loadConfig();
}
loadConfig() {
"use strict";
panHelperEffect.duration = animationTime(250);
},
this.duration = animationTime(250);
}
geometryChange: function (window, oldGeometry) {
manage(window) {
window.windowFrameGeometryChanged.connect(this.geometryChange.bind(this));
}
geometryChange(window, oldGeometry) {
"use strict";
var newGeometry = window.geometry;
@ -45,7 +58,7 @@ var panHelperEffect = {
// ignore
return
}
if (((distx != 0 ) && (distx < newGeometry.width / 6)) ||
if (((distx != 0 ) && (distx < newGeometry.width / 6)) ||
((disty != 0 ) && (disty < newGeometry.height / 6))) {
if (window.moveAnimation) {
delete window.moveAnimation;
@ -59,13 +72,13 @@ var panHelperEffect = {
couldRetarget = retarget(window.moveAnimation[0], {
value1: newGeometry.width,
value2: newGeometry.height
}, panHelperEffect.duration);
}, this.duration);
}
if (couldRetarget && window.moveAnimation[1]) {
couldRetarget = retarget(window.moveAnimation[1], {
value1: newGeometry.x + newGeometry.width / 2,
value2: newGeometry.y + newGeometry.height / 2
}, panHelperEffect.duration);
}, this.duration);
}
if (!couldRetarget) {
cancel(window.moveAnimation[0]);
@ -77,7 +90,7 @@ var panHelperEffect = {
if (!couldRetarget) {
window.moveAnimation = animate({
window: window,
duration: panHelperEffect.duration,
duration: this.duration,
animations: [{
type: Effect.Size,
curve: QEasingCurve.OutCubic,
@ -103,12 +116,7 @@ var panHelperEffect = {
}]
});
}
},
}
init: function () {
"use strict";
effect.configChanged.connect(panHelperEffect.loadConfig);
effects.windowGeometryShapeChanged.connect(panHelperEffect.geometryChange);
}
};
panHelperEffect.init();
}
new panHelperEffect();

@ -1,17 +0,0 @@
[Desktop Entry]
Comment=Pan window helper
Type=Service
X-KDE-ParentApp=
X-KDE-PluginInfo-Author=Marco Martin
X-KDE-PluginInfo-Category=Appearance
X-KDE-PluginInfo-Email=mart@kde.org
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-Name=kwin4_effect_panhelper
X-KDE-PluginInfo-Version=1
X-KDE-PluginInfo-Website=
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-Ordering=60
X-Plasma-API=javascript
X-Plasma-MainScript=code/panhelper.js
X-Plasma-RemoteLocation=

@ -8,18 +8,15 @@
}
],
"Category": "Window Pan Animation",
"Description": "Make windows smoothly pan when they are moved ",
"Description": "Make windows smoothly pan when they are moved (KDE6 version)",
"EnabledByDefault": true,
"Icon": "preferences-system-windows-effect-scale",
"Id": "kwin4_effect_panhelper",
"Id": "panhelper",
"License": "GPL",
"Name": "Pan Helper",
"Version": "1"
},
"X-KDE-Ordering": "60",
"X-KDE-PluginKeyword": "kwin4_effect_panhelper",
"X-KWin-Config-TranslationDomain": "kwin_effects",
"X-KWin-Exclusive-Category": "toplevel-pan-animation",
"X-Plasma-API": "javascript",
"X-Plasma-MainScript": "code/panhelper.js"
"X-Plasma-API": "javascript"
}

Loading…
Cancel
Save