diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-06-01 13:02:57 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-06-01 13:37:44 +0200 |
commit | f05236a40d7ee9299c5855d70e542143a2d342c8 (patch) | |
tree | c782143206780620f9e5ff3036273b494a18fab3 /src/plugins/platforms/xcb/qxcbwindow.cpp | |
parent | ead7c1c33c12a078638202b98be7081a4d008780 (diff) |
Prevent XSetInputFocus BadMatch errors.
The BadMatch errors are generated if XSetInputFocus is called before the
window has been mapped, so we need to set a flag when we get the map
notify event.
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbwindow.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index d46e1407c7..e4f4fd7c0f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -94,6 +94,7 @@ QXcbWindow::QXcbWindow(QWindow *window) , m_window(0) , m_context(0) , m_syncCounter(0) + , m_mapped(false) { m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0)); @@ -278,6 +279,7 @@ void QXcbWindow::destroy() connection()->removeWindow(m_window); Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); } + m_mapped = false; } void QXcbWindow::setGeometry(const QRect &rect) @@ -367,6 +369,8 @@ void QXcbWindow::hide() XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); xcb_flush(xcb_connection()); + + m_mapped = false; } struct QtMotifWmHints { @@ -877,8 +881,10 @@ void QXcbWindow::propagateSizeHints() void QXcbWindow::requestActivateWindow() { - Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, XCB_TIME_CURRENT_TIME)); - connection()->sync(); + if (m_mapped){ + Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, XCB_TIME_CURRENT_TIME)); + connection()->sync(); + } } QPlatformGLContext *QXcbWindow::glContext() const @@ -968,6 +974,12 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * #endif } +void QXcbWindow::handleMapNotifyEvent(const xcb_map_notify_event_t *event) +{ + if (event->window == m_window) + m_mapped = true; +} + static Qt::MouseButtons translateMouseButtons(int s) { Qt::MouseButtons ret = 0; |