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.
72 lines
2.9 KiB
72 lines
2.9 KiB
From 284ca7af172ea94a3fb8a631b220db50f1da7b91 Mon Sep 17 00:00:00 2001
|
|
From: Kai Uwe Broulik <kde@privat.broulik.de>
|
|
Date: Sun, 13 Dec 2015 21:16:49 +0100
|
|
Subject: [PATCH 2/2] [XRandRBrightness] Cache XCB connection in variable
|
|
|
|
QX11Info::connection() is expensive
|
|
---
|
|
daemon/backends/upower/xrandrbrightness.cpp | 20 +++++++++++---------
|
|
1 file changed, 11 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/daemon/backends/upower/xrandrbrightness.cpp b/daemon/backends/upower/xrandrbrightness.cpp
|
|
index f899400..586801c 100644
|
|
--- a/daemon/backends/upower/xrandrbrightness.cpp
|
|
+++ b/daemon/backends/upower/xrandrbrightness.cpp
|
|
@@ -30,16 +30,18 @@ XRandrBrightness::XRandrBrightness()
|
|
return;
|
|
}
|
|
|
|
- xcb_prefetch_extension_data(QX11Info::connection(), &xcb_randr_id);
|
|
+ auto *c = QX11Info::connection();
|
|
+
|
|
+ xcb_prefetch_extension_data(c, &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);
|
|
+ auto *extension = xcb_get_extension_data(c, &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),
|
|
+ ScopedCPointer<xcb_randr_query_version_reply_t> versionReply(xcb_randr_query_version_reply(c,
|
|
+ xcb_randr_query_version(c, 1, 2),
|
|
nullptr));
|
|
|
|
if (!versionReply) {
|
|
@@ -52,8 +54,8 @@ XRandrBrightness::XRandrBrightness()
|
|
return;
|
|
}
|
|
|
|
- ScopedCPointer<xcb_intern_atom_reply_t> backlightReply(xcb_intern_atom_reply(QX11Info::connection(),
|
|
- xcb_intern_atom (QX11Info::connection(), 1, strlen("Backlight"), "Backlight"),
|
|
+ ScopedCPointer<xcb_intern_atom_reply_t> backlightReply(xcb_intern_atom_reply(c,
|
|
+ xcb_intern_atom(c, 1, strlen("Backlight"), "Backlight"),
|
|
nullptr));
|
|
|
|
if (!backlightReply) {
|
|
@@ -68,7 +70,7 @@ XRandrBrightness::XRandrBrightness()
|
|
return;
|
|
}
|
|
|
|
- xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(QX11Info::connection()));
|
|
+ xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(c));
|
|
if (!iter.rem) {
|
|
qCWarning(POWERDEVIL, "XCB Screen Roots Iterator rem was null");
|
|
return;
|
|
@@ -77,8 +79,8 @@ XRandrBrightness::XRandrBrightness()
|
|
xcb_screen_t *screen = iter.data;
|
|
xcb_window_t root = screen->root;
|
|
|
|
- m_resources.reset(xcb_randr_get_screen_resources_current_reply(QX11Info::connection(),
|
|
- xcb_randr_get_screen_resources_current(QX11Info::connection(), root)
|
|
+ m_resources.reset(xcb_randr_get_screen_resources_current_reply(c,
|
|
+ xcb_randr_get_screen_resources_current(c, root)
|
|
, nullptr));
|
|
|
|
if (!m_resources) {
|
|
--
|
|
2.5.0
|
|
|