2
* Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
#include "logouteffect.h"
28
#include "fadeeffect.h"
29
#include "curtaineffect.h"
31
#include <unistd.h> // for gethostname()
34
static bool localDisplay(Display *dpy)
36
QByteArray display(XDisplayString(dpy));
37
QByteArray hostPart = display.left(display.indexOf(':'));
39
if (hostPart.isEmpty())
42
if (hostPart == "localhost")
45
if (hostPart == "127.0.0.1")
49
gethostname(name, sizeof(name));
57
static bool supportedFormat(const QPixmap *pixmap)
59
int depth = pixmap->depth();
60
Visual *visual = (Visual*)pixmap->x11Info().visual();
62
if (ImageByteOrder(pixmap->x11Info().display()) != LSBFirst)
65
// Assume this means the pixmap is ARGB32
66
if (pixmap->hasAlphaChannel())
69
// 24/34 bit x8a8r8g8b8
70
if ((depth == 24 || depth == 32) &&
71
visual->red_mask == 0x00ff0000 &&
72
visual->green_mask == 0x0000ff00 &&
73
visual->blue_mask == 0x000000ff)
80
visual->red_mask == 0xf800 &&
81
visual->green_mask == 0x07e0 &&
82
visual->blue_mask == 0x001f)
92
// ----------------------------------------------------------------------------
96
LogoutEffect::LogoutEffect(QWidget *parent, QPixmap *pixmap)
97
: QObject(parent), parent(parent), pixmap(pixmap)
101
LogoutEffect::~LogoutEffect()
105
LogoutEffect *LogoutEffect::create(QWidget *parent, QPixmap *pixmap)
107
Display *dpy = parent->x11Info().display();
109
if (!localDisplay(dpy) || !supportedFormat(pixmap))
110
return new CurtainEffect(parent, pixmap);
112
return new FadeEffect(parent, pixmap);