Fixed two trivial XCB related bugs.

This commit is contained in:
Lukas Dürrenberger 2015-02-11 14:06:42 +01:00
parent 9f2aecf9cf
commit 8dd31f2f52
2 changed files with 11 additions and 16 deletions

View File

@ -194,24 +194,21 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
// Get pointer mask
xcb_query_pointer_reply_t* pointer = xcb_query_pointer_reply(connection, xcb_query_pointer(connection, XDefaultRootWindow(display)), NULL);
uint16_t mask = pointer->mask;
free(pointer);
// Close the connection with the X server
CloseDisplay(display);
bool result = false;
switch (button)
{
case Mouse::Left: result = pointer->mask & XCB_BUTTON_MASK_1;
case Mouse::Right: result = pointer->mask & XCB_BUTTON_MASK_3;
case Mouse::Middle: result = pointer->mask & XCB_BUTTON_MASK_2;
case Mouse::XButton1: // not supported by X
case Mouse::XButton2: // not supported by X
default: result = false;
case Mouse::Left: return mask & XCB_BUTTON_MASK_1;
case Mouse::Right: return mask & XCB_BUTTON_MASK_3;
case Mouse::Middle: return mask & XCB_BUTTON_MASK_2;
case Mouse::XButton1: return false; // not supported by X
case Mouse::XButton2: return false; // not supported by X
default: return false;
}
free(pointer);
return result;
}

View File

@ -530,12 +530,10 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8
xcb_free_gc(m_connection, iconGC);
xcb_generic_error_t* errptr = xcb_request_check(m_connection, cookie);
bool setWindowIconFailed = (errptr != NULL);
free(errptr);
if (setWindowIconFailed)
if (errptr)
{
err() << "Failed to set the window's icon: Error code " << (int)errptr->error_code << std::endl;
err() << "Failed to set the window's icon: Error code " << static_cast<int>(errptr->error_code) << std::endl;
free(errptr);
return;
}