2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of the KDE project.
|
2012-10-26 09:50:44 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2012-10-26 09:50:44 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2018-11-05 09:48:56 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
2012-10-26 09:50:44 +00:00
|
|
|
var maximizeEffect = {
|
|
|
|
duration: animationTime(250),
|
|
|
|
loadConfig: function () {
|
|
|
|
maximizeEffect.duration = animationTime(250);
|
|
|
|
},
|
|
|
|
maximizeChanged: function (window) {
|
|
|
|
if (!window.oldGeometry) {
|
|
|
|
return;
|
|
|
|
}
|
2018-05-27 16:51:15 +00:00
|
|
|
window.setData(Effect.WindowForceBlurRole, true);
|
2012-10-26 09:50:44 +00:00
|
|
|
var oldGeometry, newGeometry;
|
|
|
|
oldGeometry = window.oldGeometry;
|
|
|
|
newGeometry = window.geometry;
|
2014-05-29 21:52:40 +00:00
|
|
|
if (oldGeometry.width == newGeometry.width && oldGeometry.height == newGeometry.height)
|
|
|
|
oldGeometry = window.olderGeometry;
|
|
|
|
window.olderGeometry = window.oldGeometry;
|
|
|
|
window.oldGeometry = newGeometry;
|
2015-11-07 20:51:59 +00:00
|
|
|
window.maximizeAnimation1 = animate({
|
Adding more declarative way to animate a window in JavaScript
The current API call to animate a window does not feel very JavaScripty.
Therefore a new method "animate" is added to the global scope, which
takes a JavaScript object of the following structure:
{
window: EffectWindow, /* the window to animate, required */
duration: int, /* duration in msec, required */
curve: QEasingCurve.Type, /* global easing curve, optional */
type: Effect.Attribute, /* for first animation, optional */
from: FPx2, /* for first animation, optional */
to: FPx2, /* for first animation, optional */
delay: int, /* for first animation, optional */
animations: [ /* additional animations, optional */
{
curve: QEasingCurve.Type, /* overrides global */
type: Effect.Attribute,
from: FPx2,
to: FPx2,
delay: int
}
]
}
At least one animation needs to be specified either on the root level
or in the array of animations. Curve is the only property on root level
which is used in the animations, if not provided.
REVIEW: 107079
2012-10-27 15:43:14 +00:00
|
|
|
window: window,
|
|
|
|
duration: maximizeEffect.duration,
|
|
|
|
animations: [{
|
2013-01-28 21:19:40 +00:00
|
|
|
type: Effect.Size,
|
Adding more declarative way to animate a window in JavaScript
The current API call to animate a window does not feel very JavaScripty.
Therefore a new method "animate" is added to the global scope, which
takes a JavaScript object of the following structure:
{
window: EffectWindow, /* the window to animate, required */
duration: int, /* duration in msec, required */
curve: QEasingCurve.Type, /* global easing curve, optional */
type: Effect.Attribute, /* for first animation, optional */
from: FPx2, /* for first animation, optional */
to: FPx2, /* for first animation, optional */
delay: int, /* for first animation, optional */
animations: [ /* additional animations, optional */
{
curve: QEasingCurve.Type, /* overrides global */
type: Effect.Attribute,
from: FPx2,
to: FPx2,
delay: int
}
]
}
At least one animation needs to be specified either on the root level
or in the array of animations. Curve is the only property on root level
which is used in the animations, if not provided.
REVIEW: 107079
2012-10-27 15:43:14 +00:00
|
|
|
to: {
|
2013-01-28 21:19:40 +00:00
|
|
|
value1: newGeometry.width,
|
|
|
|
value2: newGeometry.height
|
Adding more declarative way to animate a window in JavaScript
The current API call to animate a window does not feel very JavaScripty.
Therefore a new method "animate" is added to the global scope, which
takes a JavaScript object of the following structure:
{
window: EffectWindow, /* the window to animate, required */
duration: int, /* duration in msec, required */
curve: QEasingCurve.Type, /* global easing curve, optional */
type: Effect.Attribute, /* for first animation, optional */
from: FPx2, /* for first animation, optional */
to: FPx2, /* for first animation, optional */
delay: int, /* for first animation, optional */
animations: [ /* additional animations, optional */
{
curve: QEasingCurve.Type, /* overrides global */
type: Effect.Attribute,
from: FPx2,
to: FPx2,
delay: int
}
]
}
At least one animation needs to be specified either on the root level
or in the array of animations. Curve is the only property on root level
which is used in the animations, if not provided.
REVIEW: 107079
2012-10-27 15:43:14 +00:00
|
|
|
},
|
|
|
|
from: {
|
2013-01-28 21:19:40 +00:00
|
|
|
value1: oldGeometry.width,
|
|
|
|
value2: oldGeometry.height
|
Adding more declarative way to animate a window in JavaScript
The current API call to animate a window does not feel very JavaScripty.
Therefore a new method "animate" is added to the global scope, which
takes a JavaScript object of the following structure:
{
window: EffectWindow, /* the window to animate, required */
duration: int, /* duration in msec, required */
curve: QEasingCurve.Type, /* global easing curve, optional */
type: Effect.Attribute, /* for first animation, optional */
from: FPx2, /* for first animation, optional */
to: FPx2, /* for first animation, optional */
delay: int, /* for first animation, optional */
animations: [ /* additional animations, optional */
{
curve: QEasingCurve.Type, /* overrides global */
type: Effect.Attribute,
from: FPx2,
to: FPx2,
delay: int
}
]
}
At least one animation needs to be specified either on the root level
or in the array of animations. Curve is the only property on root level
which is used in the animations, if not provided.
REVIEW: 107079
2012-10-27 15:43:14 +00:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
type: Effect.Translation,
|
|
|
|
to: {
|
|
|
|
value1: 0,
|
|
|
|
value2: 0
|
|
|
|
},
|
|
|
|
from: {
|
|
|
|
value1: oldGeometry.x - newGeometry.x - (newGeometry.width / 2 - oldGeometry.width / 2),
|
|
|
|
value2: oldGeometry.y - newGeometry.y - (newGeometry.height / 2 - oldGeometry.height / 2)
|
|
|
|
}
|
|
|
|
}]
|
2012-10-26 09:50:44 +00:00
|
|
|
});
|
2015-05-26 20:37:51 +00:00
|
|
|
if (!window.resize) {
|
2015-11-07 20:51:59 +00:00
|
|
|
window.maximizeAnimation2 =animate({
|
2015-05-26 20:37:51 +00:00
|
|
|
window: window,
|
|
|
|
duration: maximizeEffect.duration,
|
|
|
|
animations: [{
|
|
|
|
type: Effect.CrossFadePrevious,
|
|
|
|
to: 1.0,
|
|
|
|
from: 0.0
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
}
|
2012-10-26 09:50:44 +00:00
|
|
|
},
|
[effects/maximize] Enable blur behind windows
Summary: Use the blur effect even while the window is being maximized/unmaximized.
Test Plan:
Before:
{F5828510}
After:
{F5828511}
Reviewers: #kwin, #vdg, graesslin, ngraham
Reviewed By: #kwin, #vdg, graesslin, ngraham
Subscribers: ngraham, graesslin, zzag, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D12623
2018-05-01 21:03:14 +00:00
|
|
|
restoreForceBlurState: function(window) {
|
2018-06-11 11:25:10 +00:00
|
|
|
window.setData(Effect.WindowForceBlurRole, null);
|
[effects/maximize] Enable blur behind windows
Summary: Use the blur effect even while the window is being maximized/unmaximized.
Test Plan:
Before:
{F5828510}
After:
{F5828511}
Reviewers: #kwin, #vdg, graesslin, ngraham
Reviewed By: #kwin, #vdg, graesslin, ngraham
Subscribers: ngraham, graesslin, zzag, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D12623
2018-05-01 21:03:14 +00:00
|
|
|
},
|
2012-10-26 09:50:44 +00:00
|
|
|
geometryChange: function (window, oldGeometry) {
|
2015-11-07 20:51:59 +00:00
|
|
|
if (window.maximizeAnimation1) {
|
|
|
|
if (window.geometry.width != window.oldGeometry.width ||
|
|
|
|
window.geometry.height != window.oldGeometry.height) {
|
|
|
|
cancel(window.maximizeAnimation1);
|
|
|
|
delete window.maximizeAnimation1;
|
|
|
|
if (window.maximizeAnimation2) {
|
|
|
|
cancel(window.maximizeAnimation2);
|
|
|
|
delete window.maximizeAnimation2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-29 21:52:40 +00:00
|
|
|
window.oldGeometry = window.geometry;
|
|
|
|
window.olderGeometry = oldGeometry;
|
2012-10-26 09:50:44 +00:00
|
|
|
},
|
|
|
|
init: function () {
|
|
|
|
effect.configChanged.connect(maximizeEffect.loadConfig);
|
2020-02-11 17:04:18 +00:00
|
|
|
effects.windowFrameGeometryChanged.connect(maximizeEffect.geometryChange);
|
2012-10-26 09:50:44 +00:00
|
|
|
effects.windowMaximizedStateChanged.connect(maximizeEffect.maximizeChanged);
|
[effects/maximize] Enable blur behind windows
Summary: Use the blur effect even while the window is being maximized/unmaximized.
Test Plan:
Before:
{F5828510}
After:
{F5828511}
Reviewers: #kwin, #vdg, graesslin, ngraham
Reviewed By: #kwin, #vdg, graesslin, ngraham
Subscribers: ngraham, graesslin, zzag, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D12623
2018-05-01 21:03:14 +00:00
|
|
|
effect.animationEnded.connect(maximizeEffect.restoreForceBlurState);
|
2012-10-26 09:50:44 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
maximizeEffect.init();
|