From 0302b97aea6a686b9d62c2d8c63b736cb9d93128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sun, 6 Sep 2015 16:44:07 +0200 Subject: [PATCH] prevent calling xrandr w/o extension available BUG: 343844 FIXED-IN: 5.5 REVIEW: 125074 --- screens_xrandr.cpp | 4 ++++ useractions.cpp | 51 +++++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/screens_xrandr.cpp b/screens_xrandr.cpp index bd73e6b682..4063846ead 100644 --- a/screens_xrandr.cpp +++ b/screens_xrandr.cpp @@ -42,6 +42,10 @@ void XRandRScreens::update() }; m_geometries.clear(); m_names.clear(); + if (!Xcb::Extensions::self()->isRandrAvailable()) { + fallback(); + return; + } T resources(rootWindow()); if (resources.isNull()) { fallback(); diff --git a/useractions.cpp b/useractions.cpp index 058e1cd5ce..0300b793fb 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -1746,33 +1746,34 @@ void Workspace::slotInvertScreen() using namespace Xcb::RandR; bool succeeded = false; - //BEGIN Xrandr inversion - does atm NOT work with the nvidia blob - ScreenResources res(active_client ? active_client->window() : rootWindow()); + if (Xcb::Extensions::self()->isRandrAvailable()) { + ScreenResources res(active_client ? active_client->window() : rootWindow()); - if (!res.isNull()) { - for (int j = 0; j < res->num_crtcs; ++j) { - auto crtc = res.crtcs()[j]; - CrtcGamma gamma(crtc); - if (gamma.isNull()) { - continue; - } - if (gamma->size) { - qCDebug(KWIN_CORE) << "inverting screen using XRRSetCrtcGamma"; - const int half = gamma->size / 2 + 1; - - uint16_t *red = gamma.red(); - uint16_t *green = gamma.green(); - uint16_t *blue = gamma.blue(); - for (int i = 0; i < half; ++i) { - auto invert = [&gamma, i](uint16_t *ramp) { - qSwap(ramp[i], ramp[gamma->size - 1 - i]); - }; - invert(red); - invert(green); - invert(blue); + if (!res.isNull()) { + for (int j = 0; j < res->num_crtcs; ++j) { + auto crtc = res.crtcs()[j]; + CrtcGamma gamma(crtc); + if (gamma.isNull()) { + continue; + } + if (gamma->size) { + qCDebug(KWIN_CORE) << "inverting screen using xcb_randr_set_crtc_gamma"; + const int half = gamma->size / 2 + 1; + + uint16_t *red = gamma.red(); + uint16_t *green = gamma.green(); + uint16_t *blue = gamma.blue(); + for (int i = 0; i < half; ++i) { + auto invert = [&gamma, i](uint16_t *ramp) { + qSwap(ramp[i], ramp[gamma->size - 1 - i]); + }; + invert(red); + invert(green); + invert(blue); + } + xcb_randr_set_crtc_gamma(connection(), crtc, gamma->size, red, green, blue); + succeeded = true; } - xcb_randr_set_crtc_gamma(connection(), crtc, gamma->size, red, green, blue); - succeeded = true; } } }