~ubuntu-branches/ubuntu/oneiric/kde-workspace/oneiric

« back to all changes in this revision

Viewing changes to .pc/0029-Repaint-the-whole-window-in-the-taskbar-thumbnail.patch/kwin/effects/taskbarthumbnail/taskbarthumbnail.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2011-09-25 00:42:41 UTC
  • Revision ID: package-import@ubuntu.com-20110925004241-c5ck55dokn3yt1kg
Tags: 4:4.7.1-0ubuntu3
* Update debian/kdm.upstart to match latest gdm.upstart improvements:
  - Also export LC_MESSAGES with the rest of locale information
  - When kdm is shut down by a runlevel call, emit an upstart event that can
    be caught by plymouth so it can distinguish between the DM shutting down
    for a runlevel change vs. other causes (LP: #854329)
* Update patches for post-4.7.1 changes.  Add to debian/patches:
    0001-SVN_SILENT-made-messages-.desktop-file.patch
    0003-SVN_SILENT-made-messages-.desktop-file.patch
    0004-SVN_SILENT-made-messages-.desktop-file.patch
    0005-SVN_SILENT-made-messages-.desktop-file.patch
    0006-preferred-app-launchers-need-to-use-the-type-of-the-.patch
    0007-SVN_SILENT-made-messages-.desktop-file.patch
    0009-SVN_SILENT-made-messages-.desktop-file.patch
    0010-add-some-missing-connects-for-the-ruleswidget.patch
    0011-fix-yet-another-fun-with-pointers-tabbing-segfault.patch
    0013-catch-changeMaximize-recursion-from-setNoBorder.patch
    0014-Clear-thumbnails-for-deleted-windows.patch
    0015-Fix-pointer-accesses-in-tiling-code.patch
    0016-SVN_SILENT-made-messages-.desktop-file.patch
    0017-SVN_SILENT-made-messages-.desktop-file.patch
    0018-SVN_SILENT-made-messages-.desktop-file.patch
    0019-Test-for-widget-creation-before-deleting-property-at.patch
    0020-SVN_SILENT-made-messages-.desktop-file.patch
    0023-fix-kiosk-restrictions-for-user-switching-and-logout.patch
    0024-Fix-typo-use-the-right-signal-signature.patch
    0025-Repaint-old-area-of-the-thumbnail.patch
    0026-Use-Client-layoutMetric-to-access-shadowSize-instead.patch
    0027-ShowCalendarPopup-false-suppresses-calendar-popup-an.patch
    0028-show-the-keyboard-on-immediately-entering-a-text-are.patch
    0029-Repaint-the-whole-window-in-the-taskbar-thumbnail.patch
    0030-SVN_SILENT-made-messages-.desktop-file.patch
    0031-Fix-wrong-inital-tab-in-keyboard-kcm.patch

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) 2007 Rivo Laks <rivolaks@hot.ee>
 
6
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
 
7
 
 
8
This program is free software; you can redistribute it and/or modify
 
9
it under the terms of the GNU General Public License as published by
 
10
the Free Software Foundation; either version 2 of the License, or
 
11
(at your option) any later version.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU General Public License
 
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
*********************************************************************/
 
21
 
 
22
#include "taskbarthumbnail.h"
 
23
 
 
24
#include <kdebug.h>
 
25
 
 
26
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
 
27
#include <kwinglutils.h>
 
28
#endif
 
29
 
 
30
// This effect shows a preview inside a window that has a special property set
 
31
// on it that says which window and where to render. It is used by the taskbar
 
32
// to show window previews in tooltips.
 
33
 
 
34
namespace KWin
 
