Provide x11Connection as a property on the KWin::Application
KWin::connection() uses the property to resolve the value instead of using QX11Info. In practice this doesn't change anything at the moment, but allows kwin_wayland to provide an xcb connection without depending on QX11Info. As we cannot make xcb_connection_t* available as a metatype, the property's type is set to void*.
This commit is contained in:
parent
fe9873e4b1
commit
0d51952d78
13 changed files with 48 additions and 6 deletions
|
@ -49,6 +49,7 @@ class TestBuiltInEffectLoader : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testHasEffect_data();
|
||||
void testHasEffect();
|
||||
void testKnownEffects();
|
||||
|
@ -61,6 +62,11 @@ private Q_SLOTS:
|
|||
void testLoadAllEffects();
|
||||
};
|
||||
|
||||
void TestBuiltInEffectLoader::initTestCase()
|
||||
{
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
}
|
||||
|
||||
void TestBuiltInEffectLoader::testHasEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
|
|
|
@ -84,6 +84,7 @@ void TestClientMachine::initTestCase()
|
|||
freeaddrinfo(res);
|
||||
|
||||
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
}
|
||||
|
||||
void TestClientMachine::cleanupTestCase()
|
||||
|
|
|
@ -135,6 +135,7 @@ private Q_SLOTS:
|
|||
void TestScreenEdges::initTestCase()
|
||||
{
|
||||
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
KWin::atoms = new KWin::Atoms;
|
||||
qRegisterMetaType<KWin::ElectricBorder>();
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ private:
|
|||
void TestXcbSizeHints::initTestCase()
|
||||
{
|
||||
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
}
|
||||
|
||||
void TestXcbSizeHints::init()
|
||||
|
|
|
@ -46,6 +46,7 @@ private Q_SLOTS:
|
|||
void TestXcbWindow::initTestCase()
|
||||
{
|
||||
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
}
|
||||
|
||||
void TestXcbWindow::defaultCtor()
|
||||
|
|
|
@ -64,6 +64,7 @@ private:
|
|||
void TestXcbWrapper::initTestCase()
|
||||
{
|
||||
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
}
|
||||
|
||||
void TestXcbWrapper::init()
|
||||
|
|
|
@ -39,11 +39,6 @@ QPoint Cursor::pos()
|
|||
static xcb_window_t s_rootWindow = XCB_WINDOW_NONE;
|
||||
static xcb_connection_t *s_connection = nullptr;
|
||||
|
||||
xcb_connection_t *QX11Info::connection()
|
||||
{
|
||||
return s_connection;
|
||||
}
|
||||
|
||||
using namespace KWin;
|
||||
using namespace KWin::Xcb;
|
||||
|
||||
|
@ -98,6 +93,7 @@ void TestXRandRScreens::initTestCase()
|
|||
}
|
||||
QVERIFY(s_rootWindow != XCB_WINDOW_NONE);
|
||||
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(s_rootWindow));
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(s_connection));
|
||||
|
||||
// get the extensions
|
||||
if (!Extensions::self()->isRandrAvailable()) {
|
||||
|
|
|
@ -142,7 +142,7 @@ KWIN_EXPORT xcb_connection_t *connection()
|
|||
{
|
||||
static xcb_connection_t *s_con = nullptr;
|
||||
if (!s_con) {
|
||||
s_con = QX11Info::connection();
|
||||
s_con = reinterpret_cast<xcb_connection_t*>(qApp->property("x11Connection").value<void*>());
|
||||
}
|
||||
return s_con;
|
||||
}
|
||||
|
|
1
main.cpp
1
main.cpp
|
@ -149,6 +149,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
|
|||
, m_operationMode(mode)
|
||||
{
|
||||
setX11RootWindow(QX11Info::appRootWindow());
|
||||
setX11Connection(QX11Info::connection());
|
||||
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
|
||||
}
|
||||
|
||||
|
|
20
main.h
20
main.h
|
@ -47,6 +47,7 @@ class KWIN_EXPORT Application : public QApplication
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(quint32 x11Time READ x11Time WRITE setX11Time)
|
||||
Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT)
|
||||
Q_PROPERTY(void *x11Connection READ x11Connection NOTIFY x11ConnectionChanged)
|
||||
public:
|
||||
/**
|
||||
* @brief This enum provides the various operation modes of KWin depending on the available
|
||||
|
@ -127,6 +128,13 @@ public:
|
|||
return m_rootWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the X11 xcb connection
|
||||
**/
|
||||
xcb_connection_t *x11Connection() const {
|
||||
return m_connection;
|
||||
}
|
||||
|
||||
static void setupMalloc();
|
||||
static void setupLocalizedString();
|
||||
static void setupLoggingCategoryFilters();
|
||||
|
@ -134,6 +142,9 @@ public:
|
|||
static bool usesLibinput();
|
||||
static void setUseLibinput(bool use);
|
||||
|
||||
Q_SIGNALS:
|
||||
void x11ConnectionChanged();
|
||||
|
||||
protected:
|
||||
Application(OperationMode mode, int &argc, char **argv);
|
||||
virtual void performStartup() = 0;
|
||||
|
@ -151,6 +162,14 @@ protected:
|
|||
void setX11RootWindow(xcb_window_t root) {
|
||||
m_rootWindow = root;
|
||||
}
|
||||
/**
|
||||
* Inheriting classes should use this method to set the xcb connection
|
||||
* before accessing any X11 specific code pathes.
|
||||
**/
|
||||
void setX11Connection(xcb_connection_t *c) {
|
||||
m_connection = c;
|
||||
emit x11ConnectionChanged();
|
||||
}
|
||||
|
||||
bool notify(QObject* o, QEvent* e);
|
||||
static void crashHandler(int signal);
|
||||
|
@ -165,6 +184,7 @@ private:
|
|||
OperationMode m_operationMode;
|
||||
xcb_timestamp_t m_x11Time = XCB_TIME_CURRENT_TIME;
|
||||
xcb_window_t m_rootWindow = XCB_WINDOW_NONE;
|
||||
xcb_connection_t *m_connection = nullptr;
|
||||
static int crashes;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,8 +22,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "clientmodel.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <QX11Info>
|
||||
using namespace KWin;
|
||||
|
||||
void TestTabBoxClientModel::initTestCase()
|
||||
{
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
}
|
||||
|
||||
void TestTabBoxClientModel::testLongestCaptionWithNullClient()
|
||||
{
|
||||
MockTabBoxHandler tabboxhandler;
|
||||
|
|
|
@ -25,6 +25,7 @@ class TestTabBoxClientModel : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
/**
|
||||
* Tests that calculating the longest caption does not
|
||||
* crash in case the internal m_clientList contains a weak
|
||||
|
|
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "mock_tabboxhandler.h"
|
||||
#include "clientmodel.h"
|
||||
#include <QtTest/QtTest>
|
||||
#include <QX11Info>
|
||||
|
||||
using namespace KWin;
|
||||
|
||||
|
@ -27,6 +28,7 @@ class TestTabBoxHandler : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
/**
|
||||
* Test to verify that update outline does not crash
|
||||
* if the ModelIndex for which the outline should be
|
||||
|
@ -37,6 +39,11 @@ private slots:
|
|||
void testDontCrashUpdateOutlineNullClient();
|
||||
};
|
||||
|
||||
void TestTabBoxHandler::initTestCase()
|
||||
{
|
||||
qApp->setProperty("x11Connection", QVariant::fromValue<void*>(QX11Info::connection()));
|
||||
}
|
||||
|
||||
void TestTabBoxHandler::testDontCrashUpdateOutlineNullClient()
|
||||
{
|
||||
MockTabBoxHandler tabboxhandler;
|
||||
|
|
Loading…
Reference in a new issue