ScreenSaver: Make sure password window is shown

… before resuming the saver on B_KEY_DOWN in the message filter.

It was assumed before, now we’re actually checking to make sure.
This commit is contained in:
John Scipione 2013-11-14 16:39:07 -05:00
parent be888b3a49
commit 0f1162d27e
3 changed files with 14 additions and 3 deletions

View File

@ -284,6 +284,13 @@ ScreenBlanker::QuitRequested()
}
bool
ScreenBlanker::IsPasswordWindowShown() const
{
return fPasswordWindow != NULL && !fPasswordWindow->IsHidden();
}
void
ScreenBlanker::_Shutdown()
{

View File

@ -54,6 +54,7 @@ class ScreenBlanker : public BApplication {
BMessageRunner* fStandByScreenRunner;
BMessageRunner* fSuspendScreenRunner;
BMessageRunner* fTurnOffScreenRunner;
bool IsPasswordWindowShown() const;
};
#endif // SCREEN_SAVER_APP_H

View File

@ -57,11 +57,14 @@ ScreenSaverFilter::Filter(BMessage* message, BHandler** target)
be_app->PostMessage(B_QUIT_REQUESTED);
break;
}
} else if (message->what == B_KEY_DOWN) {
} else if (message->what == B_KEY_DOWN
&& dynamic_cast<ScreenBlanker*>(be_app)->IsPasswordWindowShown()) {
// Handle the escape key when the password window is showing
const char *string = NULL;
if (message->FindString("bytes", &string) == B_OK && string[0] == B_ESCAPE)
const char* string = NULL;
if (message->FindString("bytes", &string) == B_OK
&& string[0] == B_ESCAPE) {
be_app->PostMessage(kMsgResumeSaver);
}
}
return B_DISPATCH_MESSAGE;