From 2dcbbd6a3a8da998be415818bc45e8d10d4aa26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 11 Feb 2013 15:52:36 +0100 Subject: [PATCH] Move detection for defaultDepth to xcbutils --- outline.cpp | 12 +----------- xcbutils.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/outline.cpp b/outline.cpp index 708ceb42f9..1fcabed0c9 100644 --- a/outline.cpp +++ b/outline.cpp @@ -96,17 +96,7 @@ void Outline::showWithX() m_initialized = true; } - int screen = QX11Info::appScreen(); - int defaultDepth = 0; - // TODO: move into xcbutils or maybe kwinglobals - for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(connection())); - it.rem; - --screen, xcb_screen_next(&it)) { - if (screen == 0) { - defaultDepth = it.data->root_depth; - break; - } - } + const int defaultDepth = Xcb::defaultDepth(); // left/right parts are between top/bottom, they don't reach as far as the corners const uint16_t verticalWidth = 5; diff --git a/xcbutils.h b/xcbutils.h index 60a770364e..488d746075 100644 --- a/xcbutils.h +++ b/xcbutils.h @@ -512,6 +512,24 @@ static inline void restackWindowsWithRaise(const QVector &windows) restackWindows(windows); } +static inline int defaultDepth() +{ + static int depth = 0; + if (depth != 0) { + return depth; + } + int screen = QX11Info::appScreen(); + for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(connection())); + it.rem; + --screen, xcb_screen_next(&it)) { + if (screen == 0) { + depth = it.data->root_depth; + break; + } + } + return depth; +} + } // namespace X11 } // namespace KWin