Game Development Community

Mac bug fix for 1.7.4: onWindowFocusChange()

by Vern Jensen · in Torque Game Builder · 06/05/2009 (1:44 pm) · 5 replies

I reported to GG a while ago that the onWindowFocusChange() callback does not get called on the Mac build, but does on Windows.

Since they've not fixed this yet, I found the fix myself. Open macCarbEvents.cc and find the _onActivate() method. Modify it like so:

//-----------------------------------------------------------------------------
static void _OnActivate(bool activating)
{
   if(activating)
   {
      Input::activate();
      Game->refreshWindow();
      platState.backgrounded = false;
      pthread_kill((pthread_t)platState.torqueThreadId, SIGALRM);
      
      Con::executef(2, "onWindowFocusChange", "1");
   }
   else
   {
      Input::deactivate();
      platState.backgrounded = true;
      
      Con::executef(2, "onWindowFocusChange", "0");
   }
}

All I added was the two "Con::execute" lines -- don't change anything else.

Just posting this in case anyone else finds it helpful.

Still frustrated that really easy-to-fix, basic bugs like this have gone unfixed for months/years, despite being reported. Sigh.

#1
06/10/2009 (1:01 pm)
I believe I filed this when it was sent to me. But I don't think there has been a new release since the fix was sent. I know that Melv and Philip and the Torque 2D team are working hard on the next version.
#2
06/10/2009 (1:59 pm)
Good to hear. There was a time before Melv became a GG employee that bugs kinda just feel through the cracks and went unfixed for years, but it sounds like this may be changing. Awesome. :-)
#3
06/10/2009 (9:27 pm)
Speaking of the next version..... :D
#4
08/03/2009 (11:19 am)
Thanks for the post, Vern.
I had it working in 1.7.2 and completely forgot about it. hopefully it'l be there for 1.7.5
#5
08/03/2009 (11:38 am)
Cool, good to hear these are being tracked.