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

Author Topic: 2.0rc weird mouse behaviour only on Windows  (Read 3294 times)

0 Members and 1 Guest are viewing this topic.

defcronyke

  • Newbie
  • *
  • Posts: 3
    • View Profile
2.0rc weird mouse behaviour only on Windows
« on: August 08, 2012, 05:56:17 pm »
Hey,

I'm working on a 3D OpenGL project using SFML 2.0rc, where I'm using _window->setMouseCursorVisible(0) to hide the mouse, and whenever the mouse reaches the edge of the window, I'm using sf::Mouse::setPosition() to bring the cursor back to the middle of the window. This is working great in Linux, but in Windows7 the mouse becomes visible again after a few seconds of moving it around. Also on Windows7, if I'm not using fullscreen mode, every time I click the mouse, the whole window becomes sort of "highlighted", or "grayed out". I've tried throwing in extra calls to _window->setMouseCursorVisible(0) in the main loop, and in other places, and I've also tried throwing in extra calls to _window->setActive() as a shot-in-the-dark but these things aren't fixing the strange behavior at all. I was really loving SFML 2.0rc until I discovered this problem, but it seems completely unusable on Windows until I can find a solution. Of course this could all be my fault somehow, as it's certainly possible I'm doing something wrong in my code, so please let me know if it would help to provide some code from my project. I haven't heard of anyone else having this problem, so that's why I think it may be something I'm doing wrong. Anyway, until this is sorted out, I think I'm going to start the move over to GLFW and see if it has the same problem on Windows. I really want to stick with SFML if I can though.

Thanks in advance to anyone who has some time to help out with this.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: 2.0rc weird mouse behaviour only on Windows
« Reply #1 on: August 08, 2012, 06:53:29 pm »
Unfortunatly SFML doesn't have RAW data support for the mouse capturing yet, thus you can't lock the mouse pointer and just use the deltas to calculate the movement.
But there's defently a better way to handle the mouse repositioning. Instead of checking if the mouse leaves the window, you always check if the mouse has moved, then you take that movement for calcualting 3D camera movement (other what ever you want to do) and you reposition the mouse in the center of the window. Like a implied this is a better version, but you mouse pointer can still leave the window of a split second and being shown again.

For the strange window behaviour I can't tell you anything without some code. I've never experienced anything like your describing, unless by "greying-out" you mean that the window loses focus, this can happen if you click with your mouse outside the window, because the mouse couldn't have been reposition quick enough.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

defcronyke

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: 2.0rc weird mouse behaviour only on Windows
« Reply #2 on: August 08, 2012, 07:16:51 pm »
Hey eXpl0it3r,
Thanks for a quick reply!

I've just tested the problem again, and it seems to be unrelated to the positioning of the mouse / mouse leaving the window when moving too fast (I don't have this problem). Rather what's happening is after my program runs for about 5-10 seconds or so, even without moving the mouse at all, the cursor appears with the loading circle (a.k.a. the hourglass symbol), and it stays visible from that point on. As for the graying out of the non-fullscreen window, it's not a priority right now, because I plan on only supporting fullscreen mode for my program.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: 2.0rc weird mouse behaviour only on Windows
« Reply #3 on: August 08, 2012, 08:23:54 pm »
Do you poll events? Because if you doesn't the application will soon seem to Windows as being not responsive and thus chaning the mouse cursor and "greying-out" the window...

You'll need to call window.pollEvent().
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

defcronyke

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: 2.0rc weird mouse behaviour only on Windows
« Reply #4 on: August 08, 2012, 08:39:08 pm »
Hey, that totally fixed the problem!!

I wasn't polling the events because all my input was using the realtime system, but I was actually checking for a few events without ever using window->pollEvent(). Clearly this was my mistake, and now I know that whether or not I'm using the event polling system for anything, I should probably call pollEvent() anyway so Windows doesn't think the window is frozen. Thank you for solving my problem!! Now I don't have to rewrite using GLFW! Yaaaay!