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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - nwp

Pages: [1]
1
Window / Bug Report window not responding
« on: December 19, 2015, 11:39:18 pm »
The following code compiles, links and runs correctly, but after ~5 seconds I get a kill popup that window "Test" is not responding and if I want to kill it. I understand that the window manager sends events to my window and if I do not get them the window manager assumes my program is stuck. However, as you can see in the code, I don't leave the message queue unattended for more than 100ms so I should not get a kill popup.

#include <SFML/Graphics.hpp>

void do_useful_stuff(){
        //changed this_thread::sleep_for to sf::sleep, thanks to Hapax
        sf::sleep(sf::milliseconds(100)); //pretend this does something useful
}

int main(){
        //initialize window
        sf::RenderWindow window(sf::VideoMode(800, 600), "Test");

        //optional workaround
        if (false){ //set to true to enable workaround
                sf::Event event;
                window.pollEvent(event);
        }

        //initialize stuff that needs the RenderWindow
        do_useful_stuff();

        //enter event loop
        sf::Event event;
        while (window.isOpen()){
                while (window.pollEvent(event)){
                        if (event.type == sf::Event::Closed){
                                window.close();
                        }
                }
                window.clear(sf::Color::Black);
                window.display();
                do_useful_stuff(); //other logic stuff
        }
}

The code has an optional workaround, which is polling an event right after creating the window which prevents the kill popup.  This may be a bug in my window manager and not in SFML, so it would be good if someone could try it on another platform.

Platform details:
* Up to date Debian testing
* SFML 2.3.2+dfsg-1
* Gnome 1:3.14+3

A friend has the same issue on Debian Sid, but it takes 10 seconds for the window manager to complain.

Maybe someone has KDE and could try it? Then we can figure out if it is likely to be a problem with the X-server or Gnome.

2
General discussions / Re: Understanding The syntax of SFML.
« on: January 04, 2014, 01:39:46 am »
It is a namespace like std. Use
using namespace sf;
if it bothers you.

3
Hmm, somehow I missed the Code dropdown thingie.

Which mouse of yours has such issues?
It says Microsoft Wireless Mobile Mouse 1000 Model 1452 on the back. I do not think this is a mouse issue though, its just a disagreement between windows and SFML how mousewheels work.

4
Somehow I did not find the bug report subforum, sorry for that.

Under Windows the translation from WM_MOUSEWHEEL to sf::Event::MouseWheelMoved in SFML/Window/Win32/WindowImplWin32.cpp:603 is wrong for SFML 2.1. The WM_MOUSEWHEEL goes in WHEEL_DELTA units, which is 120. The line says
Quote
event.mouseWheel.delta = static_cast<Int16>(HIWORD(wParam)) / 120;
The Windows documentation states
Quote
The delta was set to 120 to allow Microsoft or other vendors to build finer-resolution wheels (a freely-rotating wheel with no notches) to send more messages per rotation, but with a smaller value in each message.
I have one of those mice (mouses?). If I scroll 1 notch, HIWORD(wParam) will be 112. It is then rounded down to 0 when it is divided by 120. Consequently in SFML I get lots of sf::Event::MouseWheelMoved with event.mouseWheel.delta equaling 0. When scrolling very fast so Windows reports scrolldistances bigger than 112 it sort of works.
Quick workaround:
Change the offending line to
Quote
event.mouseWheel.delta = static_cast<Int16>((HIWORD(wParam)) + 60) / 120;
That way at least the scrolling sort of works.
Real solution:
Change the type of event.mouseWheel.delta to float and the line to
Quote
event.mouseWheel.delta = (HIWORD(wParam)) / 120.f;

For extra style points change the magic number 120 to the Windows defined macro WHEEL_DELTA.

PS: How come the forum supports marquee and glow text, but no C++-code tags?

Edit: My recommended quick workaround only works for scrolling up, which is insufficient. New workaround:
event.mouseWheel.delta = (static_cast<Int16>(HIWORD(wParam)) * 3 / 2) / WHEEL_DELTA;
But its still a bad hack.

Pages: [1]
anything