2007-11-27 22:40:25 +03:00
|
|
|
/********************************************************************
|
2007-11-14 03:09:14 +03:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
2013-03-12 16:17:53 +04:00
|
|
|
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
|
2010-02-01 10:44:27 +03:00
|
|
|
Copyright (C) 2009, 2010 Lucas Murray <lmurray@undefinedfire.com>
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2007-11-27 22:40:25 +03:00
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
2007-11-14 03:09:14 +03:00
|
|
|
|
|
|
|
#include "logout.h"
|
2012-12-27 11:12:36 +04:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "logoutconfig.h"
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2007-11-14 16:48:16 +03:00
|
|
|
#include "kwinglutils.h"
|
2013-03-22 15:48:57 +04:00
|
|
|
#include "kwinglplatform.h"
|
2007-11-14 16:48:16 +03:00
|
|
|
|
2009-11-03 12:47:33 +03:00
|
|
|
#include <math.h>
|
2012-07-09 21:04:56 +04:00
|
|
|
|
|
|
|
#include <QtGui/QMatrix4x4>
|
|
|
|
#include <QtGui/QVector2D>
|
2007-11-14 03:09:14 +03:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
LogoutEffect::LogoutEffect()
|
2011-01-30 17:34:42 +03:00
|
|
|
: progress(0.0)
|
|
|
|
, displayEffect(false)
|
|
|
|
, logoutWindow(NULL)
|
|
|
|
, logoutWindowClosed(true)
|
|
|
|
, logoutWindowPassed(false)
|
2014-04-16 16:27:48 +04:00
|
|
|
, logoutAtom(QByteArrayLiteral("_KDE_LOGGING_OUT"))
|
2011-01-30 17:34:42 +03:00
|
|
|
, canDoPersistent(false)
|
2010-02-01 10:44:27 +03:00
|
|
|
, ignoredWindows()
|
2012-07-09 21:04:56 +04:00
|
|
|
, m_vignettingShader(NULL)
|
|
|
|
, m_blurShader(NULL)
|
2013-08-07 11:53:08 +04:00
|
|
|
, m_shadersDir(QStringLiteral("kwin/shaders/1.10/"))
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2014-04-16 16:27:48 +04:00
|
|
|
if (logoutAtom.isValid()) {
|
2014-03-16 13:16:52 +04:00
|
|
|
// Persistent effect
|
|
|
|
effects->registerPropertyType(logoutAtom, true);
|
|
|
|
}
|
2010-02-01 10:44:27 +03:00
|
|
|
|
2009-07-27 16:54:02 +04:00
|
|
|
blurTexture = NULL;
|
|
|
|
blurTarget = NULL;
|
2011-01-30 17:34:42 +03:00
|
|
|
reconfigure(ReconfigureAll);
|
2012-01-29 15:29:24 +04: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(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*)));
|
|
|
|
connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long)));
|
2013-07-19 16:19:27 +04:00
|
|
|
|
|
|
|
#ifdef KWIN_HAVE_OPENGLES
|
|
|
|
const qint64 coreVersionNumber = kVersionNumber(3, 0);
|
|
|
|
#else
|
|
|
|
const qint64 coreVersionNumber = kVersionNumber(1, 40);
|
|
|
|
#endif
|
|
|
|
if (GLPlatform::instance()->glslVersion() >= coreVersionNumber)
|
2013-08-07 11:53:08 +04:00
|
|
|
m_shadersDir = QStringLiteral("kwin/shaders/1.40/");
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-03-06 09:10:00 +03:00
|
|
|
|
|
|
|
LogoutEffect::~LogoutEffect()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2009-03-06 09:10:00 +03:00
|
|
|
delete blurTexture;
|
|
|
|
delete blurTarget;
|
2012-07-09 21:04:56 +04:00
|
|
|
delete m_vignettingShader;
|
|
|
|
delete m_blurShader;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-03-06 09:10:00 +03:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void LogoutEffect::reconfigure(ReconfigureFlags)
|
|
|
|
{
|
2014-03-25 19:29:03 +04:00
|
|
|
LogoutConfig::self()->read();
|
2009-10-03 11:06:51 +04:00
|
|
|
frameDelay = 0;
|
2012-12-27 11:12:36 +04:00
|
|
|
useBlur = LogoutConfig::useBlur();
|
2009-07-27 16:54:02 +04:00
|
|
|
delete blurTexture;
|
2009-02-15 13:34:41 +03:00
|
|
|
blurTexture = NULL;
|
2009-07-27 16:54:02 +04:00
|
|
|
delete blurTarget;
|
2009-02-15 13:34:41 +03:00
|
|
|
blurTarget = NULL;
|
2009-07-27 16:54:02 +04:00
|
|
|
blurSupported = false;
|
2012-07-09 21:04:56 +04:00
|
|
|
delete m_blurShader;
|
|
|
|
m_blurShader = NULL;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void LogoutEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (!displayEffect && progress == 0.0) {
|
|
|
|
if (blurTexture) {
|
2009-07-27 16:54:02 +04:00
|
|
|
delete blurTexture;
|
|
|
|
blurTexture = NULL;
|
|
|
|
delete blurTarget;
|
|
|
|
blurTarget = NULL;
|
|
|
|
blurSupported = false;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
} else if (!blurTexture) {
|
2009-07-27 16:54:02 +04:00
|
|
|
blurSupported = false;
|
|
|
|
delete blurTarget; // catch as we just tested the texture ;-P
|
2014-11-22 17:53:15 +03:00
|
|
|
if (effects->isOpenGLCompositing() && GLRenderTarget::blitSupported() && useBlur) {
|
2011-01-30 17:34:42 +03:00
|
|
|
// TODO: It seems that it is not possible to create a GLRenderTarget that has
|
2009-07-27 16:54:02 +04:00
|
|
|
// a different size than the display right now. Most likely a KWin core bug.
|
|
|
|
// Create texture and render target
|
2014-12-10 22:26:23 +03:00
|
|
|
const QSize size = effects->virtualScreenSize();
|
|
|
|
|
|
|
|
// The fragment shader uses a LOD bias of 1.75, so we need 3 mipmap levels.
|
|
|
|
blurTexture = new GLTexture(size, 3);
|
2011-01-30 17:34:42 +03:00
|
|
|
blurTexture->setFilter(GL_LINEAR_MIPMAP_LINEAR);
|
|
|
|
blurTexture->setWrapMode(GL_CLAMP_TO_EDGE);
|
2009-07-27 16:54:02 +04:00
|
|
|
|
2011-07-17 19:57:30 +04:00
|
|
|
blurTarget = new GLRenderTarget(*blurTexture);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (blurTarget->valid())
|
2009-07-27 16:54:02 +04:00
|
|
|
blurSupported = true;
|
2009-10-03 11:06:51 +04:00
|
|
|
|
|
|
|
// As creating the render target takes time it can cause the first two frames of the
|
|
|
|
// blur animation to be jerky. For this reason we only start the animation after the
|
|
|
|
// third frame.
|
|
|
|
frameDelay = 2;
|
2009-07-27 16:54:02 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-07-27 16:54:02 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (frameDelay)
|
2009-10-03 11:06:51 +04:00
|
|
|
--frameDelay;
|
2012-05-24 13:25:51 +04:00
|
|
|
else {
|
2011-01-30 17:34:42 +03:00
|
|
|
if (displayEffect)
|
|
|
|
progress = qMin(1.0, progress + time / animationTime(2000.0));
|
|
|
|
else if (progress > 0.0)
|
|
|
|
progress = qMax(0.0, progress - time / animationTime(500.0));
|
|
|
|
}
|
2009-02-08 17:07:00 +03:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (blurSupported && progress > 0.0) {
|
2009-02-08 17:07:00 +03:00
|
|
|
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-02-08 17:07:00 +03:00
|
|
|
|
2014-01-25 01:32:53 +04:00
|
|
|
data.paint |= effects->clientArea(FullArea, 0, 0);
|
2011-01-30 17:34:42 +03:00
|
|
|
effects->prePaintScreen(data, time);
|
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void LogoutEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
|
|
|
if (progress > 0.0) {
|
2012-09-20 13:33:32 +04:00
|
|
|
if (effects->isOpenGLCompositing()) {
|
2011-01-30 17:34:42 +03:00
|
|
|
// In OpenGL mode we add vignetting and, if supported, a slight blur
|
|
|
|
if (blurSupported) {
|
|
|
|
// When using blur we render everything to an FBO and as such don't do the vignetting
|
|
|
|
// until after we render the FBO to the screen.
|
|
|
|
if (w == logoutWindow) {
|
|
|
|
// Window is rendered after the FBO
|
2012-07-12 19:20:17 +04:00
|
|
|
windowOpacity = data.opacity();
|
|
|
|
data.setOpacity(0.0); // Cheat, we need the opacity for later but don't want to blur it
|
2011-01-30 17:34:42 +03:00
|
|
|
} else {
|
|
|
|
if (logoutWindowPassed || ignoredWindows.contains(w)) {
|
|
|
|
// Window is rendered after the FBO
|
|
|
|
windows.append(w);
|
2012-07-12 19:20:17 +04:00
|
|
|
windowsOpacities[ w ] = data.opacity();
|
|
|
|
data.setOpacity(0.0);
|
2011-01-30 17:34:42 +03:00
|
|
|
} else // Window is added to the FBO
|
2012-07-12 19:20:17 +04:00
|
|
|
data.multiplySaturation((1.0 - progress * 0.2));
|
2009-02-08 19:04:02 +03:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
} else {
|
|
|
|
// If we are not blurring then we are not rendering to an FBO
|
|
|
|
if (w == logoutWindow)
|
2009-11-20 09:48:05 +03:00
|
|
|
// This is the logout window don't alter it but render our vignetting now
|
|
|
|
renderVignetting();
|
2011-01-30 17:34:42 +03:00
|
|
|
else if (!logoutWindowPassed && !ignoredWindows.contains(w))
|
2009-11-20 09:48:05 +03:00
|
|
|
// Window is in the background, desaturate
|
2012-07-12 19:20:17 +04:00
|
|
|
data.multiplySaturation((1.0 - progress * 0.2));
|
2009-11-20 09:48:05 +03:00
|
|
|
// All other windows are unaltered
|
2007-11-14 16:48:16 +03:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
if (effects->compositingType() == KWin::XRenderCompositing) {
|
|
|
|
// Since we can't do vignetting in XRender just do a stronger desaturation and darken
|
|
|
|
if (w != logoutWindow && !logoutWindowPassed && !ignoredWindows.contains(w)) {
|
2012-07-12 19:20:17 +04:00
|
|
|
data.multiplySaturation((1.0 - progress * 0.8));
|
|
|
|
data.multiplyBrightness((1.0 - progress * 0.3));
|
2009-11-20 09:48:05 +03:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
if (w == logoutWindow ||
|
|
|
|
ignoredWindows.contains(w)) // HACK: All windows past the first ignored one should not be
|
|
|
|
// blurred as it affects the stacking order.
|
2009-11-20 09:48:05 +03:00
|
|
|
// All following windows are on top of the logout window and should not be altered either
|
2009-05-11 16:14:41 +04:00
|
|
|
logoutWindowPassed = true;
|
2007-11-14 03:09:14 +03:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
effects->paintWindow(w, mask, region, data);
|
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void LogoutEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
|
|
|
effects->paintScreen(mask, region, data);
|
2009-02-08 17:07:00 +03:00
|
|
|
|
2012-09-20 13:33:32 +04:00
|
|
|
if (effects->isOpenGLCompositing() && progress > 0.0) {
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!blurSupported) {
|
|
|
|
if (!logoutWindowPassed)
|
2009-11-20 09:48:05 +03:00
|
|
|
// The logout window has been deleted but we still want to fade out the vignetting, thus
|
|
|
|
// render it on the top of everything if still animating. We don't check if logoutWindow
|
|
|
|
// is set as it may still be even if it wasn't rendered.
|
|
|
|
renderVignetting();
|
2011-01-30 17:34:42 +03:00
|
|
|
} else {
|
2012-07-09 21:04:56 +04:00
|
|
|
GLRenderTarget::pushRenderTarget(blurTarget);
|
|
|
|
blurTarget->blitFromFramebuffer();
|
|
|
|
GLRenderTarget::popRenderTarget();
|
2009-11-20 09:48:05 +03:00
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
// Render the screen effect
|
2012-07-09 21:04:56 +04:00
|
|
|
renderBlurTexture();
|
2009-11-03 12:47:33 +03:00
|
|
|
|
2009-11-20 09:48:05 +03:00
|
|
|
// Vignetting (Radial gradient with transparent middle and black edges)
|
|
|
|
renderVignetting();
|
|
|
|
//--------------------------
|
|
|
|
|
|
|
|
// Render the logout window
|
2011-01-30 17:34:42 +03:00
|
|
|
if (logoutWindow) {
|
2009-11-20 09:48:05 +03:00
|
|
|
int winMask = logoutWindow->hasAlpha() ? PAINT_WINDOW_TRANSLUCENT : PAINT_WINDOW_OPAQUE;
|
2011-01-30 17:34:42 +03:00
|
|
|
WindowPaintData winData(logoutWindow);
|
2012-07-12 19:20:17 +04:00
|
|
|
winData.setOpacity(windowOpacity);
|
2011-01-30 17:34:42 +03:00
|
|
|
effects->drawWindow(logoutWindow, winMask, region, winData);
|
|
|
|
}
|
2009-05-11 16:14:41 +04:00
|
|
|
|
2009-11-20 09:48:05 +03:00
|
|
|
// Render all windows on top of logout window
|
2011-01-30 17:34:42 +03:00
|
|
|
foreach (EffectWindow * w, windows) {
|
2009-11-20 09:48:05 +03:00
|
|
|
int winMask = w->hasAlpha() ? PAINT_WINDOW_TRANSLUCENT : PAINT_WINDOW_OPAQUE;
|
2011-01-30 17:34:42 +03:00
|
|
|
WindowPaintData winData(w);
|
2012-07-12 19:20:17 +04:00
|
|
|
winData.setOpacity(windowsOpacities[ w ]);
|
2011-01-30 17:34:42 +03:00
|
|
|
effects->drawWindow(w, winMask, region, winData);
|
|
|
|
}
|
2009-11-20 09:48:05 +03:00
|
|
|
|
|
|
|
windows.clear();
|
|
|
|
windowsOpacities.clear();
|
2009-02-08 17:07:00 +03:00
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2009-02-08 19:04:02 +03:00
|
|
|
void LogoutEffect::postPaintScreen()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if ((progress != 0.0 && progress != 1.0) || frameDelay)
|
2009-02-08 19:04:02 +03:00
|
|
|
effects->addRepaintFull();
|
2009-10-07 19:10:15 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (progress > 0.0)
|
2009-05-11 16:14:41 +04:00
|
|
|
logoutWindowPassed = false;
|
2009-02-08 19:04:02 +03:00
|
|
|
effects->postPaintScreen();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-02-08 19:04:02 +03:00
|
|
|
|
2011-02-26 00:06:02 +03:00
|
|
|
void LogoutEffect::slotWindowAdded(EffectWindow* w)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (isLogoutDialog(w)) {
|
2009-02-08 19:04:02 +03:00
|
|
|
logoutWindow = w;
|
|
|
|
logoutWindowClosed = false; // So we don't blur the window on close
|
|
|
|
progress = 0.0;
|
2010-02-01 10:44:27 +03:00
|
|
|
displayEffect = true;
|
|
|
|
ignoredWindows.clear();
|
2007-11-14 03:09:14 +03:00
|
|
|
effects->addRepaintFull();
|
2011-01-30 17:34:42 +03:00
|
|
|
} else if (canDoPersistent)
|
2010-02-01 10:44:27 +03:00
|
|
|
// TODO: Add parent
|
2011-01-30 17:34:42 +03:00
|
|
|
ignoredWindows.append(w);
|
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2011-02-27 11:25:45 +03:00
|
|
|
void LogoutEffect::slotWindowClosed(EffectWindow* w)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (w == logoutWindow) {
|
2009-02-08 19:04:02 +03:00
|
|
|
logoutWindowClosed = true;
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!canDoPersistent)
|
2010-02-01 10:44:27 +03:00
|
|
|
displayEffect = false; // Fade back to normal
|
2007-11-14 03:09:14 +03:00
|
|
|
effects->addRepaintFull();
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2011-02-27 12:47:42 +03:00
|
|
|
void LogoutEffect::slotWindowDeleted(EffectWindow* w)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2011-02-06 18:54:20 +03:00
|
|
|
windows.removeAll(w);
|
2011-04-25 16:38:13 +04:00
|
|
|
ignoredWindows.removeAll(w);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (w == logoutWindow)
|
2009-02-08 19:04:02 +03:00
|
|
|
logoutWindow = NULL;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-02-08 19:04:02 +03:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
bool LogoutEffect::isLogoutDialog(EffectWindow* w)
|
|
|
|
{
|
|
|
|
// TODO there should be probably a better way (window type?)
|
2013-07-23 09:02:52 +04:00
|
|
|
if (w->windowClass() == QStringLiteral("ksmserver ksmserver")
|
|
|
|
&& (w->windowRole() == QStringLiteral("logoutdialog") || w->windowRole() == QStringLiteral("logouteffect"))) {
|
2007-11-14 03:09:14 +03:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return false;
|
|
|
|
}
|
2007-11-14 03:09:14 +03:00
|
|
|
|
2009-11-20 09:48:05 +03:00
|
|
|
void LogoutEffect::renderVignetting()
|
2012-07-09 21:04:56 +04:00
|
|
|
{
|
|
|
|
if (!m_vignettingShader) {
|
|
|
|
m_vignettingShader = ShaderManager::instance()->loadFragmentShader(KWin::ShaderManager::ColorShader,
|
2013-08-09 16:19:09 +04:00
|
|
|
QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
|
|
|
m_shadersDir + QStringLiteral("vignetting.frag")));
|
2012-07-09 21:04:56 +04:00
|
|
|
if (!m_vignettingShader->isValid()) {
|
2013-11-29 09:18:28 +04:00
|
|
|
qCDebug(KWINEFFECTS) << "Vignetting Shader failed to load";
|
2012-07-09 21:04:56 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (!m_vignettingShader->isValid()) {
|
|
|
|
// shader broken
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// need to get the projection matrix from the ortho shader for the vignetting shader
|
|
|
|
QMatrix4x4 projection = ShaderManager::instance()->pushShader(KWin::ShaderManager::SimpleShader)->getUniformMatrix4x4("projection");
|
|
|
|
ShaderManager::instance()->popShader();
|
|
|
|
|
2012-09-21 13:25:08 +04:00
|
|
|
ShaderBinder binder(m_vignettingShader);
|
2012-07-09 21:04:56 +04:00
|
|
|
m_vignettingShader->setUniform(KWin::GLShader::ProjectionMatrix, projection);
|
|
|
|
m_vignettingShader->setUniform("u_progress", (float)progress * 0.9f);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
const QRect fullArea = effects->clientArea(FullArea, 0, 0);
|
|
|
|
for (int screen = 0; screen < effects->numScreens(); screen++) {
|
|
|
|
const QRect screenGeom = effects->clientArea(ScreenArea, screen, 0);
|
2014-11-25 10:40:23 +03:00
|
|
|
glScissor(screenGeom.x(), effects->virtualScreenSize().height() - screenGeom.y() - screenGeom.height(),
|
2012-07-09 21:04:56 +04:00
|
|
|
screenGeom.width(), screenGeom.height()); // GL coords are flipped
|
|
|
|
const float cenX = screenGeom.x() + screenGeom.width() / 2;
|
|
|
|
const float cenY = fullArea.height() - screenGeom.y() - screenGeom.height() / 2;
|
|
|
|
const float r = float((screenGeom.width() > screenGeom.height())
|
|
|
|
? screenGeom.width() : screenGeom.height()) * 0.8f; // Radius
|
|
|
|
m_vignettingShader->setUniform("u_center", QVector2D(cenX, cenY));
|
|
|
|
m_vignettingShader->setUniform("u_radius", r);
|
|
|
|
QVector<float> vertices;
|
|
|
|
vertices << screenGeom.x() << screenGeom.y();
|
|
|
|
vertices << screenGeom.x() << screenGeom.y() + screenGeom.height();
|
|
|
|
vertices << screenGeom.x() + screenGeom.width() << screenGeom.y();
|
|
|
|
vertices << screenGeom.x() + screenGeom.width() << screenGeom.y() + screenGeom.height();
|
|
|
|
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
|
|
|
|
vbo->setData(vertices.count()/2, 2, vertices.constData(), NULL);
|
|
|
|
vbo->render(GL_TRIANGLE_STRIP);
|
|
|
|
}
|
|
|
|
glDisable(GL_SCISSOR_TEST);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LogoutEffect::renderBlurTexture()
|
|
|
|
{
|
|
|
|
if (!m_blurShader) {
|
|
|
|
m_blurShader = ShaderManager::instance()->loadFragmentShader(KWin::ShaderManager::SimpleShader,
|
2013-08-09 16:19:09 +04:00
|
|
|
QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
|
|
|
m_shadersDir + QStringLiteral("logout-blur.frag")));
|
2012-07-09 21:04:56 +04:00
|
|
|
if (!m_blurShader->isValid()) {
|
2013-11-29 09:18:28 +04:00
|
|
|
qCDebug(KWINEFFECTS) << "Logout blur shader failed to load";
|
2012-07-09 21:04:56 +04:00
|
|
|
}
|
|
|
|
} else if (!m_blurShader->isValid()) {
|
|
|
|
// shader is broken - no need to continue here
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Unmodified base image
|
2012-09-21 13:25:08 +04:00
|
|
|
ShaderBinder binder(m_blurShader);
|
2012-07-09 21:04:56 +04:00
|
|
|
m_blurShader->setUniform(GLShader::Offset, QVector2D(0, 0));
|
|
|
|
m_blurShader->setUniform(GLShader::ModulationConstant, QVector4D(1.0, 1.0, 1.0, 1.0));
|
|
|
|
m_blurShader->setUniform(GLShader::Saturation, 1.0);
|
|
|
|
m_blurShader->setUniform("u_alphaProgress", (float)progress * 0.4f);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
blurTexture->bind();
|
2014-12-12 00:22:08 +03:00
|
|
|
blurTexture->generateMipmaps();
|
2014-02-24 19:13:30 +04:00
|
|
|
blurTexture->render(infiniteRegion(), effects->virtualScreenGeometry());
|
2012-07-09 21:04:56 +04:00
|
|
|
blurTexture->unbind();
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2011-03-12 21:18:19 +03:00
|
|
|
void LogoutEffect::slotPropertyNotify(EffectWindow* w, long a)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (w || a != logoutAtom)
|
2010-02-01 10:44:27 +03:00
|
|
|
return; // Not our atom
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
QByteArray byteData = effects->readRootProperty(logoutAtom, logoutAtom, 8);
|
|
|
|
if (byteData.length() < 1) {
|
|
|
|
// Property was deleted
|
2010-02-01 10:44:27 +03:00
|
|
|
displayEffect = false;
|
|
|
|
return;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2010-02-01 10:44:27 +03:00
|
|
|
|
|
|
|
// We are using a compatible KSMServer therefore only terminate the effect when the
|
|
|
|
// atom is deleted, not when the dialog is closed.
|
|
|
|
canDoPersistent = true;
|
2012-07-09 21:04:56 +04:00
|
|
|
effects->addRepaintFull();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2010-02-01 10:44:27 +03:00
|
|
|
|
2011-08-27 13:21:31 +04:00
|
|
|
bool LogoutEffect::isActive() const
|
|
|
|
{
|
2012-07-09 21:04:56 +04:00
|
|
|
return progress != 0 || logoutWindow;
|
2011-08-27 13:21:31 +04:00
|
|
|
}
|
|
|
|
|
2007-11-14 03:09:14 +03:00
|
|
|
} // namespace
|