Protect readProperty and deleteProperty in case of no X11

Summary:
Read(Window)Property and deleteProperty should only operate if there is
an X11 connection available.

In addition the methods are changed to the x11 wrappers provided on the
KWin::Application as that one can support restarting XWayland in opposite
to the global methods.

Test Plan: Compiles

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7651
This commit is contained in:
Martin Flöser 2017-09-02 10:04:15 +02:00
parent 536739f095
commit 4db4fa42f7

View file

@ -90,7 +90,7 @@ static void deleteWindowProperty(Window win, long int atom)
if (win == XCB_WINDOW_NONE) { if (win == XCB_WINDOW_NONE) {
return; return;
} }
xcb_delete_property(connection(), win, atom); xcb_delete_property(kwinApp()->x11Connection(), win, atom);
} }
static xcb_atom_t registerSupportProperty(const QByteArray &propertyName) static xcb_atom_t registerSupportProperty(const QByteArray &propertyName)
@ -867,7 +867,10 @@ void EffectsHandlerImpl::removeSupportProperty(const QByteArray &propertyName, E
QByteArray EffectsHandlerImpl::readRootProperty(long atom, long type, int format) const QByteArray EffectsHandlerImpl::readRootProperty(long atom, long type, int format) const
{ {
return readWindowProperty(rootWindow(), atom, type, format); if (!kwinApp()->x11Connection()) {
return QByteArray();
}
return readWindowProperty(kwinApp()->x11RootWindow(), atom, type, format);
} }
void EffectsHandlerImpl::activateWindow(EffectWindow* c) void EffectsHandlerImpl::activateWindow(EffectWindow* c)
@ -1737,12 +1740,17 @@ QRect EffectWindowImpl::decorationInnerRect() const
QByteArray EffectWindowImpl::readProperty(long atom, long type, int format) const QByteArray EffectWindowImpl::readProperty(long atom, long type, int format) const
{ {
if (!kwinApp()->x11Connection()) {
return QByteArray();
}
return readWindowProperty(window()->window(), atom, type, format); return readWindowProperty(window()->window(), atom, type, format);
} }
void EffectWindowImpl::deleteProperty(long int atom) const void EffectWindowImpl::deleteProperty(long int atom) const
{ {
deleteWindowProperty(window()->window(), atom); if (kwinApp()->x11Connection()) {
deleteWindowProperty(window()->window(), atom);
}
} }
EffectWindow* EffectWindowImpl::findModal() EffectWindow* EffectWindowImpl::findModal()