2010-07-23 19:52:20 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2010 Andreas Demmer <ademmer@opensuse.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "dashboard.h"
|
2012-09-19 07:13:01 +00:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "dashboardconfig.h"
|
|
|
|
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KConfigGroup>
|
2010-07-23 19:52:20 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
DashboardEffect::DashboardEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
: transformWindow(false)
|
2011-05-01 12:57:01 +00:00
|
|
|
, retransformWindow(false)
|
2011-01-30 14:34:42 +00:00
|
|
|
, activateAnimation(false)
|
|
|
|
, deactivateAnimation(false)
|
2011-03-17 19:02:52 +00:00
|
|
|
, window(NULL)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-12-13 23:09:47 +00:00
|
|
|
// TODO: better namespacing for atoms
|
|
|
|
atom = effects->announceSupportProperty("_WM_EFFECT_KDE_DASHBOARD", this);
|
2010-07-23 19:52:20 +00:00
|
|
|
|
|
|
|
// read settings
|
|
|
|
reconfigure(ReconfigureAll);
|
2012-01-29 11:29:24 +00:00
|
|
|
connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*)));
|
|
|
|
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
|
|
|
|
connect(effects, SIGNAL(windowActivated(KWin::EffectWindow*)), this, SLOT(slotWindowActivated(KWin::EffectWindow*)));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
|
|
|
DashboardEffect::~DashboardEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void DashboardEffect::reconfigure(ReconfigureFlags)
|
|
|
|
{
|
2013-08-25 23:19:06 +00:00
|
|
|
DashboardConfig::self()->readConfig();
|
2012-09-19 07:13:01 +00:00
|
|
|
brightness = DashboardConfig::brightness()/ 100.0;
|
|
|
|
saturation = DashboardConfig::saturation()/ 100.0;
|
|
|
|
blur = DashboardConfig::blur();
|
2010-10-20 06:33:55 +00:00
|
|
|
|
2012-11-25 17:46:13 +00:00
|
|
|
timeline.setDuration(animationTime<DashboardConfig>(500));
|
2013-08-25 23:19:06 +00:00
|
|
|
if (transformWindow)
|
|
|
|
effects->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void DashboardEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
|
|
|
if (transformWindow && (w != window) && w->isManaged() && !isDashboard(w)) {
|
2010-07-23 19:52:20 +00:00
|
|
|
// dashboard active, transform other windows
|
2012-07-12 15:20:17 +00:00
|
|
|
data.multiplyBrightness((1 - ((1.0 - brightness) * timeline.currentValue())));
|
|
|
|
data.multiplySaturation((1 - ((1.0 - saturation) * timeline.currentValue())));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (transformWindow && (w == window) && w->isManaged()) {
|
2010-11-07 12:32:08 +00:00
|
|
|
// transform dashboard
|
2011-03-14 21:50:05 +00:00
|
|
|
if ((timeline.currentValue() * 2) <= 1) {
|
2012-07-12 15:20:17 +00:00
|
|
|
data.multiplyOpacity(timeline.currentValue() * 2);
|
2010-10-21 15:07:34 +00:00
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintWindow(w, mask, region, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DashboardEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (transformWindow) {
|
|
|
|
if (activateAnimation)
|
2011-03-14 21:50:05 +00:00
|
|
|
timeline.setCurrentTime(timeline.currentTime() + time);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (deactivateAnimation)
|
2011-03-14 21:50:05 +00:00
|
|
|
timeline.setCurrentTime(timeline.currentTime() - time);
|
2010-10-20 06:33:55 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintScreen(data, time);
|
|
|
|
}
|
2010-10-20 06:33:55 +00:00
|
|
|
|
2010-07-23 19:52:20 +00:00
|
|
|
void DashboardEffect::postPaintScreen()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (transformWindow) {
|
|
|
|
if (retransformWindow) {
|
2010-07-23 19:52:20 +00:00
|
|
|
retransformWindow = false;
|
|
|
|
transformWindow = false;
|
|
|
|
effects->addRepaintFull();
|
2011-03-17 19:02:52 +00:00
|
|
|
window = NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->setActiveFullScreenEffect(0);
|
|
|
|
}
|
2010-10-20 06:33:55 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (activateAnimation) {
|
2011-03-14 21:50:05 +00:00
|
|
|
if (timeline.currentValue() == 1.0)
|
2010-10-20 06:33:55 +00:00
|
|
|
activateAnimation = false;
|
|
|
|
|
|
|
|
effects->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-10-20 06:33:55 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (deactivateAnimation) {
|
2011-03-14 21:50:05 +00:00
|
|
|
if (timeline.currentValue() == 0.0) {
|
2010-10-20 06:33:55 +00:00
|
|
|
deactivateAnimation = false;
|
|
|
|
transformWindow = false;
|
2011-03-17 19:02:52 +00:00
|
|
|
window = NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->setActiveFullScreenEffect(0);
|
|
|
|
}
|
2010-10-20 06:33:55 +00:00
|
|
|
|
|
|
|
effects->addRepaintFull();
|
2010-07-23 19:52:20 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
|
|
|
effects->postPaintScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool DashboardEffect::isDashboard(EffectWindow *w)
|
|
|
|
{
|
2013-07-23 05:02:52 +00:00
|
|
|
return w->windowRole() == QStringLiteral("plasma-dashboard");
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
2011-02-27 09:05:04 +00:00
|
|
|
void DashboardEffect::slotWindowActivated(EffectWindow *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!w)
|
2010-07-23 19:52:20 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// apply effect on dashboard activation
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isDashboard(w)) {
|
|
|
|
effects->setActiveFullScreenEffect(this);
|
2010-07-23 19:52:20 +00:00
|
|
|
transformWindow = true;
|
|
|
|
window = w;
|
|
|
|
|
|
|
|
effects->addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
|
|
|
if (transformWindow) {
|
2010-07-23 19:52:20 +00:00
|
|
|
retransformWindow = true;
|
|
|
|
effects->addRepaintFull();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-23 19:52:20 +00:00
|
|
|
|
2011-02-25 21:06:02 +00:00
|
|
|
void DashboardEffect::slotWindowAdded(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (isDashboard(w)) {
|
2010-11-07 12:32:08 +00:00
|
|
|
// Tell other windowAdded() effects to ignore this window
|
2011-01-30 14:34:42 +00:00
|
|
|
w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
2012-08-10 08:01:23 +00:00
|
|
|
if (blur) {
|
|
|
|
w->setData(WindowBlurBehindRole, w->geometry());
|
|
|
|
w->setData(WindowForceBlurRole, QVariant(true));
|
|
|
|
}
|
2010-10-20 06:33:55 +00:00
|
|
|
|
|
|
|
activateAnimation = true;
|
|
|
|
deactivateAnimation = false;
|
2011-03-14 21:50:05 +00:00
|
|
|
timeline.setCurrentTime(0);
|
2010-10-20 06:33:55 +00:00
|
|
|
|
2010-11-07 12:32:08 +00:00
|
|
|
w->addRepaintFull();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-11-07 12:32:08 +00:00
|
|
|
|
2011-02-27 08:25:45 +00:00
|
|
|
void DashboardEffect::slotWindowClosed(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (isDashboard(w)) {
|
2010-11-07 12:32:08 +00:00
|
|
|
// Tell other windowClosed() effects to ignore this window
|
2011-01-30 14:34:42 +00:00
|
|
|
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
2010-11-07 12:32:08 +00:00
|
|
|
w->addRepaintFull();
|
2010-08-11 09:25:25 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-08-11 09:25:25 +00:00
|
|
|
|
2011-08-27 09:21:31 +00:00
|
|
|
bool DashboardEffect::isActive() const
|
|
|
|
{
|
|
|
|
return transformWindow;
|
|
|
|
}
|
|
|
|
|
2010-07-23 19:52:20 +00:00
|
|
|
} // namespace
|