Commit 118b8418 authored by Martin Flöser's avatar Martin Flöser
Browse files

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: 108403
parent 049588ec
......@@ -81,6 +81,7 @@ set( kwin4_effect_include_directories )
# scripted effects
add_subdirectory( fade )
add_subdirectory( login )
# scripted effects only relevant to desktop
if( NOT KWIN_MOBILE_EFFECTS )
......@@ -93,7 +94,6 @@ endif( NOT KWIN_MOBILE_EFFECTS )
# Common effects
include( dialogparent/CMakeLists.txt )
include( login/CMakeLists.txt )
include( outline/CMakeLists.txt )
include( presentwindows/CMakeLists.txt )
include( screenedge/CMakeLists.txt )
......
......@@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dashboard/dashboard_config.h"
#include "desktopgrid/desktopgrid_config.h"
#include "diminactive/diminactive_config.h"
#include "login/login_config.h"
#include "magiclamp/magiclamp_config.h"
#include "translucency/translucency_config.h"
#include "presentwindows/presentwindows_config.h"
......@@ -62,7 +61,6 @@ KWIN_EFFECT_CONFIG_MULTIPLE(builtins,
KWIN_EFFECT_CONFIG_SINGLE(dashboard, DashboardEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE(desktopgrid, DesktopGridEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE(diminactive, DimInactiveEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE(login, LoginEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE(magiclamp, MagicLampEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE(presentwindows, PresentWindowsEffectConfig)
KWIN_EFFECT_CONFIG_SINGLE(resize, ResizeEffectConfig)
......
#######################################
# 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)
/********************************************************************
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
/********************************************************************
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
/********************************************************************
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"
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_kwin4_effect_builtins
X-KDE-ParentComponents=kwin4_effect_login
X-KDE-PluginKeyword=login
Name=Login
Name[af]=Aanteken
Name[ar]=ولوج
Name[ast]=Accesu
Name[be]=Уваход
Name[be@latin]=Uvachod
Name[bg]=Вход
Name[bn]=লগ-ইন
Name[bn_IN]=লগ-ইন করুন
Name[bs]=Prijava
Name[ca]=Entrada
Name[ca@valencia]=Entrada
Name[cs]=Přihlášení
Name[csb]=Logòwanié
Name[da]=Login
Name[de]=Anmelden
Name[el]=Σύνδεση
Name[en_GB]=Login
Name[eo]=Ensaluto
Name[es]=Acceso
Name[et]=Sisselogimine
Name[eu]=Saio hasiera
Name[fi]=Sisäänkirjautuminen
Name[fr]=Connexion
Name[fy]=Ynlogge
Name[ga]=Logáil Isteach
Name[gl]=Acceso
Name[gu]=પ્રવેશ
Name[he]=כניסה
Name[hi]=लॉगइन
Name[hne]=लागइन
Name[hr]=Prijava
Name[hsb]=Přizjewjenje
Name[hu]=Bejelentkezés
Name[ia]=Accesso de identification
Name[id]=Log Masuk
Name[is]=Innskráning
Name[it]=Accesso
Name[ja]=ログイン
Name[kk]=Кіру
Name[km]=ចូល
Name[kn]=ಪ್ರವೇಶಿಸು (ಲಾಗಿನ್)
Name[ko]=로그인
Name[ku]=Têketin
Name[lt]=Prisijungti
Name[lv]=Pieteikties
Name[mai]=लागिन
Name[mk]=Најавување
Name[ml]=അകത്തുകയറുക
Name[mr]=प्रवेश
Name[nb]=Logg inn
Name[nds]=Anmellen
Name[ne]=लगइन गर्नुहोस्
Name[nl]=Aanmelden
Name[nn]=Innlogging
Name[oc]=Connexion
Name[or]=ଲଗଇନ
Name[pa]=ਲਾਗਇਨ
Name[pl]=Logowanie
Name[pt]=Arranque
Name[pt_BR]=Início de sessão
Name[ro]=Autentificare
Name[ru]=Вход в систему
Name[se]=Sisačáliheapmi
Name[si]=පිවිසුම
Name[sk]=Prihlásenie
Name[sl]=Prijava
Name[sr]=Пријава
Name[sr@ijekavian]=Пријава
Name[sr@ijekavianlatin]=Prijava
Name[sr@latin]=Prijava
Name[sv]=Inloggning
Name[ta]=நுழைக
Name[te]=లాగిన్
Name[tg]=Воридот
Name[th]=ลงบันทึกเข้าระบบ
Name[tr]=Giriş
Name[ug]=كىرىش
Name[uk]=Вхід
Name[uz]=Kirish
Name[uz@cyrillic]=Кириш
Name[vi]=Đăng nhập
Name[wa]=Elodjaedje
Name[x-test]=xxLoginxx
Name[zh_CN]=登录
Name[zh_TW]=登入
/********************************************************************
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
File=login.kcfg
ClassName=LoginConfig
NameSpace=KWin
Singleton=true
Mutators=true
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)
/********************************************************************
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();
......@@ -3,8 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc"/>
<group name="Effect-Login">
<kcfgfile name=""/>
<group name="">
<entry name="FadeToBlack" type="Bool">
<default>false</default>
</entry>
......
......@@ -22,7 +22,7 @@ Name[es]=Acceso
Name[et]=Sisselogimine
Name[eu]=Saio hasiera
Name[fi]=Sisäänkirjautuminen
Name[fr]=Connexion
Name[fr]=Connexion
Name[fy]=Ynlogge
Name[ga]=Logáil Isteach
Name[gl]=Acceso
......@@ -154,14 +154,18 @@ Comment[zh_CN]=登录时平滑淡入到桌面
Comment[zh_TW]=登入時平順地淡入桌面
Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Lubos Lunak, Kai Uwe Broulik
X-KDE-PluginInfo-Email=l.lunak@kde.org, kde@privat.broulik.de
X-KDE-ServiceTypes=KWin/Effect,KCModule
X-KDE-PluginInfo-Author=Lubos Lunak, Kai Uwe Broulik, Martin Gräßlin
X-KDE-PluginInfo-Email=l.lunak@kde.org, kde@privat.broulik.de, mgraesslin@kde.org
X-KDE-PluginInfo-Name=kwin4_effect_login
X-KDE-PluginInfo-Version=0.1.1
X-KDE-PluginInfo-Version=0.2.0
X-KDE-PluginInfo-Category=Appearance
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true