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()
|
DimScreenEffect::DimScreenEffect()
|
||||||
: mActivated(false)
|
: mActivated(false)
|
||||||
, activateAnimation(false)
|
, mActivateAnimation(false)
|
||||||
, deactivateAnimation(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);
|
reconfigure(ReconfigureAll);
|
||||||
connect(
|
connect(
|
||||||
effects, SIGNAL(windowActivated(KWin::EffectWindow*)),
|
effects, SIGNAL(windowActivated(KWin::EffectWindow*)),
|
||||||
|
@ -34,42 +41,43 @@ DimScreenEffect::DimScreenEffect()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
DimScreenEffect::~DimScreenEffect()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DimScreenEffect::reconfigure(ReconfigureFlags)
|
void DimScreenEffect::reconfigure(ReconfigureFlags)
|
||||||
{
|
{
|
||||||
timeline.setDuration(animationTime(250));
|
mTimeline.setDuration(animationTime(250));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||||
{
|
{
|
||||||
if (mActivated && activateAnimation && !effects->activeFullScreenEffect())
|
if (mActivated && mActivateAnimation && !effects->activeFullScreenEffect()) {
|
||||||
timeline.setCurrentTime(timeline.currentTime() + time);
|
mTimeline.setCurrentTime(mTimeline.currentTime() + time);
|
||||||
if (mActivated && deactivateAnimation)
|
}
|
||||||
timeline.setCurrentTime(timeline.currentTime() - time);
|
if (mActivated && mDeactivateAnimation) {
|
||||||
if (mActivated && effects->activeFullScreenEffect())
|
mTimeline.setCurrentTime(mTimeline.currentTime() - time);
|
||||||
timeline.setCurrentTime(timeline.currentTime() - time);
|
}
|
||||||
if (mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.currentValue() != 1.0)
|
if (mActivated && effects->activeFullScreenEffect()) {
|
||||||
timeline.setCurrentTime(timeline.currentTime() + time);
|
mTimeline.setCurrentTime(mTimeline.currentTime() - time);
|
||||||
|
}
|
||||||
|
if (mActivated && !mActivateAnimation && !mDeactivateAnimation &&
|
||||||
|
!effects->activeFullScreenEffect() && mTimeline.currentValue() != 1.0) {
|
||||||
|
mTimeline.setCurrentTime(mTimeline.currentTime() + time);
|
||||||
|
}
|
||||||
effects->prePaintScreen(data, time);
|
effects->prePaintScreen(data, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DimScreenEffect::postPaintScreen()
|
void DimScreenEffect::postPaintScreen()
|
||||||
{
|
{
|
||||||
if (mActivated) {
|
if (mActivated) {
|
||||||
if (activateAnimation && timeline.currentValue() == 1.0) {
|
if (mActivateAnimation && mTimeline.currentValue() == 1.0) {
|
||||||
activateAnimation = false;
|
mActivateAnimation = false;
|
||||||
effects->addRepaintFull();
|
effects->addRepaintFull();
|
||||||
}
|
}
|
||||||
if (deactivateAnimation && timeline.currentValue() == 0.0) {
|
if (mDeactivateAnimation && mTimeline.currentValue() == 0.0) {
|
||||||
deactivateAnimation = false;
|
mDeactivateAnimation = false;
|
||||||
mActivated = false;
|
mActivated = false;
|
||||||
effects->addRepaintFull();
|
effects->addRepaintFull();
|
||||||
}
|
}
|
||||||
// still animating
|
// still animating
|
||||||
if (timeline.currentValue() > 0.0 && timeline.currentValue() < 1.0)
|
if (mTimeline.currentValue() > 0.0 && mTimeline.currentValue() < 1.0)
|
||||||
effects->addRepaintFull();
|
effects->addRepaintFull();
|
||||||
}
|
}
|
||||||
effects->postPaintScreen();
|
effects->postPaintScreen();
|
||||||
|
@ -77,9 +85,9 @@ void DimScreenEffect::postPaintScreen()
|
||||||
|
|
||||||
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
||||||
{
|
{
|
||||||
if (mActivated && (w != window) && w->isManaged()) {
|
if (mActivated && (w != mWindow) && w->isManaged()) {
|
||||||
data.multiplyBrightness((1.0 - 0.33 * timeline.currentValue()));
|
data.multiplyBrightness((1.0 - 0.33 * mTimeline.currentValue()));
|
||||||
data.multiplySaturation((1.0 - 0.33 * timeline.currentValue()));
|
data.multiplySaturation((1.0 - 0.33 * mTimeline.currentValue()));
|
||||||
}
|
}
|
||||||
effects->paintWindow(w, mask, region, data);
|
effects->paintWindow(w, mask, region, data);
|
||||||
}
|
}
|
||||||
|
@ -89,22 +97,16 @@ void DimScreenEffect::slotWindowActivated(EffectWindow *w)
|
||||||
if (!w) {
|
if (!w) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QStringList check;
|
if (mCheck.contains(w->windowClass())) {
|
||||||
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())) {
|
|
||||||
mActivated = true;
|
mActivated = true;
|
||||||
activateAnimation = true;
|
mActivateAnimation = true;
|
||||||
deactivateAnimation = false;
|
mDeactivateAnimation = false;
|
||||||
window = w;
|
mWindow = w;
|
||||||
effects->addRepaintFull();
|
effects->addRepaintFull();
|
||||||
} else {
|
} else {
|
||||||
if (mActivated) {
|
if (mActivated) {
|
||||||
activateAnimation = false;
|
mActivateAnimation = false;
|
||||||
deactivateAnimation = true;
|
mDeactivateAnimation = true;
|
||||||
effects->addRepaintFull();
|
effects->addRepaintFull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ class DimScreenEffect
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DimScreenEffect();
|
DimScreenEffect();
|
||||||
~DimScreenEffect();
|
|
||||||
|
|
||||||
void reconfigure(ReconfigureFlags) final;
|
void reconfigure(ReconfigureFlags) final;
|
||||||
void prePaintScreen(ScreenPrePaintData& data, int time) final;
|
void prePaintScreen(ScreenPrePaintData& data, int time) final;
|
||||||
|
@ -46,10 +45,11 @@ public Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mActivated;
|
bool mActivated;
|
||||||
bool activateAnimation;
|
bool mActivateAnimation;
|
||||||
bool deactivateAnimation;
|
bool mDeactivateAnimation;
|
||||||
QTimeLine timeline;
|
QTimeLine mTimeline;
|
||||||
EffectWindow* window;
|
EffectWindow* mWindow;
|
||||||
|
QStringList mCheck;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Add table
Reference in a new issue