35
{
 
36
 
 
37
KWIN_EFFECT(taskbarthumbnail, TaskbarThumbnailEffect)
 
38
 
 
39
TaskbarThumbnailEffect::TaskbarThumbnailEffect()
 
40
{
 
41
    atom = XInternAtom(display(), "_KDE_WINDOW_PREVIEW", False);
 
42
    effects->registerPropertyType(atom, true);
 
43
    // TODO hackish way to announce support, make better after 4.0
 
44
    unsigned char dummy = 0;
 
45
    XChangeProperty(display(), rootWindow(), atom, atom, 8, PropModeReplace, &dummy, 1);
 
46
    connect(effects, SIGNAL(windowAdded(EffectWindow*)), this, SLOT(slotWindowAdded(EffectWindow*)));
 
47
    connect(effects, SIGNAL(windowDeleted(EffectWindow*)), this, SLOT(slotWindowDeleted(EffectWindow*)));
 
48
    connect(effects, SIGNAL(windowDamaged(EffectWindow*,QRect)), this, SLOT(slotWindowDamaged(EffectWindow*,QRect)));
 
49
    connect(effects, SIGNAL(propertyNotify(EffectWindow*,long)), this, SLOT(slotPropertyNotify(EffectWindow*,long)));
 
50
}
 
51
 
 
52
TaskbarThumbnailEffect::~TaskbarThumbnailEffect()
 
53
{
 
54
    XDeleteProperty(display(), rootWindow(), atom);
 
55
    effects->registerPropertyType(atom, false);
 
56
}
 
57
 
 
58
void TaskbarThumbnailEffect::prePaintScreen(ScreenPrePaintData& data, int time)
 
59
{
 
60
    if (thumbnails.count() > 0) {
 
61
        data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS;
 
62
    }
 
63
    effects->prePaintScreen(data, time);
 
64
}
 
65
 
 
66
void TaskbarThumbnailEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
 
67
{
 
68
    // TODO what if of the windows is translucent and one not? change data.mask?
 
69
    effects->prePaintWindow(w, data, time);
 
70
}
 
71
 
 
72
void TaskbarThumbnailEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
 
73
{
 
74
    effects->paintWindow(w, mask, region, data);   // paint window first
 
75
    if (thumbnails.contains(w)) {
 
76
        // paint thumbnails on it
 
77
        int mask = PAINT_WINDOW_TRANSFORMED;
 
78
        if (data.opacity == 1.0)
 
79
            mask |= PAINT_WINDOW_OPAQUE;
 
80
        else
 
81
            mask |= PAINT_WINDOW_TRANSLUCENT;
 
82
        mask |= PAINT_WINDOW_LANCZOS;
 
83
        foreach (const Data & thumb, thumbnails.values(w)) {
 
84
            EffectWindow* thumbw = effects->findWindow(thumb.window);
 
85
            if (thumbw == NULL)
 
86
                continue;
 
87
            WindowPaintData thumbData(thumbw);
 
88
            thumbData.opacity *= data.opacity;
 
89
            QRect r;
 
90
 
 
91
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
 
92
            if (effects->compositingType() == KWin::OpenGLCompositing) {
 
93
                if (data.shader) {
 
94
                    thumbData.shader = data.shader;
 
95
                }
 
96
            } // if ( effects->compositingType() == KWin::OpenGLCompositing )
 
97
#endif
 
98
            setPositionTransformations(thumbData, r,
 
99
                                       thumbw, thumb.rect.translated(w->pos()), Qt::KeepAspectRatio);
 
100
            effects->drawWindow(thumbw, mask, r, thumbData);
 
101
        }
 
102
    }
 
103
} // End of function
 
104
 
 
105
void TaskbarThumbnailEffect::slotWindowDamaged(EffectWindow* w, const QRect& damage)
 
106
{
 
107
    Q_UNUSED(damage);
 
108
    // Update the thumbnail if the window was damaged
 
109
    foreach (EffectWindow * window, thumbnails.uniqueKeys())
 
110
    foreach (const Data & thumb, thumbnails.values(window))
 
111
    if (w == effects->findWindow(thumb.window))
 
112
        effects->addRepaint(thumb.rect.translated(window->pos()));
 
113
}
 
114
 
 
115
void TaskbarThumbnailEffect::slotWindowAdded(EffectWindow* w)
 
116
{
 
117
    slotPropertyNotify(w, atom);   // read initial value
 
118
}
 
119
 
 
120
void TaskbarThumbnailEffect::slotWindowDeleted(EffectWindow* w)
 
121
{
 
122
    foreach (EffectWindow *window, thumbnails.uniqueKeys()) {
 
123
        foreach (const Data &thumb, thumbnails.values(window)) {
 
124
            if (w == effects->findWindow(thumb.window)) {
 
125
                window->addRepaint(thumb.rect);
 
126
            }
 
127
        }
 
128
    }
 
129
    thumbnails.remove(w);
 
130
}
 
131
 
 
132
void TaskbarThumbnailEffect::slotPropertyNotify(EffectWindow* w, long a)
 
133
{
 
134
    if (!w || a != atom)
 
135
        return;
 
136
    foreach (const Data & thumb, thumbnails.values(w)) {
 
137
        w->addRepaint(thumb.rect.translated(w->pos()));
 
138
    }
 
139
    thumbnails.remove(w);
 
140
    QByteArray data = w->readProperty(atom, atom, 32);
 
141
    if (data.length() < 1)
 
142
        return;
 
143
    long* d = reinterpret_cast< long* >(data.data());
 
144
    int len = data.length() / sizeof(d[ 0 ]);
 
145
    int pos = 0;
 
146
    int cnt = d[ 0 ];
 
147
    ++pos;
 
148
    for (int i = 0;
 
149
            i < cnt;
 
150
            ++i) {
 
151
        int size = d[ pos ];
 
152
        if (len - pos < size)
 
153
            return; // format error
 
154
        ++pos;
 
155
        Data data;
 
156
        data.window = d[ pos ];
 
157
        data.rect = QRect(d[ pos + 1 ], d[ pos + 2 ], d[ pos + 3 ], d[ pos + 4 ]);
 
158
        thumbnails.insert(w, data);
 
159
        effects->addRepaint(data.rect);
 
160
        pos += size;
 
161
    }
 
162
}
 
163
 
 
164
} // namespace