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_x11.h" | 5 #include "ui/aura/root_window_host_x11.h" |
6 | 6 |
7 #include <strings.h> | 7 #include <strings.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/Xfixes.h> | 9 #include <X11/extensions/Xfixes.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 gfx::Point recent_locations_[kMaxEvents]; | 313 gfx::Point recent_locations_[kMaxEvents]; |
314 size_t insert_index_; | 314 size_t insert_index_; |
315 | 315 |
316 DISALLOW_COPY_AND_ASSIGN(MouseMoveFilter); | 316 DISALLOW_COPY_AND_ASSIGN(MouseMoveFilter); |
317 }; | 317 }; |
318 | 318 |
319 //////////////////////////////////////////////////////////////////////////////// | 319 //////////////////////////////////////////////////////////////////////////////// |
320 // RootWindowHostX11 | 320 // RootWindowHostX11 |
321 | 321 |
322 RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds) | 322 RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds) |
323 : delegate_(NULL), | 323 : xdisplay_(gfx::GetXDisplay()), |
324 xdisplay_(gfx::GetXDisplay()), | |
325 xwindow_(0), | 324 xwindow_(0), |
326 x_root_window_(DefaultRootWindow(xdisplay_)), | 325 x_root_window_(DefaultRootWindow(xdisplay_)), |
327 current_cursor_(ui::kCursorNull), | 326 current_cursor_(ui::kCursorNull), |
328 window_mapped_(false), | 327 window_mapped_(false), |
329 bounds_(bounds), | 328 bounds_(bounds), |
330 is_internal_display_(false), | 329 is_internal_display_(false), |
331 focus_when_shown_(false), | 330 focus_when_shown_(false), |
332 touch_calibrate_(new internal::TouchEventCalibrate), | 331 touch_calibrate_(new internal::TouchEventCalibrate), |
333 mouse_move_filter_(new MouseMoveFilter), | 332 mouse_move_filter_(new MouseMoveFilter), |
334 atom_cache_(xdisplay_, kAtomsToCache), | 333 atom_cache_(xdisplay_, kAtomsToCache), |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 } | 576 } |
578 | 577 |
579 ui::MouseEvent mouseev(xev); | 578 ui::MouseEvent mouseev(xev); |
580 TranslateAndDispatchMouseEvent(&mouseev); | 579 TranslateAndDispatchMouseEvent(&mouseev); |
581 break; | 580 break; |
582 } | 581 } |
583 } | 582 } |
584 return true; | 583 return true; |
585 } | 584 } |
586 | 585 |
587 void RootWindowHostX11::SetDelegate(RootWindowHostDelegate* delegate) { | |
588 delegate_ = delegate; | |
589 } | |
590 | |
591 RootWindow* RootWindowHostX11::GetRootWindow() { | 586 RootWindow* RootWindowHostX11::GetRootWindow() { |
592 return delegate_->AsRootWindow(); | 587 return delegate_->AsRootWindow(); |
593 } | 588 } |
594 | 589 |
595 gfx::AcceleratedWidget RootWindowHostX11::GetAcceleratedWidget() { | 590 gfx::AcceleratedWidget RootWindowHostX11::GetAcceleratedWidget() { |
596 return xwindow_; | 591 return xwindow_; |
597 } | 592 } |
598 | 593 |
599 void RootWindowHostX11::Show() { | 594 void RootWindowHostX11::Show() { |
600 if (!window_mapped_) { | 595 if (!window_mapped_) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 void RootWindowHostX11::OnCursorVisibilityChanged(bool show) { | 778 void RootWindowHostX11::OnCursorVisibilityChanged(bool show) { |
784 SetCrOSTapPaused(!show); | 779 SetCrOSTapPaused(!show); |
785 } | 780 } |
786 | 781 |
787 void RootWindowHostX11::MoveCursorTo(const gfx::Point& location) { | 782 void RootWindowHostX11::MoveCursorTo(const gfx::Point& location) { |
788 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, | 783 XWarpPointer(xdisplay_, None, x_root_window_, 0, 0, 0, 0, |
789 bounds_.x() + location.x(), | 784 bounds_.x() + location.x(), |
790 bounds_.y() + location.y()); | 785 bounds_.y() + location.y()); |
791 } | 786 } |
792 | 787 |
793 void RootWindowHostX11::SetFocusWhenShown(bool focus_when_shown) { | |
794 static const char* k_NET_WM_USER_TIME = "_NET_WM_USER_TIME"; | |
795 focus_when_shown_ = focus_when_shown; | |
796 if (IsWindowManagerPresent() && !focus_when_shown_) { | |
797 ui::SetIntProperty(xwindow_, | |
798 k_NET_WM_USER_TIME, | |
799 k_NET_WM_USER_TIME, | |
800 0); | |
801 } | |
802 } | |
803 | |
804 void RootWindowHostX11::PostNativeEvent( | 788 void RootWindowHostX11::PostNativeEvent( |
805 const base::NativeEvent& native_event) { | 789 const base::NativeEvent& native_event) { |
806 DCHECK(xwindow_); | 790 DCHECK(xwindow_); |
807 DCHECK(xdisplay_); | 791 DCHECK(xdisplay_); |
808 XEvent xevent = *native_event; | 792 XEvent xevent = *native_event; |
809 xevent.xany.display = xdisplay_; | 793 xevent.xany.display = xdisplay_; |
810 xevent.xany.window = xwindow_; | 794 xevent.xany.window = xwindow_; |
811 | 795 |
812 switch (xevent.type) { | 796 switch (xevent.type) { |
813 case EnterNotify: | 797 case EnterNotify: |
814 case LeaveNotify: | 798 case LeaveNotify: |
815 case MotionNotify: | 799 case MotionNotify: |
816 case KeyPress: | 800 case KeyPress: |
817 case KeyRelease: | 801 case KeyRelease: |
818 case ButtonPress: | 802 case ButtonPress: |
819 case ButtonRelease: { | 803 case ButtonRelease: { |
820 // The fields used below are in the same place for all of events | 804 // The fields used below are in the same place for all of events |
821 // above. Using xmotion from XEvent's unions to avoid repeating | 805 // above. Using xmotion from XEvent's unions to avoid repeating |
822 // the code. | 806 // the code. |
823 xevent.xmotion.root = x_root_window_; | 807 xevent.xmotion.root = x_root_window_; |
824 xevent.xmotion.time = CurrentTime; | 808 xevent.xmotion.time = CurrentTime; |
825 | 809 |
826 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); | 810 gfx::Point point(xevent.xmotion.x, xevent.xmotion.y); |
827 delegate_->AsRootWindow()->ConvertPointToNativeScreen(&point); | 811 delegate_->AsRootWindow()->host()->ConvertPointToNativeScreen(&point); |
828 xevent.xmotion.x_root = point.x(); | 812 xevent.xmotion.x_root = point.x(); |
829 xevent.xmotion.y_root = point.y(); | 813 xevent.xmotion.y_root = point.y(); |
830 } | 814 } |
831 default: | 815 default: |
832 break; | 816 break; |
833 } | 817 } |
834 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); | 818 XSendEvent(xdisplay_, xwindow_, False, 0, &xevent); |
835 } | 819 } |
836 | 820 |
837 void RootWindowHostX11::OnDeviceScaleFactorChanged( | 821 void RootWindowHostX11::OnDeviceScaleFactorChanged( |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 } | 1076 } |
1093 | 1077 |
1094 namespace test { | 1078 namespace test { |
1095 | 1079 |
1096 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 1080 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
1097 default_override_redirect = override_redirect; | 1081 default_override_redirect = override_redirect; |
1098 } | 1082 } |
1099 | 1083 |
1100 } // namespace test | 1084 } // namespace test |
1101 } // namespace aura | 1085 } // namespace aura |
OLD | NEW |