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_host_linux.h" | 5 #include "ui/aura/root_window_host_linux.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/Xcursor/Xcursor.h> | 8 #include <X11/Xcursor/Xcursor.h> |
9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
10 #include <X11/cursorfont.h> | 10 #include <X11/cursorfont.h> |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 // the X Cursor and the corresponding XcursorImages. We need a pointer to the | 466 // the X Cursor and the corresponding XcursorImages. We need a pointer to the |
467 // images so that we can free them on destruction. | 467 // images so that we can free them on destruction. |
468 typedef std::map<int, std::pair<Cursor, XcursorImages*> > AnimatedCursorMap; | 468 typedef std::map<int, std::pair<Cursor, XcursorImages*> > AnimatedCursorMap; |
469 AnimatedCursorMap animated_cursors_; | 469 AnimatedCursorMap animated_cursors_; |
470 | 470 |
471 float scale_factor_; | 471 float scale_factor_; |
472 | 472 |
473 DISALLOW_COPY_AND_ASSIGN(ImageCursors); | 473 DISALLOW_COPY_AND_ASSIGN(ImageCursors); |
474 }; | 474 }; |
475 | 475 |
476 RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) | 476 RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, |
477 : root_window_(NULL), | 477 const gfx::Rect& bounds) |
| 478 : delegate_(delegate), |
478 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 479 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), |
479 xwindow_(0), | 480 xwindow_(0), |
480 x_root_window_(DefaultRootWindow(xdisplay_)), | 481 x_root_window_(DefaultRootWindow(xdisplay_)), |
481 current_cursor_(ui::kCursorNull), | 482 current_cursor_(ui::kCursorNull), |
482 cursor_shown_(true), | 483 cursor_shown_(true), |
483 bounds_(bounds), | 484 bounds_(bounds), |
484 focus_when_shown_(false), | 485 focus_when_shown_(false), |
485 pointer_barriers_(NULL), | 486 pointer_barriers_(NULL), |
486 image_cursors_(new ImageCursors), | 487 image_cursors_(new ImageCursors), |
487 atom_cache_(xdisplay_, kAtomsToCache) { | 488 atom_cache_(xdisplay_, kAtomsToCache) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 XFreeCursor(xdisplay_, invisible_cursor_); | 575 XFreeCursor(xdisplay_, invisible_cursor_); |
575 } | 576 } |
576 | 577 |
577 bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { | 578 bool RootWindowHostLinux::Dispatch(const base::NativeEvent& event) { |
578 XEvent* xev = event; | 579 XEvent* xev = event; |
579 | 580 |
580 CheckXEventForConsistency(xev); | 581 CheckXEventForConsistency(xev); |
581 | 582 |
582 switch (xev->type) { | 583 switch (xev->type) { |
583 case Expose: | 584 case Expose: |
584 root_window_->ScheduleFullDraw(); | 585 delegate_->AsRootWindow()->ScheduleFullDraw(); |
585 break; | 586 break; |
586 case KeyPress: { | 587 case KeyPress: { |
587 KeyEvent keydown_event(xev, false); | 588 KeyEvent keydown_event(xev, false); |
588 root_window_->DispatchKeyEvent(&keydown_event); | 589 delegate_->OnHostKeyEvent(&keydown_event); |
589 break; | 590 break; |
590 } | 591 } |
591 case KeyRelease: { | 592 case KeyRelease: { |
592 KeyEvent keyup_event(xev, false); | 593 KeyEvent keyup_event(xev, false); |
593 root_window_->DispatchKeyEvent(&keyup_event); | 594 delegate_->OnHostKeyEvent(&keyup_event); |
594 break; | 595 break; |
595 } | 596 } |
596 case ButtonPress: { | 597 case ButtonPress: { |
597 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || | 598 if (static_cast<int>(xev->xbutton.button) == kBackMouseButton || |
598 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { | 599 static_cast<int>(xev->xbutton.button) == kForwardMouseButton) { |
599 client::UserActionClient* gesture_client = | 600 client::UserActionClient* gesture_client = |
600 client::GetUserActionClient(root_window_); | 601 client::GetUserActionClient(delegate_->AsRootWindow()); |
601 if (gesture_client) { | 602 if (gesture_client) { |
602 gesture_client->OnUserAction( | 603 gesture_client->OnUserAction( |
603 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? | 604 static_cast<int>(xev->xbutton.button) == kBackMouseButton ? |
604 client::UserActionClient::BACK : | 605 client::UserActionClient::BACK : |
605 client::UserActionClient::FORWARD); | 606 client::UserActionClient::FORWARD); |
606 } | 607 } |
607 break; | 608 break; |
608 } | 609 } |
609 } // fallthrough | 610 } // fallthrough |
610 case ButtonRelease: { | 611 case ButtonRelease: { |
611 MouseEvent mouseev(xev); | 612 MouseEvent mouseev(xev); |
612 root_window_->DispatchMouseEvent(&mouseev); | 613 delegate_->OnHostMouseEvent(&mouseev); |
613 break; | 614 break; |
614 } | 615 } |
615 case FocusOut: | 616 case FocusOut: |
616 if (xev->xfocus.mode != NotifyGrab) { | 617 if (xev->xfocus.mode != NotifyGrab) |
617 Window* capture_window = client::GetCaptureWindow(root_window_); | 618 delegate_->OnHostLostCapture(); |
618 if (capture_window && capture_window->GetRootWindow() == root_window_) | |
619 capture_window->ReleaseCapture(); | |
620 } | |
621 break; | 619 break; |
622 case ConfigureNotify: { | 620 case ConfigureNotify: { |
623 DCHECK_EQ(xwindow_, xev->xconfigure.window); | 621 DCHECK_EQ(xwindow_, xev->xconfigure.window); |
624 DCHECK_EQ(xwindow_, xev->xconfigure.event); | 622 DCHECK_EQ(xwindow_, xev->xconfigure.event); |
625 // It's possible that the X window may be resized by some other means than | 623 // It's possible that the X window may be resized by some other means than |
626 // from within aura (e.g. the X window manager can change the size). Make | 624 // from within aura (e.g. the X window manager can change the size). Make |
627 // sure the root window size is maintained properly. | 625 // sure the root window size is maintained properly. |
628 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, | 626 gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y, |
629 xev->xconfigure.width, xev->xconfigure.height); | 627 xev->xconfigure.width, xev->xconfigure.height); |
630 bool size_changed = bounds_.size() != bounds.size(); | 628 bool size_changed = bounds_.size() != bounds.size(); |
631 bounds_ = bounds; | 629 bounds_ = bounds; |
632 // Update barrier and mouse location when the root window has | 630 // Update barrier and mouse location when the root window has |
633 // moved/resized. | 631 // moved/resized. |
634 if (pointer_barriers_.get()) { | 632 if (pointer_barriers_.get()) { |
635 UnConfineCursor(); | 633 UnConfineCursor(); |
636 gfx::Point p = gfx::Screen::GetCursorScreenPoint(); | 634 gfx::Point p = gfx::Screen::GetCursorScreenPoint(); |
637 XWarpPointer(xdisplay_, None, xwindow_, 0, 0, 0, 0, p.x(), p.y()); | 635 XWarpPointer(xdisplay_, None, xwindow_, 0, 0, 0, 0, p.x(), p.y()); |
638 ConfineCursorToRootWindow(); | 636 ConfineCursorToRootWindow(); |
639 } | 637 } |
640 if (size_changed) | 638 if (size_changed) |
641 root_window_->OnHostResized(bounds.size()); | 639 delegate_->OnHostResized(bounds.size()); |
642 break; | 640 break; |
643 } | 641 } |
644 case GenericEvent: { | 642 case GenericEvent: { |
645 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); | 643 ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); |
646 if (!factory->ShouldProcessXI2Event(xev)) | 644 if (!factory->ShouldProcessXI2Event(xev)) |
647 break; | 645 break; |
648 | 646 |
649 ui::EventType type = ui::EventTypeFromNative(xev); | 647 ui::EventType type = ui::EventTypeFromNative(xev); |
650 XEvent last_event; | 648 XEvent last_event; |
651 int num_coalesced = 0; | 649 int num_coalesced = 0; |
652 | 650 |
653 switch (type) { | 651 switch (type) { |
654 case ui::ET_TOUCH_PRESSED: | 652 case ui::ET_TOUCH_PRESSED: |
655 case ui::ET_TOUCH_RELEASED: | 653 case ui::ET_TOUCH_RELEASED: |
656 case ui::ET_TOUCH_MOVED: { | 654 case ui::ET_TOUCH_MOVED: { |
657 TouchEvent touchev(xev); | 655 TouchEvent touchev(xev); |
658 root_window_->DispatchTouchEvent(&touchev); | 656 delegate_->OnHostTouchEvent(&touchev); |
659 break; | 657 break; |
660 } | 658 } |
661 case ui::ET_MOUSE_MOVED: | 659 case ui::ET_MOUSE_MOVED: |
662 case ui::ET_MOUSE_DRAGGED: | 660 case ui::ET_MOUSE_DRAGGED: |
663 case ui::ET_MOUSE_PRESSED: | 661 case ui::ET_MOUSE_PRESSED: |
664 case ui::ET_MOUSE_RELEASED: | 662 case ui::ET_MOUSE_RELEASED: |
665 case ui::ET_MOUSEWHEEL: | 663 case ui::ET_MOUSEWHEEL: |
666 case ui::ET_MOUSE_ENTERED: | 664 case ui::ET_MOUSE_ENTERED: |
667 case ui::ET_MOUSE_EXITED: { | 665 case ui::ET_MOUSE_EXITED: { |
668 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { | 666 if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_DRAGGED) { |
669 // If this is a motion event, we want to coalesce all pending motion | 667 // If this is a motion event, we want to coalesce all pending motion |
670 // events that are at the top of the queue. | 668 // events that are at the top of the queue. |
671 num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event); | 669 num_coalesced = CoalescePendingXIMotionEvents(xev, &last_event); |
672 if (num_coalesced > 0) | 670 if (num_coalesced > 0) |
673 xev = &last_event; | 671 xev = &last_event; |
674 } else if (type == ui::ET_MOUSE_PRESSED) { | 672 } else if (type == ui::ET_MOUSE_PRESSED) { |
675 XIDeviceEvent* xievent = | 673 XIDeviceEvent* xievent = |
676 static_cast<XIDeviceEvent*>(xev->xcookie.data); | 674 static_cast<XIDeviceEvent*>(xev->xcookie.data); |
677 int button = xievent->detail; | 675 int button = xievent->detail; |
678 if (button == kBackMouseButton || button == kForwardMouseButton) { | 676 if (button == kBackMouseButton || button == kForwardMouseButton) { |
679 client::UserActionClient* gesture_client = | 677 client::UserActionClient* gesture_client = |
680 client::GetUserActionClient(root_window_); | 678 client::GetUserActionClient(delegate_->AsRootWindow()); |
681 if (gesture_client) { | 679 if (gesture_client) { |
682 bool reverse_direction = | 680 bool reverse_direction = |
683 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); | 681 ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled(); |
684 gesture_client->OnUserAction( | 682 gesture_client->OnUserAction( |
685 (button == kBackMouseButton && !reverse_direction) || | 683 (button == kBackMouseButton && !reverse_direction) || |
686 (button == kForwardMouseButton && reverse_direction) ? | 684 (button == kForwardMouseButton && reverse_direction) ? |
687 client::UserActionClient::BACK : | 685 client::UserActionClient::BACK : |
688 client::UserActionClient::FORWARD); | 686 client::UserActionClient::FORWARD); |
689 } | 687 } |
690 break; | 688 break; |
691 } | 689 } |
692 } | 690 } |
693 MouseEvent mouseev(xev); | 691 MouseEvent mouseev(xev); |
694 root_window_->DispatchMouseEvent(&mouseev); | 692 delegate_->OnHostMouseEvent(&mouseev); |
695 break; | 693 break; |
696 } | 694 } |
697 case ui::ET_SCROLL_FLING_START: | 695 case ui::ET_SCROLL_FLING_START: |
698 case ui::ET_SCROLL_FLING_CANCEL: | 696 case ui::ET_SCROLL_FLING_CANCEL: |
699 case ui::ET_SCROLL: { | 697 case ui::ET_SCROLL: { |
700 ScrollEvent scrollev(xev); | 698 ScrollEvent scrollev(xev); |
701 root_window_->DispatchScrollEvent(&scrollev); | 699 delegate_->OnHostScrollEvent(&scrollev); |
702 break; | 700 break; |
703 } | 701 } |
704 case ui::ET_UNKNOWN: | 702 case ui::ET_UNKNOWN: |
705 break; | 703 break; |
706 default: | 704 default: |
707 NOTREACHED(); | 705 NOTREACHED(); |
708 } | 706 } |
709 | 707 |
710 // If we coalesced an event we need to free its cookie. | 708 // If we coalesced an event we need to free its cookie. |
711 if (num_coalesced > 0) | 709 if (num_coalesced > 0) |
712 XFreeEventData(xev->xgeneric.display, &last_event.xcookie); | 710 XFreeEventData(xev->xgeneric.display, &last_event.xcookie); |
713 break; | 711 break; |
714 } | 712 } |
715 case MapNotify: { | 713 case MapNotify: { |
716 // If there's no window manager running, we need to assign the X input | 714 // If there's no window manager running, we need to assign the X input |
717 // focus to our host window. | 715 // focus to our host window. |
718 if (!IsWindowManagerPresent() && focus_when_shown_) | 716 if (!IsWindowManagerPresent() && focus_when_shown_) |
719 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); | 717 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); |
720 break; | 718 break; |
721 } | 719 } |
722 case ClientMessage: { | 720 case ClientMessage: { |
723 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); | 721 Atom message_type = static_cast<Atom>(xev->xclient.data.l[0]); |
724 if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { | 722 if (message_type == atom_cache_.GetAtom("WM_DELETE_WINDOW")) { |
725 // We have received a close message from the window manager. | 723 // We have received a close message from the window manager. |
726 root_window_->OnRootWindowHostClosed(); | 724 delegate_->AsRootWindow()->OnRootWindowHostClosed(); |
727 } else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) { | 725 } else if (message_type == atom_cache_.GetAtom("_NET_WM_PING")) { |
728 XEvent reply_event = *xev; | 726 XEvent reply_event = *xev; |
729 reply_event.xclient.window = x_root_window_; | 727 reply_event.xclient.window = x_root_window_; |
730 | 728 |
731 XSendEvent(xdisplay_, | 729 XSendEvent(xdisplay_, |
732 reply_event.xclient.window, | 730 reply_event.xclient.window, |
733 False, | 731 False, |
734 SubstructureRedirectMask | SubstructureNotifyMask, | 732 SubstructureRedirectMask | SubstructureNotifyMask, |
735 &reply_event); | 733 &reply_event); |
736 } | 734 } |
737 break; | 735 break; |
738 } | 736 } |
739 case MappingNotify: { | 737 case MappingNotify: { |
740 switch (xev->xmapping.request) { | 738 switch (xev->xmapping.request) { |
741 case MappingModifier: | 739 case MappingModifier: |
742 case MappingKeyboard: | 740 case MappingKeyboard: |
743 XRefreshKeyboardMapping(&xev->xmapping); | 741 XRefreshKeyboardMapping(&xev->xmapping); |
744 root_window_->OnKeyboardMappingChanged(); | 742 delegate_->AsRootWindow()->OnKeyboardMappingChanged(); |
745 break; | 743 break; |
746 case MappingPointer: | 744 case MappingPointer: |
747 ui::UpdateButtonMap(); | 745 ui::UpdateButtonMap(); |
748 break; | 746 break; |
749 default: | 747 default: |
750 NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request; | 748 NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request; |
751 break; | 749 break; |
752 } | 750 } |
753 break; | 751 break; |
754 } | 752 } |
755 case MotionNotify: { | 753 case MotionNotify: { |
756 // Discard all but the most recent motion event that targets the same | 754 // Discard all but the most recent motion event that targets the same |
757 // window with unchanged state. | 755 // window with unchanged state. |
758 XEvent last_event; | 756 XEvent last_event; |
759 while (XPending(xev->xany.display)) { | 757 while (XPending(xev->xany.display)) { |
760 XEvent next_event; | 758 XEvent next_event; |
761 XPeekEvent(xev->xany.display, &next_event); | 759 XPeekEvent(xev->xany.display, &next_event); |
762 if (next_event.type == MotionNotify && | 760 if (next_event.type == MotionNotify && |
763 next_event.xmotion.window == xev->xmotion.window && | 761 next_event.xmotion.window == xev->xmotion.window && |
764 next_event.xmotion.subwindow == xev->xmotion.subwindow && | 762 next_event.xmotion.subwindow == xev->xmotion.subwindow && |
765 next_event.xmotion.state == xev->xmotion.state) { | 763 next_event.xmotion.state == xev->xmotion.state) { |
766 XNextEvent(xev->xany.display, &last_event); | 764 XNextEvent(xev->xany.display, &last_event); |
767 xev = &last_event; | 765 xev = &last_event; |
768 } else { | 766 } else { |
769 break; | 767 break; |
770 } | 768 } |
771 } | 769 } |
772 | 770 |
773 MouseEvent mouseev(xev); | 771 MouseEvent mouseev(xev); |
774 root_window_->DispatchMouseEvent(&mouseev); | 772 delegate_->OnHostMouseEvent(&mouseev); |
775 break; | 773 break; |
776 } | 774 } |
777 } | 775 } |
778 return true; | 776 return true; |
779 } | 777 } |
780 | 778 |
781 void RootWindowHostLinux::SetRootWindow(RootWindow* root_window) { | |
782 root_window_ = root_window; | |
783 // The device scale factor is now accessible, so load cursors now. | |
784 image_cursors_->Reload(root_window_->layer()->device_scale_factor()); | |
785 } | |
786 | |
787 RootWindow* RootWindowHostLinux::GetRootWindow() { | 779 RootWindow* RootWindowHostLinux::GetRootWindow() { |
788 return root_window_; | 780 return delegate_->AsRootWindow(); |
789 } | 781 } |
790 | 782 |
791 gfx::AcceleratedWidget RootWindowHostLinux::GetAcceleratedWidget() { | 783 gfx::AcceleratedWidget RootWindowHostLinux::GetAcceleratedWidget() { |
792 return xwindow_; | 784 return xwindow_; |
793 } | 785 } |
794 | 786 |
795 void RootWindowHostLinux::Show() { | 787 void RootWindowHostLinux::Show() { |
| 788 // The device scale factor is now accessible, so load cursors now. |
| 789 image_cursors_->Reload(delegate_->GetDeviceScaleFactor()); |
| 790 |
796 // Before we map the window, set size hints. Otherwise, some window managers | 791 // Before we map the window, set size hints. Otherwise, some window managers |
797 // will ignore toplevel XMoveWindow commands. | 792 // will ignore toplevel XMoveWindow commands. |
798 XSizeHints size_hints; | 793 XSizeHints size_hints; |
799 size_hints.flags = PPosition; | 794 size_hints.flags = PPosition; |
800 size_hints.x = bounds_.x(); | 795 size_hints.x = bounds_.x(); |
801 size_hints.y = bounds_.y(); | 796 size_hints.y = bounds_.y(); |
802 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); | 797 XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); |
803 | 798 |
804 XMapWindow(xdisplay_, xwindow_); | 799 XMapWindow(xdisplay_, xwindow_); |
805 } | 800 } |
806 | 801 |
807 void RootWindowHostLinux::ToggleFullScreen() { | 802 void RootWindowHostLinux::ToggleFullScreen() { |
808 NOTIMPLEMENTED(); | 803 NOTIMPLEMENTED(); |
809 } | 804 } |
810 | 805 |
811 gfx::Rect RootWindowHostLinux::GetBounds() const { | 806 gfx::Rect RootWindowHostLinux::GetBounds() const { |
812 return bounds_; | 807 return bounds_; |
813 } | 808 } |
814 | 809 |
815 void RootWindowHostLinux::SetBounds(const gfx::Rect& bounds) { | 810 void RootWindowHostLinux::SetBounds(const gfx::Rect& bounds) { |
816 // Even if the host window's size doesn't change, aura's root window | 811 // Even if the host window's size doesn't change, aura's root window |
817 // size, which is in DIP, changes when the scale changes. | 812 // size, which is in DIP, changes when the scale changes. |
818 float current_scale = root_window_->compositor()->device_scale_factor(); | 813 float current_scale = delegate_->GetDeviceScaleFactor(); |
819 float new_scale = | 814 float new_scale = gfx::Screen::GetDisplayNearestWindow( |
820 gfx::Screen::GetDisplayNearestWindow(root_window_).device_scale_factor(); | 815 delegate_->AsRootWindow()).device_scale_factor(); |
821 bool size_changed = bounds_.size() != bounds.size() || | 816 bool size_changed = bounds_.size() != bounds.size() || |
822 current_scale != new_scale; | 817 current_scale != new_scale; |
823 | 818 |
824 if (bounds.size() != bounds_.size()) | 819 if (bounds.size() != bounds_.size()) |
825 XResizeWindow(xdisplay_, xwindow_, bounds.width(), bounds.height()); | 820 XResizeWindow(xdisplay_, xwindow_, bounds.width(), bounds.height()); |
826 | 821 |
827 if (bounds.origin() != bounds_.origin()) | 822 if (bounds.origin() != bounds_.origin()) |
828 XMoveWindow(xdisplay_, xwindow_, bounds.x(), bounds.y()); | 823 XMoveWindow(xdisplay_, xwindow_, bounds.x(), bounds.y()); |
829 | 824 |
830 // Assume that the resize will go through as requested, which should be the | 825 // Assume that the resize will go through as requested, which should be the |
831 // case if we're running without a window manager. If there's a window | 826 // case if we're running without a window manager. If there's a window |
832 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a | 827 // manager, it can modify or ignore the request, but (per ICCCM) we'll get a |
833 // (possibly synthetic) ConfigureNotify about the actual size and correct | 828 // (possibly synthetic) ConfigureNotify about the actual size and correct |
834 // |bounds_| later. | 829 // |bounds_| later. |
835 bounds_ = bounds; | 830 bounds_ = bounds; |
836 if (size_changed) | 831 if (size_changed) { |
837 root_window_->OnHostResized(bounds.size()); | 832 delegate_->OnHostResized(bounds.size()); |
838 else | 833 } else { |
839 root_window_->SchedulePaintInRect(root_window_->bounds()); | 834 delegate_->AsRootWindow()->SchedulePaintInRect( |
| 835 delegate_->AsRootWindow()->bounds()); |
| 836 } |
840 } | 837 } |
841 | 838 |
842 gfx::Point RootWindowHostLinux::GetLocationOnNativeScreen() const { | 839 gfx::Point RootWindowHostLinux::GetLocationOnNativeScreen() const { |
843 return bounds_.origin(); | 840 return bounds_.origin(); |
844 } | 841 } |
845 | 842 |
846 void RootWindowHostLinux::SetCapture() { | 843 void RootWindowHostLinux::SetCapture() { |
847 // TODO(oshima): Grab x input. | 844 // TODO(oshima): Grab x input. |
848 } | 845 } |
849 | 846 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 case KeyRelease: | 1009 case KeyRelease: |
1013 case ButtonPress: | 1010 case ButtonPress: |
1014 case ButtonRelease: { | 1011 case ButtonRelease: { |
1015 // The fields used below are in the same place for all of events | 1012 // The fields used below are in the same place for all of events |
1016 // above. Using xmotion from XEvent's unions to avoid repeating | 1013 // above. Using xmotion from XEvent's unions to avoid repeating |
1017 // the code. | 1014 // the code. |
1018 xevent.xmotion.root = x_root_window_; | 1015 xevent.xmotion.root = x_root_window_; |
1019 xevent.xmotion.time = CurrentTime; | 1016 xevent.xmotion.time = CurrentTime; |
1020 | 1017 |
1021 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); | 1018 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); |
1022 root_window_->ConvertPointToNativeScreen(&point); | 1019 delegate_->AsRootWindow()->ConvertPointToNativeScreen(&point); |
1023 xevent.xmotion.x_root = point.x(); | 1020 xevent.xmotion.x_root = point.x(); |
1024 xevent.xmotion.y_root = point.y(); | 1021 xevent.xmotion.y_root = point.y(); |
1025 } | 1022 } |
1026 default: | 1023 default: |
1027 break; | 1024 break; |
1028 } | 1025 } |
1029 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); | 1026 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); |
1030 } | 1027 } |
1031 | 1028 |
1032 void RootWindowHostLinux::OnDeviceScaleFactorChanged( | 1029 void RootWindowHostLinux::OnDeviceScaleFactorChanged( |
(...skipping 12 matching lines...) Expand all Loading... |
1045 ::Cursor xcursor = | 1042 ::Cursor xcursor = |
1046 image_cursors_->IsImageCursor(cursor) ? | 1043 image_cursors_->IsImageCursor(cursor) ? |
1047 image_cursors_->ImageCursorFromNative(cursor) : | 1044 image_cursors_->ImageCursorFromNative(cursor) : |
1048 (cursor == ui::kCursorNone ? invisible_cursor_ : | 1045 (cursor == ui::kCursorNone ? invisible_cursor_ : |
1049 (cursor == ui::kCursorCustom ? cursor.platform() : | 1046 (cursor == ui::kCursorCustom ? cursor.platform() : |
1050 ui::GetXCursor(CursorShapeFromNative(cursor)))); | 1047 ui::GetXCursor(CursorShapeFromNative(cursor)))); |
1051 XDefineCursor(xdisplay_, xwindow_, xcursor); | 1048 XDefineCursor(xdisplay_, xwindow_, xcursor); |
1052 } | 1049 } |
1053 | 1050 |
1054 // static | 1051 // static |
1055 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { | 1052 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, |
1056 return new RootWindowHostLinux(bounds); | 1053 const gfx::Rect& bounds) { |
| 1054 return new RootWindowHostLinux(delegate, bounds); |
1057 } | 1055 } |
1058 | 1056 |
1059 // static | 1057 // static |
1060 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( | 1058 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( |
1061 gfx::AcceleratedWidget accelerated_widget) { | 1059 gfx::AcceleratedWidget accelerated_widget) { |
1062 return reinterpret_cast<RootWindowHost*>( | 1060 return reinterpret_cast<RootWindowHost*>( |
1063 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); | 1061 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); |
1064 } | 1062 } |
1065 | 1063 |
1066 // static | 1064 // static |
1067 gfx::Size RootWindowHost::GetNativeScreenSize() { | 1065 gfx::Size RootWindowHost::GetNativeScreenSize() { |
1068 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 1066 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
1069 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 1067 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
1070 } | 1068 } |
1071 | 1069 |
1072 } // namespace aura | 1070 } // namespace aura |
OLD | NEW |