OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/aura/window_tree_host.h" | 5 #include "ui/aura/window_tree_host.h" |
6 | 6 |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "ui/aura/client/capture_client.h" | 9 #include "ui/aura/client/capture_client.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 188 } |
189 | 189 |
190 void WindowTreeHost::SetSharedInputMethod(ui::InputMethod* input_method) { | 190 void WindowTreeHost::SetSharedInputMethod(ui::InputMethod* input_method) { |
191 DCHECK(!input_method_); | 191 DCHECK(!input_method_); |
192 input_method_ = input_method; | 192 input_method_ = input_method; |
193 owned_input_method_ = false; | 193 owned_input_method_ = false; |
194 } | 194 } |
195 | 195 |
196 bool WindowTreeHost::DispatchKeyEventPostIME(const ui::KeyEvent& event) { | 196 bool WindowTreeHost::DispatchKeyEventPostIME(const ui::KeyEvent& event) { |
197 ui::KeyEvent copied_event(event); | 197 ui::KeyEvent copied_event(event); |
198 ui::EventDispatchDetails details = | 198 ui::EventDispatchDetails details = SendEventToProcessor(&copied_event); |
199 event_processor()->OnEventFromSource(&copied_event); | |
200 DCHECK(!details.dispatcher_destroyed); | 199 DCHECK(!details.dispatcher_destroyed); |
201 return copied_event.stopped_propagation(); | 200 return copied_event.stopped_propagation(); |
202 } | 201 } |
203 | 202 |
204 void WindowTreeHost::Show() { | 203 void WindowTreeHost::Show() { |
205 if (compositor()) | 204 if (compositor()) |
206 compositor()->SetVisible(true); | 205 compositor()->SetVisible(true); |
207 ShowImpl(); | 206 ShowImpl(); |
208 } | 207 } |
209 | 208 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 void WindowTreeHost::OnHostLostWindowCapture() { | 298 void WindowTreeHost::OnHostLostWindowCapture() { |
300 Window* capture_window = client::GetCaptureWindow(window()); | 299 Window* capture_window = client::GetCaptureWindow(window()); |
301 if (capture_window && capture_window->GetRootWindow() == window()) | 300 if (capture_window && capture_window->GetRootWindow() == window()) |
302 capture_window->ReleaseCapture(); | 301 capture_window->ReleaseCapture(); |
303 } | 302 } |
304 | 303 |
305 ui::EventProcessor* WindowTreeHost::GetEventProcessor() { | 304 ui::EventProcessor* WindowTreeHost::GetEventProcessor() { |
306 return event_processor(); | 305 return event_processor(); |
307 } | 306 } |
308 | 307 |
309 ui::EventDispatchDetails WindowTreeHost::DeliverEventToProcessor( | |
310 ui::Event* event) { | |
311 if (event->IsKeyEvent()) { | |
312 GetInputMethod()->DispatchKeyEvent(*static_cast<ui::KeyEvent*>(event)); | |
313 event->StopPropagation(); | |
314 // TODO(shuchen): pass around the EventDispatchDetails from | |
315 // DispatchKeyEventPostIME instead of creating new from here. | |
316 return ui::EventDispatchDetails(); | |
317 } | |
318 return ui::EventSource::DeliverEventToProcessor(event); | |
319 } | |
320 | |
321 //////////////////////////////////////////////////////////////////////////////// | 308 //////////////////////////////////////////////////////////////////////////////// |
322 // WindowTreeHost, private: | 309 // WindowTreeHost, private: |
323 | 310 |
324 void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, | 311 void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, |
325 const gfx::Point& host_location) { | 312 const gfx::Point& host_location) { |
326 last_cursor_request_position_in_host_ = host_location; | 313 last_cursor_request_position_in_host_ = host_location; |
327 MoveCursorToNative(host_location); | 314 MoveCursorToNative(host_location); |
328 client::CursorClient* cursor_client = client::GetCursorClient(window()); | 315 client::CursorClient* cursor_client = client::GetCursorClient(window()); |
329 if (cursor_client) { | 316 if (cursor_client) { |
330 const gfx::Display& display = | 317 const gfx::Display& display = |
331 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); | 318 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); |
332 cursor_client->SetDisplay(display); | 319 cursor_client->SetDisplay(display); |
333 } | 320 } |
334 dispatcher()->OnCursorMovedToRootLocation(root_location); | 321 dispatcher()->OnCursorMovedToRootLocation(root_location); |
335 } | 322 } |
336 | 323 |
337 } // namespace aura | 324 } // namespace aura |
OLD | NEW |