[PanelView] Check whether we're X11 before calling QX11Info::connection()

QX11Info::connection() looks up the connection in the QPA.
The Wayland QPA happens to have a property with the same name,
so it happily reinterpret_casts a wl_connection_t* to xcb_connection_t*
and disaster ensues.

Differential Revision: https://phabricator.kde.org/D1718
wilder-5.14
Kai Uwe Broulik 10 years ago
parent f8a381a54a
commit e26f4ee475
  1. 89
      shell/panelview.cpp

@ -560,59 +560,58 @@ void PanelView::restoreAutoHide()
void PanelView::setAutoHideEnabled(bool enabled) void PanelView::setAutoHideEnabled(bool enabled)
{ {
#if HAVE_X11 #if HAVE_X11
xcb_connection_t *c = QX11Info::connection(); if (QX11Info::isPlatformX11()) {
if (!c) { xcb_connection_t *c = QX11Info::connection();
return;
}
const QByteArray effectName = QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"); const QByteArray effectName = QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW");
xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c, false, effectName.length(), effectName.constData()); xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c, false, effectName.length(), effectName.constData());
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, atomCookie, NULL)); QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, atomCookie, NULL));
if (!atom) { if (!atom) {
return; return;
} }
if (!enabled) { if (!enabled) {
xcb_delete_property(c, winId(), atom->atom); xcb_delete_property(c, winId(), atom->atom);
return; return;
} }
KWindowEffects::SlideFromLocation slideLocation = KWindowEffects::NoEdge; KWindowEffects::SlideFromLocation slideLocation = KWindowEffects::NoEdge;
uint32_t value = 0; uint32_t value = 0;
switch (location()) { switch (location()) {
case Plasma::Types::TopEdge: case Plasma::Types::TopEdge:
value = 0; value = 0;
slideLocation = KWindowEffects::TopEdge; slideLocation = KWindowEffects::TopEdge;
break; break;
case Plasma::Types::RightEdge: case Plasma::Types::RightEdge:
value = 1; value = 1;
slideLocation = KWindowEffects::RightEdge; slideLocation = KWindowEffects::RightEdge;
break; break;
case Plasma::Types::BottomEdge: case Plasma::Types::BottomEdge:
value = 2; value = 2;
slideLocation = KWindowEffects::BottomEdge; slideLocation = KWindowEffects::BottomEdge;
break; break;
case Plasma::Types::LeftEdge: case Plasma::Types::LeftEdge:
value = 3; value = 3;
slideLocation = KWindowEffects::LeftEdge; slideLocation = KWindowEffects::LeftEdge;
break; break;
case Plasma::Types::Floating: case Plasma::Types::Floating:
default: default:
value = 4; value = 4;
break; break;
} }
int hideType = 0; int hideType = 0;
if (m_visibilityMode == LetWindowsCover) { if (m_visibilityMode == LetWindowsCover) {
hideType = 1; hideType = 1;
} }
value |= hideType << 8; value |= hideType << 8;
xcb_change_property(c, XCB_PROP_MODE_REPLACE, winId(), atom->atom, XCB_ATOM_CARDINAL, 32, 1, &value); xcb_change_property(c, XCB_PROP_MODE_REPLACE, winId(), atom->atom, XCB_ATOM_CARDINAL, 32, 1, &value);
KWindowEffects::slideWindow(winId(), slideLocation, -1); KWindowEffects::slideWindow(winId(), slideLocation, -1);
}
#endif #endif
} }

Loading…
Cancel
Save