Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 2187513003: mash: Partially migrate ShelfLayoutManager to ash common types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_widget.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <cstring>
10 #include <string>
11 #include <vector> 9 #include <vector>
12 10
13 #include "ash/aura/wm_window_aura.h"
14 #include "ash/common/accelerators/accelerator_commands.h"
15 #include "ash/common/ash_switches.h"
16 #include "ash/common/material_design/material_design_controller.h" 11 #include "ash/common/material_design/material_design_controller.h"
17 #include "ash/common/session/session_state_delegate.h" 12 #include "ash/common/session/session_state_delegate.h"
18 #include "ash/common/shelf/shelf_constants.h" 13 #include "ash/common/shelf/shelf_constants.h"
19 #include "ash/common/shelf/shelf_delegate.h" 14 #include "ash/common/shelf/shelf_delegate.h"
20 #include "ash/common/shelf/wm_shelf_util.h" 15 #include "ash/common/shelf/wm_shelf_util.h"
21 #include "ash/common/shell_window_ids.h" 16 #include "ash/common/shell_window_ids.h"
22 #include "ash/common/system/status_area_widget.h" 17 #include "ash/common/system/status_area_widget.h"
18 #include "ash/common/wm/fullscreen_window_finder.h"
23 #include "ash/common/wm/mru_window_tracker.h" 19 #include "ash/common/wm/mru_window_tracker.h"
24 #include "ash/common/wm/window_state.h" 20 #include "ash/common/wm/window_state.h"
21 #include "ash/common/wm_lookup.h"
25 #include "ash/common/wm_root_window_controller.h" 22 #include "ash/common/wm_root_window_controller.h"
26 #include "ash/common/wm_root_window_controller_observer.h" 23 #include "ash/common/wm_root_window_controller_observer.h"
27 #include "ash/common/wm_shell.h" 24 #include "ash/common/wm_shell.h"
28 #include "ash/root_window_controller.h" 25 #include "ash/common/wm_window.h"
29 #include "ash/screen_util.h" 26 #include "ash/screen_util.h"
30 #include "ash/shelf/shelf.h" 27 #include "ash/shelf/shelf.h"
31 #include "ash/shelf/shelf_bezel_event_filter.h" 28 #include "ash/shelf/shelf_bezel_event_filter.h"
32 #include "ash/shelf/shelf_layout_manager_observer.h" 29 #include "ash/shelf/shelf_layout_manager_observer.h"
33 #include "ash/shelf/shelf_util.h"
34 #include "ash/shelf/shelf_widget.h"
35 #include "ash/shell.h" 30 #include "ash/shell.h"
36 #include "ash/wm/gestures/shelf_gesture_handler.h" 31 #include "ash/wm/gestures/shelf_gesture_handler.h"
37 #include "ash/wm/window_animations.h" 32 #include "ash/wm/window_animations.h"
38 #include "ash/wm/window_state_aura.h"
39 #include "ash/wm/window_util.h"
40 #include "ash/wm/workspace_controller.h" 33 #include "ash/wm/workspace_controller.h"
41 #include "base/auto_reset.h" 34 #include "base/auto_reset.h"
42 #include "base/command_line.h"
43 #include "base/i18n/rtl.h" 35 #include "base/i18n/rtl.h"
44 #include "base/strings/string_number_conversions.h"
45 #include "base/strings/string_util.h"
46 #include "ui/aura/client/cursor_client.h"
47 #include "ui/aura/window_event_dispatcher.h"
48 #include "ui/base/ui_base_switches.h"
49 #include "ui/compositor/layer.h" 36 #include "ui/compositor/layer.h"
50 #include "ui/compositor/layer_animation_observer.h" 37 #include "ui/compositor/layer_animation_observer.h"
51 #include "ui/compositor/layer_animator.h" 38 #include "ui/compositor/layer_animator.h"
52 #include "ui/compositor/scoped_layer_animation_settings.h" 39 #include "ui/compositor/scoped_layer_animation_settings.h"
40 #include "ui/display/display.h"
53 #include "ui/display/screen.h" 41 #include "ui/display/screen.h"
54 #include "ui/events/event.h" 42 #include "ui/events/event.h"
55 #include "ui/events/event_handler.h" 43 #include "ui/events/event_handler.h"
56 #include "ui/keyboard/keyboard_util.h" 44 #include "ui/keyboard/keyboard_util.h"
57 #include "ui/views/border.h" 45 #include "ui/views/border.h"
58 #include "ui/views/widget/widget.h" 46 #include "ui/views/widget/widget.h"
59 #include "ui/wm/public/activation_client.h"
60 47
61 namespace ash { 48 namespace ash {
62 namespace { 49 namespace {
63 50
64 // Delay before showing the shelf. This is after the mouse stops moving. 51 // Delay before showing the shelf. This is after the mouse stops moving.
65 const int kAutoHideDelayMS = 200; 52 const int kAutoHideDelayMS = 200;
66 53
67 // To avoid hiding the shelf when the mouse transitions from a message bubble 54 // To avoid hiding the shelf when the mouse transitions from a message bubble
68 // into the shelf, the hit test area is enlarged by this amount of pixels to 55 // into the shelf, the hit test area is enlarged by this amount of pixels to
69 // keep the shelf from hiding. 56 // keep the shelf from hiding.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)) && 117 event->type() != ui::ET_MOUSE_CAPTURE_CHANGED)) &&
131 !shelf_->IsShelfWindow(static_cast<aura::Window*>(event->target())); 118 !shelf_->IsShelfWindow(static_cast<aura::Window*>(event->target()));
132 shelf_->UpdateAutoHideForMouseEvent(event); 119 shelf_->UpdateAutoHideForMouseEvent(event);
133 } 120 }
134 121
135 void ShelfLayoutManager::AutoHideEventFilter::OnGestureEvent( 122 void ShelfLayoutManager::AutoHideEventFilter::OnGestureEvent(
136 ui::GestureEvent* event) { 123 ui::GestureEvent* event) {
137 shelf_->UpdateAutoHideForGestureEvent(event); 124 shelf_->UpdateAutoHideForGestureEvent(event);
138 } 125 }
139 126
140 // ShelfLayoutManager:UpdateShelfObserver -------------------------------------- 127 // ShelfLayoutManager::UpdateShelfObserver -------------------------------------
141 128
142 // UpdateShelfObserver is used to delay updating the background until the 129 // UpdateShelfObserver is used to delay updating the background until the
143 // animation completes. 130 // animation completes.
144 class ShelfLayoutManager::UpdateShelfObserver 131 class ShelfLayoutManager::UpdateShelfObserver
145 : public ui::ImplicitAnimationObserver { 132 : public ui::ImplicitAnimationObserver {
146 public: 133 public:
147 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { 134 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) {
148 shelf_->update_shelf_observer_ = this; 135 shelf_->update_shelf_observer_ = this;
149 } 136 }
150 137
(...skipping 23 matching lines...) Expand all
174 // via WmRootWindowControllerObserver instead of via ShellObserver. There are 161 // via WmRootWindowControllerObserver instead of via ShellObserver. There are
175 // implicit assumptions that these layout managers run in order. In order to 162 // implicit assumptions that these layout managers run in order. In order to
176 // preserve the ordering, OnShelfAlignmentChanged() is implemented here in terms 163 // preserve the ordering, OnShelfAlignmentChanged() is implemented here in terms
177 // of a WmRootWindowControllerObserver instead of a ShellObserver. This gives us 164 // of a WmRootWindowControllerObserver instead of a ShellObserver. This gives us
178 // a sane ordering (or at least ordering as we've always had it in ash). 165 // a sane ordering (or at least ordering as we've always had it in ash).
179 class ShelfLayoutManager::RootWindowControllerObserverImpl 166 class ShelfLayoutManager::RootWindowControllerObserverImpl
180 : public WmRootWindowControllerObserver { 167 : public WmRootWindowControllerObserver {
181 public: 168 public:
182 explicit RootWindowControllerObserverImpl( 169 explicit RootWindowControllerObserverImpl(
183 ShelfLayoutManager* shelf_layout_manager) 170 ShelfLayoutManager* shelf_layout_manager)
184 : shelf_layout_manager_(shelf_layout_manager) {} 171 : shelf_layout_manager_(shelf_layout_manager),
185 ~RootWindowControllerObserverImpl() override {} 172 root_window_controller_(
173 WmLookup::Get()
174 ->GetWindowForWidget(shelf_layout_manager->shelf_widget())
175 ->GetRootWindowController()) {
176 root_window_controller_->AddObserver(this);
177 }
178 ~RootWindowControllerObserverImpl() override {
179 root_window_controller_->RemoveObserver(this);
180 }
186 181
187 // WmRootWindowControllerObserver: 182 // WmRootWindowControllerObserver:
188 void OnShelfAlignmentChanged() override { 183 void OnShelfAlignmentChanged() override {
189 shelf_layout_manager_->LayoutShelf(); 184 shelf_layout_manager_->LayoutShelf();
190 } 185 }
191 186
192 private: 187 private:
193 ShelfLayoutManager* shelf_layout_manager_; 188 ShelfLayoutManager* shelf_layout_manager_;
189 WmRootWindowController* root_window_controller_;
194 190
195 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl); 191 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl);
196 }; 192 };
197 193
198 // ShelfLayoutManager ---------------------------------------------------------- 194 // ShelfLayoutManager ----------------------------------------------------------
199 195
200 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget) 196 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget)
201 : SnapToPixelLayoutManager(shelf_widget->GetNativeView()->parent()), 197 : SnapToPixelLayoutManager(shelf_widget->GetNativeView()->parent()),
202 root_window_(shelf_widget->GetNativeView()->GetRootWindow()), 198 root_window_(shelf_widget->GetNativeView()->GetRootWindow()),
203 updating_bounds_(false), 199 updating_bounds_(false),
204 shelf_widget_(shelf_widget), 200 shelf_widget_(shelf_widget),
205 workspace_controller_(NULL), 201 workspace_controller_(NULL),
206 window_overlaps_shelf_(false), 202 window_overlaps_shelf_(false),
207 mouse_over_shelf_when_auto_hide_timer_started_(false), 203 mouse_over_shelf_when_auto_hide_timer_started_(false),
208 bezel_event_filter_(new ShelfBezelEventFilter(this)), 204 bezel_event_filter_(new ShelfBezelEventFilter(this)),
209 gesture_drag_status_(GESTURE_DRAG_NONE), 205 gesture_drag_status_(GESTURE_DRAG_NONE),
210 gesture_drag_amount_(0.f), 206 gesture_drag_amount_(0.f),
211 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), 207 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
212 update_shelf_observer_(NULL), 208 update_shelf_observer_(NULL),
213 chromevox_panel_height_(0), 209 chromevox_panel_height_(0),
214 duration_override_in_ms_(0) { 210 duration_override_in_ms_(0),
211 root_window_controller_observer_(
212 new RootWindowControllerObserverImpl(this)) {
215 WmShell::Get()->AddShellObserver(this); 213 WmShell::Get()->AddShellObserver(this);
216
217 if (!Shell::GetInstance()->in_mus()) {
218 root_window_controller_observer_.reset(
219 new RootWindowControllerObserverImpl(this));
220 WmWindowAura::Get(root_window_)
221 ->GetRootWindowController()
222 ->AddObserver(root_window_controller_observer_.get());
223 }
224 WmShell::Get()->AddLockStateObserver(this); 214 WmShell::Get()->AddLockStateObserver(this);
225 aura::client::GetActivationClient(root_window_)->AddObserver(this); 215 WmShell::Get()->AddActivationObserver(this);
226 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); 216 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
227 } 217 }
228 218
229 ShelfLayoutManager::~ShelfLayoutManager() { 219 ShelfLayoutManager::~ShelfLayoutManager() {
230 if (update_shelf_observer_) 220 if (update_shelf_observer_)
231 update_shelf_observer_->Detach(); 221 update_shelf_observer_->Detach();
232 222
233 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 223 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
234 WillDeleteShelfLayoutManager()); 224 WillDeleteShelfLayoutManager());
235 WmShell::Get()->RemoveShellObserver(this); 225 WmShell::Get()->RemoveShellObserver(this);
236 WmShell::Get()->RemoveLockStateObserver(this); 226 WmShell::Get()->RemoveLockStateObserver(this);
237 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( 227 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this);
238 this);
239 if (root_window_controller_observer_) {
240 WmWindowAura::Get(root_window_)
241 ->GetRootWindowController()
242 ->RemoveObserver(root_window_controller_observer_.get());
243 }
244 } 228 }
245 229
246 void ShelfLayoutManager::PrepareForShutdown() { 230 void ShelfLayoutManager::PrepareForShutdown() {
247 in_shutdown_ = true; 231 in_shutdown_ = true;
248 // Clear all event filters, otherwise sometimes those filters may catch 232 // Clear all event filters, otherwise sometimes those filters may catch
249 // synthesized mouse event and cause crashes during the shutdown. 233 // synthesized mouse event and cause crashes during the shutdown.
250 set_workspace_controller(NULL); 234 set_workspace_controller(NULL);
251 auto_hide_event_filter_.reset(); 235 auto_hide_event_filter_.reset();
252 bezel_event_filter_.reset(); 236 bezel_event_filter_.reset();
253 // Stop observing window change, otherwise we can attempt to update a 237 // Stop observing changes to avoid updating a partially destructed shelf.
254 // partially destructed shelf. 238 WmShell::Get()->RemoveActivationObserver(this);
255 aura::client::GetActivationClient(root_window_)->RemoveObserver(this);
256 } 239 }
257 240
258 bool ShelfLayoutManager::IsVisible() const { 241 bool ShelfLayoutManager::IsVisible() const {
259 // status_area_widget() may be NULL during the shutdown. 242 // status_area_widget() may be NULL during the shutdown.
260 return shelf_widget_->status_area_widget() && 243 return shelf_widget_->status_area_widget() &&
261 shelf_widget_->status_area_widget()->IsVisible() && 244 shelf_widget_->status_area_widget()->IsVisible() &&
262 (state_.visibility_state == SHELF_VISIBLE || 245 (state_.visibility_state == SHELF_VISIBLE ||
263 (state_.visibility_state == SHELF_AUTO_HIDE && 246 (state_.visibility_state == SHELF_AUTO_HIDE &&
264 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); 247 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN));
265 } 248 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 SetState(SHELF_VISIBLE); 296 SetState(SHELF_VISIBLE);
314 } else if (WmShell::Get()->IsPinned()) { 297 } else if (WmShell::Get()->IsPinned()) {
315 SetState(SHELF_HIDDEN); 298 SetState(SHELF_HIDDEN);
316 } else { 299 } else {
317 // TODO(zelidrag): Verify shelf drag animation still shows on the device 300 // TODO(zelidrag): Verify shelf drag animation still shows on the device
318 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. 301 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
319 wm::WorkspaceWindowState window_state( 302 wm::WorkspaceWindowState window_state(
320 workspace_controller_->GetWindowState()); 303 workspace_controller_->GetWindowState());
321 switch (window_state) { 304 switch (window_state) {
322 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { 305 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: {
323 const aura::Window* fullscreen_window = 306 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode(
324 GetRootWindowController(root_window_)->GetWindowForFullscreenMode(); 307 WmLookup::Get()->GetWindowForWidget(shelf_widget_));
325 if (fullscreen_window && 308 if (fullscreen_window &&
326 wm::GetWindowState(fullscreen_window) 309 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen()) {
327 ->hide_shelf_when_fullscreen()) {
328 SetState(SHELF_HIDDEN); 310 SetState(SHELF_HIDDEN);
329 } else { 311 } else {
330 // The shelf is sometimes not hidden when in immersive fullscreen. 312 // The shelf is sometimes not hidden when in immersive fullscreen.
331 // Force the shelf to be auto hidden in this case. 313 // Force the shelf to be auto hidden in this case.
332 SetState(SHELF_AUTO_HIDE); 314 SetState(SHELF_AUTO_HIDE);
333 } 315 }
334 break; 316 break;
335 } 317 }
336 318
337 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: 319 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED:
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(WmWindow* root_window) { 533 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(WmWindow* root_window) {
552 UpdateVisibilityState(); 534 UpdateVisibilityState();
553 } 535 }
554 536
555 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) { 537 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) {
556 // Shelf needs to be hidden on entering to pinned mode, or restored 538 // Shelf needs to be hidden on entering to pinned mode, or restored
557 // on exiting from pinned mode. 539 // on exiting from pinned mode.
558 UpdateVisibilityState(); 540 UpdateVisibilityState();
559 } 541 }
560 542
561 void ShelfLayoutManager::OnWindowActivated( 543 void ShelfLayoutManager::OnWindowActivated(WmWindow* gained_active,
562 aura::client::ActivationChangeObserver::ActivationReason reason, 544 WmWindow* lost_active) {
563 aura::Window* gained_active,
564 aura::Window* lost_active) {
565 UpdateAutoHideStateNow(); 545 UpdateAutoHideStateNow();
566 } 546 }
567 547
568 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { 548 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
569 bool keyboard_is_about_to_hide = false; 549 bool keyboard_is_about_to_hide = false;
570 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) 550 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty())
571 keyboard_is_about_to_hide = true; 551 keyboard_is_about_to_hide = true;
572 552
573 keyboard_bounds_ = new_bounds; 553 keyboard_bounds_ = new_bounds;
574 OnWindowResized(); 554 OnWindowResized();
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 // visible. 1004 // visible.
1025 return show_shelf_region_in_screen; 1005 return show_shelf_region_in_screen;
1026 } 1006 }
1027 1007
1028 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( 1008 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
1029 ShelfVisibilityState visibility_state) const { 1009 ShelfVisibilityState visibility_state) const {
1030 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_ || 1010 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_ ||
1031 !shelf_widget_->shelf()) 1011 !shelf_widget_->shelf())
1032 return SHELF_AUTO_HIDE_HIDDEN; 1012 return SHELF_AUTO_HIDE_HIDDEN;
1033 1013
1014 const int64_t shelf_display_id = WmLookup::Get()
1015 ->GetWindowForWidget(shelf_widget_)
1016 ->GetDisplayNearestWindow()
1017 .id();
1018
1034 // Unhide the shelf only on the active screen when the AppList is shown 1019 // Unhide the shelf only on the active screen when the AppList is shown
1035 // (crbug.com/312445). 1020 // (crbug.com/312445).
1036 if (WmShell::Get()->GetAppListTargetVisibility()) { 1021 if (WmShell::Get()->GetAppListTargetVisibility()) {
1037 aura::Window* active_window = wm::GetActiveWindow(); 1022 WmWindow* window = WmShell::Get()->GetActiveWindow();
1038 aura::Window* shelf_window = shelf_widget_->GetNativeWindow(); 1023 if (window && window->GetDisplayNearestWindow().id() == shelf_display_id)
1039 if (active_window && shelf_window &&
1040 active_window->GetRootWindow() == shelf_window->GetRootWindow()) {
1041 return SHELF_AUTO_HIDE_SHOWN; 1024 return SHELF_AUTO_HIDE_SHOWN;
1042 }
1043 } 1025 }
1044 1026
1045 if (shelf_widget_->status_area_widget() && 1027 if (shelf_widget_->status_area_widget() &&
1046 shelf_widget_->status_area_widget()->ShouldShowShelf()) 1028 shelf_widget_->status_area_widget()->ShouldShowShelf())
1047 return SHELF_AUTO_HIDE_SHOWN; 1029 return SHELF_AUTO_HIDE_SHOWN;
1048 1030
1049 if (shelf_widget_->shelf() && shelf_widget_->shelf()->IsShowingMenu()) 1031 if (shelf_widget_->shelf() && shelf_widget_->shelf()->IsShowingMenu())
1050 return SHELF_AUTO_HIDE_SHOWN; 1032 return SHELF_AUTO_HIDE_SHOWN;
1051 1033
1052 if (shelf_widget_->shelf() && 1034 if (shelf_widget_->shelf() &&
1053 shelf_widget_->shelf()->IsShowingOverflowBubble()) 1035 shelf_widget_->shelf()->IsShowingOverflowBubble())
1054 return SHELF_AUTO_HIDE_SHOWN; 1036 return SHELF_AUTO_HIDE_SHOWN;
1055 1037
1056 if (shelf_widget_->IsActive() || 1038 if (shelf_widget_->IsActive() ||
1057 (shelf_widget_->status_area_widget() && 1039 (shelf_widget_->status_area_widget() &&
1058 shelf_widget_->status_area_widget()->IsActive())) 1040 shelf_widget_->status_area_widget()->IsActive()))
1059 return SHELF_AUTO_HIDE_SHOWN; 1041 return SHELF_AUTO_HIDE_SHOWN;
1060 1042
1061 // TODO(jamescook): Track visible windows on mash via ShelfDelegate. 1043 // TODO(jamescook): Track visible windows on mash via ShelfDelegate.
1062 if (!Shell::GetInstance()->in_mus()) { 1044 if (!Shell::GetInstance()->in_mus()) {
1063 const std::vector<WmWindow*> windows = 1045 const std::vector<WmWindow*> windows =
1064 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); 1046 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal();
1065 1047
1066 // Process the window list and check if there are any visible windows. 1048 // Process the window list and check if there are any visible windows.
1067 bool visible_window = false; 1049 bool visible_window = false;
1068 for (size_t i = 0; i < windows.size(); ++i) { 1050 for (size_t i = 0; i < windows.size(); ++i) {
1069 if (windows[i] && windows[i]->IsVisible() && 1051 if (windows[i] && windows[i]->IsVisible() &&
1070 !windows[i]->GetWindowState()->IsMinimized() && 1052 !windows[i]->GetWindowState()->IsMinimized() &&
1071 root_window_ == 1053 windows[i]->GetDisplayNearestWindow().id() == shelf_display_id) {
1072 WmWindowAura::GetAuraWindow(windows[i]->GetRootWindow())) {
1073 visible_window = true; 1054 visible_window = true;
1074 break; 1055 break;
1075 } 1056 }
1076 } 1057 }
1077 // If there are no visible windows do not hide the shelf. 1058 // If there are no visible windows do not hide the shelf.
1078 if (!visible_window) 1059 if (!visible_window)
1079 return SHELF_AUTO_HIDE_SHOWN; 1060 return SHELF_AUTO_HIDE_SHOWN;
1080 } 1061 }
1081 1062
1082 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) 1063 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS)
1083 return gesture_drag_auto_hide_state_; 1064 return gesture_drag_auto_hide_state_;
1084 1065
1085 // Don't show if the user is dragging the mouse. 1066 // Don't show if the user is dragging the mouse.
1086 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) 1067 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag())
1087 return SHELF_AUTO_HIDE_HIDDEN; 1068 return SHELF_AUTO_HIDE_HIDDEN;
1088 1069
1089 // Ignore the mouse position if mouse events are disabled. 1070 // Ignore the mouse position if mouse events are disabled.
1090 aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( 1071 if (!shelf_widget_->IsMouseEventsEnabled())
1091 shelf_widget_->GetNativeWindow()->GetRootWindow());
1092 if (!cursor_client->IsMouseEventsEnabled())
1093 return SHELF_AUTO_HIDE_HIDDEN; 1072 return SHELF_AUTO_HIDE_HIDDEN;
1094 1073
1095 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen(); 1074 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen();
1096 if (shelf_widget_->status_area_widget() && 1075 if (shelf_widget_->status_area_widget() &&
1097 shelf_widget_->status_area_widget()->IsMessageBubbleShown() && 1076 shelf_widget_->status_area_widget()->IsMessageBubbleShown() &&
1098 IsVisible()) { 1077 IsVisible()) {
1099 // Increase the the hit test area to prevent the shelf from disappearing 1078 // Increase the the hit test area to prevent the shelf from disappearing
1100 // when the mouse is over the bubble gap. 1079 // when the mouse is over the bubble gap.
1101 ShelfAlignment alignment = GetAlignment(); 1080 ShelfAlignment alignment = GetAlignment();
1102 shelf_region.Inset( 1081 shelf_region.Inset(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 if (ash::MaterialDesignController::IsShelfMaterial()) { 1185 if (ash::MaterialDesignController::IsShelfMaterial()) {
1207 return (state.visibility_state == SHELF_AUTO_HIDE && 1186 return (state.visibility_state == SHELF_AUTO_HIDE &&
1208 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN) 1187 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)
1209 ? 1.0f 1188 ? 1.0f
1210 : 0.0f; 1189 : 0.0f;
1211 } 1190 }
1212 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; 1191 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f;
1213 } 1192 }
1214 1193
1215 } // namespace ash 1194 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698