Provide x11RootWindow as a property on the KWin::Application

KWin::rootWindow() 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 a root window without depending on
QX11Info.
icc-effect-5.14.5
Martin Gräßlin 2015-02-18 08:31:53 +01:00
parent d66a804bbb
commit fe9873e4b1
9 changed files with 42 additions and 5 deletions

View File

@ -82,6 +82,8 @@ void TestClientMachine::initTestCase()
}
}
freeaddrinfo(res);
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
}
void TestClientMachine::cleanupTestCase()

View File

@ -134,6 +134,7 @@ private Q_SLOTS:
void TestScreenEdges::initTestCase()
{
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
KWin::atoms = new KWin::Atoms;
qRegisterMetaType<KWin::ElectricBorder>();
}

View File

@ -35,6 +35,7 @@ class TestXcbSizeHints : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testSizeHints_data();
@ -48,6 +49,11 @@ private:
Window m_testWindow;
};
void TestXcbSizeHints::initTestCase()
{
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
}
void TestXcbSizeHints::init()
{
const uint32_t values[] = { true };

View File

@ -32,6 +32,7 @@ class TestXcbWindow : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void defaultCtor();
void ctor();
void classCtor();
@ -42,6 +43,11 @@ private Q_SLOTS:
void destroyNotManaged();
};
void TestXcbWindow::initTestCase()
{
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
}
void TestXcbWindow::defaultCtor()
{
Xcb::Window window;

View File

@ -34,6 +34,7 @@ class TestXcbWrapper : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void defaultCtor();
@ -60,6 +61,11 @@ private:
Window m_testWindow;
};
void TestXcbWrapper::initTestCase()
{
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(QX11Info::appRootWindow()));
}
void TestXcbWrapper::init()
{
const uint32_t values[] = { true };

View File

@ -39,10 +39,6 @@ QPoint Cursor::pos()
static xcb_window_t s_rootWindow = XCB_WINDOW_NONE;
static xcb_connection_t *s_connection = nullptr;
unsigned long QX11Info::appRootWindow(int)
{
return s_rootWindow;
}
xcb_connection_t *QX11Info::connection()
{
return s_connection;
@ -101,6 +97,7 @@ void TestXRandRScreens::initTestCase()
}
}
QVERIFY(s_rootWindow != XCB_WINDOW_NONE);
qApp->setProperty("x11RootWindow", QVariant::fromValue<quint32>(s_rootWindow));
// get the extensions
if (!Extensions::self()->isRandrAvailable()) {

View File

@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QCoreApplication>
#include <QVariant>
#include <QtX11Extras/QX11Info>
#include <QCoreApplication>
#include <QVariant>
#include <kwin_export.h>
@ -150,7 +152,7 @@ KWIN_EXPORT xcb_window_t rootWindow()
{
static xcb_window_t s_rootWindow = XCB_WINDOW_NONE;
if (s_rootWindow == XCB_WINDOW_NONE) {
s_rootWindow = QX11Info::appRootWindow();
s_rootWindow = qApp->property("x11RootWindow").value<quint32>();
}
return s_rootWindow;
}

View File

@ -148,6 +148,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
, m_configLock(false)
, m_operationMode(mode)
{
setX11RootWindow(QX11Info::appRootWindow());
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
}

16
main.h
View File

@ -46,6 +46,7 @@ class KWIN_EXPORT Application : public QApplication
{
Q_OBJECT
Q_PROPERTY(quint32 x11Time READ x11Time WRITE setX11Time)
Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT)
public:
/**
* @brief This enum provides the various operation modes of KWin depending on the available
@ -119,6 +120,13 @@ public:
*/
static void setX11MultiHead(bool multiHead);
/**
* @returns the X11 root window.
**/
xcb_window_t x11RootWindow() const {
return m_rootWindow;
}
static void setupMalloc();
static void setupLocalizedString();
static void setupLoggingCategoryFilters();
@ -136,6 +144,13 @@ protected:
void createOptions();
void setupEventFilters();
void destroyWorkspace();
/**
* Inheriting classes should use this method to set the X11 root window
* before accessing any X11 specific code pathes.
**/
void setX11RootWindow(xcb_window_t root) {
m_rootWindow = root;
}
bool notify(QObject* o, QEvent* e);
static void crashHandler(int signal);
@ -149,6 +164,7 @@ private:
bool m_configLock;
OperationMode m_operationMode;
xcb_timestamp_t m_x11Time = XCB_TIME_CURRENT_TIME;
xcb_window_t m_rootWindow = XCB_WINDOW_NONE;
static int crashes;
};