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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 void RootWindow::SetGestureRecognizerForTesting(GestureRecognizer* gr) { | 406 void RootWindow::SetGestureRecognizerForTesting(GestureRecognizer* gr) { |
407 gesture_recognizer_.reset(gr); | 407 gesture_recognizer_.reset(gr); |
408 } | 408 } |
409 | 409 |
410 #if !defined(NDEBUG) | 410 #if !defined(NDEBUG) |
411 void RootWindow::ToggleFullScreen() { | 411 void RootWindow::ToggleFullScreen() { |
412 host_->ToggleFullScreen(); | 412 host_->ToggleFullScreen(); |
413 } | 413 } |
414 #endif | 414 #endif |
415 | 415 |
| 416 //////////////////////////////////////////////////////////////////////////////// |
| 417 // RootWindow, Window overrides: |
| 418 |
416 RootWindow* RootWindow::GetRootWindow() { | 419 RootWindow* RootWindow::GetRootWindow() { |
417 return this; | 420 return this; |
418 } | 421 } |
419 | 422 |
420 void RootWindow::SetTransform(const ui::Transform& transform) { | 423 void RootWindow::SetTransform(const ui::Transform& transform) { |
421 Window::SetTransform(transform); | 424 Window::SetTransform(transform); |
422 | 425 |
423 // If the layer is not animating, then we need to update the host size | 426 // If the layer is not animating, then we need to update the host size |
424 // immediately. | 427 // immediately. |
425 if (!layer()->GetAnimator()->is_animating()) | 428 if (!layer()->GetAnimator()->is_animating()) |
426 OnHostResized(host_->GetSize()); | 429 OnHostResized(host_->GetSize()); |
427 } | 430 } |
428 | 431 |
429 //////////////////////////////////////////////////////////////////////////////// | 432 //////////////////////////////////////////////////////////////////////////////// |
| 433 // RootWindow, ui::CompositorDelegate implementation: |
| 434 |
| 435 void RootWindow::ScheduleDraw() { |
| 436 if (!schedule_paint_factory_.HasWeakPtrs()) { |
| 437 MessageLoop::current()->PostTask( |
| 438 FROM_HERE, |
| 439 base::Bind(&RootWindow::Draw, schedule_paint_factory_.GetWeakPtr())); |
| 440 } |
| 441 } |
| 442 |
| 443 //////////////////////////////////////////////////////////////////////////////// |
430 // RootWindow, private: | 444 // RootWindow, private: |
431 | 445 |
432 RootWindow::RootWindow() | 446 RootWindow::RootWindow() |
433 : Window(NULL), | 447 : Window(NULL), |
434 host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())), | 448 host_(aura::RootWindowHost::Create(GetInitialHostWindowBounds())), |
435 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), | 449 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), |
436 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), | 450 ALLOW_THIS_IN_INITIALIZER_LIST(event_factory_(this)), |
437 mouse_button_flags_(0), | 451 mouse_button_flags_(0), |
438 last_cursor_(kCursorNull), | 452 last_cursor_(kCursorNull), |
439 screen_(new ScreenAura), | 453 screen_(new ScreenAura), |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 return false; | 622 return false; |
609 bool handled = false; | 623 bool handled = false; |
610 for (unsigned int i = 0; i < gestures->size(); i++) { | 624 for (unsigned int i = 0; i < gestures->size(); i++) { |
611 GestureEvent* gesture = gestures->at(i).get(); | 625 GestureEvent* gesture = gestures->at(i).get(); |
612 if (DispatchGestureEvent(gesture) != ui::GESTURE_STATUS_UNKNOWN) | 626 if (DispatchGestureEvent(gesture) != ui::GESTURE_STATUS_UNKNOWN) |
613 handled = true; | 627 handled = true; |
614 } | 628 } |
615 return handled; | 629 return handled; |
616 } | 630 } |
617 | 631 |
618 void RootWindow::ScheduleDraw() { | 632 void RootWindow::OnWindowRemovedFromRootWindow(Window* detached) { |
619 if (!schedule_paint_factory_.HasWeakPtrs()) { | |
620 MessageLoop::current()->PostTask( | |
621 FROM_HERE, | |
622 base::Bind(&RootWindow::Draw, schedule_paint_factory_.GetWeakPtr())); | |
623 } | |
624 } | |
625 | |
626 bool RootWindow::CanFocus() const { | |
627 return IsVisible(); | |
628 } | |
629 | |
630 bool RootWindow::CanReceiveEvents() const { | |
631 return IsVisible(); | |
632 } | |
633 | |
634 internal::FocusManager* RootWindow::GetFocusManager() { | |
635 return this; | |
636 } | |
637 | |
638 void RootWindow::OnWindowDetachingFromRootWindow(Window* detached) { | |
639 DCHECK(capture_window_ != this); | 633 DCHECK(capture_window_ != this); |
640 | 634 |
641 // If the ancestor of the capture window is detached, | 635 // If the ancestor of the capture window is detached, |
642 // release the capture. | 636 // release the capture. |
643 if (detached->Contains(capture_window_) && detached != this) | 637 if (detached->Contains(capture_window_) && detached != this) |
644 ReleaseCapture(capture_window_); | 638 ReleaseCapture(capture_window_); |
645 | 639 |
646 // If the ancestor of the focused window is detached, | 640 // If the ancestor of the focused window is detached, |
647 // release the focus. | 641 // release the focus. |
648 if (detached->Contains(focused_window_)) | 642 if (detached->Contains(focused_window_)) |
649 SetFocusedWindow(NULL); | 643 SetFocusedWindow(NULL); |
650 | 644 |
651 // If the ancestor of any event handler windows are detached, release the | 645 // If the ancestor of any event handler windows are detached, release the |
652 // pointer to those windows. | 646 // pointer to those windows. |
653 if (detached->Contains(mouse_pressed_handler_)) | 647 if (detached->Contains(mouse_pressed_handler_)) |
654 mouse_pressed_handler_ = NULL; | 648 mouse_pressed_handler_ = NULL; |
655 if (detached->Contains(mouse_moved_handler_)) | 649 if (detached->Contains(mouse_moved_handler_)) |
656 mouse_moved_handler_ = NULL; | 650 mouse_moved_handler_ = NULL; |
657 if (detached->Contains(touch_event_handler_)) | 651 if (detached->Contains(touch_event_handler_)) |
658 touch_event_handler_ = NULL; | 652 touch_event_handler_ = NULL; |
659 | 653 |
660 if (detached->IsVisible() && | 654 if (detached->IsVisible() && |
661 detached->ContainsPointInRoot(last_mouse_location_)) { | 655 detached->ContainsPointInRoot(last_mouse_location_)) { |
662 PostMouseMoveEventAfterWindowChange(); | 656 PostMouseMoveEventAfterWindowChange(); |
663 } | 657 } |
664 } | 658 } |
665 | 659 |
666 void RootWindow::OnWindowAttachedToRootWindow(Window* attached) { | 660 void RootWindow::OnWindowAddedToRootWindow(Window* attached) { |
667 if (attached->IsVisible() && | 661 if (attached->IsVisible() && |
668 attached->ContainsPointInRoot(last_mouse_location_)) | 662 attached->ContainsPointInRoot(last_mouse_location_)) |
669 PostMouseMoveEventAfterWindowChange(); | 663 PostMouseMoveEventAfterWindowChange(); |
670 } | 664 } |
671 | 665 |
| 666 bool RootWindow::CanFocus() const { |
| 667 return IsVisible(); |
| 668 } |
| 669 |
| 670 bool RootWindow::CanReceiveEvents() const { |
| 671 return IsVisible(); |
| 672 } |
| 673 |
| 674 internal::FocusManager* RootWindow::GetFocusManager() { |
| 675 return this; |
| 676 } |
| 677 |
672 void RootWindow::OnLayerAnimationEnded( | 678 void RootWindow::OnLayerAnimationEnded( |
673 const ui::LayerAnimationSequence* animation) { | 679 const ui::LayerAnimationSequence* animation) { |
674 OnHostResized(host_->GetSize()); | 680 OnHostResized(host_->GetSize()); |
675 } | 681 } |
676 | 682 |
677 void RootWindow::OnLayerAnimationScheduled( | 683 void RootWindow::OnLayerAnimationScheduled( |
678 const ui::LayerAnimationSequence* animation) { | 684 const ui::LayerAnimationSequence* animation) { |
679 } | 685 } |
680 | 686 |
681 void RootWindow::OnLayerAnimationAborted( | 687 void RootWindow::OnLayerAnimationAborted( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 synthesize_mouse_move_ = false; | 764 synthesize_mouse_move_ = false; |
759 gfx::Point orig_mouse_location = last_mouse_location_; | 765 gfx::Point orig_mouse_location = last_mouse_location_; |
760 layer()->transform().TransformPoint(orig_mouse_location); | 766 layer()->transform().TransformPoint(orig_mouse_location); |
761 | 767 |
762 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's | 768 // TODO(derat|oshima): Don't use mouse_button_flags_ as it's |
763 // is currently broken. See/ crbug.com/107931. | 769 // is currently broken. See/ crbug.com/107931. |
764 MouseEvent event(ui::ET_MOUSE_MOVED, | 770 MouseEvent event(ui::ET_MOUSE_MOVED, |
765 orig_mouse_location, | 771 orig_mouse_location, |
766 orig_mouse_location, | 772 orig_mouse_location, |
767 0); | 773 0); |
768 DispatchMouseEvent(&event); | 774 //DispatchMouseEvent(&event); |
769 } | 775 } |
770 | 776 |
771 } // namespace aura | 777 } // namespace aura |
OLD | NEW |