-
Notifications
You must be signed in to change notification settings - Fork 0
/
systemtray.patch
75 lines (66 loc) · 2.58 KB
/
systemtray.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff --git a/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.h b/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.h
index a58fafa..fdabee6 100644
--- a/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.h
+++ b/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.h
@@ -45,6 +45,7 @@ protected:
private slots:
void ensureValidSize();
+ void directRepaint();
private:
static QPixmap toX11Pixmap(const QPixmap& pix);
diff --git a/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.cpp b/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.cpp
index 1826512..12cccc0 100644
--- a/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.cpp
+++ b/plasma/generic/applets/systemtray/protocols/fdo/x11embedcontainer.cpp
@@ -27,6 +27,7 @@
#include <KDebug>
// Qt
+#include <QtCore/QTimer>
#include <QtGui/QPainter>
#include <QtGui/QPaintEngine>
#include <QtGui/QX11Info>
@@ -51,7 +52,8 @@ public:
Private(X11EmbedContainer *q)
: q(q),
picture(None),
- updatesEnabled(true)
+ updatesEnabled(true),
+ blockDirectPaint(false)
{
}
@@ -68,6 +70,7 @@ public:
Picture picture;
bool updatesEnabled;
QImage oldBackgroundImage;
+ bool blockDirectPaint;
};
@@ -192,6 +197,15 @@ void X11EmbedContainer::paintEvent(QPaintEvent *event)
return;
}
+ // Qt's backing store code doesn't expect an inferior window having a different visual
+ // than the toplevel and wouldn't paint anything for it. Therefore a direct paint may be needed.
+ // QWidget::render() will give exactly the contents to paint, but it can't be called in paintEvent(),
+ // so instead delay and do not bother painting right now (since the stuff below is inefficient).
+ if(x11Info().visual() != window()->x11Info().visual() && !d->blockDirectPaint) {
+ QTimer::singleShot(0, this, SLOT(directRepaint()));
+ return;
+ }
+
// Taking a detour via a QPixmap is unfortunately the only way we can get
// the window contents into Qt's backing store.
QPixmap pixmap(size());
@@ -246,6 +260,16 @@ QPixmap X11EmbedContainer::toX11Pixmap(const QPixmap& pix)
return ret;
}
+void X11EmbedContainer::directRepaint()
+{
+ QPixmap pix(size());
+ d->blockDirectPaint = true;
+ render( &pix );
+ d->blockDirectPaint = false;
+ XRenderComposite(x11Info().display(), PictOpSrc, pix.x11PictureHandle(), None, x11PictureHandle(),
+ 0, 0, 0, 0, 0, 0, width(), height());
+}
+
}
#include "x11embedcontainer.moc"