From 8dd31f2f52267f043fc7d6f78ba0a20c0f35afa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Wed, 11 Feb 2015 14:06:42 +0100 Subject: [PATCH] Fixed two trivial XCB related bugs. --- src/SFML/Window/Unix/InputImpl.cpp | 19 ++++++++----------- src/SFML/Window/Unix/WindowImplX11.cpp | 8 +++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/SFML/Window/Unix/InputImpl.cpp b/src/SFML/Window/Unix/InputImpl.cpp index a41fa46b..14ff4c9e 100644 --- a/src/SFML/Window/Unix/InputImpl.cpp +++ b/src/SFML/Window/Unix/InputImpl.cpp @@ -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; } diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 0ecc8eea..28798e6e 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -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(errptr->error_code) << std::endl; + free(errptr); return; }