Index: ash/shelf/shelf_layout_manager.cc |
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc |
index 68302878ad26b2618d1f535db572c9167d6702f3..db45c681e8e053282f840bcddb664756867fee18 100644 |
--- a/ash/shelf/shelf_layout_manager.cc |
+++ b/ash/shelf/shelf_layout_manager.cc |
@@ -36,6 +36,7 @@ |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_util.h" |
#include "ui/aura/client/activation_client.h" |
+#include "ui/aura/client/cursor_client.h" |
#include "ui/aura/root_window.h" |
#include "ui/base/events/event.h" |
#include "ui/base/events/event_handler.h" |
@@ -280,7 +281,8 @@ void ShelfLayoutManager::LayoutShelf() { |
if (shelf_->launcher()) |
shelf_->launcher()->SetLauncherViewBounds( |
target_bounds.launcher_bounds_in_shelf); |
- GetLayer(shelf_->status_area_widget())->SetOpacity(target_bounds.opacity); |
+ GetLayer(shelf_->status_area_widget())->SetOpacity( |
+ target_bounds.status_opacity); |
// TODO(harrym): Once status area widget is a child view of shelf |
// this can be simplified. |
gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; |
@@ -571,12 +573,6 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
state.window_state = workspace_controller_ ? |
workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT; |
- // It's possible for SetState() when a window becomes maximized but the state |
pkotwicz
2013/08/09 00:04:34
This comment is outdated. State::window_state now
|
- // won't have changed value. Do the dimming check before the early exit. |
- shelf_->SetDimsShelf( |
- (state.visibility_state == SHELF_VISIBLE) && |
- state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED); |
- |
if (state_.Equals(state)) |
return; // Nothing changed. |
@@ -631,18 +627,11 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
old_state.visibility_state != SHELF_VISIBLE) { |
change_type = BackgroundAnimator::CHANGE_IMMEDIATE; |
} else { |
- // Delay updating the background when going from SHELF_AUTO_HIDE_SHOWN to |
- // SHELF_AUTO_HIDE_HIDDEN until the shelf animates out. Otherwise during the |
- // animation you see the background change. |
- // Also delay the animation when the shelf was hidden, and has just been |
- // made visible (e.g. using a gesture-drag). |
- if (state.visibility_state == SHELF_AUTO_HIDE && |
pkotwicz
2013/08/09 00:04:34
To the extent of my understanding this is dead cod
|
- state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN && |
- old_state.visibility_state == SHELF_AUTO_HIDE) { |
- delay_background_change = true; |
- } else if (state.visibility_state == SHELF_VISIBLE && |
- old_state.visibility_state == SHELF_AUTO_HIDE && |
- old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
+ // Delay the animation when the shelf was hidden, and has just been made |
+ // visible (e.g. using a gesture-drag). |
+ if (state.visibility_state == SHELF_VISIBLE && |
+ old_state.visibility_state == SHELF_AUTO_HIDE && |
+ old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
delay_background_change = true; |
} |
} |
@@ -653,7 +642,14 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
// UpdateShelfBackground deletes itself when the animation is done. |
update_shelf_observer_ = new UpdateShelfObserver(this); |
status_animation_setter.AddObserver(update_shelf_observer_); |
+ } else { |
pkotwicz
2013/08/09 00:04:34
Some house cleaning.
|
+ UpdateShelfBackground(change_type); |
} |
+ |
+ shelf_->SetDimsShelf( |
+ (state.visibility_state == SHELF_VISIBLE) && |
+ state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED); |
+ |
ui::Layer* layer = GetLayer(shelf_->status_area_widget()); |
// TODO(harrym): Remove when status_area is view (crbug.com/180422). |
gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; |
@@ -666,8 +662,6 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { |
Shell::GetInstance()->SetDisplayWorkAreaInsets( |
root_window_, target_bounds.work_area_insets); |
UpdateHitTestBounds(); |
- if (!delay_background_change) |
- UpdateShelfBackground(change_type); |
sadrul
2013/08/09 05:30:13
This change, the change between newlines 645-652,
|
// OnAutoHideStateChanged Should be emitted when: |
// - firstly state changed to auto-hide from other state |
@@ -789,7 +783,8 @@ void ShelfLayoutManager::CalculateTargetBounds( |
state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; |
target_bounds->status_opacity = |
(state.visibility_state == SHELF_AUTO_HIDE && |
- state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) ? |
+ state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN && |
+ gesture_drag_status_ != GESTURE_DRAG_IN_PROGRESS) ? |
0.0f : target_bounds->opacity; |
if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) |
@@ -941,9 +936,6 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
if (visibility_state != SHELF_AUTO_HIDE || !shelf_) |
return SHELF_AUTO_HIDE_HIDDEN; |
- if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
- return gesture_drag_auto_hide_state_; |
- |
Shell* shell = Shell::GetInstance(); |
if (shell->GetAppListTargetVisibility()) |
return SHELF_AUTO_HIDE_SHOWN; |
@@ -961,10 +953,36 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
if (shelf_->IsActive() || shelf_->status_area_widget()->IsActive()) |
return SHELF_AUTO_HIDE_SHOWN; |
+ const std::vector<aura::Window*> windows = |
+ ash::MruWindowTracker::BuildWindowList(false); |
+ |
+ // Process the window list and check if there are any visible windows. |
+ bool visible_window = false; |
+ for (size_t i = 0; i < windows.size(); ++i) { |
+ if (windows[i] && windows[i]->IsVisible() && |
+ !ash::wm::IsWindowMinimized(windows[i]) && |
+ root_window_ == windows[i]->GetRootWindow()) { |
+ visible_window = true; |
+ break; |
+ } |
+ } |
+ // If there are no visible windows do not hide the shelf. |
+ if (!visible_window) |
+ return SHELF_AUTO_HIDE_SHOWN; |
+ |
+ if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
+ return gesture_drag_auto_hide_state_; |
+ |
// Don't show if the user is dragging the mouse. |
if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) |
return SHELF_AUTO_HIDE_HIDDEN; |
+ // Ignore the mouse position if mouse events are disabled. |
+ aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( |
+ shelf_->GetNativeWindow()->GetRootWindow()); |
+ if (!cursor_client->IsMouseEventsEnabled()) |
+ return SHELF_AUTO_HIDE_HIDDEN; |
+ |
gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen(); |
if (shelf_->status_area_widget() && |
shelf_->status_area_widget()->IsMessageBubbleShown() && |
@@ -1005,19 +1023,7 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
return SHELF_AUTO_HIDE_SHOWN; |
} |
- const std::vector<aura::Window*> windows = |
- ash::MruWindowTracker::BuildWindowList(false); |
- |
- // Process the window list and check if there are any visible windows. |
- for (size_t i = 0; i < windows.size(); ++i) { |
- if (windows[i] && windows[i]->IsVisible() && |
- !ash::wm::IsWindowMinimized(windows[i]) && |
- root_window_ == windows[i]->GetRootWindow()) |
- return SHELF_AUTO_HIDE_HIDDEN; |
- } |
- |
- // If there are no visible windows do not hide the shelf. |
- return SHELF_AUTO_HIDE_SHOWN; |
+ return SHELF_AUTO_HIDE_HIDDEN; |
} |
void ShelfLayoutManager::UpdateHitTestBounds() { |