From 704456e91dd3682ca3e425eece9c8f6a386cc9c3 Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Tue, 21 Aug 2001 00:31:49 +0000 Subject: [PATCH] disable audio for alt-tab --- direct/src/showbase/ShowBase.py | 14 ++++++++++++++ panda/src/wdxdisplay/wdxGraphicsWindow.cxx | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index ad9e073f5a..696284e853 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -623,6 +623,20 @@ class ShowBase: self.notify.info("Taking screenshot: " + imageName) takeSnapshot(self.win, imageName) + def DisableAudio(self): + if self.wantSfx: + self.sfxManager.setActive(0) + if self.wantMusic: + self.musicManager.setActive(0) + self.notify.debug("Disabling audio") + + def EnableAudio(self): + if self.wantSfx: + self.sfxManager.setActive(1) + if self.wantMusic: + self.musicManager.setActive(1) + self.notify.debug("Enabling audio") + def run(self): self.taskMgr.run() diff --git a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx index 2ff7617e30..d6b7fe3eed 100644 --- a/panda/src/wdxdisplay/wdxGraphicsWindow.cxx +++ b/panda/src/wdxdisplay/wdxGraphicsWindow.cxx @@ -28,6 +28,8 @@ #include #include +#include + #ifdef DO_PSTATS #include #endif @@ -673,6 +675,8 @@ void wdxGraphicsWindow::deactivate_window(void) { if((wndpl.showCmd!=SW_MINIMIZE)&&(wndpl.showCmd!=SW_SHOWMINIMIZED)) { ShowWindow(_mwindow, SW_MINIMIZE); } + + throw_event("PandaPaused"); // right now this is used to signal python event handler to disable audio } // if(!bResponsive_minimized_fullscreen_window) { @@ -722,6 +726,10 @@ void wdxGraphicsWindow::reactivate_window(void) { // SetWindowPos(_mwindow, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOOWNERZORDER); GdiFlush(); } + + if(_props._fullscreen) { + throw_event("PandaRestarted"); // right now this is used to signal python event handler to re-enable audio + } } ////////////////////////////////////////////////////////////////////