summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.cpp
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2014-09-24 18:14:22 +0400
committerAlexander Volkov <a.volkov@rusbitech.ru>2014-10-29 10:03:55 +0100
commit100ed0c01d7678a97e3b7b3a46320d84b3a7096d (patch)
tree6f48ed8cbc70e418cc9c709c7ad76aee228267a0 /src/plugins/platforms/xcb/qxcbconnection.cpp
parent6c38a82aa8165bbe3cbdc7f17e67999439842c29 (diff)
xcb: Fix getting the primary screen from QXcbConnection::screens()
Currently getting QXcbScreen* for primary screen is too messy and it wrongly uses QXcbConnection::primaryScreen() as an index in QXcbConnection::screens() although QXcbConnection::screens() returns the primary screen as the first item in the list since 3c8eb404877df9c967d81fa9df7d718c538fb407. So to clear the API rename primaryScreen() to primaryScreenNumber(), add QXcbConnection::primaryScreen() that returns correct QXcbScreen* and use it directly. Change-Id: Icb7391aa3e82b32ca48f2bda764dcf7ffd89cc47 Reviewed-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 835c414d85..5510c3b1b4 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -244,7 +244,7 @@ void QXcbConnection::updateScreens()
// the first or an exact match. An exact match isn't
// always available if primary->output is XCB_NONE
// or currently disconnected output.
- if (m_primaryScreen == xcbScreenNumber) {
+ if (m_primaryScreenNumber == xcbScreenNumber) {
if (!primaryScreen || (primary && outputs[i] == primary->output)) {
primaryScreen = screen;
siblings.prepend(siblings.takeLast());
@@ -306,7 +306,7 @@ void QXcbConnection::updateScreens()
QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, const char *displayName)
: m_connection(0)
, m_canGrabServer(canGrabServer)
- , m_primaryScreen(0)
+ , m_primaryScreenNumber(0)
, m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY"))
, m_nativeInterface(nativeInterface)
, xfixes_first_event(0)
@@ -331,7 +331,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
#ifdef XCB_USE_XLIB
dpy = XOpenDisplay(m_displayName.constData());
if (dpy) {
- m_primaryScreen = DefaultScreen(dpy);
+ m_primaryScreenNumber = DefaultScreen(dpy);
m_connection = XGetXCBConnection(dpy);
XSetEventQueueOwner(dpy, XCBOwnsEventQueue);
XSetErrorHandler(nullErrorHandler);
@@ -339,7 +339,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
m_xlib_display = dpy;
}
#else
- m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreen);
+ m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreenNumber);
#endif //XCB_USE_XLIB
if (!m_connection || xcb_connection_has_error(m_connection))
@@ -449,6 +449,16 @@ QXcbConnection::~QXcbConnection()
delete m_keyboard;
}
+QXcbScreen *QXcbConnection::primaryScreen() const
+{
+ if (!m_screens.isEmpty()) {
+ Q_ASSERT(m_screens.first()->screenNumber() == primaryScreenNumber());
+ return m_screens.first();
+ }
+
+ return Q_NULLPTR;
+}
+
void QXcbConnection::addWindowEventListener(xcb_window_t id, QXcbWindowEventListener *eventListener)
{
m_mapper.insert(id, eventListener);
@@ -1219,7 +1229,7 @@ xcb_timestamp_t QXcbConnection::getTimestamp()
xcb_window_t QXcbConnection::rootWindow()
{
- return screens().at(primaryScreen())->root();
+ return primaryScreen()->root();
}
void QXcbConnection::processXcbEvents()