diff options
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 76979bf05f..728dd1dd00 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -60,6 +60,7 @@ #include <stdio.h> #include <errno.h> #include <xcb/xfixes.h> +#include <xcb/randr.h> #ifdef XCB_USE_XLIB #include <X11/Xlib.h> @@ -109,7 +110,9 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char , m_has_support_for_dri2(false) #endif , xfixes_first_event(0) + , xrandr_first_event(0) , has_shape_extension(false) + , has_randr_extension(false) , has_input_shape(false) { m_primaryScreen = 0; @@ -160,6 +163,8 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char xcb_screen_iterator_t it = xcb_setup_roots_iterator(m_setup); + initializeXRandr(); + int screenNumber = 0; while (it.rem) { m_screens << new QXcbScreen(this, it.data, screenNumber++); @@ -586,6 +591,15 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) setTime(((xcb_xfixes_selection_notify_event_t *)event)->timestamp); m_clipboard->handleXFixesSelectionRequest((xcb_xfixes_selection_notify_event_t *)event); handled = true; + } else if (has_randr_extension && response_type == xrandr_first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY) { + xcb_randr_screen_change_notify_event_t *change_event = (xcb_randr_screen_change_notify_event_t *)event; + foreach (QXcbScreen *s, m_screens) { + if (s->root() == change_event->root ) { + s->updateRefreshRate(); + break; + } + } + handled = true; } } @@ -1060,6 +1074,31 @@ void QXcbConnection::initializeXRender() #endif } +void QXcbConnection::initializeXRandr() +{ + const xcb_query_extension_reply_t *xrandr_reply = xcb_get_extension_data(m_connection, &xcb_randr_id); + if (!xrandr_reply || !xrandr_reply->present) + return; + + xrandr_first_event = xrandr_reply->first_event; + + xcb_generic_error_t *error = 0; + xcb_randr_query_version_cookie_t xrandr_query_cookie = xcb_randr_query_version(m_connection, + XCB_RANDR_MAJOR_VERSION, + XCB_RANDR_MINOR_VERSION); + + has_randr_extension = true; + + xcb_randr_query_version_reply_t *xrandr_query = xcb_randr_query_version_reply(m_connection, + xrandr_query_cookie, &error); + if (!xrandr_query || error || (xrandr_query->major_version < 1 || (xrandr_query->major_version == 1 && xrandr_query->minor_version < 2))) { + qWarning("QXcbConnection: Failed to initialize XRandr"); + free(error); + has_randr_extension = false; + } + free(xrandr_query); +} + void QXcbConnection::initializeXShape() { const xcb_query_extension_reply_t *xshape_reply = xcb_get_extension_data(m_connection, &xcb_shape_id); |