179784: go back to beep by default for typeahead find "not found",

since the nsSound solution doesn't work well on linux or mac.
  r=aaronl sr=sfraser
This commit is contained in:
akkana%netscape.com 2002-12-03 23:51:10 +00:00
Родитель 9b6c970217
Коммит 1889b530c2
5 изменённых файлов: 27 добавлений и 15 удалений

Просмотреть файл

@ -153,8 +153,7 @@ nsTypeAheadFind::nsTypeAheadFind():
mIsBackspaceProtectOn(PR_FALSE),
mBadKeysSinceMatch(0), mLastBadChar(0),
mRepeatingMode(eRepeatingNone), mTimeoutLength(0),
mSoundInterface(nsnull), mIsSoundInitialized(PR_FALSE),
mIsSoundEnabledPref(PR_FALSE)
mSoundInterface(nsnull), mIsSoundInitialized(PR_FALSE)
{
NS_INIT_ISUPPORTS();
@ -315,9 +314,10 @@ nsTypeAheadFind::PrefsReset()
prefBranch->GetBoolPref("accessibility.typeaheadfind.startlinksonly",
&mStartLinksOnlyPref);
prefBranch->GetBoolPref("accessibility.typeaheadfind.enablesound",
&mIsSoundEnabledPref);
mSoundInterface = nsnull; // will get as needed
nsXPIDLCString soundStr;
prefBranch->GetCharPref("accessibility.typeaheadfind.soundURL",
getter_Copies(soundStr));
mNotFoundSoundURL = soundStr;
prefBranch->GetIntPref("accessibility.typeaheadfind.timeout",
&mTimeoutLength);
@ -522,7 +522,7 @@ nsTypeAheadFind::KeyPress(nsIDOMEvent* aEvent)
#ifdef XP_WIN
// Deal with nsISound impl quirks in Windows
if (!mIsSoundInitialized && mIsSoundEnabledPref) {
if (!mIsSoundInitialized) {
// Don't play a sound, just make sure sound system is initialized
// This makes sure system sound library (winmm.dll) is loaded so that
// there's no lag before the first sound is played
@ -924,9 +924,7 @@ nsTypeAheadFind::HandleChar(PRUnichar aChar)
// Error sound (don't fire when backspace is pressed, they're
// trying to correct the mistake!)
if (mIsSoundEnabledPref) {
PlayNotFoundSound();
}
PlayNotFoundSound();
// Remove bad character from buffer, so we can continue typing from
// last matched character
@ -973,13 +971,25 @@ nsTypeAheadFind::SaveFind()
void
nsTypeAheadFind::PlayNotFoundSound()
{
if (mNotFoundSoundURL.IsEmpty()) // no sound
return;
if (!mSoundInterface) {
mSoundInterface = do_CreateInstance("@mozilla.org/sound;1");
}
if (mSoundInterface) {
mIsSoundInitialized = PR_TRUE;
if (mNotFoundSoundURL.Equals("beep")) {
mSoundInterface->Beep();
return;
}
nsCOMPtr<nsIURI> soundURI;
NS_NewURI(getter_AddRefs(soundURI), NS_LITERAL_CSTRING(TYPEAHEADFIND_NOTFOUND_WAV_URL));
if (mNotFoundSoundURL.Equals("default"))
NS_NewURI(getter_AddRefs(soundURI),
NS_LITERAL_CSTRING(TYPEAHEADFIND_NOTFOUND_WAV_URL));
else
NS_NewURI(getter_AddRefs(soundURI), mNotFoundSoundURL);
nsCOMPtr<nsIURL> soundURL(do_QueryInterface(soundURI));
if (soundURL) {
mSoundInterface->Play(soundURL);

Просмотреть файл

@ -186,6 +186,8 @@ protected:
nsString mFindNextBuffer;
nsString mIMEString;
nsCString mNotFoundSoundURL;
// PRBool's are used instead of PRPackedBool's where the address of the
// boolean variable is getting passed into a method. For example:
// GetBoolPref("accessibility.typeaheadfind.linksonly", &mLinksOnlyPref);
@ -217,7 +219,6 @@ protected:
// If we destroy mSoundInterface before sound has played, it won't play
nsCOMPtr<nsISound> mSoundInterface;
PRBool mIsSoundInitialized;
PRBool mIsSoundEnabledPref;
static PRInt32 sAccelKey; // magic value of -1 indicates unitialized state

Просмотреть файл

@ -139,7 +139,7 @@ pref("accessibility.typeaheadfind", true);
pref("accessibility.typeaheadfind.linksonly", true);
pref("accessibility.typeaheadfind.startlinksonly", false);
pref("accessibility.typeaheadfind.timeout", 4000);
pref("accessibility.typeaheadfind.enablesound", true);
pref("accessibility.typeaheadfind.soundURL", "default");
// Dialog modality issues
pref("browser.prefWindowModal", true);

Просмотреть файл

@ -184,6 +184,8 @@ pref("font.size.fixed.zh-TW", 16);
// 1 focuses text controls, 2 focuses other form elements, 4 adds links.
pref("accessibility.tabfocus", 1);
pref("accessibility.typeaheadfind.soundURL", "beep");
// Override the Windows settings: no menu key, meta accelerator key. ctrl for general access key in HTML/XUL
// Use 17 for Ctrl, 18 for Option, 224 for Cmd, 0 for none
pref("ui.key.menuAccessKey", 0);

Просмотреть файл

@ -72,9 +72,8 @@ pref("browser.urlbar.clickSelectsAll", false);
// Leave this at the default, 7, to match mozilla1.0-era user expectations.
// pref("accessibility.tabfocus", 1);
// Keep sound pref'd off in Linux, at least until nsISound becomes
// asynchronous (bug 110385)
pref("accessibility.typeaheadfind.enablesound", false);
// Beep instead of playing sound in Linux, at least until nsISound is fixed:
pref("accessibility.typeaheadfind.soundURL", "beep");
// override double-click word selection behavior.
pref("layout.word_select.stop_at_punctuation", false);