mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kwin: dimscreen effect optimization
there should be option which window classes to check for Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
88040d12d7
commit
e31b04eaa2
2 changed files with 42 additions and 40 deletions
|
@ -24,9 +24,16 @@ namespace KWin
|
|||
|
||||
DimScreenEffect::DimScreenEffect()
|
||||
: mActivated(false)
|
||||
, activateAnimation(false)
|
||||
, deactivateAnimation(false)
|
||||
, mActivateAnimation(false)
|
||||
, mDeactivateAnimation(false)
|
||||
, mWindow(nullptr)
|
||||
{
|
||||
mCheck << "kdesu kdesu";
|
||||
mCheck << "kdesudo kdesudo";
|
||||
mCheck << "polkit-kde-manager polkit-kde-manager";
|
||||
mCheck << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1";
|
||||
mCheck << "pinentry pinentry";
|
||||
|
||||
reconfigure(ReconfigureAll);
|
||||
connect(
|
||||
effects, SIGNAL(windowActivated(KWin::EffectWindow*)),
|
||||
|
@ -34,42 +41,43 @@ DimScreenEffect::DimScreenEffect()
|
|||
);
|
||||
}
|
||||
|
||||
DimScreenEffect::~DimScreenEffect()
|
||||
{
|
||||
}
|
||||
|
||||
void DimScreenEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
timeline.setDuration(animationTime(250));
|
||||
mTimeline.setDuration(animationTime(250));
|
||||
}
|
||||
|
||||
void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (mActivated && activateAnimation && !effects->activeFullScreenEffect())
|
||||
timeline.setCurrentTime(timeline.currentTime() + time);
|
||||
if (mActivated && deactivateAnimation)
|
||||
timeline.setCurrentTime(timeline.currentTime() - time);
|
||||
if (mActivated && effects->activeFullScreenEffect())
|
||||
timeline.setCurrentTime(timeline.currentTime() - time);
|
||||
if (mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.currentValue() != 1.0)
|
||||
timeline.setCurrentTime(timeline.currentTime() + time);
|
||||
if (mActivated && mActivateAnimation && !effects->activeFullScreenEffect()) {
|
||||
mTimeline.setCurrentTime(mTimeline.currentTime() + time);
|
||||
}
|
||||
if (mActivated && mDeactivateAnimation) {
|
||||
mTimeline.setCurrentTime(mTimeline.currentTime() - time);
|
||||
}
|
||||
if (mActivated && effects->activeFullScreenEffect()) {
|
||||
mTimeline.setCurrentTime(mTimeline.currentTime() - time);
|
||||
}
|
||||
if (mActivated && !mActivateAnimation && !mDeactivateAnimation &&
|
||||
!effects->activeFullScreenEffect() && mTimeline.currentValue() != 1.0) {
|
||||
mTimeline.setCurrentTime(mTimeline.currentTime() + time);
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void DimScreenEffect::postPaintScreen()
|
||||
{
|
||||
if (mActivated) {
|
||||
if (activateAnimation && timeline.currentValue() == 1.0) {
|
||||
activateAnimation = false;
|
||||
if (mActivateAnimation && mTimeline.currentValue() == 1.0) {
|
||||
mActivateAnimation = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
if (deactivateAnimation && timeline.currentValue() == 0.0) {
|
||||
deactivateAnimation = false;
|
||||
if (mDeactivateAnimation && mTimeline.currentValue() == 0.0) {
|
||||
mDeactivateAnimation = false;
|
||||
mActivated = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
// still animating
|
||||
if (timeline.currentValue() > 0.0 && timeline.currentValue() < 1.0)
|
||||
if (mTimeline.currentValue() > 0.0 && mTimeline.currentValue() < 1.0)
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
effects->postPaintScreen();
|
||||
|
@ -77,9 +85,9 @@ void DimScreenEffect::postPaintScreen()
|
|||
|
||||
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
||||
{
|
||||
if (mActivated && (w != window) && w->isManaged()) {
|
||||
data.multiplyBrightness((1.0 - 0.33 * timeline.currentValue()));
|
||||
data.multiplySaturation((1.0 - 0.33 * timeline.currentValue()));
|
||||
if (mActivated && (w != mWindow) && w->isManaged()) {
|
||||
data.multiplyBrightness((1.0 - 0.33 * mTimeline.currentValue()));
|
||||
data.multiplySaturation((1.0 - 0.33 * mTimeline.currentValue()));
|
||||
}
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
@ -89,22 +97,16 @@ void DimScreenEffect::slotWindowActivated(EffectWindow *w)
|
|||
if (!w) {
|
||||
return;
|
||||
}
|
||||
QStringList check;
|
||||
check << "kdesu kdesu";
|
||||
check << "kdesudo kdesudo";
|
||||
check << "polkit-kde-manager polkit-kde-manager";
|
||||
check << "polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1";
|
||||
check << "pinentry pinentry";
|
||||
if (check.contains(w->windowClass())) {
|
||||
if (mCheck.contains(w->windowClass())) {
|
||||
mActivated = true;
|
||||
activateAnimation = true;
|
||||
deactivateAnimation = false;
|
||||
window = w;
|
||||
mActivateAnimation = true;
|
||||
mDeactivateAnimation = false;
|
||||
mWindow = w;
|
||||
effects->addRepaintFull();
|
||||
} else {
|
||||
if (mActivated) {
|
||||
activateAnimation = false;
|
||||
deactivateAnimation = true;
|
||||
mActivateAnimation = false;
|
||||
mDeactivateAnimation = true;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ class DimScreenEffect
|
|||
Q_OBJECT
|
||||
public:
|
||||
DimScreenEffect();
|
||||
~DimScreenEffect();
|
||||
|
||||
void reconfigure(ReconfigureFlags) final;
|
||||
void prePaintScreen(ScreenPrePaintData& data, int time) final;
|
||||
|
@ -46,10 +45,11 @@ public Q_SLOTS:
|
|||
|
||||
private:
|
||||
bool mActivated;
|
||||
bool activateAnimation;
|
||||
bool deactivateAnimation;
|
||||
QTimeLine timeline;
|
||||
EffectWindow* window;
|
||||
bool mActivateAnimation;
|
||||
bool mDeactivateAnimation;
|
||||
QTimeLine mTimeline;
|
||||
EffectWindow* mWindow;
|
||||
QStringList mCheck;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Reference in a new issue