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/system/tray/tray_event_filter.h" | 5 #include "ash/system/tray/tray_event_filter.h" |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/shell_port.h" | 8 #include "ash/shell_port.h" |
9 #include "ash/system/tray/tray_background_view.h" | 9 #include "ash/system/tray/tray_background_view.h" |
10 #include "ash/system/tray/tray_bubble_wrapper.h" | 10 #include "ash/system/tray/tray_bubble_wrapper.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 const gfx::Point& location_in_screen, | 40 const gfx::Point& location_in_screen, |
41 views::Widget* target) { | 41 views::Widget* target) { |
42 if (event.type() == ui::ET_POINTER_DOWN) | 42 if (event.type() == ui::ET_POINTER_DOWN) |
43 ProcessPressedEvent(location_in_screen, target); | 43 ProcessPressedEvent(location_in_screen, target); |
44 } | 44 } |
45 | 45 |
46 void TrayEventFilter::ProcessPressedEvent(const gfx::Point& location_in_screen, | 46 void TrayEventFilter::ProcessPressedEvent(const gfx::Point& location_in_screen, |
47 views::Widget* target) { | 47 views::Widget* target) { |
48 if (target) { | 48 if (target) { |
49 aura::Window* window = target->GetNativeWindow(); | 49 aura::Window* window = target->GetNativeWindow(); |
50 int container_id = wm::GetContainerForWindow(window)->id(); | 50 int target_container_id = wm::GetContainerForWindow(window)->id(); |
51 // Don't process events that occurred inside an embedded menu, for example | 51 // Don't process events that occurred inside an embedded menu, for example |
52 // the right-click menu in a popup notification. | 52 // the right-click menu in a popup notification. |
53 if (container_id == kShellWindowId_MenuContainer) | 53 if (target_container_id == kShellWindowId_MenuContainer) |
54 return; | 54 return; |
55 // Don't process events that occurred inside a popup notification | 55 // Don't process events that occurred inside a popup notification |
56 // from message center. | 56 // from message center. |
57 if (container_id == kShellWindowId_StatusContainer && | 57 if (target_container_id == kShellWindowId_StatusContainer && |
58 window->type() == aura::client::WINDOW_TYPE_POPUP && | 58 window->type() == aura::client::WINDOW_TYPE_POPUP && |
59 target->IsAlwaysOnTop()) { | 59 target->IsAlwaysOnTop()) { |
60 return; | 60 return; |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 std::set<TrayBackgroundView*> trays; | 64 std::set<TrayBackgroundView*> trays; |
65 // Check the boundary for all wrappers, and do not handle the event if it | 65 // Check the boundary for all wrappers, and do not handle the event if it |
66 // happens inside of any of those wrappers. | 66 // happens inside of any of those wrappers. |
67 for (std::set<TrayBubbleWrapper*>::const_iterator iter = wrappers_.begin(); | 67 for (std::set<TrayBubbleWrapper*>::const_iterator iter = wrappers_.begin(); |
68 iter != wrappers_.end(); ++iter) { | 68 iter != wrappers_.end(); ++iter) { |
69 const TrayBubbleWrapper* wrapper = *iter; | 69 const TrayBubbleWrapper* wrapper = *iter; |
70 const views::Widget* bubble_widget = wrapper->bubble_widget(); | 70 const views::Widget* bubble_widget = wrapper->bubble_widget(); |
71 if (!bubble_widget) | 71 if (!bubble_widget) |
72 continue; | 72 continue; |
73 | 73 |
74 gfx::Rect bounds = bubble_widget->GetWindowBoundsInScreen(); | 74 gfx::Rect bounds = bubble_widget->GetWindowBoundsInScreen(); |
75 bounds.Inset(wrapper->bubble_view()->GetBorderInsets()); | 75 bounds.Inset(wrapper->bubble_view()->GetBorderInsets()); |
76 if (bounds.Contains(location_in_screen)) | 76 int bubble_container_id = |
| 77 wm::GetContainerForWindow(bubble_widget->GetNativeWindow())->id(); |
| 78 // Don't process the events that occurred inside the bubble. |
| 79 if (bounds.Contains(location_in_screen) && |
| 80 bubble_container_id == kShellWindowId_SettingBubbleContainer) |
77 continue; | 81 continue; |
78 if (wrapper->tray()) { | 82 if (wrapper->tray()) { |
79 // If the user clicks on the parent tray, don't process the event here, | 83 // If the user clicks on the parent tray, don't process the event here, |
80 // let the tray logic handle the event and determine show/hide behavior. | 84 // let the tray logic handle the event and determine show/hide behavior. |
81 bounds = wrapper->tray()->GetBoundsInScreen(); | 85 bounds = wrapper->tray()->GetBoundsInScreen(); |
82 if (bounds.Contains(location_in_screen)) | 86 if (bounds.Contains(location_in_screen)) |
83 continue; | 87 continue; |
84 } | 88 } |
85 trays.insert((*iter)->tray()); | 89 trays.insert((*iter)->tray()); |
86 } | 90 } |
87 | 91 |
88 // Close all bubbles other than the one a user clicked on the tray | 92 // Close all bubbles other than the one a user clicked on the tray |
89 // or its bubble. | 93 // or its bubble. |
90 for (std::set<TrayBackgroundView*>::iterator iter = trays.begin(); | 94 for (std::set<TrayBackgroundView*>::iterator iter = trays.begin(); |
91 iter != trays.end(); ++iter) { | 95 iter != trays.end(); ++iter) { |
92 (*iter)->ClickedOutsideBubble(); | 96 (*iter)->ClickedOutsideBubble(); |
93 } | 97 } |
94 } | 98 } |
95 | 99 |
96 } // namespace ash | 100 } // namespace ash |
OLD | NEW |