OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/system/web_notification/ash_popup_alignment_delegate.h" | 5 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
9 #include "ash/shelf/shelf_constants.h" | 9 #include "ash/shelf/shelf_constants.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 const gfx::Display& display) { | 48 const gfx::Display& display) { |
49 screen_ = screen; | 49 screen_ = screen; |
50 work_area_ = display.work_area(); | 50 work_area_ = display.work_area(); |
51 root_window_ = ash::Shell::GetInstance() | 51 root_window_ = ash::Shell::GetInstance() |
52 ->display_controller() | 52 ->display_controller() |
53 ->GetRootWindowForDisplayId(display.id()); | 53 ->GetRootWindowForDisplayId(display.id()); |
54 UpdateShelf(); | 54 UpdateShelf(); |
55 screen->AddObserver(this); | 55 screen->AddObserver(this); |
56 Shell::GetInstance()->AddShellObserver(this); | 56 Shell::GetInstance()->AddShellObserver(this); |
57 if (system_tray_height_ > 0) | 57 if (system_tray_height_ > 0) |
58 UpdateWorkArea(display, shelf_->auto_hide_state()); | 58 UpdateWorkArea(); |
59 } | 59 } |
60 | 60 |
61 void AshPopupAlignmentDelegate::SetSystemTrayHeight(int height) { | 61 void AshPopupAlignmentDelegate::SetSystemTrayHeight(int height) { |
62 system_tray_height_ = height; | 62 system_tray_height_ = height; |
63 | 63 |
64 // If the shelf is shown during auto-hide state, the distance from the edge | 64 // If the shelf is shown during auto-hide state, the distance from the edge |
65 // should be reduced by the height of shelf's shown height. | 65 // should be reduced by the height of shelf's shown height. |
66 if (shelf_ && shelf_->visibility_state() == SHELF_AUTO_HIDE && | 66 if (shelf_ && shelf_->visibility_state() == SHELF_AUTO_HIDE && |
67 shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { | 67 shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { |
68 system_tray_height_ -= kShelfSize - ShelfLayoutManager::kAutoHideSize; | 68 system_tray_height_ -= kShelfSize - ShelfLayoutManager::kAutoHideSize; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 shelf_ = ShelfLayoutManager::ForShelf(root_window_); | 127 shelf_ = ShelfLayoutManager::ForShelf(root_window_); |
128 if (shelf_) | 128 if (shelf_) |
129 shelf_->AddObserver(this); | 129 shelf_->AddObserver(this); |
130 } | 130 } |
131 | 131 |
132 gfx::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const { | 132 gfx::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const { |
133 return Shell::GetScreen()->GetDisplayNearestWindow( | 133 return Shell::GetScreen()->GetDisplayNearestWindow( |
134 shelf_->shelf_widget()->GetNativeView()); | 134 shelf_->shelf_widget()->GetNativeView()); |
135 } | 135 } |
136 | 136 |
137 void AshPopupAlignmentDelegate::UpdateWorkArea(const gfx::Display& display, | 137 void AshPopupAlignmentDelegate::UpdateWorkArea() { |
138 ShelfAutoHideState new_state) { | 138 work_area_ = shelf_->non_shelf_bounds_in_root(); |
oshima
2015/05/07 19:14:51
can you rename to "non_shelf_bounds_" ?
jonross
2015/05/07 20:58:29
Done.
| |
139 work_area_ = display.work_area(); | 139 |
140 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) { | 140 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) { |
141 gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInScreen( | 141 gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInScreen( |
142 shelf_->shelf_widget()->GetNativeView()); | 142 shelf_->shelf_widget()->GetNativeView()); |
143 work_area_.Intersect(bounds); | 143 work_area_.Intersect(bounds); |
144 } | 144 } |
oshima
2015/05/07 19:14:51
you should no longer need this if block.
jonross
2015/05/07 20:58:29
Done.
| |
145 | |
146 int width = 0; | |
147 if (shelf_ && (shelf_->visibility_state() == SHELF_AUTO_HIDE) && | |
148 new_state == SHELF_AUTO_HIDE_SHOWN) { | |
149 // Since the work_area is already reduced by kAutoHideSize, the inset width | |
150 // should be just the difference. | |
151 width = kShelfSize - ShelfLayoutManager::kAutoHideSize; | |
152 } | |
153 work_area_.Inset(shelf_->SelectValueForShelfAlignment( | |
154 gfx::Insets(0, 0, width, 0), | |
155 gfx::Insets(0, width, 0, 0), | |
156 gfx::Insets(0, 0, 0, width), | |
157 gfx::Insets(width, 0, 0, 0))); | |
158 | |
159 DoUpdateIfPossible(); | 145 DoUpdateIfPossible(); |
160 } | 146 } |
161 | 147 |
162 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() { | 148 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() { |
163 UpdateShelf(); | 149 UpdateShelf(); |
164 UpdateWorkArea(GetCurrentDisplay(), shelf_->auto_hide_state()); | 150 UpdateWorkArea(); |
165 } | 151 } |
166 | 152 |
167 void AshPopupAlignmentDelegate::OnAutoHideStateChanged( | 153 void AshPopupAlignmentDelegate::OnAutoHideStateChanged( |
168 ShelfAutoHideState new_state) { | 154 ShelfAutoHideState new_state) { |
169 UpdateWorkArea(GetCurrentDisplay(), new_state); | 155 UpdateWorkArea(); |
170 } | 156 } |
171 | 157 |
172 void AshPopupAlignmentDelegate::OnDisplayAdded( | 158 void AshPopupAlignmentDelegate::OnDisplayAdded( |
173 const gfx::Display& new_display) { | 159 const gfx::Display& new_display) { |
174 } | 160 } |
175 | 161 |
176 void AshPopupAlignmentDelegate::OnDisplayRemoved( | 162 void AshPopupAlignmentDelegate::OnDisplayRemoved( |
177 const gfx::Display& old_display) { | 163 const gfx::Display& old_display) { |
178 } | 164 } |
179 | 165 |
180 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( | 166 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( |
181 const gfx::Display& display, | 167 const gfx::Display& display, |
182 uint32_t metrics) { | 168 uint32_t metrics) { |
183 UpdateShelf(); | 169 UpdateShelf(); |
184 if (shelf_ && GetCurrentDisplay().id() == display.id()) | 170 if (shelf_ && GetCurrentDisplay().id() == display.id()) |
185 UpdateWorkArea(display, shelf_->auto_hide_state()); | 171 UpdateWorkArea(); |
186 } | 172 } |
187 | 173 |
188 } // namespace ash | 174 } // namespace ash |
OLD | NEW |