Added backend logic to mute sound when GUI focus is lost. Still TODO add window controls.

This commit is contained in:
mjbudd77 2021-08-05 23:43:44 -04:00
parent 455df4caae
commit f925e82d85
3 changed files with 37 additions and 0 deletions

View File

@ -124,6 +124,7 @@ consoleWin_t::consoleWin_t(QWidget *parent)
g_config->getOption( "SDL.PauseOnMainMenuAccess", &mainMenuPauseWhenActv );
g_config->getOption( "SDL.ContextMenuEnable", &contextMenuEnable );
g_config->getOption( "SDL.Sound.MuteOnDefocus", &muteSoundOnDefocus );
g_config->getOption ("SDL.VideoDriver", &use_SDL_video);
if ( use_SDL_video )
@ -359,6 +360,8 @@ void consoleWin_t::initScreenHandler(void)
scrHandlerConnected = true;
winScreenChanged( hdl->screen() );
connect( hdl, SIGNAL(activeChanged(void)), this, SLOT(winActiveChanged(void)) );
}
}
}
@ -381,6 +384,37 @@ void consoleWin_t::winScreenChanged(QScreen *scr)
}
}
void consoleWin_t::winActiveChanged(void)
{
QWidget *w;
w = this->window();
if ( w != NULL)
{
QWindow *hdl = w->windowHandle();
if (hdl != NULL)
{
if ( muteSoundOnDefocus )
{
fceuWrapperLock();
if ( hdl->isActive() )
{
int vol;
g_config->getOption("SDL.Sound.Volume", &vol);
FCEUI_SetSoundVolume(vol);
}
else
{
FCEUI_SetSoundVolume(0);
}
fceuWrapperUnLock();
}
}
}
}
QSize consoleWin_t::calcRequiredSize(void)
{
QSize out( GL_NES_WIDTH, GL_NES_HEIGHT );

View File

@ -254,6 +254,7 @@ class consoleWin_t : public QMainWindow
bool mainMenuPauseWhenActv;
bool scrHandlerConnected;
bool contextMenuEnable;
bool muteSoundOnDefocus;
std::list <std::string*> romList;
std::vector <autoFireMenuAction*> afActList;
@ -417,6 +418,7 @@ class consoleWin_t : public QMainWindow
void wavRecordAsStart(void);
void wavRecordStop(void);
void winScreenChanged( QScreen *scr );
void winActiveChanged(void);
void emuFrameFinish(void);
};

View File

@ -486,6 +486,7 @@ InitConfig()
config->addOption("soundrecord", "SDL.Sound.RecordFile", "");
config->addOption("soundbufsize", "SDL.Sound.BufSize", 128);
config->addOption("lowpass", "SDL.Sound.LowPass", 0);
config->addOption("SDL.Sound.MuteOnDefocus", 0);
config->addOption('g', "gamegenie", "SDL.GameGenie", 0);
config->addOption("pal", "SDL.PAL", 0);