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 "ui/views/controls/menu/menu_message_loop_aura.h" | 5 #include "ui/views/controls/menu/menu_message_loop_aura.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 const gfx::Point& screen_loc) { | 99 const gfx::Point& screen_loc) { |
100 aura::Window* root = window->GetRootWindow(); | 100 aura::Window* root = window->GetRootWindow(); |
101 aura::client::ScreenPositionClient* spc = | 101 aura::client::ScreenPositionClient* spc = |
102 aura::client::GetScreenPositionClient(root); | 102 aura::client::GetScreenPositionClient(root); |
103 if (!spc) | 103 if (!spc) |
104 return; | 104 return; |
105 | 105 |
106 gfx::Point root_loc(screen_loc); | 106 gfx::Point root_loc(screen_loc); |
107 spc->ConvertPointFromScreen(root, &root_loc); | 107 spc->ConvertPointFromScreen(root, &root_loc); |
108 | 108 |
109 scoped_ptr<ui::Event> clone = ui::Event::Clone(*event); | 109 std::unique_ptr<ui::Event> clone = ui::Event::Clone(*event); |
110 scoped_ptr<ui::LocatedEvent> located_event( | 110 std::unique_ptr<ui::LocatedEvent> located_event( |
111 static_cast<ui::LocatedEvent*>(clone.release())); | 111 static_cast<ui::LocatedEvent*>(clone.release())); |
112 located_event->set_location(root_loc); | 112 located_event->set_location(root_loc); |
113 located_event->set_root_location(root_loc); | 113 located_event->set_root_location(root_loc); |
114 | 114 |
115 root->GetHost()->dispatcher()->RepostEvent(located_event.get()); | 115 root->GetHost()->dispatcher()->RepostEvent(located_event.get()); |
116 } | 116 } |
117 | 117 |
118 MenuMessageLoopAura::MenuMessageLoopAura() : owner_(nullptr) {} | 118 MenuMessageLoopAura::MenuMessageLoopAura() : owner_(nullptr) {} |
119 | 119 |
120 MenuMessageLoopAura::~MenuMessageLoopAura() {} | 120 MenuMessageLoopAura::~MenuMessageLoopAura() {} |
121 | 121 |
122 void MenuMessageLoopAura::Run(MenuController* controller, | 122 void MenuMessageLoopAura::Run(MenuController* controller, |
123 Widget* owner, | 123 Widget* owner, |
124 bool nested_menu) { | 124 bool nested_menu) { |
125 // |owner_| may be NULL. | 125 // |owner_| may be NULL. |
126 owner_ = owner; | 126 owner_ = owner; |
127 aura::Window* root = GetOwnerRootWindow(owner_); | 127 aura::Window* root = GetOwnerRootWindow(owner_); |
128 // It is possible for the same MenuMessageLoopAura to start a nested | 128 // It is possible for the same MenuMessageLoopAura to start a nested |
129 // message-loop while it is already running a nested loop. So make sure the | 129 // message-loop while it is already running a nested loop. So make sure the |
130 // quit-closure gets reset to the outer loop's quit-closure once the innermost | 130 // quit-closure gets reset to the outer loop's quit-closure once the innermost |
131 // loop terminates. | 131 // loop terminates. |
132 base::AutoReset<base::Closure> reset_quit_closure(&message_loop_quit_, | 132 base::AutoReset<base::Closure> reset_quit_closure(&message_loop_quit_, |
133 base::Closure()); | 133 base::Closure()); |
134 | 134 |
135 scoped_ptr<ActivationChangeObserverImpl> observer; | 135 std::unique_ptr<ActivationChangeObserverImpl> observer; |
136 if (root) { | 136 if (root) { |
137 if (!nested_menu) | 137 if (!nested_menu) |
138 observer.reset(new ActivationChangeObserverImpl(controller, root)); | 138 observer.reset(new ActivationChangeObserverImpl(controller, root)); |
139 } | 139 } |
140 | 140 |
141 base::MessageLoop* loop = base::MessageLoop::current(); | 141 base::MessageLoop* loop = base::MessageLoop::current(); |
142 base::MessageLoop::ScopedNestableTaskAllower allow(loop); | 142 base::MessageLoop::ScopedNestableTaskAllower allow(loop); |
143 base::RunLoop run_loop; | 143 base::RunLoop run_loop; |
144 message_loop_quit_ = run_loop.QuitClosure(); | 144 message_loop_quit_ = run_loop.QuitClosure(); |
145 | 145 |
(...skipping 10 matching lines...) Expand all Loading... |
156 if (ui::PlatformEventSource::GetInstance()) | 156 if (ui::PlatformEventSource::GetInstance()) |
157 ui::PlatformEventSource::GetInstance()->StopCurrentEventStream(); | 157 ui::PlatformEventSource::GetInstance()->StopCurrentEventStream(); |
158 #endif | 158 #endif |
159 } | 159 } |
160 | 160 |
161 void MenuMessageLoopAura::ClearOwner() { | 161 void MenuMessageLoopAura::ClearOwner() { |
162 owner_ = NULL; | 162 owner_ = NULL; |
163 } | 163 } |
164 | 164 |
165 } // namespace views | 165 } // namespace views |
OLD | NEW |