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_names.clear();
|
||||
if (!Xcb::Extensions::self()->isRandrAvailable()) {
|
||||
fallback();
|
||||
return;
|
||||
}
|
||||
T resources(rootWindow());
|
||||
if (resources.isNull()) {
|
||||
fallback();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue