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 "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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 ProcessMouseEvent(mouse_moved_handler_, &translated_event); | 475 ProcessMouseEvent(mouse_moved_handler_, &translated_event); |
476 } | 476 } |
477 } | 477 } |
478 | 478 |
479 bool RootWindow::ProcessMouseEvent(Window* target, MouseEvent* event) { | 479 bool RootWindow::ProcessMouseEvent(Window* target, MouseEvent* event) { |
480 if (!target->IsVisible()) | 480 if (!target->IsVisible()) |
481 return false; | 481 return false; |
482 | 482 |
483 EventFilters filters; | 483 EventFilters filters; |
484 GetEventFiltersToNotify(target->parent(), &filters); | 484 GetEventFiltersToNotify(target->parent(), &filters); |
485 for (EventFilters::const_reverse_iterator it = filters.rbegin(); | 485 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
486 it != filters.rend(); ++it) { | 486 rend = filters.rend(); |
| 487 it != rend; ++it) { |
487 if ((*it)->PreHandleMouseEvent(target, event)) | 488 if ((*it)->PreHandleMouseEvent(target, event)) |
488 return true; | 489 return true; |
489 } | 490 } |
490 | 491 |
491 return target->delegate()->OnMouseEvent(event); | 492 return target->delegate()->OnMouseEvent(event); |
492 } | 493 } |
493 | 494 |
494 bool RootWindow::ProcessKeyEvent(Window* target, KeyEvent* event) { | 495 bool RootWindow::ProcessKeyEvent(Window* target, KeyEvent* event) { |
495 EventFilters filters; | 496 EventFilters filters; |
496 | 497 |
497 if (!target) { | 498 if (!target) { |
498 // When no window is focused, send the key event to |this| so event filters | 499 // When no window is focused, send the key event to |this| so event filters |
499 // for the window could check if the key is a global shortcut like Alt+Tab. | 500 // for the window could check if the key is a global shortcut like Alt+Tab. |
500 target = this; | 501 target = this; |
501 GetEventFiltersToNotify(this, &filters); | 502 GetEventFiltersToNotify(this, &filters); |
502 } else { | 503 } else { |
503 if (!target->IsVisible()) | 504 if (!target->IsVisible()) |
504 return false; | 505 return false; |
505 GetEventFiltersToNotify(target->parent(), &filters); | 506 GetEventFiltersToNotify(target->parent(), &filters); |
506 } | 507 } |
507 | 508 |
508 for (EventFilters::const_reverse_iterator it = filters.rbegin(); | 509 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
509 it != filters.rend(); ++it) { | 510 rend = filters.rend(); |
| 511 it != rend; ++it) { |
510 if ((*it)->PreHandleKeyEvent(target, event)) | 512 if ((*it)->PreHandleKeyEvent(target, event)) |
511 return true; | 513 return true; |
512 } | 514 } |
513 | 515 |
514 if (!target->delegate()) | 516 if (!target->delegate()) |
515 return false; | 517 return false; |
516 return target->delegate()->OnKeyEvent(event); | 518 return target->delegate()->OnKeyEvent(event); |
517 } | 519 } |
518 | 520 |
519 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, | 521 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, |
520 TouchEvent* event) { | 522 TouchEvent* event) { |
521 if (!target->IsVisible()) | 523 if (!target->IsVisible()) |
522 return ui::TOUCH_STATUS_UNKNOWN; | 524 return ui::TOUCH_STATUS_UNKNOWN; |
523 | 525 |
524 EventFilters filters; | 526 EventFilters filters; |
525 GetEventFiltersToNotify(target->parent(), &filters); | 527 GetEventFiltersToNotify(target->parent(), &filters); |
526 for (EventFilters::const_reverse_iterator it = filters.rbegin(); | 528 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
527 it != filters.rend(); ++it) { | 529 rend = filters.rend(); |
| 530 it != rend; ++it) { |
528 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); | 531 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); |
529 if (status != ui::TOUCH_STATUS_UNKNOWN) | 532 if (status != ui::TOUCH_STATUS_UNKNOWN) |
530 return status; | 533 return status; |
531 } | 534 } |
532 | 535 |
533 return target->delegate()->OnTouchEvent(event); | 536 return target->delegate()->OnTouchEvent(event); |
534 } | 537 } |
535 | 538 |
536 ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target, | 539 ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target, |
537 GestureEvent* event) { | 540 GestureEvent* event) { |
538 if (!target->IsVisible()) | 541 if (!target->IsVisible()) |
539 return ui::GESTURE_STATUS_UNKNOWN; | 542 return ui::GESTURE_STATUS_UNKNOWN; |
540 | 543 |
541 EventFilters filters; | 544 EventFilters filters; |
542 GetEventFiltersToNotify(target->parent(), &filters); | 545 GetEventFiltersToNotify(target->parent(), &filters); |
543 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; | 546 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; |
544 for (EventFilters::const_reverse_iterator it = filters.rbegin(); | 547 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
545 it != filters.rend(); ++it) { | 548 rend = filters.rend(); |
| 549 it != rend; ++it) { |
546 status = (*it)->PreHandleGestureEvent(target, event); | 550 status = (*it)->PreHandleGestureEvent(target, event); |
547 if (status != ui::GESTURE_STATUS_UNKNOWN) | 551 if (status != ui::GESTURE_STATUS_UNKNOWN) |
548 return status; | 552 return status; |
549 } | 553 } |
550 | 554 |
551 status = target->delegate()->OnGestureEvent(event); | 555 status = target->delegate()->OnGestureEvent(event); |
552 if (status == ui::GESTURE_STATUS_UNKNOWN) { | 556 if (status == ui::GESTURE_STATUS_UNKNOWN) { |
553 // The gesture was unprocessed. Generate corresponding mouse events here | 557 // The gesture was unprocessed. Generate corresponding mouse events here |
554 // (e.g. tap to click). | 558 // (e.g. tap to click). |
555 switch (event->type()) { | 559 switch (event->type()) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's | 753 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's |
750 // is currently broken. See/ crbug.com/107931. | 754 // is currently broken. See/ crbug.com/107931. |
751 MouseEvent event(ui::ET_MOUSE_MOVED, | 755 MouseEvent event(ui::ET_MOUSE_MOVED, |
752 orig_mouse_location, | 756 orig_mouse_location, |
753 orig_mouse_location, | 757 orig_mouse_location, |
754 0); | 758 0); |
755 DispatchMouseEvent(&event); | 759 DispatchMouseEvent(&event); |
756 } | 760 } |
757 | 761 |
758 } // namespace aura | 762 } // namespace aura |
OLD | NEW |