OLD | NEW |
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/system/tray/system_tray.h" | 5 #include "ash/common/system/tray/system_tray.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "ui/display/screen.h" | 62 #include "ui/display/screen.h" |
63 #include "ui/events/event_constants.h" | 63 #include "ui/events/event_constants.h" |
64 #include "ui/gfx/canvas.h" | 64 #include "ui/gfx/canvas.h" |
65 #include "ui/gfx/skia_util.h" | 65 #include "ui/gfx/skia_util.h" |
66 #include "ui/message_center/message_center.h" | 66 #include "ui/message_center/message_center.h" |
67 #include "ui/message_center/message_center_style.h" | 67 #include "ui/message_center/message_center_style.h" |
68 #include "ui/views/border.h" | 68 #include "ui/views/border.h" |
69 #include "ui/views/controls/label.h" | 69 #include "ui/views/controls/label.h" |
70 #include "ui/views/view.h" | 70 #include "ui/views/view.h" |
71 #include "ui/views/widget/widget.h" | 71 #include "ui/views/widget/widget.h" |
| 72 #include "ui/wm/core/window_util.h" |
72 #include "ui/wm/public/activation_change_observer.h" | 73 #include "ui/wm/public/activation_change_observer.h" |
73 #include "ui/wm/public/activation_client.h" | 74 #include "ui/wm/public/activation_client.h" |
74 | 75 |
75 using views::TrayBubbleView; | 76 using views::TrayBubbleView; |
76 | 77 |
77 namespace ash { | 78 namespace ash { |
78 | 79 |
79 namespace { | 80 namespace { |
80 | 81 |
81 // A tray item that just reserves space in the tray. | 82 // A tray item that just reserves space in the tray. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 172 } |
172 | 173 |
173 ~ActivationObserver() override { | 174 ~ActivationObserver() override { |
174 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 175 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
175 } | 176 } |
176 | 177 |
177 // WmActivationObserver: | 178 // WmActivationObserver: |
178 void OnWindowActivated(ActivationReason reason, | 179 void OnWindowActivated(ActivationReason reason, |
179 aura::Window* gained_active, | 180 aura::Window* gained_active, |
180 aura::Window* lost_active) override { | 181 aura::Window* lost_active) override { |
181 WmWindow* wm_gained_active = WmWindow::Get(gained_active); | |
182 if (!tray_->HasSystemBubble() || !gained_active) | 182 if (!tray_->HasSystemBubble() || !gained_active) |
183 return; | 183 return; |
184 | 184 |
| 185 WmWindow* wm_gained_active = WmWindow::Get(gained_active); |
185 int container_id = | 186 int container_id = |
186 wm::GetContainerForWindow(wm_gained_active)->GetShellWindowId(); | 187 wm::GetContainerForWindow(wm_gained_active)->GetShellWindowId(); |
187 | 188 |
188 // Don't close the bubble if a popup notification is activated. | 189 // Don't close the bubble if a popup notification is activated. |
189 if (container_id == kShellWindowId_StatusContainer) | 190 if (container_id == kShellWindowId_StatusContainer) |
190 return; | 191 return; |
191 | 192 |
192 if (tray_->GetSystemBubble()->bubble_view()->GetWidget() != | 193 views::Widget* bubble_widget = |
193 wm_gained_active->GetInternalWidget()) { | 194 tray_->GetSystemBubble()->bubble_view()->GetWidget(); |
194 tray_->CloseSystemBubble(); | 195 // Don't close the bubble if a transient child is gaining or losing |
| 196 // activation. |
| 197 if (bubble_widget == wm_gained_active->GetInternalWidget() || |
| 198 ::wm::HasTransientAncestor(gained_active, |
| 199 bubble_widget->GetNativeWindow()) || |
| 200 ::wm::HasTransientAncestor(lost_active, |
| 201 bubble_widget->GetNativeWindow())) { |
| 202 return; |
195 } | 203 } |
| 204 |
| 205 tray_->CloseSystemBubble(); |
196 } | 206 } |
197 | 207 |
198 private: | 208 private: |
199 SystemTray* tray_; | 209 SystemTray* tray_; |
200 | 210 |
201 DISALLOW_COPY_AND_ASSIGN(ActivationObserver); | 211 DISALLOW_COPY_AND_ASSIGN(ActivationObserver); |
202 }; | 212 }; |
203 | 213 |
204 // SystemTray | 214 // SystemTray |
205 | 215 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 .work_area() | 781 .work_area() |
772 .height(); | 782 .height(); |
773 if (work_area_height > 0) { | 783 if (work_area_height > 0) { |
774 UMA_HISTOGRAM_CUSTOM_COUNTS( | 784 UMA_HISTOGRAM_CUSTOM_COUNTS( |
775 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 785 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
776 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 786 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
777 } | 787 } |
778 } | 788 } |
779 | 789 |
780 } // namespace ash | 790 } // namespace ash |
OLD | NEW |