xcb: fix (negative) coordinate handling

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 <samuel.rodal@nokia.com>
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
This commit is contained in:
Marc Mutz 2012-03-22 17:31:57 +01:00 committed by Qt by Nokia
parent 9c6c7038ac
commit d86e101d1b

View File

@ -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<qint32>(-XCOORD_MAX, rect.x(), XCOORD_MAX),
qBound<qint32>(-XCOORD_MAX, rect.y(), XCOORD_MAX),
qBound<qint32>(1, rect.width(), XCOORD_MAX),
qBound<qint32>(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<const quint32*>(values)));
xcb_flush(xcb_connection());
}