Detect Minimise on Mac - I've added a minimise btn

BlitzMax Forums/BlitzMax Programming/Detect Minimise on Mac - I've added a minimise btn

Grey Alien(Posted 2007) [#1]
OK I figured out how to add a minimise button to graphics windows created on Mac OSX with Graphics w,h,0.

A minimise button cannot be added once the window is created (according to the Mac Developer docs) only as the window is created. So I had to modify glgraphics.macos.m by finding this line (990):

style=NSTitledWindowMask|NSClosableWindowMask


and changing it to:

style=NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask;


Then rebuild modules.

This works and when you click minimise it does minimise, woo! However it not passing a suspended event into BMax so I can't stop the music and can't stop game logic which is naff.

However, I've no idea where to go from here. I.e. how to detect the minimise. Probably another module needs to be modified so that an AppSuspend event is fired off when the game is minimised. Can anyone help with this as it would be great to get it sorted for the Mac! Thanks in advance.


grable(Posted 2007) [#2]
Look into the windowDidMiniaturize and windowDidDeminiaturize delegates.

Adding them to the BBGLWindow object and firing the aproproate events may work.

And check out the isMiniaturized, miniaturize and deminiaturize methods as well.


Grey Alien(Posted 2007) [#3]
souunds good. Anyone with good Objective C skills able to assist? thx


grable(Posted 2007) [#4]
Add these after windowShouldClose on line 39 and see what happens ;)
-(void) windowDidMiniaturize:(NSNotification *) note {
	bbSystemEmitEvent( BBEVENT_APPSUSPEND,&bbNullObject,0,0,0,0,&bbNullObject );
}
-(void) windowDidDeminiaturize:(NSNotification *) note {
	bbSystemEmitEvent( BBEVENT_APPRESUME,&bbNullObject,0,0,0,0,&bbNullObject );
}



Grey Alien(Posted 2007) [#5]
Awesome, thanks, will try in about an hour!


Grey Alien(Posted 2007) [#6]
Excellent it works thanks! Really appreciated. Shame it's a module tweak though, it would be great if BRL made this standard (or at least made the minimise icon optional.

Interestingly, because my game uses HideMouse so it can draw it's own mouse cursor, when the window is minimised, the Mac mouse cursor still disapears when it moves over where the window was, how freaky is that? I fixed that with some code that called ShowMouse when suspended was detected and HideMouse when it resumes.

OK someting else related, if I press F11 to hide all windows to show the desktop, the game continues to run and also if you move the mouse where the window was, all the buttons make mouse over noises (although they can't be clicked as focus goes to the desktop). Do you know how to detect the F11 event as I'd like to treat it like a normal suspend/resume via app lost focus or app was minimised. Thanks!


Tachyon(Posted 2007) [#7]
Grey- I've been watching your Framework evolve for quite some time and I am pleased to see progress being made on cross-platform functionality. I'll be buying 1.05 for sure.


grable(Posted 2007) [#8]
This seems to be a common problem with cocoa (from what i could find with my limited searching anyway).
Does this happen without the minimize tweak as well?
And does it only happen when showing the desktop, and not when doing expose?

There are ways to not include the window in any expose action though, but thats probably not what you want.


Grey Alien(Posted 2007) [#9]
Tachyon: Cool! Yeah the framework has compiled on the Mac for a long time but it's only recently that I've been looking into all the little OS-related quirks and getting them fixed (which I did for Windows last year). They are very nearly all done. I'm finding the Mac ones hard to solve though because I can deal with Windows API but the Mac stuff is very new to me. So I rely on the help of Mac experts like Grable, Brucey and others.

Grable: I can take the tweak out and see. I had never tried to press F11 when one of my games was running before. Ok just confirmed that it happens without the tweak.

What is expose? Basically the problem is with F11, is there something else I should test?

Yeah I just need to receive a system message that F11 was pressed OR detect that the system is in the F11 state (whatever it's called) so I can take my own action.

Any ideas?


grable(Posted 2007) [#10]
What is expose? Basically the problem is with F11, is there something else I should test?

Exposè (got the right letter this time ;) is all the fancy effects like F11 and the "show all windows" thingy.


Yeah I just need to receive a system message that F11 was pressed OR detect that the system is in the F11 state (whatever it's called) so I can take my own action.

you can remap them to any key or mouse button though, so calling it F11 can be a bit misleading. and whatever button it is assigned to is trapped by the os, so im not sure you can check for it.

I cant find any info on detecting expose actions, im not even sure its possible.
It seems the windows arent moved at all, only the graphic of them.

You could try the various mailing lists, google isnt much help today.


Grey Alien(Posted 2007) [#11]
Hmm OK thx. This may just have to be a "feature", much as I'd hate to leave it at that.


GfK(Posted 2011) [#12]
BUMP

I'm doing the Mac build of my game and this has had me stumped for nearly two bloody hours and I couldn't find a thread about it til now. I've trawled all through my Magicville code because I knew I figured it out for that, yet I could see no sign of how I'd done it.

Mark, if you're reading this - PLEASE, for my sanity if nothing else, put this in the official build! If I happen upon the same problem/thread at the end of my next game and it takes me as long to figure out it was done via a mod tweak, then I'm probably going to murder some kittens (or at least shout at some inanimate objects).


Grey Alien(Posted 2011) [#13]
Bumping this again as a couple of times a year I have to rebuild my Mac games and if I've updated Blitz and forgot to modify the modules, they don't have a minimise button. It would be great to have that support build-in finally.

Pretty Please Mark?


ImaginaryHuman(Posted 2011) [#14]
Isn't it time you bought MaxGUI?


Jesse(Posted 2011) [#15]
bought??????????????????????????
have you been away that long:
http://www.blitzmax.com/Community/posts.php?topic=91243


Grey Alien(Posted 2011) [#16]
No cos all my games use vanilla BMax and so do lots of other devs. In order to have a professional quality game you need a minimise button.


Czar Flavius(Posted 2011) [#17]
MaxGUI is vanilla now!


ImaginaryHuman(Posted 2011) [#18]
I totally missed that thread, didn't know that!


SLotman(Posted 2011) [#19]
Add MaxGUI (and a bunch of unnecessary code) just for a minimize button???