SFML community forums

Help => Window => Topic started by: dabbertorres on January 10, 2015, 10:29:39 pm

Title: XCB version does not create MouseButtonReleased events
Post by: dabbertorres on January 10, 2015, 10:29:39 pm
OS: Arch Linux x86_64
g++: 4.9.2-20141224
SFML: master branch today

Example Code:
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

#include <iostream>

int main()
{
        sf::Window window;

        window.create({800, 600, 32}, "SFML");

        while(window.isOpen())
        {
                sf::Event event;

                while(window.pollEvent(event))
                {
                        switch(event.type)
                        {
                                case sf::Event::MouseButtonPressed:
                                        std::cerr << "Mouse Button Pressed\n";
                                        break;
                                case sf::Event::MouseButtonReleased:
                                        std::cerr << "Mouse Button Released\n";
                                        break;
                                default:
                                        break;
                        }
                }
        }

        return 0;
}
 

Output:
Code: [Select]
[alec@alec-desktop-archlinux:~]$ ./a.out
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
Unable to get joystick attribute. Could not find USB device for joystick at index 1.
Unable to get joystick attribute. Could not find USB device for joystick at index 1.
Mouse Button Pressed
Mouse Button Pressed
Mouse Button Pressed
Mouse Button Pressed
^C

(Joystick output can be ignored for this post I believe)
So, it's creating two Button Press events per mouse click, rather than one ButtonPress and one ButtonRelease.
Title: Re: XCB version does not create MouseButtonReleased events
Post by: FRex on January 10, 2015, 11:15:28 pm
That's right, I got same results (Fedora 21 x86, g++ (GCC) 4.9.2 20141101 (Red Hat 4.9.2-1), latest master SFML too).
Found it: this line is wrong:
https://github.com/SFML/SFML/blob/master/src/SFML/Window/Unix/WindowImplX11.cpp#L1078
https://github.com/SFML/SFML/pull/773