You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
powerdevil/0001-XRandRBrightness-Don-t...

39 lines
1.3 KiB

From dde0ecce02259a26655737e6674950e2e303bc6f Mon Sep 17 00:00:00 2001
From: Kai Uwe Broulik <kde@privat.broulik.de>
Date: Sun, 13 Dec 2015 21:15:44 +0100
Subject: [PATCH 1/2] [XRandRBrightness] Don't call for xrandr if it's not
available
Check whether the extension is available before calling into it.
REVIEW: 126146
BUG: 352462
FIXED-IN: 5.5.1
---
daemon/backends/upower/xrandrbrightness.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/daemon/backends/upower/xrandrbrightness.cpp b/daemon/backends/upower/xrandrbrightness.cpp
index 0abcefe..f899400 100644
--- a/daemon/backends/upower/xrandrbrightness.cpp
+++ b/daemon/backends/upower/xrandrbrightness.cpp
@@ -29,6 +29,15 @@ XRandrBrightness::XRandrBrightness()
if (!QX11Info::isPlatformX11()) {
return;
}
+
+ xcb_prefetch_extension_data(QX11Info::connection(), &xcb_randr_id);
+ // this reply, for once, does not need to be managed by us
+ auto *extension = xcb_get_extension_data(QX11Info::connection(), &xcb_randr_id);
+ if (!extension || !extension->present) {
+ qCWarning(POWERDEVIL) << "XRandR extension not available";
+ return;
+ }
+
ScopedCPointer<xcb_randr_query_version_reply_t> versionReply(xcb_randr_query_version_reply(QX11Info::connection(),
xcb_randr_query_version(QX11Info::connection(), 1, 2),
nullptr));
--
2.5.0