From 3d17542cde70df0ba5df06c57538c7b6877b6c72 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 28 Jun 2018 14:58:56 +0200 Subject: xcb: move XSync extensions initialization to QXcbConnection ... where we do initialization of all other extensions. Having this code in QXcbVirtualDesktop does not make sense. Change-Id: I3bf3034b4a24e06aa5792e7d49133f46c5728b07 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 10 ++++++++++ src/plugins/platforms/xcb/qxcbconnection.h | 3 +++ src/plugins/platforms/xcb/qxcbscreen.cpp | 6 ------ src/plugins/platforms/xcb/qxcbscreen.h | 3 --- src/plugins/platforms/xcb/qxcbwindow.cpp | 14 ++++++-------- src/plugins/platforms/xcb/qxcbwindow.h | 1 - 6 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index c0e6d793e9..4ffeb4ff77 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -590,6 +590,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeAllAtoms(); + initializeXSync(); initializeShm(); if (!qEnvironmentVariableIsSet("QT_XCB_NO_XRANDR")) initializeXRandr(); @@ -2248,6 +2249,15 @@ void QXcbConnection::initializeXKB() #endif } +void QXcbConnection::initializeXSync() +{ + const xcb_query_extension_reply_t *reply = xcb_get_extension_data(xcb_connection(), &xcb_sync_id); + if (!reply || !reply->present) + return; + + has_sync_extension = true; +} + QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const { if (!m_systemTrayTracker) { diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 3a6c9db69c..3a2aee873d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -475,6 +475,7 @@ public: bool hasXInput2() const { return m_xi2Enabled; } bool hasShm() const { return has_shm; } bool hasShmFd() const { return has_shm_fd; } + bool hasXSync() const { return has_sync_extension; } bool threadedEventHandling() const { return m_reader->isRunning(); } @@ -548,6 +549,7 @@ private: void initializeXinerama(); void initializeXShape(); void initializeXKB(); + void initializeXSync(); void handleClientMessageEvent(const xcb_client_message_event_t *event); QXcbScreen* findScreenForCrtc(xcb_window_t rootWindow, xcb_randr_crtc_t crtc) const; QXcbScreen* findScreenForOutput(xcb_window_t rootWindow, xcb_randr_output_t output) const; @@ -694,6 +696,7 @@ private: bool has_render_extension = false; bool has_shm = false; bool has_shm_fd = false; + bool has_sync_extension = false; QPair m_xrenderVersion; diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index e1bd8eb752..3b440bbb71 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -95,12 +95,6 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t m_windowManagerName = QXcbWindow::windowTitle(connection, windowManager); } - const xcb_query_extension_reply_t *sync_reply = xcb_get_extension_data(xcb_connection(), &xcb_sync_id); - if (!sync_reply || !sync_reply->present) - m_syncRequestSupported = false; - else - m_syncRequestSupported = true; - xcb_depth_iterator_t depth_iterator = xcb_screen_allowed_depths_iterator(screen); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 4a9b1bd209..664d972777 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -99,7 +99,6 @@ public: int antialiasingEnabled() const { return m_antialiasingEnabled; } QString windowManagerName() const { return m_windowManagerName; } - bool syncRequestSupported() const { return m_syncRequestSupported; } QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &format) const; @@ -130,7 +129,6 @@ private: QFontEngine::SubpixelAntialiasingType m_subpixelType = QFontEngine::SubpixelAntialiasingType(-1); int m_antialiasingEnabled = -1; QString m_windowManagerName; - bool m_syncRequestSupported = false; QMap m_visuals; QMap m_visualDepths; }; @@ -187,7 +185,6 @@ public: void windowShown(QXcbWindow *window); QString windowManagerName() const { return m_virtualDesktop->windowManagerName(); } - bool syncRequestSupported() const { return m_virtualDesktop->syncRequestSupported(); } QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &format) const; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 7297887559..3c2d4edc4d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -446,9 +446,7 @@ void QXcbWindow::create() properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); - m_usingSyncProtocol = platformScreen->syncRequestSupported(); - - if (m_usingSyncProtocol) + if (connection()->hasXSync()) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); if (window()->flags() & Qt::WindowContextHelpButtonHint) @@ -472,7 +470,7 @@ void QXcbWindow::create() XCB_ATOM_STRING, 8, wmClass.size(), wmClass.constData()); } - if (m_usingSyncProtocol) { + if (connection()->hasXSync()) { m_syncCounter = xcb_generate_id(xcb_connection()); xcb_sync_create_counter(xcb_connection(), m_syncCounter, m_syncValue); @@ -575,7 +573,7 @@ void QXcbWindow::destroy() if (connection()->mouseGrabber() == this) connection()->setMouseGrabber(nullptr); - if (m_syncCounter && m_usingSyncProtocol) + if (m_syncCounter && connection()->hasXSync()) xcb_sync_destroy_counter(xcb_connection(), m_syncCounter); if (m_window) { if (m_netWmUserTimeWindow) { @@ -1926,7 +1924,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even connection()->setTime(event->data.data32[1]); m_syncValue.lo = event->data.data32[2]; m_syncValue.hi = event->data.data32[3]; - if (m_usingSyncProtocol) + if (connection()->hasXSync()) m_syncState = SyncReceived; #ifndef QT_NO_WHATSTHIS } else if (protocolAtom == atom(QXcbAtom::_NET_WM_CONTEXT_HELP)) { @@ -2001,7 +1999,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * } m_oldWindowSize = actualGeometry.size(); - if (m_usingSyncProtocol && m_syncState == SyncReceived) + if (connection()->hasXSync() && m_syncState == SyncReceived) m_syncState = SyncAndConfigureReceived; m_dirtyFrameMargins = true; @@ -2474,7 +2472,7 @@ void QXcbWindow::updateSyncRequestCounter() // window manager does not expect a sync event yet. return; } - if (m_usingSyncProtocol && (m_syncValue.lo != 0 || m_syncValue.hi != 0)) { + if (connection()->hasXSync() && (m_syncValue.lo != 0 || m_syncValue.hi != 0)) { xcb_sync_set_counter(xcb_connection(), m_syncCounter, m_syncValue); xcb_flush(xcb_connection()); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index d75f22bb51..49968b2e0d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -255,7 +255,6 @@ protected: bool m_mapped = false; bool m_transparent = false; - bool m_usingSyncProtocol = false; bool m_deferredActivation = false; bool m_embedded = false; bool m_alertState = false; -- cgit v1.2.3