Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: XCB version does not create MouseButtonReleased events  (Read 3017 times)

0 Members and 2 Guests are viewing this topic.

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
XCB version does not create MouseButtonReleased events
« 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.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: XCB version does not create MouseButtonReleased events
« Reply #1 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
« Last Edit: January 10, 2015, 11:23:35 pm by FRex »
Back to C++ gamedev with SFML in May 2023