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

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
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 WmLookup::Get()
173 ->GetWindowForWidget(shelf_layout_manager_->shelf_widget())
174 ->GetRootWindowController()
175 ->AddObserver(this);
176 }
177 ~RootWindowControllerObserverImpl() override {
178 views::Widget* widget = shelf_layout_manager_->shelf_widget();
179 if (widget && WmLookup::Get()->GetWindowForWidget(widget)) {
James Cook 2016/07/27 03:15:11 Just curious, is |widget| null in tests, or does t
msw 2016/07/27 22:31:17 Neither. |window| may be null; I removed the extra
180 WmLookup::Get()
181 ->GetWindowForWidget(widget)
182 ->GetRootWindowController()
183 ->RemoveObserver(this);
184 }
185 }
186 186
187 // WmRootWindowControllerObserver: 187 // WmRootWindowControllerObserver:
188 void OnShelfAlignmentChanged() override { 188 void OnShelfAlignmentChanged() override {
189 shelf_layout_manager_->LayoutShelf(); 189 shelf_layout_manager_->LayoutShelf();
190 } 190 }
191 191
192 private: 192 private:
193 ShelfLayoutManager* shelf_layout_manager_; 193 ShelfLayoutManager* shelf_layout_manager_;
194 194
195 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl); 195 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl);
196 }; 196 };
197 197
198 // ShelfLayoutManager ---------------------------------------------------------- 198 // ShelfLayoutManager ----------------------------------------------------------
199 199
200 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget) 200 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget)
201 : SnapToPixelLayoutManager(shelf_widget->GetNativeView()->parent()), 201 : SnapToPixelLayoutManager(shelf_widget->GetNativeView()->parent()),
202 root_window_(shelf_widget->GetNativeView()->GetRootWindow()), 202 root_window_(shelf_widget->GetNativeView()->GetRootWindow()),
203 updating_bounds_(false), 203 updating_bounds_(false),
204 shelf_widget_(shelf_widget), 204 shelf_widget_(shelf_widget),
205 workspace_controller_(NULL), 205 workspace_controller_(NULL),
206 window_overlaps_shelf_(false), 206 window_overlaps_shelf_(false),
207 mouse_over_shelf_when_auto_hide_timer_started_(false), 207 mouse_over_shelf_when_auto_hide_timer_started_(false),
208 bezel_event_filter_(new ShelfBezelEventFilter(this)), 208 bezel_event_filter_(new ShelfBezelEventFilter(this)),
209 gesture_drag_status_(GESTURE_DRAG_NONE), 209 gesture_drag_status_(GESTURE_DRAG_NONE),
210 gesture_drag_amount_(0.f), 210 gesture_drag_amount_(0.f),
211 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), 211 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
212 update_shelf_observer_(NULL), 212 update_shelf_observer_(NULL),
213 chromevox_panel_height_(0), 213 chromevox_panel_height_(0),
214 duration_override_in_ms_(0) { 214 duration_override_in_ms_(0),
215 root_window_controller_observer_(
216 new RootWindowControllerObserverImpl(this)) {
215 WmShell::Get()->AddShellObserver(this); 217 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); 218 WmShell::Get()->AddLockStateObserver(this);
225 aura::client::GetActivationClient(root_window_)->AddObserver(this); 219 WmShell::Get()->AddActivationObserver(this);
226 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); 220 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
227 } 221 }
228 222
229 ShelfLayoutManager::~ShelfLayoutManager() { 223 ShelfLayoutManager::~ShelfLayoutManager() {
230 if (update_shelf_observer_) 224 if (update_shelf_observer_)
231 update_shelf_observer_->Detach(); 225 update_shelf_observer_->Detach();
232 226
233 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 227 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
234 WillDeleteShelfLayoutManager()); 228 WillDeleteShelfLayoutManager());
235 WmShell::Get()->RemoveShellObserver(this); 229 WmShell::Get()->RemoveShellObserver(this);
236 WmShell::Get()->RemoveLockStateObserver(this); 230 WmShell::Get()->RemoveLockStateObserver(this);
237 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( 231 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 } 232 }
245 233
246 void ShelfLayoutManager::PrepareForShutdown() { 234 void ShelfLayoutManager::PrepareForShutdown() {
247 in_shutdown_ = true; 235 in_shutdown_ = true;
248 // Clear all event filters, otherwise sometimes those filters may catch 236 // Clear all event filters, otherwise sometimes those filters may catch
249 // synthesized mouse event and cause crashes during the shutdown. 237 // synthesized mouse event and cause crashes during the shutdown.
250 set_workspace_controller(NULL); 238 set_workspace_controller(NULL);
251 auto_hide_event_filter_.reset(); 239 auto_hide_event_filter_.reset();
252 bezel_event_filter_.reset(); 240 bezel_event_filter_.reset();
253 // Stop observing window change, otherwise we can attempt to update a 241 // Stop observing changes to avoid updating a partially destructed shelf.
254 // partially destructed shelf. 242 WmShell::Get()->RemoveActivationObserver(this);
255 aura::client::GetActivationClient(root_window_)->RemoveObserver(this);
256 } 243 }
257 244
258 bool ShelfLayoutManager::IsVisible() const { 245 bool ShelfLayoutManager::IsVisible() const {
259 // status_area_widget() may be NULL during the shutdown. 246 // status_area_widget() may be NULL during the shutdown.
260 return shelf_widget_->status_area_widget() && 247 return shelf_widget_->status_area_widget() &&
261 shelf_widget_->status_area_widget()->IsVisible() && 248 shelf_widget_->status_area_widget()->IsVisible() &&
262 (state_.visibility_state == SHELF_VISIBLE || 249 (state_.visibility_state == SHELF_VISIBLE ||
263 (state_.visibility_state == SHELF_AUTO_HIDE && 250 (state_.visibility_state == SHELF_AUTO_HIDE &&
264 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); 251 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN));
265 } 252 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 SetState(SHELF_VISIBLE); 300 SetState(SHELF_VISIBLE);
314 } else if (WmShell::Get()->IsPinned()) { 301 } else if (WmShell::Get()->IsPinned()) {
315 SetState(SHELF_HIDDEN); 302 SetState(SHELF_HIDDEN);
316 } else { 303 } else {
317 // TODO(zelidrag): Verify shelf drag animation still shows on the device 304 // TODO(zelidrag): Verify shelf drag animation still shows on the device
318 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. 305 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
319 wm::WorkspaceWindowState window_state( 306 wm::WorkspaceWindowState window_state(
320 workspace_controller_->GetWindowState()); 307 workspace_controller_->GetWindowState());
321 switch (window_state) { 308 switch (window_state) {
322 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: { 309 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: {
323 const aura::Window* fullscreen_window = 310 const WmWindow* fullscreen_window = wm::GetWindowForFullscreenMode(
324 GetRootWindowController(root_window_)->GetWindowForFullscreenMode(); 311 WmLookup::Get()->GetWindowForWidget(shelf_widget_));
James Cook 2016/07/27 03:15:11 totally optional: Are you thinking that long-term
msw 2016/07/27 22:31:17 Yeah, we can probably nuke |root_window_| soon; co
325 if (fullscreen_window && 312 if (fullscreen_window &&
326 wm::GetWindowState(fullscreen_window) 313 fullscreen_window->GetWindowState()->hide_shelf_when_fullscreen()) {
327 ->hide_shelf_when_fullscreen()) {
328 SetState(SHELF_HIDDEN); 314 SetState(SHELF_HIDDEN);
329 } else { 315 } else {
330 // The shelf is sometimes not hidden when in immersive fullscreen. 316 // The shelf is sometimes not hidden when in immersive fullscreen.
331 // Force the shelf to be auto hidden in this case. 317 // Force the shelf to be auto hidden in this case.
332 SetState(SHELF_AUTO_HIDE); 318 SetState(SHELF_AUTO_HIDE);
333 } 319 }
334 break; 320 break;
335 } 321 }
336 322
337 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED: 323 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) { 537 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(WmWindow* root_window) {
552 UpdateVisibilityState(); 538 UpdateVisibilityState();
553 } 539 }
554 540
555 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) { 541 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) {
556 // Shelf needs to be hidden on entering to pinned mode, or restored 542 // Shelf needs to be hidden on entering to pinned mode, or restored
557 // on exiting from pinned mode. 543 // on exiting from pinned mode.
558 UpdateVisibilityState(); 544 UpdateVisibilityState();
559 } 545 }
560 546
561 void ShelfLayoutManager::OnWindowActivated( 547 void ShelfLayoutManager::OnWindowActivated(WmWindow* gained_active,
562 aura::client::ActivationChangeObserver::ActivationReason reason, 548 WmWindow* lost_active) {
563 aura::Window* gained_active,
564 aura::Window* lost_active) {
565 UpdateAutoHideStateNow(); 549 UpdateAutoHideStateNow();
566 } 550 }
567 551
568 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { 552 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
569 bool keyboard_is_about_to_hide = false; 553 bool keyboard_is_about_to_hide = false;
570 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) 554 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty())
571 keyboard_is_about_to_hide = true; 555 keyboard_is_about_to_hide = true;
572 556
573 keyboard_bounds_ = new_bounds; 557 keyboard_bounds_ = new_bounds;
574 OnWindowResized(); 558 OnWindowResized();
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1011
1028 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( 1012 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
1029 ShelfVisibilityState visibility_state) const { 1013 ShelfVisibilityState visibility_state) const {
1030 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_ || 1014 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_ ||
1031 !shelf_widget_->shelf()) 1015 !shelf_widget_->shelf())
1032 return SHELF_AUTO_HIDE_HIDDEN; 1016 return SHELF_AUTO_HIDE_HIDDEN;
1033 1017
1034 // Unhide the shelf only on the active screen when the AppList is shown 1018 // Unhide the shelf only on the active screen when the AppList is shown
1035 // (crbug.com/312445). 1019 // (crbug.com/312445).
1036 if (WmShell::Get()->GetAppListTargetVisibility()) { 1020 if (WmShell::Get()->GetAppListTargetVisibility()) {
1037 aura::Window* active_window = wm::GetActiveWindow(); 1021 WmWindow* active_window = WmShell::Get()->GetActiveWindow();
1038 aura::Window* shelf_window = shelf_widget_->GetNativeWindow(); 1022 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_);
1039 if (active_window && shelf_window && 1023 if (active_window && shelf_window &&
1040 active_window->GetRootWindow() == shelf_window->GetRootWindow()) { 1024 active_window->GetRootWindow()->GetDisplayNearestWindow().id() ==
1025 shelf_window->GetRootWindow()->GetDisplayNearestWindow().id()) {
1041 return SHELF_AUTO_HIDE_SHOWN; 1026 return SHELF_AUTO_HIDE_SHOWN;
1042 } 1027 }
1043 } 1028 }
1044 1029
1045 if (shelf_widget_->status_area_widget() && 1030 if (shelf_widget_->status_area_widget() &&
1046 shelf_widget_->status_area_widget()->ShouldShowShelf()) 1031 shelf_widget_->status_area_widget()->ShouldShowShelf())
1047 return SHELF_AUTO_HIDE_SHOWN; 1032 return SHELF_AUTO_HIDE_SHOWN;
1048 1033
1049 if (shelf_widget_->shelf() && shelf_widget_->shelf()->IsShowingMenu()) 1034 if (shelf_widget_->shelf() && shelf_widget_->shelf()->IsShowingMenu())
1050 return SHELF_AUTO_HIDE_SHOWN; 1035 return SHELF_AUTO_HIDE_SHOWN;
1051 1036
1052 if (shelf_widget_->shelf() && 1037 if (shelf_widget_->shelf() &&
1053 shelf_widget_->shelf()->IsShowingOverflowBubble()) 1038 shelf_widget_->shelf()->IsShowingOverflowBubble())
1054 return SHELF_AUTO_HIDE_SHOWN; 1039 return SHELF_AUTO_HIDE_SHOWN;
1055 1040
1056 if (shelf_widget_->IsActive() || 1041 if (shelf_widget_->IsActive() ||
1057 (shelf_widget_->status_area_widget() && 1042 (shelf_widget_->status_area_widget() &&
1058 shelf_widget_->status_area_widget()->IsActive())) 1043 shelf_widget_->status_area_widget()->IsActive()))
1059 return SHELF_AUTO_HIDE_SHOWN; 1044 return SHELF_AUTO_HIDE_SHOWN;
1060 1045
1061 // TODO(jamescook): Track visible windows on mash via ShelfDelegate. 1046 // TODO(jamescook): Track visible windows on mash via ShelfDelegate.
1062 if (!Shell::GetInstance()->in_mus()) { 1047 if (!Shell::GetInstance()->in_mus()) {
1063 const std::vector<WmWindow*> windows = 1048 const std::vector<WmWindow*> windows =
1064 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal(); 1049 WmShell::Get()->mru_window_tracker()->BuildWindowListIgnoreModal();
1065 1050
1066 // Process the window list and check if there are any visible windows. 1051 // Process the window list and check if there are any visible windows.
1067 bool visible_window = false; 1052 bool visible_window = false;
1053 int64_t display_id = WmLookup::Get()
James Cook 2016/07/27 03:15:11 Would it work to use this for the applist check?
msw 2016/07/27 22:31:17 Done.
1054 ->GetWindowForWidget(shelf_widget_)
1055 ->GetDisplayNearestWindow()
1056 .id();
1068 for (size_t i = 0; i < windows.size(); ++i) { 1057 for (size_t i = 0; i < windows.size(); ++i) {
1069 if (windows[i] && windows[i]->IsVisible() && 1058 if (windows[i] && windows[i]->IsVisible() &&
1070 !windows[i]->GetWindowState()->IsMinimized() && 1059 !windows[i]->GetWindowState()->IsMinimized() &&
1071 root_window_ == 1060 windows[i]->GetDisplayNearestWindow().id() == display_id) {
1072 WmWindowAura::GetAuraWindow(windows[i]->GetRootWindow())) {
1073 visible_window = true; 1061 visible_window = true;
1074 break; 1062 break;
1075 } 1063 }
1076 } 1064 }
1077 // If there are no visible windows do not hide the shelf. 1065 // If there are no visible windows do not hide the shelf.
1078 if (!visible_window) 1066 if (!visible_window)
1079 return SHELF_AUTO_HIDE_SHOWN; 1067 return SHELF_AUTO_HIDE_SHOWN;
1080 } 1068 }
1081 1069
1082 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) 1070 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS)
1083 return gesture_drag_auto_hide_state_; 1071 return gesture_drag_auto_hide_state_;
1084 1072
1085 // Don't show if the user is dragging the mouse. 1073 // Don't show if the user is dragging the mouse.
1086 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) 1074 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag())
1087 return SHELF_AUTO_HIDE_HIDDEN; 1075 return SHELF_AUTO_HIDE_HIDDEN;
1088 1076
1089 // Ignore the mouse position if mouse events are disabled. 1077 // Ignore the mouse position if mouse events are disabled.
1090 aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( 1078 if (!shelf_widget_->IsMouseEventsEnabled())
1091 shelf_widget_->GetNativeWindow()->GetRootWindow());
1092 if (!cursor_client->IsMouseEventsEnabled())
1093 return SHELF_AUTO_HIDE_HIDDEN; 1079 return SHELF_AUTO_HIDE_HIDDEN;
1094 1080
1095 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen(); 1081 gfx::Rect shelf_region = shelf_widget_->GetWindowBoundsInScreen();
1096 if (shelf_widget_->status_area_widget() && 1082 if (shelf_widget_->status_area_widget() &&
1097 shelf_widget_->status_area_widget()->IsMessageBubbleShown() && 1083 shelf_widget_->status_area_widget()->IsMessageBubbleShown() &&
1098 IsVisible()) { 1084 IsVisible()) {
1099 // Increase the the hit test area to prevent the shelf from disappearing 1085 // Increase the the hit test area to prevent the shelf from disappearing
1100 // when the mouse is over the bubble gap. 1086 // when the mouse is over the bubble gap.
1101 ShelfAlignment alignment = GetAlignment(); 1087 ShelfAlignment alignment = GetAlignment();
1102 shelf_region.Inset( 1088 shelf_region.Inset(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 if (ash::MaterialDesignController::IsShelfMaterial()) { 1192 if (ash::MaterialDesignController::IsShelfMaterial()) {
1207 return (state.visibility_state == SHELF_AUTO_HIDE && 1193 return (state.visibility_state == SHELF_AUTO_HIDE &&
1208 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN) 1194 state.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)
1209 ? 1.0f 1195 ? 1.0f
1210 : 0.0f; 1196 : 0.0f;
1211 } 1197 }
1212 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; 1198 return (state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f;
1213 } 1199 }
1214 1200
1215 } // namespace ash 1201 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698