~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/scene_basic.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
7
This program is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation; either version 2 of the License, or
 
10
(at your option) any later version.
 
11
 
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*********************************************************************/
 
20
 
 
21
/*
 
22
 This is very simple compositing code using only plain X. It doesn't use any effects
 
23
 or anything like that, it merely draws everything as it would be visible without
 
24
 compositing. It was the first compositing code in KWin and is usable only for testing
 
25
 and as the very simple "this is how it works".
 
26
*/
 
27
 
 
28
#include "scene_basic.h"
 
29
 
 
30
#include "utils.h"
 
31
#include "client.h"
 
32
 
 
33
namespace KWin
 
34
{
 
35
 
 
36
SceneBasic::SceneBasic(Workspace* ws)
 
37
    : Scene(ws)
 
38
{
 
39
}
 
40
 
 
41
SceneBasic::~SceneBasic()
 
42
{
 
43
}
 
44
 
 
45
void SceneBasic::paint(QRegion, ToplevelList windows)
 
46
{
 
47
    QTime t = QTime::currentTime();
 
48
    Pixmap composite_pixmap = XCreatePixmap(display(), rootWindow(), displayWidth(), displayHeight(), DefaultDepth(display(), DefaultScreen(display())));
 
49
    XGCValues val;
 
50
    val.foreground = WhitePixel(display(), DefaultScreen(display()));
 
51
    val.subwindow_mode = IncludeInferiors;
 
52
    GC gc = XCreateGC(display(), composite_pixmap, GCForeground | GCSubwindowMode, &val);
 
53
    XFillRectangle(display(), composite_pixmap, gc, 0, 0, displayWidth(), displayHeight());
 
54
    for (ToplevelList::ConstIterator it = windows.constBegin();
 
55
            it != windows.constEnd();
 
56
            ++it) {
 
57
        QRect r = (*it)->geometry().intersected(QRect(0, 0, displayWidth(), displayHeight()));
 
58
        if (!r.isEmpty()) {
 
59
            Pixmap pix = (*it)->windowPixmap();
 
60
            if (pix == None)
 
61
                continue;
 
62
            XCopyArea(display(), pix, composite_pixmap, gc,
 
63
                      qMax(0, -(*it)->x()), qMax(0, -(*it)->y()), r.width(), r.height(), r.x(), r.y());
 
64
        }
 
65
    }
 
66
    lastRenderTime = t.elapsed();
 
67
    XCopyArea(display(), composite_pixmap, rootWindow(), gc, 0, 0, displayWidth(), displayHeight(), 0, 0);
 
68
    XFreeGC(display(), gc);
 
69
    XFreePixmap(display(), composite_pixmap);
 
70
    XFlush(display());
 
71
}
 
72
 
 
73
bool SceneBasic::initFailed() const
 
74
{
 
75
    return false;
 
76
}
 
77
 
 
78
// These functions are not used at all, SceneBasic
 
79
// is not using inherited functionality.
 
80
 
 
81
void SceneBasic::paintBackground(QRegion)
 
82
{
 
83
}
 
84
 
 
85
void SceneBasic::windowGeometryShapeChanged(Toplevel*)
 
86
{
 
87
}
 
88
 
 
89
void SceneBasic::windowOpacityChanged(Toplevel*)
 
90
{
 
91
}
 
92
 
 
93
void SceneBasic::windowAdded(Toplevel*)
 
94
{
 
95
}
 
96
 
 
97
void SceneBasic::windowClosed(Toplevel*, Deleted*)
 
98
{
 
99
}
 
100
 
 
101
void SceneBasic::windowDeleted(Deleted*)
 
102
{
 
103
}
 
104
 
 
105
} // namespace