From: Ketmar Dark Date: Fri, 15 Apr 2016 12:14:47 +0000 (+0300) Subject: sound muting should work on first window deactivation now X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=3bedb8ac6ca3fe3a45921bb840b7b6be3171d6a9;p=d2df-sdl.git sound muting should work on first window deactivation now --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index c5e144c..b6f7474 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -244,7 +244,7 @@ var gWinPosX, gWinPosY: Integer; gWinSizeX, gWinSizeY: Integer; gWinFrameX, gWinFrameY, gWinCaption: Integer; - gWinActive: Boolean = False; + gWinActive: Boolean = True; // by default window is active, lol gResolutionChange: Boolean = False; gRC_Width, gRC_Height: Word; gRC_FullScreen, gRC_Maximized: Boolean; diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 081c3b2..ef1d362 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -273,23 +273,33 @@ begin e_WriteLog('[DEBUG] WinMsgs: Now restored', MSG_NOTIFY); end; end; - + SDL_WINDOWEVENT_FOCUS_GAINED: + begin wActivate := True; - + //e_WriteLog('window gained focus!', MSG_NOTIFY); + end; + SDL_WINDOWEVENT_FOCUS_LOST: + begin wDeactivate := True; + //e_WriteLog('window lost focus!', MSG_NOTIFY); + end; end; - + if wDeactivate then begin if gWinActive then begin + e_WriteLog('deactivating window', MSG_NOTIFY); e_EnableInput := False; e_ClearInputBuffer(); if gMuteWhenInactive then + begin + //e_WriteLog('deactivating sounds', MSG_NOTIFY); e_MuteChannels(True); + end; if g_debug_WinMsgs then begin @@ -304,10 +314,14 @@ begin begin if not gWinActive then begin + //e_WriteLog('activating window', MSG_NOTIFY); e_EnableInput := True; if gMuteWhenInactive then + begin + //e_WriteLog('activating sounds', MSG_NOTIFY); e_MuteChannels(False); + end; if g_debug_WinMsgs then begin