added compositing methods

wilder-pre-rebase
Hugo Pereira Da Costa 12 years ago
parent 293572071f
commit 3af443867f
  1. 66
      kstyle/breezehelper.cpp
  2. 39
      kstyle/breezehelper.h

@ -25,14 +25,35 @@
#include "breezemetrics.h"
#include <KColorUtils>
#include <KWindowSystem>
#include <QGuiApplication>
#include <QPainter>
namespace Breeze
{
//____________________________________________________________________
Helper::Helper( KSharedConfig::Ptr config ):
_config( config )
{}
_config( config ),
_isX11( false )
{
#if HAVE_X11
// initialize X11 flag
_isX11 = QGuiApplication::platformName() == QStringLiteral("xcb");
if( _isX11 )
{
// create compositing screen
const QString atomName( QStringLiteral( "_NET_WM_CM_S%1" ).arg( QX11Info::appScreen() ) );
_compositingManagerAtom = createAtom( atomName );
}
#endif
}
//____________________________________________________________________
KSharedConfigPtr Helper::config() const
@ -878,4 +899,45 @@ namespace Breeze
}
//________________________________________________________________________________________________________
bool Helper::compositingActive( void ) const
{
#if HAVE_X11
if( isX11() )
{
// direct call to X
xcb_get_selection_owner_cookie_t cookie( xcb_get_selection_owner( QX11Info::connection(), _compositingManagerAtom ) );
ScopedPointer<xcb_get_selection_owner_reply_t> reply( xcb_get_selection_owner_reply( QX11Info::connection(), cookie, nullptr ) );
return reply && reply->owner;
}
#endif
// use KWindowSystem
return KWindowSystem::compositingActive();
}
#if HAVE_X11
//____________________________________________________________________
xcb_atom_t Helper::createAtom( const QString& name ) const
{
if( isX11() )
{
xcb_connection_t* connection( QX11Info::connection() );
xcb_intern_atom_cookie_t cookie( xcb_intern_atom( connection, false, name.size(), qPrintable( name ) ) );
ScopedPointer<xcb_intern_atom_reply_t> reply( xcb_intern_atom_reply( connection, cookie, nullptr) );
return reply ? reply->atom:0;
} else return 0;
}
#endif
}

@ -29,6 +29,12 @@
#include <KColorScheme>
#include <QPainterPath>
#include <QWidget>
#if HAVE_X11
#include <QX11Info>
#include <xcb/xcb.h>
#endif
namespace Breeze
{
@ -189,6 +195,28 @@ namespace Breeze
//@}
//!@name compositing utilities
//@{
//! true if style was compiled for and is running on X11
bool isX11() const
{ return _isX11; }
//! returns true if compositing is active
bool compositingActive( void ) const;
//! returns true if a given widget supports alpha channel
bool hasAlphaChannel( const QWidget* ) const;
#if HAVE_X11
//! create xcb atom
xcb_atom_t createAtom( const QString& ) const;
#endif
//@}
protected:
//! return color key for a given color, properly accounting for invalid colors
@ -210,7 +238,16 @@ namespace Breeze
KStatefulBrush _viewNegativeTextBrush;
//@}
};
bool _isX11;
#if HAVE_X11
//! atom used for compositing manager
xcb_atom_t _compositingManagerAtom;
#endif
};
}

Loading…
Cancel
Save