MinimizeWindow() on Mac doesn't work full-screen
by Richard McKinney · in Torque Game Builder · 11/06/2006 (4:52 pm) · 4 replies
I know basically nothing about mac platform coding, so I'm having some trouble resolving this issue. On windows I can call the minimizeWindow() console method and my full-screen display will minimize to the taskbar. On a Mac, minimizeWindow() only works in windowed mode, where I don't need it since the button's already visible.
I've tried playing around with the source and the code paths look totally different in macCarbWindow.cc's setDisplayMode() depending on if you're windowed or full-screen. I'm gonna play around and see what I can come up with, but if anyone knows this one offhand, I'd appreciate it. Thanks!
I've tried playing around with the source and the code paths look totally different in macCarbWindow.cc's setDisplayMode() depending on if you're windowed or full-screen. I'm gonna play around and see what I can come up with, but if anyone knows this one offhand, I'd appreciate it. Thanks!
About the author
#2
Hopefully with this I'll have it working tomorrow and can post back all the steps to get it working.
Thanks!
11/07/2006 (12:01 am)
Thanks for your help! I had it where minimizeWindow() was setting it to windowed mode first and then added the mac version of onFocusChanged in _OnActivate() but it was causing problems because the focus wasn't always changing correctly. I'd have to click on something else other than the taskbar to force focus off the minimized app and get a cursor back, but if you go straight to the taskbar _OnActivate() wasn't always getting called. I'll try your change tomorrow to hopefully alleviate that focus issue. It looks really ugly having to go to windowed mode first and then minimize and vice-versa, but better to have the functionality in a non-perfect state than not at all! I may be able to setScreenMode() to create the window but have it not draw itself. I tried the Collapsed event and that didn't help.Hopefully with this I'll have it working tomorrow and can post back all the steps to get it working.
Thanks!
#3
On restore, if you haven't clicked on something else before reselecting the minimized icon in the taskbar, you don't get a kEventAppActivated message (since you never got the deactivation), but you do get the kEventWindowExpanded.
Knowing this, I'm calling the method to do all my chores when the game is minimized in both minimizeWindow() and _OnActivate. I'm calling the method to do all my restoration chores in both the kEventWindowCollapsed handler and in _OnActivate.
So now the only remaining issue is that invisible window that I can't get rid of until I click on something that's eating up my cursor. I've tried every variation of CollapseWindow, CollapseAllWindows, SendToBack, ActivateWindow, changing the window group level, deactivating the game input, setWindowLocked(false), HideWindow(), and so on and have made no progress on this part. It's acceptable since the functionality still works and just acts a little weird, but still not ideal. At least I got my first exposure to Carbon in the process...
11/07/2006 (8:04 pm)
I think this is working as well as it can now, which still isn't ideal. When the window is collapsed, you don't get kEventWindowCollapsed notification, nor a kEventAppDeactivated notification. It's like the window is still there, eating up the cursor and accepting my mouse input (mouseover sounds on guis are going off). I have to click again anywhere to get the kEventAppDeactivated notification and regain a visible cursor in the area the game was in.On restore, if you haven't clicked on something else before reselecting the minimized icon in the taskbar, you don't get a kEventAppActivated message (since you never got the deactivation), but you do get the kEventWindowExpanded.
Knowing this, I'm calling the method to do all my chores when the game is minimized in both minimizeWindow() and _OnActivate. I'm calling the method to do all my restoration chores in both the kEventWindowCollapsed handler and in _OnActivate.
So now the only remaining issue is that invisible window that I can't get rid of until I click on something that's eating up my cursor. I've tried every variation of CollapseWindow, CollapseAllWindows, SendToBack, ActivateWindow, changing the window group level, deactivating the game input, setWindowLocked(false), HideWindow(), and so on and have made no progress on this part. It's acceptable since the functionality still works and just acts a little weird, but still not ideal. At least I got my first exposure to Carbon in the process...
#4
I also suspect that _OnMouseMovedDragged() should stop handling events when the window is minimized, but I don't want to touch that right now.
You're right about not getting a kEventWindowCollapsed event when calling minimizeWindow(). I'm surprised at that too actually, but I guess commands issued by yourself don't generate event messages. So you could put the Con::executef(1, "onWindowMaximize") inside Platform::minimizeWindow() in macCarbWindow.cc too.
Another method you could try, which looks much better is to hide the application rather than minimizing the window. And actually, come to think about it, perhaps this is what windowMinimize() should be doing anyway if the goal is to match what the Windows version is doing.
So, first make sure that display capture is off in prefs.cs:
And in Platform::minimizeWindow() in macCarbWindow.cc, change
Yes, this is somewhat of a hack. Yes, this doesn't match the Mac concept of minimizing a window. But to the end user it should work wonderfully.
11/08/2006 (11:37 am)
Fiddling around a bit myself with this. First off, the issue with the mouse still disappearing after the window is minimized can be fixed by changing a line in MacCarbCheckHideCursor () in macCarbEvents.cc. Change:if(platState.mouseLocked || Video::isFullScreen())to
if(platState.minimized || platState.mouseLocked || Video::isFullScreen())
I also suspect that _OnMouseMovedDragged() should stop handling events when the window is minimized, but I don't want to touch that right now.
You're right about not getting a kEventWindowCollapsed event when calling minimizeWindow(). I'm surprised at that too actually, but I guess commands issued by yourself don't generate event messages. So you could put the Con::executef(1, "onWindowMaximize") inside Platform::minimizeWindow() in macCarbWindow.cc too.
Another method you could try, which looks much better is to hide the application rather than minimizing the window. And actually, come to think about it, perhaps this is what windowMinimize() should be doing anyway if the goal is to match what the Windows version is doing.
So, first make sure that display capture is off in prefs.cs:
$pref::mac::captureDisplay = "0";
And in Platform::minimizeWindow() in macCarbWindow.cc, change
cmd.commandID = kHICommandMinimizeWindow;to
cmd.commandID = kHICommandHide;
Yes, this is somewhat of a hack. Yes, this doesn't match the Mac concept of minimizing a window. But to the end user it should work wonderfully.
Torque Owner Ken Pajala
Problem is, AFAIK, when you want to remaximize the window I don't think TGB has any way to notify you of the fact so that you can switch back to fullscreen. If you don't mind modifying the source you could do the following to macCarbEvents.cc (about line 343):
case kEventWindowExpanded: platState.minimized = false; Con::executef(1, "onWindowMaximize"); // <---- Insert this lineThen create a onWindowMaximize() script function where you can return to fullscreen. That should work.