XCB: Simplify xcb error handling

Instead of getting errors just to feed them to the default error handle,
the corresponding unchecked request is used which automatically makes
errors go to the default error handler.

Change-Id: Ib213a860affb72de6f9896f68505e283a809d58f
Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
Uli Schlachter 2012-03-26 21:02:22 +02:00 committed by Qt by Nokia
parent aea0b24d69
commit 0af9217430
4 changed files with 41 additions and 132 deletions

View File

@ -84,20 +84,15 @@ QPixmap qt_xcb_pixmapFromXPixmap(QXcbConnection *connection, xcb_pixmap_t pixmap
const xcb_visualtype_t *visual) const xcb_visualtype_t *visual)
{ {
xcb_connection_t *conn = connection->xcb_connection(); xcb_connection_t *conn = connection->xcb_connection();
xcb_generic_error_t *error = 0;
xcb_get_image_cookie_t get_image_cookie = 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); 0, 0, width, height, 0xffffffff);
xcb_get_image_reply_t *image_reply = 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 (!image_reply) {
if (error) {
connection->handleXcbError(error);
free(error);
}
return QPixmap(); return QPixmap();
} }

View File

@ -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_change_window_attributes(xcb_connection(), screen->root, mask, values);
xcb_generic_error_t *error;
xcb_get_property_reply_t *reply = xcb_get_property_reply_t *reply =
xcb_get_property_reply(xcb_connection(), 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), 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) { if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) {
xcb_window_t windowManager = *((xcb_window_t *)xcb_get_property_value(reply)); 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) { if (windowManager != XCB_WINDOW_NONE) {
xcb_get_property_reply_t *windowManagerReply = xcb_get_property_reply_t *windowManagerReply =
xcb_get_property_reply(xcb_connection(), 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::_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)) { 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)); m_windowManagerName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply));
#ifdef Q_XCB_DEBUG #ifdef Q_XCB_DEBUG
qDebug("Running window manager: %s", qPrintable(m_windowManagerName)); qDebug("Running window manager: %s", qPrintable(m_windowManagerName));
#endif #endif
} else if (error) {
connection->handleXcbError(error);
free(error);
} }
free(windowManagerReply); free(windowManagerReply);
} }
} else if (error) {
connection->handleXcbError(error);
free(error);
} }
free(reply); free(reply);
@ -171,23 +163,17 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const
int x = p.x(); int x = p.x();
int y = p.y(); int y = p.y();
xcb_generic_error_t *error;
xcb_window_t parent = root; xcb_window_t parent = root;
xcb_window_t child = root; xcb_window_t child = root;
do { do {
xcb_translate_coordinates_cookie_t translate_cookie = 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_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 (!translate_reply) {
if (error) {
connection()->handleXcbError(error);
free(error);
}
return 0; return 0;
} }
@ -252,17 +238,12 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height)
if (width == 0 || height == 0) if (width == 0 || height == 0)
return QPixmap(); 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_t *reply =
xcb_get_geometry_reply(xcb_connection(), geometry_cookie, &error); xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL);
if (!reply) { if (!reply) {
if (error) {
connection()->handleXcbError(error);
free(error);
}
return QPixmap(); return QPixmap();
} }
@ -274,15 +255,11 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height)
// TODO: handle multiple screens // TODO: handle multiple screens
QXcbScreen *screen = const_cast<QXcbScreen *>(this); QXcbScreen *screen = const_cast<QXcbScreen *>(this);
xcb_window_t root = screen->root(); 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_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 (!root_reply) {
if (error) {
connection()->handleXcbError(error);
free(error);
}
free(reply); free(reply);
return QPixmap(); 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 // map x and y to the root window
xcb_translate_coordinates_cookie_t translate_cookie = 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_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 (!translate_reply) {
if (error) {
connection()->handleXcbError(error);
free(error);
}
free(reply); free(reply);
free(root_reply); free(root_reply);
return QPixmap(); 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_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 (!attributes_reply) {
if (error) {
connection()->handleXcbError(error);
free(error);
}
free(reply); free(reply);
return QPixmap(); return QPixmap();
} }
@ -338,11 +307,7 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height)
free(attributes_reply); free(attributes_reply);
xcb_pixmap_t pixmap = xcb_generate_id(xcb_connection()); 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)); xcb_create_pixmap(xcb_connection(), reply->depth, pixmap, window, width, height);
if (error) {
connection()->handleXcbError(error);
free(error);
}
uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE; uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE;
uint32_t gc_value_list[] = { XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS }; 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_gcontext_t gc = xcb_generate_id(xcb_connection());
xcb_create_gc(xcb_connection(), gc, pixmap, gc_value_mask, gc_value_list); 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)); xcb_copy_area(xcb_connection(), window, pixmap, gc, x, y, 0, 0, width, height);
if (error) {
connection()->handleXcbError(error);
free(error);
}
QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, reply->depth, visual); QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, reply->depth, visual);

View File

