Add support for XComposite translucency to the Konsole KPart.

The decision to support translucent painting is made at part 
creation depending on whether the hosting application is using 
an ARGB visual and a composition manager has claimed the re-
levant X selection (via KWindowSystem).


svn path=/trunk/KDE/kdebase/apps/konsole/; revision=758145
This commit is contained in:
Eike Hein
2008-01-07 00:35:46 +00:00
parent 69c3cbd967
commit 5246e75c2f
3 changed files with 43 additions and 1 deletions

View File

@@ -23,11 +23,13 @@
// Qt
#include <QtCore/QStringList>
// KDE
#include <KAction>
#include <KActionCollection>
#include <KDebug>
#include <KLocale>
#include <KWindowSystem>
#include <kdeversion.h>
// Konsole
@@ -39,9 +41,16 @@
#include "Session.h"
#include "SessionController.h"
#include "SessionManager.h"
#include "TerminalDisplay.h"
#include "ViewManager.h"
#include "MainWindow.h"
// X
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>
#endif
extern "C"
{
// entry point for Konsole part library,
@@ -70,6 +79,8 @@ Part::Part(QWidget* parentWidget , QObject* parent)
,_pluggedController(0)
,_manageProfilesAction(0)
{
TerminalDisplay::HAVE_TRANSPARENCY = transparencyAvailable();
// setup global actions
createGlobalActions();
@@ -109,6 +120,35 @@ void Part::setupActionsForSession(SessionController* session)
KActionCollection* collection = session->actionCollection();
collection->addAction("manage-profiles",_manageProfilesAction);
}
bool Part::transparencyAvailable()
{
#ifdef Q_WS_X11
bool ARGB = false;
int screen = QX11Info::appScreen();
bool depth = (QX11Info::appDepth() == 32);
Display* display = QX11Info::display();
Visual* visual = static_cast<Visual*>(QX11Info::appVisual(screen));
XRenderPictFormat* format = XRenderFindVisualFormat(display, visual);
if (depth && format->type == PictTypeDirect && format->direct.alphaMask)
{
ARGB = true;
}
if (ARGB)
{
return KWindowSystem::compositingActive();
}
else
#endif
{
return false;
}
}
bool Part::openFile()
{
return false;