Event Suspend Bug? - Please Test

Archives Forums/BlitzMax Bug Reports/Event Suspend Bug? - Please Test

therevills(Posted 2009) [#1]
Hi all,

Ive noticed what could be a slight bug with EVENT_APPSUSPEND.

Please try this code:



When running, click off the window and the display should says "PAUSED" and the sound should stop.

Okay, now click on the window, the pixels should redraw and the sound will start again.

Now click the minimise button and the sound should stop.

Click the taskbar icon, this will maximise the window, and the sound starts.

Now the bug, click the taskbar icon, the game minimises and the sound still plays, so the "game" is still playing...

Im testing this on Windows 7 RC1.

Thanks


Jur(Posted 2009) [#2]
Yes, the same on Vista.


therevills(Posted 2009) [#3]
Thanks for testing it Jur.

Should this be moved into the Bug forum?


SebHoll(Posted 2009) [#4]
Confirmed on my Vista PC too. Had a look into this for you guys, and it seems to be a common problem people experience when minimizing in this way. The fix is to handle the WM_ACTIVATE message instead of WM_ACTIVATEAPP.

Try replacing the WM_ACTIVATEAPP case in BlitzMax/mod/brl.mod/system.mod/system.win32.c's bbSystemEmitOsEvent() with...
	case WM_ACTIVATE:
		GetWindowThreadProcessId( lp, &lpdwProcessId );
		if(!((LOWORD(wp)!=WA_INACTIVE) && IsIconic(hwnd)) && lpdwProcessId!=GetCurrentProcessId())
			id = (LOWORD(wp) == WA_INACTIVE) ? BBEVENT_APPSUSPEND : BBEVENT_APPRESUME;
		else
			return;
		break;
Then add the following variable declaration to the top of that function:
	LPDWORD lpdwProcessId = NULL;
...and build modules.

Let me know if it works for you too. I've tested this with the latest MaxGUI and with multiple windows and it appears to work as expected.


marksibly(Posted 2009) [#5]
Hi,

To be honest, I am uncomfortable with the idea of 'supporting' SetWindowLong style hacks like this.

However, being able to minimize graphics is obviously a popular feature request, so I'll have a go at implementing it directly into Max in a nice cross-platform way soon.


SebHoll(Posted 2009) [#6]
I am uncomfortable with the idea of 'supporting' SetWindowLong style hacks like this.

This bug is also visible, though, with MaxGUI apps when windows are minimized in this way.

being able to minimize graphics is obviously a popular feature request, so I'll have a go at implementing it directly into Max in a nice cross-platform way soon

Cool!


marksibly(Posted 2009) [#7]
Hi,

> This bug is also visible, though, with MaxGUI apps when windows are minimized in this way.

Well, I'm not sure minimizing a window *should* necessarily generate an suspend event - can't app remain 'active' even with a minimized main window?

In the case of single window 'graphics' apps like the above, I think it makes sense for suspend to be triggered, but I'm not sure about 'real' GUI apps.


SebHoll(Posted 2009) [#8]
Well, I'm not sure minimizing a window *should* necessarily generate an suspend event - can't app remain 'active' even with a minimized main window?

The if statements are there to make sure it's only emitted when focus is given to a window or control in another process/application - i.e. when the *app* has loss focus. I was under the impression this was supposed to be when EVENT_APPSUSPEND was supposed to be triggered.


plash(Posted 2009) [#9]
being able to minimize graphics is obviously a popular feature request, so I'll have a go at implementing it directly into Max in a nice cross-platform way soon
Awesome. I was thinking of this just the other day.

In the case of single window 'graphics' apps like the above, I think it makes sense for suspend to be triggered, but I'm not sure about 'real' GUI apps.
That seems correct to me.. The programmer will be dealing with the event however he wishes, so I don't think it would hurt to send the event in both cases (unless there's something else that happens when the event is sent, in that case, I'd leave that up to a special event for MaxGUI).


therevills(Posted 2009) [#10]
Looks like this is fixed in 1.35 :)

Thanks Mark!