@ -66,6 +66,7 @@
#ifdef XCB_ICCCM_NUM_WM_SIZE_HINTS_ELEMENTS #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_reply xcb_icccm_get_wm_hints_reply
#define xcb_get_wm_hints xcb_icccm_get_wm_hints #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_hints xcb_icccm_set_wm_hints
#define xcb_set_wm_normal_hints xcb_icccm_set_wm_normal_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 #define xcb_size_hints_set_base_size xcb_icccm_size_hints_set_base_size
@ -420,10 +421,9 @@ QMargins QXcbWindow::frameMargins() const
connection()->wmSupport()->virtualRoots(); connection()->wmSupport()->virtualRoots();
while (!foundRoot) { 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, NULL);
xcb_query_tree_reply_t *reply = xcb_query_tree_reply(xcb_connection(), cookie, &error);
if (reply) { if (reply) {
if (reply->root == reply->parent || virtualRoots.indexOf(reply->parent) != -1) { if (reply->root == reply->parent || virtualRoots.indexOf(reply->parent) != -1) {
foundRoot = true; foundRoot = true;
@ -434,11 +434,6 @@ QMargins QXcbWindow::frameMargins() const
free(reply); free(reply);
} else { } else {
if (error) {
connection()->handleXcbError(error);
free(error);
}
m_dirtyFrameMargins = false; m_dirtyFrameMargins = false;
m_frameMargins = QMargins(); m_frameMargins = QMargins();
return m_frameMargins; return m_frameMargins;
@ -447,25 +442,22 @@ QMargins QXcbWindow::frameMargins() const
QPoint offset; QPoint offset;
xcb_generic_error_t *error;
xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply_t *reply =
xcb_translate_coordinates_reply( xcb_translate_coordinates_reply(
xcb_connection(), xcb_connection(),
xcb_translate_coordinates(xcb_connection(), window, parent, 0, 0), xcb_translate_coordinates(xcb_connection(), window, parent, 0, 0),
&error); NULL);
if (reply) { if (reply) {
offset = QPoint(reply->dst_x, reply->dst_y); offset = QPoint(reply->dst_x, reply->dst_y);
free(reply); free(reply);
} else if (error) {
free(error);
} }
xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply_t *geom =
xcb_get_geometry_reply( xcb_get_geometry_reply(
xcb_connection(), xcb_connection(),
xcb_get_geometry(xcb_connection(), parent), xcb_get_geometry(xcb_connection(), parent),
&error); NULL);
if (geom) { if (geom) {
// -- // --
@ -485,8 +477,6 @@ QMargins QXcbWindow::frameMargins() const
m_frameMargins = QMargins(left, top, right, bottom); m_frameMargins = QMargins(left, top, right, bottom);
free(geom); free(geom);
} else if (error) {
free(error);
} }
m_dirtyFrameMargins = false; m_dirtyFrameMargins = false;
@ -506,17 +496,10 @@ void QXcbWindow::setVisible(bool visible)
void QXcbWindow::show() void QXcbWindow::show()
{ {
if (window()->isTopLevel()) { if (window()->isTopLevel()) {
xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window); xcb_get_property_cookie_t cookie = xcb_get_wm_hints_unchecked(xcb_connection(), m_window);
xcb_generic_error_t *error;
xcb_wm_hints_t hints; xcb_wm_hints_t hints;
xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error); xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, NULL);
if (error) {
connection()->handleXcbError(error);
free(error);
}
if (window()->windowState() & Qt::WindowMinimized) if (window()->windowState() & Qt::WindowMinimized)
xcb_wm_hints_set_iconic(&hints); xcb_wm_hints_set_iconic(&hints);
@ -616,20 +599,15 @@ static QtMotifWmHints getMotifWmHints(QXcbConnection *c, xcb_window_t window)
QtMotifWmHints hints; QtMotifWmHints hints;
xcb_get_property_cookie_t get_cookie = 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); c->atom(QXcbAtom::_MOTIF_WM_HINTS), 0, 20);
xcb_generic_error_t *error;
xcb_get_property_reply_t *reply = 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)) { if (reply && reply->format == 32 && reply->type == c->atom(QXcbAtom::_MOTIF_WM_HINTS)) {
hints = *((QtMotifWmHints *)xcb_get_property_value(reply)); hints = *((QtMotifWmHints *)xcb_get_property_value(reply));
} else if (error) { } else {
c->handleXcbError(error);
free(error);
hints.flags = 0L; hints.flags = 0L;
hints.functions = MWM_FUNC_ALL; hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_ALL; hints.decorations = MWM_DECOR_ALL;
@ -683,13 +661,11 @@ QVector<xcb_atom_t> QXcbWindow::getNetWmState()
QVector<xcb_atom_t> result; QVector<xcb_atom_t> result;
xcb_get_property_cookie_t get_cookie = 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_ATOM_ATOM, 0, 1024);
xcb_generic_error_t *error;
xcb_get_property_reply_t *reply = 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) { if (reply && reply->format == 32 && reply->type == XCB_ATOM_ATOM) {
result.resize(reply->length); result.resize(reply->length);
@ -702,9 +678,6 @@ QVector<xcb_atom_t> QXcbWindow::getNetWmState()
#endif #endif
free(reply); free(reply);
} else if (error) {
connection()->handleXcbError(error);
free(error);
} else { } else {
#ifdef NET_WM_STATE_DEBUG #ifdef NET_WM_STATE_DEBUG
printf("getting net wm state (%x), empty\n", m_window); printf("getting net wm state (%x), empty\n", m_window);
@ -1084,16 +1057,10 @@ void QXcbWindow::setTransparentForMouseEvents(bool transparent)
void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus) void QXcbWindow::updateDoesNotAcceptFocus(bool doesNotAcceptFocus)
{ {
xcb_get_property_cookie_t cookie = xcb_get_wm_hints(xcb_connection(), m_window); xcb_get_property_cookie_t cookie = xcb_get_wm_hints_unchecked(xcb_connection(), m_window);
xcb_generic_error_t *error;
xcb_wm_hints_t hints; xcb_wm_hints_t hints;
xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, &error); if (!xcb_get_wm_hints_reply(xcb_connection(), cookie, &hints, NULL)) {
if (error) {
connection()->handleXcbError(error);
free(error);
return; return;
} }
@ -1314,14 +1281,11 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
// Do not trust the position, query it instead. // Do not trust the position, query it instead.
xcb_translate_coordinates_cookie_t cookie = xcb_translate_coordinates(xcb_connection(), xcb_window(), xcb_translate_coordinates_cookie_t cookie = xcb_translate_coordinates(xcb_connection(), xcb_window(),
m_screen->root(), 0, 0); m_screen->root(), 0, 0);
xcb_generic_error_t *error; xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(xcb_connection(), cookie, NULL);
xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(xcb_connection(), cookie, &error);
if (reply) { if (reply) {
pos.setX(reply->dst_x); pos.setX(reply->dst_x);
pos.setY(reply->dst_y); pos.setY(reply->dst_y);
free(reply); free(reply);
} else if (error) {
free(error);
} }
} }
@ -1498,19 +1462,14 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE), xcb_get_property(xcb_connection(), 0, m_window, atom(QXcbAtom::WM_STATE),
XCB_ATOM_ANY, 0, 1024); XCB_ATOM_ANY, 0, 1024);
xcb_generic_error_t *error;
xcb_get_property_reply_t *reply = 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; xcb_atom_t wm_state = XCB_WM_STATE_WITHDRAWN;
if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) { if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
if (reply->length != 0) if (reply->length != 0)
wm_state = ((long *)xcb_get_property_value(reply))[0]; wm_state = ((long *)xcb_get_property_value(reply))[0];
free(reply); free(reply);
} else if (error) {
connection()->handleXcbError(error);
free(error);
} }
QVector<xcb_atom_t> netWmState = getNetWmState(); QVector<xcb_atom_t> netWmState = getNetWmState();
@ -1576,11 +1535,9 @@ bool QXcbWindow::setKeyboardGrabEnabled(bool grab)
xcb_grab_keyboard_cookie_t cookie = xcb_grab_keyboard(xcb_connection(), false, xcb_grab_keyboard_cookie_t cookie = xcb_grab_keyboard(xcb_connection(), false,
m_window, XCB_TIME_CURRENT_TIME, m_window, XCB_TIME_CURRENT_TIME,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); 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, NULL);
xcb_grab_keyboard_reply_t *reply = xcb_grab_keyboard_reply(xcb_connection(), cookie, &err); bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS);
bool result = !(err || !reply || reply->status != XCB_GRAB_STATUS_SUCCESS);
free(reply); free(reply);
free(err);
return result; return result;
} }
@ -1597,11 +1554,9 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab)
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
XCB_WINDOW_NONE, XCB_CURSOR_NONE, XCB_WINDOW_NONE, XCB_CURSOR_NONE,
XCB_TIME_CURRENT_TIME); XCB_TIME_CURRENT_TIME);
xcb_generic_error_t *err; xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, NULL);
xcb_grab_pointer_reply_t *reply = xcb_grab_pointer_reply(xcb_connection(), cookie, &err); bool result = !(!reply || reply->status != XCB_GRAB_STATUS_SUCCESS);
bool result = !(err || !reply || reply->status != XCB_GRAB_STATUS_SUCCESS);
free(reply); free(reply);
free(err);
return result; return result;
} }

View File

@ -68,10 +68,9 @@ void QXcbWMSupport::updateNetWMAtoms()
int offset = 0; int offset = 0;
int remaining = 0; int remaining = 0;
do { 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_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); xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, NULL);
if (!reply || error) if (!reply)
break; break;
remaining = 0; remaining = 0;
@ -103,10 +102,9 @@ void QXcbWMSupport::updateVirtualRoots()
int offset = 0; int offset = 0;
int remaining = 0; int remaining = 0;
do { 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_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); xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), cookie, NULL);
if (!reply || error) if (!reply)
break; break;
remaining = 0; remaining = 0;