Rewrite of Login effect to JavaScript
Main motivation for this rewrite is the fact that the login effect had been designed under the assumption that there is only one login splash window. This assumption does no longer hold with the QML based splash, which creates a window per screen. By using a JavaScript based effect, the animation effect is implicityly used which supports animating multiple windows at the same time in a better and safer way. BUG: 313061 FIXED-IN: 4.11 REVIEW: 108403master
parent
898e120be9
commit
4c402e8045
@ -1,30 +1 @@
|
||||
#######################################
|
||||
# Effect
|
||||
|
||||
# Source files
|
||||
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
||||
login/login.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources login/loginconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
login/login.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
|
||||
#######################################
|
||||
# Config
|
||||
|
||||
# Source files
|
||||
set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources}
|
||||
login/login_config.cpp
|
||||
login/login_config.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources login/loginconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
login/login_config.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
add_subdirectory(package)
|
||||
|
@ -1,129 +0,0 @@
|
||||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.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 "login.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "loginconfig.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include <KDE/KConfigGroup>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT(login, LoginEffect)
|
||||
|
||||
LoginEffect::LoginEffect()
|
||||
: progress(1.0)
|
||||
, login_window(NULL)
|
||||
{
|
||||
reconfigure(ReconfigureAll);
|
||||
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
|
||||
}
|
||||
|
||||
void LoginEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
{
|
||||
if (login_window != NULL) {
|
||||
if (progress != 1.0) {
|
||||
progress = qBound(0.0, progress + time / animationTime(2000), 1.0);
|
||||
if (progress == 1.0) {
|
||||
login_window->unrefWindow();
|
||||
login_window = NULL;
|
||||
effects->prePaintScreen(data, time);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void LoginEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
||||
{
|
||||
if (progress != 1.0 && w == login_window) {
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
|
||||
data.setTranslucent();
|
||||
}
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
void LoginEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
{
|
||||
if (w == login_window) {
|
||||
if (m_fadeToBlack) {
|
||||
if (progress < 0.5)
|
||||
data.multiplyBrightness((1.0 - progress * 2));
|
||||
if (progress >= 0.5) {
|
||||
data.multiplyOpacity((1.0 - (progress - 0.5) * 2));
|
||||
data.setBrightness(0);
|
||||
}
|
||||
} else if (progress < 1.0) {
|
||||
data.multiplyOpacity((1.0 - progress));
|
||||
}
|
||||
}
|
||||
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void LoginEffect::postPaintScreen()
|
||||
{
|
||||
if (login_window != NULL && progress != 1.0)
|
||||
effects->addRepaintFull();
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
void LoginEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
LoginConfig::self()->readConfig();
|
||||
m_fadeToBlack = LoginConfig::fadeToBlack();
|
||||
}
|
||||
|
||||
void LoginEffect::slotWindowClosed(EffectWindow* w)
|
||||
{
|
||||
if (isLoginSplash(w)) {
|
||||
if (login_window)
|
||||
return; // We already have a window... should never happen.
|
||||
login_window = w;
|
||||
login_window->refWindow();
|
||||
progress = 0.0;
|
||||
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
|
||||
bool LoginEffect::isLoginSplash(EffectWindow* w)
|
||||
{
|
||||
// TODO there should be probably a better way (window type?)
|
||||
// see also fade effect and composite.cpp
|
||||
if (w->windowClass() == "ksplashx ksplashx"
|
||||
|| w->windowClass() == "ksplashsimple ksplashsimple"
|
||||
|| w->windowClass() == "qt-subapplication ksplashqml") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LoginEffect::isActive() const
|
||||
{
|
||||
return login_window != NULL;
|
||||
}
|
||||
|
||||
} // namespace
|
@ -1,60 +0,0 @@
|
||||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.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/>.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef KWIN_LOGIN_H
|
||||
#define KWIN_LOGIN_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class LoginEffect
|
||||
: public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool fadeToBlack READ isFadeToBlack)
|
||||
public:
|
||||
LoginEffect();
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual bool isActive() const;
|
||||
|
||||
// for properties
|
||||
bool isFadeToBlack() const {
|
||||
return m_fadeToBlack;
|
||||
}
|
||||
public Q_SLOTS:
|
||||
void slotWindowClosed(KWin::EffectWindow *w);
|
||||
|
||||
private:
|
||||
bool isLoginSplash(EffectWindow* w);
|
||||
double progress; // 0-1
|
||||
EffectWindow* login_window;
|
||||
bool m_fadeToBlack;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
@ -1,64 +0,0 @@
|
||||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2010 Martin Gräßlin <kde@martin-graesslin.com>
|
||||
Copyright (C) 2011 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
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 "login_config.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "loginconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <kconfiggroup.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT_CONFIG_FACTORY
|
||||
|
||||
LoginEffectConfigForm::LoginEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
LoginEffectConfig::LoginEffectConfig(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
m_ui = new LoginEffectConfigForm(this);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
layout->addWidget(m_ui);
|
||||
|
||||
addConfig(LoginConfig::self(), m_ui);
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
void LoginEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
EffectsHandler::sendReloadMessage("login");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "login_config.moc"
|
@ -1,55 +0,0 @@
|
||||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2010 Martin Gräßlin <kde@martin-graesslin.com>
|
||||
Copyright (C) 2011 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
|
||||
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/>.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef KWIN_LOGIN_CONFIG_H
|
||||
#define KWIN_LOGIN_CONFIG_H
|
||||
|
||||
#include <kcmodule.h>
|
||||
|
||||
#include "ui_login_config.h"
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class LoginEffectConfigForm : public QWidget, public Ui::LoginEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoginEffectConfigForm(QWidget* parent = 0);
|
||||
};
|
||||
|
||||
class LoginEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoginEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
|
||||
private:
|
||||
LoginEffectConfigForm* m_ui;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
@ -1,5 +0,0 @@
|
||||
File=login.kcfg
|
||||
ClassName=LoginConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
@ -0,0 +1,6 @@
|
||||
install(DIRECTORY contents DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_login)
|
||||
install(FILES metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_login)
|
||||
|
||||
install(FILES metadata.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME}
|
||||
RENAME kwin4_effect_login.desktop)
|
@ -0,0 +1,94 @@
|
||||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
||||
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.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/>.
|
||||
*********************************************************************/
|
||||
/*global effect, effects, animate, animationTime, Effect*/
|
||||
var loginEffect = {
|
||||
duration: animationTime(2000),
|
||||
isFadeToBlack: false,
|
||||
loadConfig: function () {
|
||||
"use strict";
|
||||
loginEffect.isFadeToBlack = effect.readConfig("FadeToBlack", false);
|
||||
},
|
||||
isLoginSplash: function (window) {
|
||||
"use strict";
|
||||
var windowClass = window.windowClass;
|
||||
if (windowClass === "ksplashx ksplashx") {
|
||||
return true;
|
||||
}
|
||||
if (windowClass === "ksplashsimple ksplashsimple") {
|
||||
return true;
|
||||
}
|
||||
if (windowClass === "qt-subapplication ksplashqml") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
fadeOut: function (window) {
|
||||
"use strict";
|
||||
animate({
|
||||
window: window,
|
||||
duration: loginEffect.duration,
|
||||
type: Effect.Opacity,
|
||||
from: 1.0,
|
||||
to: 0.0
|
||||
});
|
||||
},
|
||||
fadeToBlack: function (window) {
|
||||
"use strict";
|
||||
animate({
|
||||
window: window,
|
||||
duration: loginEffect.duration / 2,
|
||||
animations: [{
|
||||
type: Effect.Brightness,
|
||||
from: 1.0,
|
||||
to: 0.0
|
||||
}, {
|
||||
type: Effect.Opacity,
|
||||
from: 1.0,
|
||||
to: 0.0,
|
||||
delay: loginEffect.duration / 2
|
||||
}, {
|
||||
// TODO: is there a better way to keep brightness constant?
|
||||
type: Effect.Brightness,
|
||||
from: 0.0,
|
||||
to: 0.0,
|
||||
delay: loginEffect.duration / 2
|
||||
}]
|
||||
});
|
||||
},
|
||||
closed: function (window) {
|
||||
"use strict";
|
||||
if (!loginEffect.isLoginSplash(window)) {
|
||||
return;
|
||||
}
|
||||
if (loginEffect.isFadeToBlack === true) {
|
||||
loginEffect.fadeToBlack(window);
|
||||
} else {
|
||||
loginEffect.fadeOut(window);
|
||||
}
|
||||
},
|
||||
init: function () {
|
||||
"use strict";
|
||||
effect.configChanged.connect(loginEffect.loadConfig);
|
||||
effects.windowClosed.connect(loginEffect.closed);
|
||||
loginEffect.loadConfig();
|
||||
}
|
||||
};
|
||||
loginEffect.init();
|
Loading…
Reference in New Issue