Bug 683188 - nsISound should be used in Win32 widget code, not PlaySound. r=jimm
authorBrian R. Bondy <netzen@gmail.com>
Thu, 08 Sep 2011 11:24:43 -0400
changeset 76732 9401940db9d2f05c581e191ac34234e4d2d626c9
parent 76731 4a5eb5183ed9aca942b1de86b59c797fd067f13f
child 76733 2b84c0ca82b620ffeef59dd0aac52303bb785c71
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjimm
bugs683188
milestone9.0a1
Bug 683188 - nsISound should be used in Win32 widget code, not PlaySound. r=jimm
widget/src/windows/nsWindow.cpp
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -153,16 +153,17 @@
 #include "nsWindowsDllInterceptor.h"
 #include "nsIWindowMediator.h"
 #include "nsIServiceManager.h"
 #include "nsWindowGfx.h"
 #include "gfxWindowsPlatform.h"
 #include "Layers.h"
 #include "nsPrintfCString.h"
 #include "mozilla/Preferences.h"
+#include "nsISound.h"
 
 #ifdef MOZ_ENABLE_D3D9_LAYER
 #include "LayerManagerD3D9.h"
 #endif
 
 #ifdef MOZ_ENABLE_D3D10_LAYER
 #include "LayerManagerD3D10.h"
 #endif
@@ -6152,17 +6153,20 @@ void nsWindow::ActivateOtherWindowHelper
   // next window.
   ::SetWindowPos(aWnd, HWND_BOTTOM, 0, 0, 0, 0,
                  SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
   if (hwndBelow)
     ::SetForegroundWindow(hwndBelow);
 
   // Play the minimize sound while we're here, since that is also
   // forgotten when we use SW_SHOWMINIMIZED.
-  ::PlaySoundW(L"Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
+  nsCOMPtr<nsISound> sound(do_CreateInstance("@mozilla.org/sound;1"));
+  if (sound) {
+    sound->PlaySystemSound(NS_LITERAL_STRING("Minimize"));
+  }
 }
 
 void nsWindow::OnWindowPosChanging(LPWINDOWPOS& info)
 {
   // Update non-client margins if the frame size is changing, and let the
   // browser know we are changing size modes, so alternative css can kick in.
   // If we're going into fullscreen mode, ignore this, since it'll reset
   // margins to normal mode.