summaryrefslogtreecommitdiff
path: root/kde
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2009-03-10 20:58:48 +0100
committerDennis Kasprzyk <onestone@compiz-fusion.org>2009-03-10 20:58:48 +0100
commit965a9a6093a858d8f645e7c52a6f71ee248109be (patch)
tree518b2338c1d2b85879708d72bcdf0467c7d73def /kde
parent678cd60bc535f9839cbf4f92718dd3f0797ff1fb (diff)
downloadzcomp-965a9a6093a858d8f645e7c52a6f71ee248109be.tar.gz
zcomp-965a9a6093a858d8f645e7c52a6f71ee248109be.tar.bz2
Support also Qt 4.4
Diffstat (limited to 'kde')
-rw-r--r--kde/window-decorator-kde4/decorator.cpp8
-rw-r--r--kde/window-decorator-kde4/decorator.h5
-rw-r--r--kde/window-decorator-kde4/main.cpp46
-rw-r--r--kde/window-decorator-kde4/switcher.cpp21
-rw-r--r--kde/window-decorator-kde4/utils.h6
5 files changed, 82 insertions, 4 deletions
diff --git a/kde/window-decorator-kde4/decorator.cpp b/kde/window-decorator-kde4/decorator.cpp
index b8d09e9..ee533a4 100644
--- a/kde/window-decorator-kde4/decorator.cpp
+++ b/kde/window-decorator-kde4/decorator.cpp
@@ -90,9 +90,15 @@ KWD::PluginManager::PluginManager (KSharedConfigPtr config):
"kwin3_oxygen" : "kwin3_plastik";
}
-
+#ifdef QT_45
KWD::Decorator::Decorator () :
KApplication (),
+#else
+KWD::Decorator::Decorator (Display* display,
+ Qt::HANDLE visual,
+ Qt::HANDLE colormap) :
+ KApplication (display, visual, colormap),
+#endif
mConfig (0),
mCompositeWindow (0),
mSwitcher (0)
diff --git a/kde/window-decorator-kde4/decorator.h b/kde/window-decorator-kde4/decorator.h
index e3c6d75..0ab3522 100644
--- a/kde/window-decorator-kde4/decorator.h
+++ b/kde/window-decorator-kde4/decorator.h
@@ -41,6 +41,7 @@
#include "window.h"
#include "switcher.h"
#include "kdecoration_plugins.h"
+#include "utils.h"
#define ROOT_OFF_X 8192
#define ROOT_OFF_Y 8192
@@ -84,7 +85,11 @@ class PluginManager:public KDecorationPlugins {
class Decorator:public KApplication {
Q_OBJECT public:
+#ifdef QT_45
Decorator ();
+#else
+ Decorator (Display* display, Qt::HANDLE visual, Qt::HANDLE colormap);
+#endif
~Decorator (void);
static NETRootInfo *rootInfo (void)
diff --git a/kde/window-decorator-kde4/main.cpp b/kde/window-decorator-kde4/main.cpp
index eec6bae..3a6581d 100644
--- a/kde/window-decorator-kde4/main.cpp
+++ b/kde/window-decorator-kde4/main.cpp
@@ -31,6 +31,7 @@
#include <KDE/KLocale>
#include "decorator.h"
+#include "utils.h"
#include <QX11Info>
#include <QtDBus/QtDBus>
@@ -48,6 +49,14 @@ main (int argc, char **argv)
Time timestamp;
QString appname;
+#ifndef QT_45
+ Colormap colormap = 0;
+ Visual *visual = 0;
+ int event_base, error_base;
+ Display *dpy;
+ int screen;
+#endif
+
options.add ("replace", ki18n ("Replace existing window decorator"));
options.add ("sm-disable", ki18n ("Disable connection to session manager"));
options.add ("opacity <value>", ki18n ("Decoration opacity"), "0.75");
@@ -92,7 +101,44 @@ main (int argc, char **argv)
// Disable window less child widgets
QApplication::setAttribute(Qt::AA_NativeWindows, true);
+#ifdef QT_45
app = new KWD::Decorator ();
+#else
+ dpy = XOpenDisplay(0); // open default display
+ screen = DefaultScreen (dpy);
+ if (!dpy) {
+ kError() << "Cannot connect to the X server" << endl;
+ return 0;
+ }
+
+ if (XRenderQueryExtension (dpy, &event_base, &error_base))
+ {
+ int nvi;
+ XVisualInfo templ;
+ templ.screen = screen;
+ templ.depth = 32;
+ templ.c_class = TrueColor;
+ XVisualInfo *xvi = XGetVisualInfo (dpy, VisualScreenMask |
+ VisualDepthMask |
+ VisualClassMask, &templ, &nvi);
+
+ for (int i = 0; i < nvi; i++)
+ {
+ XRenderPictFormat *format =
+ XRenderFindVisualFormat (dpy, xvi[i].visual);
+ if (format->type == PictTypeDirect && format->direct.alphaMask)
+ {
+ visual = xvi[i].visual;
+ colormap = XCreateColormap (dpy, RootWindow (dpy, screen),
+ visual, AllocNone);
+ break;
+ }
+ }
+ }
+
+ app = new KWD::Decorator (dpy, visual ? Qt::HANDLE(visual) : 0,
+ colormap ? Qt::HANDLE(colormap) : 0);
+#endif
if (args->isSet ("sm-disable"))
app->disableSessionManagement ();
diff --git a/kde/window-decorator-kde4/switcher.cpp b/kde/window-decorator-kde4/switcher.cpp
index bdb2936..27fc810 100644
--- a/kde/window-decorator-kde4/switcher.cpp
+++ b/kde/window-decorator-kde4/switcher.cpp
@@ -116,6 +116,7 @@ KWD::Switcher::updateGeometry ()
if (mX11BackgroundPixmap)
XFreePixmap (QX11Info::display (), mX11BackgroundPixmap);
+#ifdef QT_45
mX11Pixmap = XCreatePixmap (QX11Info::display (),
QX11Info::appRootWindow (),
width + mBorder.left + mBorder.right,
@@ -124,10 +125,15 @@ KWD::Switcher::updateGeometry ()
mX11BackgroundPixmap = XCreatePixmap (QX11Info::display (),
QX11Info::appRootWindow (),
width, height, 32);
-
+
mPixmap = QPixmap::fromX11Pixmap (mX11Pixmap, QPixmap::ExplicitlyShared);
mBackgroundPixmap = QPixmap::fromX11Pixmap (mX11BackgroundPixmap,
QPixmap::ExplicitlyShared);
+#else
+ mPixmap = QPixmap (width + mBorder.left + mBorder.right,
+ height + mBorder.top + mBorder.bottom);
+ mBackgroundPixmap = QPixmap (width, height);
+#endif
redrawPixmap ();
update ();
@@ -161,7 +167,11 @@ KWD::Switcher::redrawPixmap ()
mGeometry.width (), mGeometry.height ());
XSetWindowBackgroundPixmap (QX11Info::display (), mId,
+#ifdef QT_45
mX11BackgroundPixmap);
+#else
+ mBackgroundPixmap.handle ());
+#endif
XClearWindow (QX11Info::display (), mId);
}
@@ -218,12 +228,17 @@ KWD::Switcher::updateWindowProperties ()
nQuad = decor_set_lXrXtXbX_window_quads (quads, &mContext, &mDecorLayout,
lh / 2, rh / 2, w, w / 2);
-
+#ifdef QT_45
decor_quads_to_property (data, mX11Pixmap,
&mBorder, &mBorder,
0, 0,
quads, nQuad);
-
+#else
+ decor_quads_to_property (data, mPixmap.handle (),
+ &mBorder, &mBorder,
+ 0, 0,
+ quads, nQuad);
+#endif
KWD::trapXError ();
XChangeProperty (QX11Info::display(), mId, Atoms::netWindowDecor,
XA_INTEGER, 32, PropModeReplace, (unsigned char *) data,
diff --git a/kde/window-decorator-kde4/utils.h b/kde/window-decorator-kde4/utils.h
index eb0e2af..e9143cc 100644
--- a/kde/window-decorator-kde4/utils.h
+++ b/kde/window-decorator-kde4/utils.h
@@ -28,6 +28,12 @@
#include <fixx11h.h>
#include <QWidget>
+#include <qglobal.h>
+
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
+ #define QT_45
+#endif
+
namespace KWD
{
namespace Atoms