| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/root_window.h" | 5 #include "ui/aura/root_window.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 189 } |
| 190 | 190 |
| 191 bool RootWindow::DispatchKeyEvent(KeyEvent* event) { | 191 bool RootWindow::DispatchKeyEvent(KeyEvent* event) { |
| 192 if (focused_window_) { | 192 if (focused_window_) { |
| 193 KeyEvent translated_event(*event); | 193 KeyEvent translated_event(*event); |
| 194 return ProcessKeyEvent(focused_window_, &translated_event); | 194 return ProcessKeyEvent(focused_window_, &translated_event); |
| 195 } | 195 } |
| 196 return false; | 196 return false; |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool RootWindow::DispatchTranslatedKeyEvent(TranslatedKeyEvent* event) { |
| 200 if (focused_window_) { |
| 201 TranslatedKeyEvent translated_event(*event); |
| 202 return ProcessTranslatedKeyEvent(focused_window_, &translated_event); |
| 203 } |
| 204 return false; |
| 205 } |
| 206 |
| 199 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { | 207 bool RootWindow::DispatchTouchEvent(TouchEvent* event) { |
| 200 event->UpdateForTransform(layer()->transform()); | 208 event->UpdateForTransform(layer()->transform()); |
| 201 bool handled = false; | 209 bool handled = false; |
| 202 Window* target = | 210 Window* target = |
| 203 touch_event_handler_ ? touch_event_handler_ : capture_window_; | 211 touch_event_handler_ ? touch_event_handler_ : capture_window_; |
| 204 if (!target) | 212 if (!target) |
| 205 target = GetEventHandlerForPoint(event->location()); | 213 target = GetEventHandlerForPoint(event->location()); |
| 206 if (target) { | 214 if (target) { |
| 207 TouchEvent translated_event(*event, this, target); | 215 TouchEvent translated_event(*event, this, target); |
| 208 ui::TouchStatus status = ProcessTouchEvent(target, &translated_event); | 216 ui::TouchStatus status = ProcessTouchEvent(target, &translated_event); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 return false; | 422 return false; |
| 415 | 423 |
| 416 EventFilters filters; | 424 EventFilters filters; |
| 417 GetEventFiltersToNotify(target, &filters); | 425 GetEventFiltersToNotify(target, &filters); |
| 418 for (EventFilters::const_reverse_iterator it = filters.rbegin(); | 426 for (EventFilters::const_reverse_iterator it = filters.rbegin(); |
| 419 it != filters.rend(); ++it) { | 427 it != filters.rend(); ++it) { |
| 420 if ((*it)->PreHandleKeyEvent(target, event)) | 428 if ((*it)->PreHandleKeyEvent(target, event)) |
| 421 return true; | 429 return true; |
| 422 } | 430 } |
| 423 | 431 |
| 432 // Usually, an EventFilter bound to an IME (input method) will consume the |
| 433 // |event|. If such EventFilter is not available, the event is dispatched to |
| 434 // the |target|. |
| 424 return target->delegate()->OnKeyEvent(event); | 435 return target->delegate()->OnKeyEvent(event); |
| 425 } | 436 } |
| 426 | 437 |
| 438 bool RootWindow::ProcessTranslatedKeyEvent(Window* target, |
| 439 TranslatedKeyEvent* event) { |
| 440 if (!target->IsVisible()) |
| 441 return false; |
| 442 |
| 443 EventFilters filters; |
| 444 GetEventFiltersToNotify(target, &filters); |
| 445 for (EventFilters::const_reverse_iterator it = filters.rbegin(); |
| 446 it != filters.rend(); ++it) { |
| 447 if ((*it)->PreHandleTranslatedKeyEvent(target, event)) |
| 448 return true; |
| 449 } |
| 450 |
| 451 // If the |filters|, such as a filter for handling global shortcut keys, do |
| 452 // not consume the |event|, dispatch it to the |target| as a normal KeyEvent. |
| 453 // Note that the target->delegate() interface is IME agnostic. |
| 454 return target->delegate()->OnKeyEvent(event); |
| 455 } |
| 456 |
| 427 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, | 457 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, |
| 428 TouchEvent* event) { | 458 TouchEvent* event) { |
| 429 if (!target->IsVisible()) | 459 if (!target->IsVisible()) |
| 430 return ui::TOUCH_STATUS_UNKNOWN; | 460 return ui::TOUCH_STATUS_UNKNOWN; |
| 431 | 461 |
| 432 EventFilters filters; | 462 EventFilters filters; |
| 433 GetEventFiltersToNotify(target, &filters); | 463 GetEventFiltersToNotify(target, &filters); |
| 434 for (EventFilters::const_reverse_iterator it = filters.rbegin(); | 464 for (EventFilters::const_reverse_iterator it = filters.rbegin(); |
| 435 it != filters.rend(); ++it) { | 465 it != filters.rend(); ++it) { |
| 436 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); | 466 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 525 |
| 496 void RootWindow::OnLayerAnimationAborted( | 526 void RootWindow::OnLayerAnimationAborted( |
| 497 const ui::LayerAnimationSequence* animation) { | 527 const ui::LayerAnimationSequence* animation) { |
| 498 } | 528 } |
| 499 | 529 |
| 500 void RootWindow::SetFocusedWindow(Window* focused_window) { | 530 void RootWindow::SetFocusedWindow(Window* focused_window) { |
| 501 if (focused_window == focused_window_) | 531 if (focused_window == focused_window_) |
| 502 return; | 532 return; |
| 503 if (focused_window && !focused_window->CanFocus()) | 533 if (focused_window && !focused_window->CanFocus()) |
| 504 return; | 534 return; |
| 505 // The NULL-check of |focused)window| is essential here before asking the | 535 // The NULL-check of |focused_window| is essential here before asking the |
| 506 // activation client, since it is valid to clear the focus by calling | 536 // activation client, since it is valid to clear the focus by calling |
| 507 // SetFocusedWindow() to NULL. | 537 // SetFocusedWindow() to NULL. |
| 508 if (focused_window && ActivationClient::GetActivationClient() && | 538 if (focused_window && ActivationClient::GetActivationClient() && |
| 509 !ActivationClient::GetActivationClient()->CanFocusWindow( | 539 !ActivationClient::GetActivationClient()->CanFocusWindow( |
| 510 focused_window)) { | 540 focused_window)) { |
| 511 return; | 541 return; |
| 512 } | 542 } |
| 513 | 543 |
| 514 if (focused_window_ && focused_window_->delegate()) | 544 if (focused_window_ && focused_window_->delegate()) |
| 515 focused_window_->delegate()->OnBlur(); | 545 focused_window_->delegate()->OnBlur(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { | 581 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { |
| 552 bounds.set_size(gfx::Size(parsed_width, parsed_height)); | 582 bounds.set_size(gfx::Size(parsed_width, parsed_height)); |
| 553 } else if (use_fullscreen_host_window_) { | 583 } else if (use_fullscreen_host_window_) { |
| 554 bounds = gfx::Rect(RootWindowHost::GetNativeScreenSize()); | 584 bounds = gfx::Rect(RootWindowHost::GetNativeScreenSize()); |
| 555 } | 585 } |
| 556 | 586 |
| 557 return bounds; | 587 return bounds; |
| 558 } | 588 } |
| 559 | 589 |
| 560 } // namespace aura | 590 } // namespace aura |
| OLD | NEW |