Commit 932e5dc4 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[kstyle] Use QX11Info::isCompositingManagerRunning()

Summary:
Every time Breeze needs to check whether given widget has an alpha
channel, it makes a synchronous X call to figure out whether a
compositing window manager is running on a particular screen. This
is inefficient!

Luckily for us, Qt XCB QPA monitors compositing manager selections
and caches the ownership status of each one. That cached ownership
data can be accessed via QX11Info::isCompositingManagerRunning().

Reviewers: #plasma, hpereiradacosta

Reviewed By: hpereiradacosta

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26978
parent 9b207261
......@@ -43,7 +43,7 @@ namespace Breeze
//____________________________________________________________________
Helper::Helper( KSharedConfig::Ptr config ):
_config( std::move( config ) )
{ init(); }
{}
//____________________________________________________________________
KSharedConfig::Ptr Helper::config() const
......@@ -1577,13 +1577,7 @@ namespace Breeze
#if BREEZE_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;
}
{ return QX11Info::isCompositingManagerRunning( QX11Info::appScreen() ); }
#endif
// use KWindowSystem
......@@ -1610,39 +1604,4 @@ namespace Breeze
return pixmap.devicePixelRatio();
}
#if BREEZE_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
//____________________________________________________________________
void Helper::init()
{
#if BREEZE_HAVE_X11
if( isX11() )
{
// create compositing screen
const QString atomName( QStringLiteral( "_NET_WM_CM_S%1" ).arg( QX11Info::appScreen() ) );
_compositingManagerAtom = createAtom( atomName );
}
#endif
}
}
......@@ -31,10 +31,6 @@
#include <QPainterPath>
#include <QWidget>
#if BREEZE_HAVE_X11
#include <xcb/xcb.h>
#endif
namespace Breeze
{
......@@ -288,18 +284,6 @@ namespace Breeze
//@}
//*@name X11 utilities
//@{
#if BREEZE_HAVE_X11
//* create xcb atom
xcb_atom_t createAtom( const QString& ) const;
#endif
//@}
//* frame radius
constexpr qreal frameRadius( const int penWidth = PenWidth::NoPen, const qreal bias = 0 ) const
{ return qMax( Metrics::Frame_FrameRadius - (0.5 * penWidth) + bias, 0.0 ); }
......@@ -316,9 +300,6 @@ namespace Breeze
protected:
//* initialize
void init();
//* return rounded path in a given rect, with only selected corners rounded, and for a given radius
QPainterPath roundedPath( const QRectF&, Corners, qreal ) const;
......@@ -342,13 +323,6 @@ namespace Breeze
QColor _inactiveTitleBarTextColor;
//@}
#if BREEZE_HAVE_X11
//* atom used for compositing manager
xcb_atom_t _compositingManagerAtom;
#endif
};
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment