prevent calling xrandr w/o extension available
BUG: 343844 FIXED-IN: 5.5 REVIEW: 125074
This commit is contained in:
parent
d04645266c
commit
0302b97aea
2 changed files with 30 additions and 25 deletions
|
@ -42,6 +42,10 @@ void XRandRScreens::update()
|
||||||
};
|
};
|
||||||
m_geometries.clear();
|
m_geometries.clear();
|
||||||
m_names.clear();
|
m_names.clear();
|
||||||
|
if (!Xcb::Extensions::self()->isRandrAvailable()) {
|
||||||
|
fallback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
T resources(rootWindow());
|
T resources(rootWindow());
|
||||||
if (resources.isNull()) {
|
if (resources.isNull()) {
|
||||||
fallback();
|
fallback();
|
||||||
|
|
|
@ -1746,33 +1746,34 @@ void Workspace::slotInvertScreen()
|
||||||
using namespace Xcb::RandR;
|
using namespace Xcb::RandR;
|
||||||
bool succeeded = false;
|
bool succeeded = false;
|
||||||
|
|
||||||
//BEGIN Xrandr inversion - does atm NOT work with the nvidia blob
|
if (Xcb::Extensions::self()->isRandrAvailable()) {
|
||||||
ScreenResources res(active_client ? active_client->window() : rootWindow());
|
ScreenResources res(active_client ? active_client->window() : rootWindow());
|
||||||
|
|
||||||
if (!res.isNull()) {
|
if (!res.isNull()) {
|
||||||
for (int j = 0; j < res->num_crtcs; ++j) {
|
for (int j = 0; j < res->num_crtcs; ++j) {
|
||||||
auto crtc = res.crtcs()[j];
|
auto crtc = res.crtcs()[j];
|
||||||
CrtcGamma gamma(crtc);
|
CrtcGamma gamma(crtc);
|
||||||
if (gamma.isNull()) {
|
if (gamma.isNull()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (gamma->size) {
|
if (gamma->size) {
|
||||||
qCDebug(KWIN_CORE) << "inverting screen using XRRSetCrtcGamma";
|
qCDebug(KWIN_CORE) << "inverting screen using xcb_randr_set_crtc_gamma";
|
||||||
const int half = gamma->size / 2 + 1;
|
const int half = gamma->size / 2 + 1;
|
||||||
|
|
||||||
uint16_t *red = gamma.red();
|
uint16_t *red = gamma.red();
|
||||||
uint16_t *green = gamma.green();
|
uint16_t *green = gamma.green();
|
||||||
uint16_t *blue = gamma.blue();
|
uint16_t *blue = gamma.blue();
|
||||||
for (int i = 0; i < half; ++i) {
|
for (int i = 0; i < half; ++i) {
|
||||||
auto invert = [&gamma, i](uint16_t *ramp) {
|
auto invert = [&gamma, i](uint16_t *ramp) {
|
||||||
qSwap(ramp[i], ramp[gamma->size - 1 - i]);
|
qSwap(ramp[i], ramp[gamma->size - 1 - i]);
|
||||||
};
|
};
|
||||||
invert(red);
|
invert(red);
|
||||||
invert(green);
|
invert(green);
|
||||||
invert(blue);
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue