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

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

Issue 2295003002: mash: Remove WmRootWindowControllerObserver. (Closed)
Patch Set: Address comments. Created 4 years, 3 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/common/shelf/shelf_layout_manager.h ('k') | ash/common/shelf/wm_shelf.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/common/shelf/shelf_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/common/material_design/material_design_controller.h" 11 #include "ash/common/material_design/material_design_controller.h"
12 #include "ash/common/session/session_state_delegate.h" 12 #include "ash/common/session/session_state_delegate.h"
13 #include "ash/common/shelf/shelf_constants.h" 13 #include "ash/common/shelf/shelf_constants.h"
14 #include "ash/common/shelf/shelf_delegate.h" 14 #include "ash/common/shelf/shelf_delegate.h"
15 #include "ash/common/shelf/shelf_layout_manager_observer.h" 15 #include "ash/common/shelf/shelf_layout_manager_observer.h"
16 #include "ash/common/shelf/wm_shelf.h" 16 #include "ash/common/shelf/wm_shelf.h"
17 #include "ash/common/shelf/wm_shelf_util.h" 17 #include "ash/common/shelf/wm_shelf_util.h"
18 #include "ash/common/shell_window_ids.h" 18 #include "ash/common/shell_window_ids.h"
19 #include "ash/common/system/status_area_widget.h" 19 #include "ash/common/system/status_area_widget.h"
20 #include "ash/common/wm/fullscreen_window_finder.h" 20 #include "ash/common/wm/fullscreen_window_finder.h"
21 #include "ash/common/wm/mru_window_tracker.h" 21 #include "ash/common/wm/mru_window_tracker.h"
22 #include "ash/common/wm/window_state.h" 22 #include "ash/common/wm/window_state.h"
23 #include "ash/common/wm/wm_screen_util.h" 23 #include "ash/common/wm/wm_screen_util.h"
24 #include "ash/common/wm_lookup.h" 24 #include "ash/common/wm_lookup.h"
25 #include "ash/common/wm_root_window_controller.h" 25 #include "ash/common/wm_root_window_controller.h"
26 #include "ash/common/wm_root_window_controller_observer.h"
27 #include "ash/common/wm_shell.h" 26 #include "ash/common/wm_shell.h"
28 #include "ash/common/wm_window.h" 27 #include "ash/common/wm_window.h"
29 #include "base/auto_reset.h" 28 #include "base/auto_reset.h"
30 #include "base/command_line.h" 29 #include "base/command_line.h"
31 #include "base/i18n/rtl.h" 30 #include "base/i18n/rtl.h"
32 #include "ui/base/ui_base_switches.h" 31 #include "ui/base/ui_base_switches.h"
33 #include "ui/compositor/layer.h" 32 #include "ui/compositor/layer.h"
34 #include "ui/compositor/layer_animation_observer.h" 33 #include "ui/compositor/layer_animation_observer.h"
35 #include "ui/compositor/layer_animator.h" 34 #include "ui/compositor/layer_animator.h"
36 #include "ui/compositor/scoped_layer_animation_settings.h" 35 #include "ui/compositor/scoped_layer_animation_settings.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (shelf_) 98 if (shelf_)
100 shelf_->update_shelf_observer_ = NULL; 99 shelf_->update_shelf_observer_ = NULL;
101 } 100 }
102 101
103 // Shelf we're in. NULL if deleted before we're deleted. 102 // Shelf we're in. NULL if deleted before we're deleted.
104 ShelfLayoutManager* shelf_; 103 ShelfLayoutManager* shelf_;
105 104
106 DISALLOW_COPY_AND_ASSIGN(UpdateShelfObserver); 105 DISALLOW_COPY_AND_ASSIGN(UpdateShelfObserver);
107 }; 106 };
108 107
109 // ShelfLayoutManager::RootWindowControllerObserverImpl ------------------------
110
111 // NOTE: Some other layout managers also observe for OnShelfAlignmentChanged()
112 // via WmRootWindowControllerObserver instead of via ShellObserver. There are
113 // implicit assumptions that these layout managers run in order. In order to
114 // preserve the ordering, OnShelfAlignmentChanged() is implemented here in terms
115 // of a WmRootWindowControllerObserver instead of a ShellObserver. This gives us
116 // a sane ordering (or at least ordering as we've always had it in ash).
117 class ShelfLayoutManager::RootWindowControllerObserverImpl
118 : public WmRootWindowControllerObserver {
119 public:
120 explicit RootWindowControllerObserverImpl(
121 ShelfLayoutManager* shelf_layout_manager)
122 : shelf_layout_manager_(shelf_layout_manager),
123 root_window_controller_(
124 WmLookup::Get()
125 ->GetWindowForWidget(shelf_layout_manager->shelf_widget())
126 ->GetRootWindowController()) {
127 root_window_controller_->AddObserver(this);
128 }
129 ~RootWindowControllerObserverImpl() override {
130 root_window_controller_->RemoveObserver(this);
131 }
132
133 // WmRootWindowControllerObserver:
134 void OnShelfAlignmentChanged() override {
135 shelf_layout_manager_->LayoutShelf();
136 }
137
138 private:
139 ShelfLayoutManager* shelf_layout_manager_;
140 WmRootWindowController* root_window_controller_;
141
142 DISALLOW_COPY_AND_ASSIGN(RootWindowControllerObserverImpl);
143 };
144
145 // ShelfLayoutManager ---------------------------------------------------------- 108 // ShelfLayoutManager ----------------------------------------------------------
146 109
147 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget, 110 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf_widget,
148 WmShelf* wm_shelf) 111 WmShelf* wm_shelf)
149 : updating_bounds_(false), 112 : updating_bounds_(false),
150 shelf_widget_(shelf_widget), 113 shelf_widget_(shelf_widget),
151 wm_shelf_(wm_shelf), 114 wm_shelf_(wm_shelf),
152 window_overlaps_shelf_(false), 115 window_overlaps_shelf_(false),
153 mouse_over_shelf_when_auto_hide_timer_started_(false), 116 mouse_over_shelf_when_auto_hide_timer_started_(false),
154 gesture_drag_status_(GESTURE_DRAG_NONE), 117 gesture_drag_status_(GESTURE_DRAG_NONE),
155 gesture_drag_amount_(0.f), 118 gesture_drag_amount_(0.f),
156 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), 119 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
157 update_shelf_observer_(NULL), 120 update_shelf_observer_(NULL),
158 chromevox_panel_height_(0), 121 chromevox_panel_height_(0),
159 duration_override_in_ms_(0), 122 duration_override_in_ms_(0) {
160 root_window_controller_observer_(
161 new RootWindowControllerObserverImpl(this)) {
162 DCHECK(shelf_widget_); 123 DCHECK(shelf_widget_);
163 DCHECK(wm_shelf_); 124 DCHECK(wm_shelf_);
164 WmShell::Get()->AddShellObserver(this); 125 WmShell::Get()->AddShellObserver(this);
165 WmShell::Get()->AddLockStateObserver(this); 126 WmShell::Get()->AddLockStateObserver(this);
166 WmShell::Get()->AddActivationObserver(this); 127 WmShell::Get()->AddActivationObserver(this);
167 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); 128 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
168 } 129 }
169 130
170 ShelfLayoutManager::~ShelfLayoutManager() { 131 ShelfLayoutManager::~ShelfLayoutManager() {
171 if (update_shelf_observer_) 132 if (update_shelf_observer_)
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 gesture_drag_status_ = GESTURE_DRAG_NONE; 1139 gesture_drag_status_ = GESTURE_DRAG_NONE;
1179 } 1140 }
1180 1141
1181 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { 1142 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const {
1182 if (invisible_auto_hide_shelf_) 1143 if (invisible_auto_hide_shelf_)
1183 return 0; 1144 return 0;
1184 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); 1145 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE);
1185 } 1146 }
1186 1147
1187 } // namespace ash 1148 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_layout_manager.h ('k') | ash/common/shelf/wm_shelf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698