All pastes #1763176 Raw Edit

co

public text v1 · immutable
#1763176 ·published 2010-01-23 20:06 UTC
rendered paste body
From 442c25dd3b12b48cce00b80fff0b9683947e5116 Mon Sep 17 00:00:00 2001From: the_cybersphinx <chr.ohm@gmx.net>Date: Sat, 23 Jan 2010 20:41:27 +0100Subject: [PATCH] Clean up handleActiveEvent.This fixes PauseOnFocusLoss to actually work in skirmish, and disablesscrolling when the mouse leaves the window.--- src/main.c |   46 ++++++++++++++++++++++++---------------------- 1 files changed, 24 insertions(+), 22 deletions(-)diff --git a/src/main.c b/src/main.cindex 37d0040..3667fff 100644--- a/src/main.c+++ b/src/main.c@@ -868,31 +868,36 @@ static void handleActiveEvent(SDL_ActiveEvent * activeEvent) 		{ 			focusState = FOCUS_IN; -			gameTimeStart();-			// Should be: audio_ResumeAll();+			// Don't pause in multiplayer!+			if (war_GetPauseOnFocusLoss() && !NetPlay.bComms)+			{+				gameTimeStart();+				audio_ResumeAll();+				cdAudio_Resume();+			}+			// enable scrolling+			setScrollPause(false); 		}--		// Resume playing audio.-		cdAudio_Resume(); 	}-	// Only loose focus when the config settings allow us to-	else if (war_GetPauseOnFocusLoss())+	else 	{ 		debug( LOG_NEVER, "WM_KILLFOCUS"); 		if (focusState != FOCUS_OUT) 		{ 			focusState = FOCUS_OUT; -			gameTimeStop();-			// Should be: audio_PauseAll();-			audio_StopAll();+			// Don't pause in multiplayer!+			if (war_GetPauseOnFocusLoss() && !NetPlay.bComms)+			{+				gameTimeStop();+				audio_PauseAll();+				cdAudio_Pause();+			}+			/* Have to tell the input system that we've lost focus */+			inputLooseFocus();+			// stop scrolling+			setScrollPause(true); 		}-		/* Have to tell the input system that we've lost focus */-		inputLooseFocus();--		// Need to pause playing to prevent the audio code from-		// thinking playing has finished.-		cdAudio_Pause(); 	} } @@ -926,11 +931,7 @@ static void mainLoop(void) 					inputHandleMouseMotionEvent(&event.motion); 					break; 				case SDL_ACTIVEEVENT:-					 // Ignore this event during multiplayer games since it breaks the game when one player suddenly pauses!-					if (!bMultiPlayer)-					{-						handleActiveEvent(&event.active);-					}+					handleActiveEvent(&event.active); 					break; 				case SDL_QUIT: 					return;@@ -945,7 +946,8 @@ static void mainLoop(void) 			inputLooseFocus();		// remove it from input stream 		} -		if (focusState == FOCUS_IN)+		// only pause when not in multiplayer, no focus, and we actually want to pause+		if (NetPlay.bComms || focusState == FOCUS_IN || !war_GetPauseOnFocusLoss()) 		{ 			if (loop_GetVideoStatus()) 			{-- 1.6.6