diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-04-10 12:48:01 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-04-10 15:31:45 +0200 |
commit | 143c4d3e13a430b951f4f4f8c28db14303f80605 (patch) | |
tree | 2b89637b93fc7d81c674106008566010f986d67c /src/plugins/platforms/xcb | |
parent | a7ed81b557d593a8ddb43b71bf4bbf3b44ead070 (diff) | |
parent | e5337ad1b1fb02873ce7b5ca8db45f6fd8063352 (diff) |
Merge remote-tracking branch 'origin/master' into api_changes
Conflicts:
configure
src/widgets/styles/qwindowsxpstyle.cpp
tests/auto/gui/kernel/qwindow/qwindow.pro
tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
Change-Id: I624b6d26abce9874c610c04954c1c45bc074bef3
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbimage.cpp | 9 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbkeyboard.cpp | 31 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.cpp | 69 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 85 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwmsupport.cpp | 10 |
5 files changed, 60 insertions, 144 deletions
diff --git a/src/plugins/platforms/xcb/qxcbimage.cpp b/src/plugins/platforms/xcb/qxcbimage.cpp index 12979bfb68..6a1209e6cf 100644 --- a/src/plugins/platforms/xcb/qxcbimage.cpp +++ b/src/plugins/platforms/xcb/qxcbimage.cpp @@ -84,20 +84,15 @@ QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap const xcb_visualtype_t *visual) { xcb_connection_t *conn = connection->xcb_connection(); - xcb_generic_error_t *error = 0; xcb_get_image_cookie_t get_image_cookie = - xcb_get_image(conn, XCB_IMAGE_FORMAT_Z_PIXMAP, pixmap, + xcb_get_image_unchecked(conn, XCB_IMAGE_FORMAT_Z_PIXMAP, pixmap, 0, 0, width, height, 0xffffffff); xcb_get_image_reply_t *image_reply = - xcb_get_image_reply(conn, get_image_cookie, &error); + xcb_get_image_reply(conn, get_image_cookie, NULL); if (!image_reply) { - if (error) { - connection->handleXcbError(error); - free(error); - } return QPixmap(); } diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index c5e124ab45..ef98f82e97 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -1073,14 +1073,6 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod int count = chars.count(); QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count); - if (inputContext) { - QKeyEvent event(type, qtcode, modifiers, string); - event.setTimestamp(time); - bool retval = inputContext->filterEvent(&event); - if (retval) - return; - } - bool isAutoRepeat = false; if (type == QEvent::KeyPress) { @@ -1099,13 +1091,28 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod m_autorepeat_code = isAutoRepeat ? code : 0; } - QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, - code, 0, state, string.left(count), isAutoRepeat); + bool filtered = false; + if (inputContext) { + QKeyEvent event(type, qtcode, modifiers, string, isAutoRepeat); + event.setTimestamp(time); + filtered = inputContext->filterEvent(&event); + } + + if (!filtered) + QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, + code, 0, state, string.left(count), isAutoRepeat); if (isAutoRepeat && type == QEvent::KeyRelease) { // since we removed it from the event queue using checkEvent we need to send the key press here - QWindowSystemInterface::handleExtendedKeyEvent(window, time, QEvent::KeyPress, qtcode, modifiers, - code, 0, state, string.left(count), isAutoRepeat); + filtered = false; + if (inputContext) { + QKeyEvent event(QEvent::KeyPress, qtcode, modifiers, string, isAutoRepeat); + event.setTimestamp(time); + filtered = inputContext->filterEvent(&event); + } + if (!filtered) + QWindowSystemInterface::handleExtendedKeyEvent(window, time, QEvent::KeyPress, qtcode, modifiers, + code, 0, state, string.left(count), isAutoRepeat); } } diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index a076dd4282..ae5e4cce34 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -76,13 +76,11 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int num xcb_change_window_attributes(xcb_connection(), screen->root, mask, values); - xcb_generic_error_t *error; - xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), - xcb_get_property(xcb_connection(), false, screen->root, + xcb_get_property_unchecked(xcb_connection(), false, screen->root, atom(QXcbAtom::_NET_SUPPORTING_WM_CHECK), - XCB_ATOM_WINDOW, 0, 1024), &error); + XCB_ATOM_WINDOW, 0, 1024), NULL); if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) { xcb_window_t windowManager = *((xcb_window_t *)xcb_get_property_value(reply)); @@ -90,24 +88,18 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int num if (windowManager != XCB_WINDOW_NONE) { xcb_get_property_reply_t *windowManagerReply = xcb_get_property_reply(xcb_connection(), - xcb_get_property(xcb_connection(), false, windowManager, + xcb_get_property_unchecked(xcb_connection(), false, windowManager, atom(QXcbAtom::_NET_WM_NAME), - atom(QXcbAtom::UTF8_STRING), 0, 1024), &error); + atom(QXcbAtom::UTF8_STRING), 0, 1024), NULL); if (windowManagerReply && windowManagerReply->format == 8 && windowManagerReply->type == atom(QXcbAtom::UTF8_STRING)) { m_windowManagerName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply)); #ifdef Q_XCB_DEBUG qDebug("Running window manager: %s", qPrintable(m_windowManagerName)); #endif - } else if (error) { - connection->handleXcbError(error); - free(error); } free(windowManagerReply); } - } else if (error) { - connection->handleXcbError(error); - free(error); } free(reply); @@ -171,23 +163,17 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const int x = p.x(); int y = p.y(); - xcb_generic_error_t *error; - xcb_window_t parent = root; xcb_window_t child = root; do { xcb_translate_coordinates_cookie_t translate_cookie = - xcb_translate_coordinates(xcb_connection(), parent, child, x, y); + xcb_translate_coordinates_unchecked(xcb_connection(), parent, child, x, y); xcb_translate_coordinates_reply_t *translate_reply = - xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, &error); + xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, NULL); if (!translate_reply) { - if (error) { - connection()->handleXcbError(error); - free(error); - } return 0; } @@ -252,17 +238,12 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) if (width == 0 || height == 0) return QPixmap(); - xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry(xcb_connection(), window); + xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), window); - xcb_generic_error_t *error; xcb_get_geometry_reply_t *reply = - xcb_get_geometry_reply(xcb_connection(), geometry_cookie, &error); + xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL); if (!reply) { - if (error) { - connection()->handleXcbError(error); - free(error); - } return QPixmap(); } @@ -274,15 +255,11 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) // TODO: handle multiple screens QXcbScreen *screen = const_cast<QXcbScreen *>(this); xcb_window_t root = screen->root(); - geometry_cookie = xcb_get_geometry(xcb_connection(), root); + geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), root); xcb_get_geometry_reply_t *root_reply = - xcb_get_geometry_reply(xcb_connection(), geometry_cookie, &error); + xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL); if (!root_reply) { - if (error) { - connection()->handleXcbError(error); - free(error); - } free(reply); return QPixmap(); } @@ -294,16 +271,12 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) // map x and y to the root window xcb_translate_coordinates_cookie_t translate_cookie = - xcb_translate_coordinates(xcb_connection(), window, root, x, y); + xcb_translate_coordinates_unchecked(xcb_connection(), window, root, x, y); xcb_translate_coordinates_reply_t *translate_reply = - xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, &error); + xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, NULL); if (!translate_reply) { - if (error) { - connection()->handleXcbError(error); - free(error); - } free(reply); free(root_reply); return QPixmap(); @@ -323,13 +296,9 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) } xcb_get_window_attributes_reply_t *attributes_reply = - xcb_get_window_attributes_reply(xcb_connection(), xcb_get_window_attributes(xcb_connection(), window), &error); + xcb_get_window_attributes_reply(xcb_connection(), xcb_get_window_attributes_unchecked(xcb_connection(), window), NULL); if (!attributes_reply) { - if (error) { - connection()->handleXcbError(error); - free(error); - } free(reply); return QPixmap(); } @@ -338,11 +307,7 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) free(attributes_reply); xcb_pixmap_t pixmap = xcb_generate_id(xcb_connection()); - error = xcb_request_check(xcb_connection(), xcb_create_pixmap_checked(xcb_connection(), reply->depth, pixmap, window, width, height)); - if (error) { - connection()->handleXcbError(error); - free(error); - } + xcb_create_pixmap(xcb_connection(), reply->depth, pixmap, window, width, height); uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE; uint32_t gc_value_list[] = { XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS }; @@ -350,11 +315,7 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) xcb_gcontext_t gc = xcb_generate_id(xcb_connection()); xcb_create_gc(xcb_connection(), gc, pixmap, gc_value_mask, gc_value_list); - error = xcb_request_check(xcb_connection(), xcb_copy_area_checked(xcb_connection(), window, pixmap, gc, x, y, 0, 0, width, height)); - if (error) { - connection()->handleXcbError(error); - free(error); - } + xcb_copy_area(xcb_connection(), window, pixmap, gc, x, y, 0, 0, width, height); QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, reply->depth, visual); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 458ba8f07f..f328c2f2f8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -66,6 +66,7 @@ #ifdef XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS #define xcb_get_wm_hints_reply xcb_icccm_get_wm_hints_reply #define xcb_get_wm_hints xcb_icccm_get_wm_hints +#define xcb_get_wm_hints_unchecked xcb_icccm_get_wm_hints_unchecked #define xcb_set_wm_hints xcb_icccm_set_wm_hints #define xcb_set_wm_normal_hints xcb_icccm_set_wm_normal_hints #define xcb_size_hints_set_base_size xcb_icccm_size_hints_set_base_size @@ -422,10 +423,9 @@ QMargins QXcbWindow::frameMargins() const connection()->wmSupport()->virtualRoots(); while (!foundRoot) { - xcb_query_tree_cookie_t cookie = xcb_query_tree(xcb_connection(), parent); + xcb_query_tree_cookie_t cookie = xcb_query_tree_unchecked(xcb_connection(), parent); - xcb_generic_error_t *error; - xcb_query_tree_reply_t *reply = xcb_query_tree_reply(xcb_connection(), cookie, &error); + xcb_query_tree_reply_t *reply = xcb_query_tree_reply(xcb_connection(), cookie, NULL); if (reply) { if (reply->root == reply->parent || virtualRoots.indexOf(reply->parent) != -1) { foundRoot = true; @@ -436,11 +436,6 @@ QMargins QXcbWindow::frameMargins() const free(reply); } else { - if (error) { - connection()->handleXcbError(error); - free(error); - } - m_dirtyFrameMargins = false; m_frameMargins = QMargins(); return m_frameMargins; @@ -449,25 +444,22 @@ QMargins QXcbWindow::frameMargins() const QPoint offset; - xcb_generic_error_t *error; xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply( xcb_connection(), xcb_translate_coordinates(xcb_connection(), window, parent, 0, 0), - &error); + NULL); if (reply) { offset = QPoint(reply->dst_x, reply->dst_y); free(reply); - } else if (error) { - free(error); } xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply( xcb_connection(), xcb_get_geometry(xcb_connection(), parent), - &error); + NULL); if (geom) { // -- @@ -487,8 +479,6 @@ QMargins QXcbWindow::frameMargins() const m_frameMargins = QMargins(left, top, right, bottom); free(geom); - } else if (error) { - free(error); } m_dirtyFrameMargins = false; @@ -508,17 +498,10 @@ void QXcbWindow::setVisible(bool visible) void QXcbWindow::show() { if (window()->isTopLevel()) { - xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window); - - xcb_generic_error_t *error; + xcb_get_property_cookie_t cookie = xcb_get_wm_hints_unchecked(xcb_connection(), m_window); xcb_wm_hints_t hints; - xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error); - - if (error) { - connection()->handleXcbError(error); - free(error); - } + xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, NULL); if (window()->windowState() & Qt::WindowMinimized) xcb_wm_hints_set_iconic(&hints); @@ -618,20 +601,15 @@ static QtMotifWmHints getMotifWmHints(QXcbConnection *c, xcb_window_t window) QtMotifWmHints hints; xcb_get_property_cookie_t get_cookie = - xcb_get_property(c->xcb_connection(), 0, window, c->atom(QXcbAtom::_MOTIF_WM_HINTS), + xcb_get_property_unchecked(c->xcb_connection(), 0, window, c->atom(QXcbAtom::_MOTIF_WM_HINTS), c->atom(QXcbAtom::_MOTIF_WM_HINTS), 0, 20); - xcb_generic_error_t *error; - xcb_get_property_reply_t *reply = - xcb_get_property_reply(c->xcb_connection(), get_cookie, &error); + xcb_get_property_reply(c->xcb_connection(), get_cookie, NULL); if (reply && reply->format == 32 && reply->type == c->atom(QXcbAtom::_MOTIF_WM_HINTS)) { hints = *((QtMotifWmHints *)xcb_get_property_value(reply)); - } else if (error) { - c->handleXcbError(error); - free(error); - + } else { hints.flags = 0L; hints.functions = MWM_FUNC_ALL; hints.decorations = MWM_DECOR_ALL; @@ -685,13 +663,11 @@ QVector<xcb_atom_t> QXcbWindow::getNetWmState() QVector<xcb_atom_t> result; xcb_get_property_cookie_t get_cookie = - xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), + xcb_get_property_unchecked(xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), XCB_ATOM_ATOM, 0, 1024); - xcb_generic_error_t *error; - xcb_get_property_reply_t *reply = - xcb_get_property_reply(xcb_connection(), get_cookie, &error); + xcb_get_property_reply(xcb_connection(), get_cookie, NULL); if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) { result.resize(reply->length); @@ -704,9 +680,6 @@ QVector<xcb_atom_t> QXcbWindow::getNetWmState() #endif free(reply); - } else if (error) { - connection()->handleXcbError(error); - free(error); } else { #ifdef NET_WM_STATE_DEBUG printf("getting net wm state (%x), empty\n", m_window); @@ -1086,16 +1059,10 @@ void QXcbWindow::setTransparentForMouseEvents(bool transparent) void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus) { - xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window); - - xcb_generic_error_t *error; + xcb_get_property_cookie_t cookie = xcb_get_wm_hints_unchecked(xcb_connection(), m_window); xcb_wm_hints_t hints; - xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error); - - if (error) { - connection()->handleXcbError(error); - free(error); + if (!xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, NULL)) { return; } @@ -1316,14 +1283,11 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * // Do not trust the position, query it instead. xcb_translate_coordinates_cookie_t cookie = xcb_translate_coordinates(xcb_connection(), xcb_window(), m_screen->root(), 0, 0); - xcb_generic_error_t *error; - xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(xcb_connection(), cookie, &error); + xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL); if (reply) { pos.setX(reply->dst_x); pos.setY(reply->dst_y); free(reply); - } else if (error) { - free(error); } } @@ -1515,19 +1479,14 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE), XCB_ATOM_ANY, 0, 1024); - xcb_generic_error_t *error; - xcb_get_property_reply_t *reply = - xcb_get_property_reply(xcb_connection(), get_cookie, &error); + xcb_get_property_reply(xcb_connection(), get_cookie, NULL); xcb_atom_t wm_state = XCB_WM_STATE_WITHDRAWN; if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) { if (reply->length != 0) wm_state = ((long *)xcb_get_property_value(reply))[0]; free(reply); - } else if (error) { - connection()->handleXcbError(error); - free(error); } QVector<xcb_atom_t> netWmState = getNetWmState(); @@ -1593,11 +1552,9 @@ bool QXcbWindow::setKeyboardGrabEnabled(bool grab) xcb_grab_keyboard_cookie_t cookie = xcb_grab_keyboard(xcb_connection(), false, m_window, XCB_TIME_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); - xcb_generic_error_t *err; - xcb_grab_keyboard_reply_t *reply = xcb_grab_keyboard_reply(xcb_connection(), cookie, &err); - bool result = !(err || !reply || reply->status != XCB_GRAB_STATUS_SUCCESS); + xcb_grab_keyboard_reply_t *reply = xcb_grab_keyboard_reply(xcb_connection(), cookie, NULL); + bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS); free(reply); - free(err); return result; } @@ -1614,11 +1571,9 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab) XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_WINDOW_NONE, XCB_CURSOR_NONE, XCB_TIME_CURRENT_TIME); - xcb_generic_error_t *err; - xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, &err); - bool result = !(err || !reply || reply->status != XCB_GRAB_STATUS_SUCCESS); + xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, NULL); + bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS); free(reply); - free(err); return result; } diff --git a/src/plugins/platforms/xcb/qxcbwmsupport.cpp b/src/plugins/platforms/xcb/qxcbwmsupport.cpp index c9f4ca69dd..e164c7ae2d 100644 --- a/src/plugins/platforms/xcb/qxcbwmsupport.cpp +++ b/src/plugins/platforms/xcb/qxcbwmsupport.cpp @@ -68,10 +68,9 @@ void QXcbWMSupport::updateNetWMAtoms() int offset = 0; int remaining = 0; do { - xcb_generic_error_t *error = 0; xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_SUPPORTED), XCB_ATOM_ATOM, offset, 1024); - xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, &error); - if (!reply || error) + xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, NULL); + if (!reply) break; remaining = 0; @@ -103,10 +102,9 @@ void QXcbWMSupport::updateVirtualRoots() int offset = 0; int remaining = 0; do { - xcb_generic_error_t *error = 0; xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, root, atom(QXcbAtom::_NET_VIRTUAL_ROOTS), XCB_ATOM_ATOM, offset, 1024); - xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, &error); - if (!reply || error) + xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, NULL); + if (!reply) break; remaining = 0; |