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

Side by Side Diff: ash/system/web_notification/ash_popup_alignment_delegate.cc

Issue 1121893004: Have Notifications appear over docked windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 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
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
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();
139 work_area_ = display.work_area();
140 if (Shell::GetInstance()->display_manager()->IsInUnifiedMode()) {
141 gfx::Rect bounds = ScreenUtil::GetShelfDisplayBoundsInScreen(
142 shelf_->shelf_widget()->GetNativeView());
143 work_area_.Intersect(bounds);
144 }
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(); 139 DoUpdateIfPossible();
160 } 140 }
161 141
162 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() { 142 void AshPopupAlignmentDelegate::OnDisplayWorkAreaInsetsChanged() {
163 UpdateShelf(); 143 UpdateShelf();
164 UpdateWorkArea(GetCurrentDisplay(), shelf_->auto_hide_state()); 144 UpdateWorkArea();
165 } 145 }
166 146
167 void AshPopupAlignmentDelegate::OnAutoHideStateChanged( 147 void AshPopupAlignmentDelegate::OnAutoHideStateChanged(
168 ShelfAutoHideState new_state) { 148 ShelfAutoHideState new_state) {
169 UpdateWorkArea(GetCurrentDisplay(), new_state); 149 UpdateWorkArea();
170 } 150 }
171 151
172 void AshPopupAlignmentDelegate::OnDisplayAdded( 152 void AshPopupAlignmentDelegate::OnDisplayAdded(
173 const gfx::Display& new_display) { 153 const gfx::Display& new_display) {
174 } 154 }
175 155
176 void AshPopupAlignmentDelegate::OnDisplayRemoved( 156 void AshPopupAlignmentDelegate::OnDisplayRemoved(
177 const gfx::Display& old_display) { 157 const gfx::Display& old_display) {
178 } 158 }
179 159
180 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( 160 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged(
181 const gfx::Display& display, 161 const gfx::Display& display,
182 uint32_t metrics) { 162 uint32_t metrics) {
183 UpdateShelf(); 163 UpdateShelf();
184 if (shelf_ && GetCurrentDisplay().id() == display.id()) 164 if (shelf_ && GetCurrentDisplay().id() == display.id())
185 UpdateWorkArea(display, shelf_->auto_hide_state()); 165 UpdateWorkArea();
186 } 166 }
187 167
188 } // namespace ash 168 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698