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

Author Topic: Windows gains focus only at borded  (Read 16192 times)

0 Members and 1 Guest are viewing this topic.

Beta_Ravener

  • Jr. Member
  • **
  • Posts: 51
    • ICQ Messenger - 271426715
    • View Profile
Windows gains focus only at borded
« on: August 22, 2013, 12:59:44 am »
I've noticed that my windows only gain focus (understand producing sf::Event::GainedFocus and bringing input to that window) only when clicking at it's border, not inside o the window. It's a little annoying and I'm somewhat sure it didn't happen in previous SFML versions (but it's too late for another testing.. ). Other means of gaining focus work fine (alt-tabing, picking up from taskbar,..).

I'm using SFML 2.1 32bit on Windows 8 64bit and can bring up more details if needed, like minimum code to reproduce, however it happens with 2 of my programs using SFML, so it looks like consistent issue.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Windows gains focus only at borded
« Reply #1 on: August 22, 2013, 01:48:15 am »
Yeah noticed that as well and was kinda surprised that nobody had reported it yet, but was too busy/lazy to report it myself... ;D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Windows gains focus only at borded
« Reply #2 on: August 22, 2013, 02:16:34 am »
Actually it's been known for a while: https://github.com/SFML/SFML/issues/437

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Windows gains focus only at borded
« Reply #3 on: August 24, 2013, 05:38:24 pm »
Came here to report this actually, it's bugging.

Is there a workaround?
Edit: I fixed it.

« Last Edit: August 24, 2013, 06:14:13 pm by xzbobzx »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Windows gains focus only at borded
« Reply #4 on: August 24, 2013, 06:29:05 pm »
You misspelled brought as brough. Otherwise perfect fix. ;D
« Last Edit: August 24, 2013, 06:32:33 pm by FRex »
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Windows gains focus only at borded
« Reply #5 on: August 24, 2013, 07:02:38 pm »
Edit: I fixed it.
Do you mind sharing what you've done to "fix it"? :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Windows gains focus only at borded
« Reply #6 on: August 24, 2013, 07:05:53 pm »
Not really a fix, he displays "click border to focus" with a lame rant in the lower right corner. ;)

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Windows gains focus only at borded
« Reply #7 on: August 24, 2013, 07:08:37 pm »
Edit: I fixed it.
Do you mind sharing what you've done to "fix it"? :)
Ah, yes of course.

Basically I've got my event checker looking for the LostFocus event, which switches the 'IsFocused' bool to false. It also switched the gamestate to the pause menu and disables the pause menu's events.
Then later on in the code when I render everything I have my code see if 'IsFocused' is false; if it's false it will display 'Click window border to focus'.
When you regain focus the overlay is removed and it puts the pause menu back in order, from here you're free to continue whatever you were doing.


Not really a fix, he displays "click border to focus" with a lame rant in the lower right corner. ;)

All in good fun  ;)
« Last Edit: August 24, 2013, 07:13:46 pm by xzbobzx »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Windows gains focus only at borded
« Reply #8 on: August 24, 2013, 07:15:29 pm »
Not really a fix, he displays "click border to focus" with a lame rant in the lower right corner. ;)
Yeah, he should instead move to some 'lame' library that actually has fully working input handling instead of saying the 'lame' truth that a bug was introduced in one of basic pieces of SFML. :-\
Back to C++ gamedev with SFML in May 2023

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Windows gains focus only at borded
« Reply #9 on: August 24, 2013, 08:12:07 pm »
Not really a fix, he displays "click border to focus" with a lame rant in the lower right corner. ;)
Yeah, he should instead move to some 'lame' library that actually has fully working input handling instead of saying the 'lame' truth that a bug was introduced in one of basic pieces of SFML. :-\
Hey now I love this library as much as the next guy, don't judge me for my bad jokes :(

xzbobzx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Windows gains focus only at borded
« Reply #10 on: August 24, 2013, 08:28:37 pm »
I fixed my fix :>


Beta_Ravener

  • Jr. Member
  • **
  • Posts: 51
    • ICQ Messenger - 271426715
    • View Profile
Re: Windows gains focus only at borded
« Reply #11 on: August 24, 2013, 09:21:27 pm »
Hey, when did reporting SFML bugs become such fun to do?  :D Anyway nice work xzbobzx, in meantime it's going to be probably my choice of 'fix' too. (Might even create fork including this.. or just really fix it.)
« Last Edit: August 24, 2013, 09:35:59 pm by Beta_Ravener »

All8Up

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Windows gains focus only at borded
« Reply #12 on: August 28, 2013, 06:51:23 am »
Just posted a reply to the bug tracker with a very simple way to fix this.  It's not 100% thanks to the message order, i.e. you get a click or drop a click prior to the focus message showing up but for my stuff dropping the click was appropriate and all the other messages show up correctly.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Windows gains focus only at borded
« Reply #13 on: August 28, 2013, 10:36:21 am »
IMO clicking into a window to gain focus shouldn't trigger a mouse click event anyway, so seems fine to me.
« Last Edit: August 28, 2013, 11:40:38 pm by Mario »

All8Up

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Windows gains focus only at borded
« Reply #14 on: August 28, 2013, 03:59:44 pm »
Using a tracking flag seems fine, though the one suggestion I would have is to wrap the check in a helper function such that if more logic needs to be added you don't have to fiddle with each message separately.  Just a trivial sort of rule of thumb type thing.

As to the behavior, I actually ended up putting in a flag on the window to control the behavior in my slightly modified SFML 2.1 because in one place dropping the click was completely appropriate but in another it was extremely annoying.  I'm working on a little secondary helper (debug) tools window for editing some items and not being able to click a button immediately without double clicking in that window was annoying.  Clicking on the viewport windows to activate them before mouse clicks were accepted was perfectly fine though.

I still think it would be possible to simply delay the send of the activation click and post it immediately after WM_SETFOCUS is processed, I just wanted the lightest change possible and figured I'd post it for further discussion.