summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 04:22:31 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 04:22:31 +0000
commitfa404270b07b471ea008520dabaa6db35d7fbe82 (patch)
tree879921a11b375817a1348e187375b34e908978fc
parent9d33f85ce5de15425824fe9d7d4074e603cda59c (diff)
downloadchromium_src-fa404270b07b471ea008520dabaa6db35d7fbe82.zip
chromium_src-fa404270b07b471ea008520dabaa6db35d7fbe82.tar.gz
chromium_src-fa404270b07b471ea008520dabaa6db35d7fbe82.tar.bz2
Removes caching of whether the launcher should be visible from
StatusAreaWidget and instead queries as necessary. The problem is the current code was caching things based on mouse location, but it wasn't always updating when the mouse moved. Since the shelf has its own mouse handler that queries for state it isn't necessary to duplicate that in the tray. BUG=148548 TEST=see bug R=sadrul@chromium.org Review URL: https://chromiumcodereview.appspot.com/10909220 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156740 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/system/status_area_widget.cc41
-rw-r--r--ash/system/status_area_widget.h11
-rw-r--r--ash/system/tray/system_tray.cc10
-rw-r--r--ash/system/tray/system_tray_bubble.cc2
-rw-r--r--ash/system/tray/tray_background_view.cc6
-rw-r--r--ash/system/tray/tray_background_view.h3
-rw-r--r--ash/system/web_notification/web_notification_tray.cc8
-rw-r--r--ash/wm/shelf_layout_manager.cc2
8 files changed, 29 insertions, 54 deletions
diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc
index 97dd7ca..b3e2b4f 100644
--- a/ash/system/status_area_widget.cc
+++ b/ash/system/status_area_widget.cc
@@ -303,8 +303,7 @@ StatusAreaWidget::StatusAreaWidget()
: status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate),
system_tray_(NULL),
web_notification_tray_(NULL),
- login_status_(user::LOGGED_IN_NONE),
- should_show_launcher_(false) {
+ login_status_(user::LOGGED_IN_NONE) {
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.delegate = status_area_widget_delegate_;
@@ -343,6 +342,22 @@ void StatusAreaWidget::Shutdown() {
delete web_notification_tray_;
}
+bool StatusAreaWidget::ShouldShowLauncher() const {
+ if ((system_tray_ && system_tray_->HasSystemBubble()) ||
+ (web_notification_tray_ &&
+ web_notification_tray_->IsMessageCenterBubbleVisible()))
+ return true;
+
+ if (!Shell::GetInstance()->shelf()->IsVisible())
+ return false;
+
+ // If the launcher is currently visible, don't hide the launcher if the mouse
+ // is in any of the notification bubbles.
+ return (system_tray_ && system_tray_->IsMouseInNotificationBubble()) ||
+ (web_notification_tray_ &&
+ web_notification_tray_->IsMouseInNotificationBubble());
+}
+
void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) {
system_tray_ = new SystemTray(this);
status_area_widget_delegate_->AddTray(system_tray_);
@@ -403,27 +418,5 @@ void StatusAreaWidget::UpdateAfterLoginStatusChange(
web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
}
-void StatusAreaWidget::UpdateShouldShowLauncher() {
- // If any bubble is visible, we should show the launcher.
- bool should_show_launcher =
- (system_tray_ && system_tray_->HasSystemBubble()) ||
- (web_notification_tray_ &&
- web_notification_tray_->IsMessageCenterBubbleVisible());
- if (!should_show_launcher && Shell::GetInstance()->shelf()->IsVisible()) {
- // If the launcher is currently visible, don't hide the launcher if
- // the mouse is in this widget or in any notification bubbles.
- should_show_launcher =
- (GetWindowBoundsInScreen().Contains(
- gfx::Screen::GetCursorScreenPoint())) ||
- (system_tray_ && system_tray_->IsMouseInNotificationBubble()) ||
- (web_notification_tray_ &&
- web_notification_tray_->IsMouseInNotificationBubble());
- }
- if (should_show_launcher != should_show_launcher_) {
- should_show_launcher_ = should_show_launcher;
- Shell::GetInstance()->shelf()->UpdateAutoHideState();
- }
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/system/status_area_widget.h b/ash/system/status_area_widget.h
index 99fac74..4a5e600 100644
--- a/ash/system/status_area_widget.h
+++ b/ash/system/status_area_widget.h
@@ -56,11 +56,6 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
// notification tray.
void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
- // Called whenever the launcher auto-hide behavior may need updating.
- // This sets should_show_launcher_ and calls
- // ShelfLayoutManager::UpdateAutoHideState() if the state has changed.
- void UpdateShouldShowLauncher();
-
internal::StatusAreaWidgetDelegate* status_area_widget_delegate() {
return status_area_widget_delegate_;
}
@@ -74,7 +69,10 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
user::LoginStatus login_status() const { return login_status_; }
- bool should_show_launcher() const { return should_show_launcher_; }
+ // Returns true if the launcher should be visible. This is used when the
+ // launcher is configured to auto-hide and test if the shelf should force
+ // the launcher to remain visible.
+ bool ShouldShowLauncher() const;
private:
void AddSystemTray(ShellDelegate* shell_delegate);
@@ -86,7 +84,6 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
SystemTray* system_tray_;
WebNotificationTray* web_notification_tray_;
user::LoginStatus login_status_;
- bool should_show_launcher_;
DISALLOW_COPY_AND_ASSIGN(StatusAreaWidget);
};
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 46df3d5..38ca270 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -31,6 +31,7 @@
#include "ash/system/tray_update.h"
#include "ash/system/user/login_status.h"
#include "ash/system/user/tray_user.h"
+#include "ash/wm/shelf_layout_manager.h"
#include "base/logging.h"
#include "base/timer.h"
#include "base/utf_string_conversions.h"
@@ -268,7 +269,7 @@ void SystemTray::RemoveBubble(SystemTrayBubble* bubble) {
if (bubble == bubble_.get()) {
DestroyBubble();
UpdateNotificationBubble(); // State changed, re-create notifications.
- UpdateShouldShowLauncher();
+ Shell::GetInstance()->shelf()->UpdateAutoHideState();
} else if (bubble == notification_bubble_) {
notification_bubble_.reset();
status_area_widget()->SetHideWebNotifications(false);
@@ -335,11 +336,6 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
init_params.arrow_color = kBackgroundColor;
}
init_params.arrow_offset = arrow_offset;
- // |bubble_->InitView()| shows and activates the status tray popup, which
- // can trigger the shelf to hide (if auto-hide is turned on). So it is
- // necessary to update the desired launcher visibility before showing the
- // status bubble.
- UpdateShouldShowLauncher();
bubble_->InitView(anchor, init_params, delegate->GetUserLoginStatus());
}
// Save height of default view for creating detailed views directly.
@@ -353,7 +349,7 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
UpdateNotificationBubble(); // State changed, re-create notifications.
status_area_widget()->SetHideWebNotifications(true);
- UpdateShouldShowLauncher();
+ Shell::GetInstance()->shelf()->UpdateAutoHideState();
}
void SystemTray::UpdateNotificationBubble() {
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc
index 89f3ea3..b721f4b 100644
--- a/ash/system/tray/system_tray_bubble.cc
+++ b/ash/system/tray/system_tray_bubble.cc
@@ -319,12 +319,10 @@ void SystemTrayBubble::BubbleViewDestroyed() {
void SystemTrayBubble::OnMouseEnteredView() {
StopAutoCloseTimer();
- tray_->UpdateShouldShowLauncher();
}
void SystemTrayBubble::OnMouseExitedView() {
RestartAutoCloseTimer();
- tray_->UpdateShouldShowLauncher();
}
void SystemTrayBubble::OnClickedOutsideView() {
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 98cd651..147c70f 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -190,13 +190,11 @@ void TrayBackgroundView::Initialize() {
void TrayBackgroundView::OnMouseEntered(const ui::MouseEvent& event) {
hover_background_animator_.SetPaintsBackground(true,
internal::BackgroundAnimator::CHANGE_ANIMATE);
- UpdateShouldShowLauncher();
}
void TrayBackgroundView::OnMouseExited(const ui::MouseEvent& event) {
hover_background_animator_.SetPaintsBackground(false,
internal::BackgroundAnimator::CHANGE_ANIMATE);
- UpdateShouldShowLauncher();
}
void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) {
@@ -279,9 +277,5 @@ void TrayBackgroundView::SetBorder() {
}
}
-void TrayBackgroundView::UpdateShouldShowLauncher() {
- status_area_widget()->UpdateShouldShowLauncher();
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/system/tray/tray_background_view.h b/ash/system/tray/tray_background_view.h
index 615a455..9f33db7d 100644
--- a/ash/system/tray/tray_background_view.h
+++ b/ash/system/tray/tray_background_view.h
@@ -96,9 +96,6 @@ class ASH_EXPORT TrayBackgroundView : public internal::ActionableView,
bool value,
internal::BackgroundAnimator::ChangeType change_type);
- // Convenience function to call same function in status_area_widget_.
- void UpdateShouldShowLauncher();
-
StatusAreaWidget* status_area_widget() {
return status_area_widget_;
}
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index 58ce164..ecfeb21 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -4,10 +4,12 @@
#include "ash/system/web_notification/web_notification_tray.h"
+#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/tray_bubble_view.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_views.h"
+#include "ash/wm/shelf_layout_manager.h"
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/stringprintf.h"
@@ -907,11 +909,9 @@ class WebNotificationTray::Bubble : public TrayBubbleView::Host,
}
virtual void OnMouseEnteredView() OVERRIDE {
- tray_->UpdateShouldShowLauncher();
}
virtual void OnMouseExitedView() OVERRIDE {
- tray_->UpdateShouldShowLauncher();
}
virtual void OnClickedOutsideView() OVERRIDE {
@@ -1157,7 +1157,7 @@ void WebNotificationTray::ShowMessageCenterBubble() {
HidePopupBubble();
message_center_bubble_.reset(new MessageCenterBubble(this));
status_area_widget()->SetHideSystemNotifications(true);
- UpdateShouldShowLauncher();
+ Shell::GetInstance()->shelf()->UpdateAutoHideState();
}
void WebNotificationTray::HideMessageCenterBubble() {
@@ -1168,7 +1168,7 @@ void WebNotificationTray::HideMessageCenterBubble() {
notification_list_->SetMessageCenterVisible(false);
UpdateTray();
status_area_widget()->SetHideSystemNotifications(false);
- UpdateShouldShowLauncher();
+ Shell::GetInstance()->shelf()->UpdateAutoHideState();
}
void WebNotificationTray::SetHidePopupBubble(bool hide) {
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 12a4171..c88d2f1 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -820,7 +820,7 @@ ShelfLayoutManager::AutoHideState ShelfLayoutManager::CalculateAutoHideState(
return AUTO_HIDE_SHOWN;
if (shell->status_area_widget() &&
- shell->status_area_widget()->should_show_launcher())
+ shell->status_area_widget()->ShouldShowLauncher())
return AUTO_HIDE_SHOWN;
if (launcher_ && launcher_->IsShowingMenu())