diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 06:47:43 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 06:47:43 +0000 |
commit | 8c38d6a380418af97de7a6e4f07433a500477122 (patch) | |
tree | e8f62c49cfca8340f04e045b745ee492da0ee461 /chrome | |
parent | 8d6fcc39959c711b3921de41fec30c8cfdd071a3 (diff) | |
download | chromium_src-8c38d6a380418af97de7a6e4f07433a500477122.zip chromium_src-8c38d6a380418af97de7a6e4f07433a500477122.tar.gz chromium_src-8c38d6a380418af97de7a6e4f07433a500477122.tar.bz2 |
Wait sending ScreenIsLocked signal until screen lock window is mapped.
* When closing and opening the lid, chrome window is briefly visible because
the computer is suspended before window is fully mapped and covers the
screen.
BUG=none
TEST=manual: close and open the lid shoudl not expose the content of chrome window.
Review URL: http://codereview.chromium.org/2762001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49233 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/login/screen_locker.cc | 73 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/screen_locker.h | 16 |
2 files changed, 63 insertions, 26 deletions
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index bba8f61..45f670d 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -131,7 +131,6 @@ class GrabWidget : public views::WidgetGtk { DISALLOW_COPY_AND_ASSIGN(GrabWidget); }; - void GrabWidget::TryGrabAllInputs() { if (kbd_grab_status_ != GDK_GRAB_SUCCESS) kbd_grab_status_ = gdk_keyboard_grab(window_contents()->window, FALSE, @@ -162,7 +161,7 @@ void GrabWidget::TryGrabAllInputs() { CHECK_EQ(GDK_GRAB_SUCCESS, mouse_grab_status_) << "Failed to grab pointer input:" << mouse_grab_status_; DLOG(INFO) << "Grab Success"; - screen_locker_->ScreenLockReady(); + screen_locker_->OnGrabInputs(); } } @@ -231,31 +230,30 @@ class MouseEventRelay : public MessageLoopForUI::Observer { namespace chromeos { +//////////////////////////////////////////////////////////////////////////////// +// ScreenLocker, public: + ScreenLocker::ScreenLocker(const UserManager::User& user) : lock_window_(NULL), lock_widget_(NULL), screen_lock_view_(NULL), user_(user), - error_info_(NULL) { + error_info_(NULL), + mapped_(false), + input_grabbed_(false) { DCHECK(!screen_locker_); screen_locker_ = this; } -ScreenLocker::~ScreenLocker() { - ClearErrors(); - DCHECK(lock_window_); - lock_window_->Close(); - // lock_widget_ will be deleted by gtk's destroy signal. - screen_locker_ = NULL; - if (CrosLibrary::Get()->EnsureLoaded()) - CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); -} - void ScreenLocker::Init(const gfx::Rect& bounds) { // TODO(oshima): Figure out which UI to keep and remove in the background. views::View* screen = new BackgroundView(); lock_window_ = new views::WidgetGtk(views::WidgetGtk::TYPE_POPUP); lock_window_->Init(NULL, bounds); + g_signal_connect(lock_window_->GetNativeView(), + "map-event", + G_CALLBACK(&OnMapThunk), + this); DCHECK(GTK_WIDGET_REALIZED(lock_window_->GetNativeView())); WmIpc::instance()->SetWindowType( lock_window_->GetNativeView(), @@ -263,7 +261,6 @@ void ScreenLocker::Init(const gfx::Rect& bounds) { NULL); lock_window_->SetContentsView(screen); lock_window_->Show(); - authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); screen_lock_view_ = new ScreenLockView(this); screen_lock_view_->Init(); @@ -282,10 +279,6 @@ void ScreenLocker::Init(const gfx::Rect& bounds) { lock_widget_->Show(); } -void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { - authenticator_ = authenticator; -} - void ScreenLocker::OnLoginFailure(const std::string& error) { DLOG(INFO) << "OnLoginFailure"; EnableInput(); @@ -370,12 +363,11 @@ void ScreenLocker::Signout() { } } -void ScreenLocker::ScreenLockReady() { - // Don't show the password field until we grab all inputs. - lock_widget_->GetRootView()->SetVisible(true); - EnableInput(); - if (CrosLibrary::Get()->EnsureLoaded()) - CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); +void ScreenLocker::OnGrabInputs() { + DLOG(INFO) << "OnGrabInputs"; + input_grabbed_ = true; + if (mapped_) + ScreenLockReady(); } // static @@ -421,4 +413,37 @@ void ScreenLocker::InitClass() { Singleton<ScreenLockObserver>::get(); } +//////////////////////////////////////////////////////////////////////////////// +// ScreenLocker, private: + +ScreenLocker::~ScreenLocker() { + ClearErrors(); + DCHECK(lock_window_); + lock_window_->Close(); + // lock_widget_ will be deleted by gtk's destroy signal. + screen_locker_ = NULL; + if (CrosLibrary::Get()->EnsureLoaded()) + CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); +} + +void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { + authenticator_ = authenticator; +} + +void ScreenLocker::ScreenLockReady() { + DLOG(INFO) << "ScreenLockReady"; + // Don't show the password field until we grab all inputs. + lock_widget_->GetRootView()->SetVisible(true); + EnableInput(); + if (CrosLibrary::Get()->EnsureLoaded()) + CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); +} + +void ScreenLocker::OnMap(GtkWidget* widget, GdkEvent* event) { + DLOG(INFO) << "OnMap"; + mapped_ = true; + if (input_grabbed_) + ScreenLockReady(); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/login/screen_locker.h b/chrome/browser/chromeos/login/screen_locker.h index 9d0a894..ec538b6 100644 --- a/chrome/browser/chromeos/login/screen_locker.h +++ b/chrome/browser/chromeos/login/screen_locker.h @@ -65,8 +65,8 @@ class ScreenLocker : public LoginStatusConsumer, // Exit the chrome, which will sign out the current session. void Signout(); - // Called when the screen locker is ready. - void ScreenLockReady(); + // Called when the all inputs are grabbed. + void OnGrabInputs(); // Returns the user to authenticate. const UserManager::User& user() const { @@ -99,6 +99,12 @@ class ScreenLocker : public LoginStatusConsumer, // Sets the authenticator. void SetAuthenticator(Authenticator* authenticator); + // Called when the screen lock is ready. + void ScreenLockReady(); + + // Event handler for map-event. + CHROMEGTK_CALLBACK_1(ScreenLocker, void, OnMap, GdkEvent*); + // The screen locker window. views::WidgetGtk* lock_window_; @@ -123,6 +129,12 @@ class ScreenLocker : public LoginStatusConsumer, // An info bubble to display login failure message. MessageBubble* error_info_; + // True if the screen locker's window is mapped. + bool mapped_; + + // True if both mouse input and keyboard input are grabbed. + bool input_grabbed_; + // Reference to the single instance of the screen locker object. // This is used to make sure there is only one screen locker instance. static ScreenLocker* screen_locker_; |