Browse Source

disable audio for alt-tab

cxgeorge 24 years ago
parent
commit
704456e91d
2 changed files with 22 additions and 0 deletions
  1. 14 0
      direct/src/showbase/ShowBase.py
  2. 8 0
      panda/src/wdxdisplay/wdxGraphicsWindow.cxx

+ 14 - 0
direct/src/showbase/ShowBase.py

@@ -623,6 +623,20 @@ class ShowBase:
         self.notify.info("Taking screenshot: " + imageName)
         self.notify.info("Taking screenshot: " + imageName)
         takeSnapshot(self.win, 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):
     def run(self):
         self.taskMgr.run()
         self.taskMgr.run()
 
 

+ 8 - 0
panda/src/wdxdisplay/wdxGraphicsWindow.cxx

@@ -28,6 +28,8 @@
 #include <keyboardButton.h>
 #include <keyboardButton.h>
 #include <mouseButton.h>
 #include <mouseButton.h>
 
 
+#include <throw_event.h>
+
 #ifdef DO_PSTATS
 #ifdef DO_PSTATS
 #include <pStatTimer.h>
 #include <pStatTimer.h>
 #endif
 #endif
@@ -673,6 +675,8 @@ void wdxGraphicsWindow::deactivate_window(void) {
        if((wndpl.showCmd!=SW_MINIMIZE)&&(wndpl.showCmd!=SW_SHOWMINIMIZED)) {
        if((wndpl.showCmd!=SW_MINIMIZE)&&(wndpl.showCmd!=SW_SHOWMINIMIZED)) {
            ShowWindow(_mwindow, SW_MINIMIZE);
            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) {
 //   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);
     //      SetWindowPos(_mwindow, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOOWNERZORDER);
         GdiFlush();
         GdiFlush();
     }
     }
+
+    if(_props._fullscreen) {
+        throw_event("PandaRestarted");  // right now this is used to signal python event handler to re-enable audio
+    }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////