From d86e101d1bbee6865aa78f131a072e732e2136ae Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Mar 2012 17:31:57 +0100 Subject: [PATCH] xcb: fix (negative) coordinate handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason, XCB accepts positions as unsigned integers, even though the X protocol explicitly allows negative values (windows overlapping the left/top screen border). After discussion with Samuel and Laszlo, use a reinterpret_cast to convert from the signed representation to the unsigned one. I also extended the clipping of the extents to the position. I guess if X can't handle widths beyond XCOORD_MAX, it won't be happy with x-coordinates exceeding that limit, either. Change-Id: I2fa0e61f823b6cd45dad6471eaa55f38bb3c3e52 Reviewed-by: Samuel Rødal Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbwindow.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 02bfb87d6e..91337adb4e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -396,12 +396,14 @@ void QXcbWindow::setGeometry(const QRect &rect) propagateSizeHints(); const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; - const quint32 values[] = { rect.x(), - rect.y(), - qBound(1, rect.width(), XCOORD_MAX), - qBound(1, rect.height(), XCOORD_MAX) }; + const qint32 values[] = { + qBound(-XCOORD_MAX, rect.x(), XCOORD_MAX), + qBound(-XCOORD_MAX, rect.y(), XCOORD_MAX), + qBound(1, rect.width(), XCOORD_MAX), + qBound(1, rect.height(), XCOORD_MAX), + }; - Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); + Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, reinterpret_cast(values))); xcb_flush(xcb_connection()); }