| 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 <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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 using std::min; | 54 using std::min; |
| 55 | 55 |
| 56 namespace aura { | 56 namespace aura { |
| 57 | 57 |
| 58 namespace { | 58 namespace { |
| 59 | 59 |
| 60 // Standard Linux mouse buttons for going back and forward. | 60 // Standard Linux mouse buttons for going back and forward. |
| 61 const int kBackMouseButton = 8; | 61 const int kBackMouseButton = 8; |
| 62 const int kForwardMouseButton = 9; | 62 const int kForwardMouseButton = 9; |
| 63 | 63 |
| 64 // These are the same values that are used to calibrate touch events in | |
| 65 // |CalibrateTouchCoordinates| (in ui/base/x/events_x.cc). | |
| 66 // TODO(sad|skuhne): Remove the duplication of values (http://crbug.com/147605) | |
| 67 const int kXRootWindowPaddingLeft = 40; | |
| 68 const int kXRootWindowPaddingRight = 40; | |
| 69 const int kXRootWindowPaddingBottom = 30; | |
| 70 const int kXRootWindowPaddingTop = 0; | |
| 71 | |
| 72 const char* kAtomsToCache[] = { | 64 const char* kAtomsToCache[] = { |
| 73 "WM_DELETE_WINDOW", | 65 "WM_DELETE_WINDOW", |
| 74 "_NET_WM_PING", | 66 "_NET_WM_PING", |
| 75 "_NET_WM_PID", | 67 "_NET_WM_PID", |
| 76 "WM_S0", | 68 "WM_S0", |
| 77 #if defined(OS_CHROMEOS) | 69 #if defined(OS_CHROMEOS) |
| 78 "Tap Paused", // Defined in the gestures library. | 70 "Tap Paused", // Defined in the gestures library. |
| 79 #endif | 71 #endif |
| 80 NULL | 72 NULL |
| 81 }; | 73 }; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 240 |
| 249 gfx::Point recent_locations_[kMaxEvents]; | 241 gfx::Point recent_locations_[kMaxEvents]; |
| 250 size_t insert_index_; | 242 size_t insert_index_; |
| 251 | 243 |
| 252 DISALLOW_COPY_AND_ASSIGN(MouseMoveFilter); | 244 DISALLOW_COPY_AND_ASSIGN(MouseMoveFilter); |
| 253 }; | 245 }; |
| 254 | 246 |
| 255 //////////////////////////////////////////////////////////////////////////////// | 247 //////////////////////////////////////////////////////////////////////////////// |
| 256 // RootWindowHostLinux | 248 // RootWindowHostLinux |
| 257 | 249 |
| 258 RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds) | 250 RootWindowHostLinux::RootWindowHostLinux(const gfx::Rect& bounds, |
| 251 bool is_internal_display) |
| 259 : delegate_(NULL), | 252 : delegate_(NULL), |
| 260 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 253 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), |
| 261 xwindow_(0), | 254 xwindow_(0), |
| 262 x_root_window_(DefaultRootWindow(xdisplay_)), | 255 x_root_window_(DefaultRootWindow(xdisplay_)), |
| 263 current_cursor_(ui::kCursorNull), | 256 current_cursor_(ui::kCursorNull), |
| 264 window_mapped_(false), | 257 window_mapped_(false), |
| 265 bounds_(bounds), | 258 bounds_(bounds), |
| 266 focus_when_shown_(false), | 259 focus_when_shown_(false), |
| 267 pointer_barriers_(NULL), | 260 pointer_barriers_(NULL), |
| 268 touch_calibrate_(new internal::TouchEventCalibrate), | 261 touch_calibrate_(new internal::TouchEventCalibrate), |
| 269 mouse_move_filter_(new MouseMoveFilter), | 262 mouse_move_filter_(new MouseMoveFilter), |
| 270 atom_cache_(xdisplay_, kAtomsToCache) { | 263 atom_cache_(xdisplay_, kAtomsToCache), |
| 264 is_internal_display_(is_internal_display) { |
| 271 XSetWindowAttributes swa; | 265 XSetWindowAttributes swa; |
| 272 memset(&swa, 0, sizeof(swa)); | 266 memset(&swa, 0, sizeof(swa)); |
| 273 swa.background_pixmap = None; | 267 swa.background_pixmap = None; |
| 274 xwindow_ = XCreateWindow( | 268 xwindow_ = XCreateWindow( |
| 275 xdisplay_, x_root_window_, | 269 xdisplay_, x_root_window_, |
| 276 bounds.x(), bounds.y(), bounds.width(), bounds.height(), | 270 bounds.x(), bounds.y(), bounds.width(), bounds.height(), |
| 277 0, // border width | 271 0, // border width |
| 278 CopyFromParent, // depth | 272 CopyFromParent, // depth |
| 279 InputOutput, | 273 InputOutput, |
| 280 CopyFromParent, // visual | 274 CopyFromParent, // visual |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 if (num_coalesced > 0) | 861 if (num_coalesced > 0) |
| 868 xev = &last_event; | 862 xev = &last_event; |
| 869 // fallthrough | 863 // fallthrough |
| 870 case ui::ET_TOUCH_PRESSED: | 864 case ui::ET_TOUCH_PRESSED: |
| 871 case ui::ET_TOUCH_CANCELLED: | 865 case ui::ET_TOUCH_CANCELLED: |
| 872 case ui::ET_TOUCH_RELEASED: { | 866 case ui::ET_TOUCH_RELEASED: { |
| 873 ui::TouchEvent touchev(xev); | 867 ui::TouchEvent touchev(xev); |
| 874 #if defined(OS_CHROMEOS) | 868 #if defined(OS_CHROMEOS) |
| 875 if (base::chromeos::IsRunningOnChromeOS()) { | 869 if (base::chromeos::IsRunningOnChromeOS()) { |
| 876 if (!bounds_.Contains(touchev.location())) { | 870 if (!bounds_.Contains(touchev.location())) { |
| 877 // This might still be in the bezel region. | 871 break; |
| 878 gfx::Rect expanded(bounds_); | |
| 879 expanded.Inset(-kXRootWindowPaddingLeft, | |
| 880 -kXRootWindowPaddingTop, | |
| 881 -kXRootWindowPaddingRight, | |
| 882 -kXRootWindowPaddingBottom); | |
| 883 if (!expanded.Contains(touchev.location())) | |
| 884 break; | |
| 885 } | 872 } |
| 886 // X maps the touch-surface to the size of the X root-window. | 873 // X maps the touch-surface to the size of the X root-window. |
| 887 // In multi-monitor setup, Coordinate Transformation Matrix | 874 // In multi-monitor setup, Coordinate Transformation Matrix |
| 888 // repositions the touch-surface onto part of X root-window | 875 // repositions the touch-surface onto part of X root-window |
| 889 // containing aura root-window corresponding to the touchscreen. | 876 // containing aura root-window corresponding to the touchscreen. |
| 890 // However, if aura root-window has non-zero origin, | 877 // However, if aura root-window has non-zero origin, |
| 891 // we need to relocate the event into aura root-window coordinates. | 878 // we need to relocate the event into aura root-window coordinates. |
| 892 touchev.Relocate(bounds_.origin()); | 879 touchev.Relocate(bounds_.origin()); |
| 880 #if defined(USE_XI2_MT) |
| 881 if (is_internal_display_) |
| 882 touchev.Calibrate(bounds_); |
| 883 #endif |
| 893 } | 884 } |
| 894 #endif // defined(OS_CHROMEOS) | 885 #endif // defined(OS_CHROMEOS) |
| 895 delegate_->OnHostTouchEvent(&touchev); | 886 delegate_->OnHostTouchEvent(&touchev); |
| 896 break; | 887 break; |
| 897 } | 888 } |
| 898 case ui::ET_MOUSE_MOVED: | 889 case ui::ET_MOUSE_MOVED: |
| 899 case ui::ET_MOUSE_DRAGGED: | 890 case ui::ET_MOUSE_DRAGGED: |
| 900 case ui::ET_MOUSE_PRESSED: | 891 case ui::ET_MOUSE_PRESSED: |
| 901 case ui::ET_MOUSE_RELEASED: | 892 case ui::ET_MOUSE_RELEASED: |
| 902 case ui::ET_MOUSE_ENTERED: | 893 case ui::ET_MOUSE_ENTERED: |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 snapshot_bounds.width(), snapshot_bounds.height(), | 987 snapshot_bounds.width(), snapshot_bounds.height(), |
| 997 AllPlanes, ZPixmap))); | 988 AllPlanes, ZPixmap))); |
| 998 if (!image->get()) { | 989 if (!image->get()) { |
| 999 LOG(ERROR) << "XGetImage failed"; | 990 LOG(ERROR) << "XGetImage failed"; |
| 1000 image.reset(); | 991 image.reset(); |
| 1001 } | 992 } |
| 1002 return image.Pass(); | 993 return image.Pass(); |
| 1003 } | 994 } |
| 1004 | 995 |
| 1005 // static | 996 // static |
| 1006 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { | 997 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds, |
| 1007 return new RootWindowHostLinux(bounds); | 998 bool is_internal_display) { |
| 999 return new RootWindowHostLinux(bounds, is_internal_display); |
| 1008 } | 1000 } |
| 1009 | 1001 |
| 1010 // static | 1002 // static |
| 1011 gfx::Size RootWindowHost::GetNativeScreenSize() { | 1003 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 1012 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 1004 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
| 1013 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 1005 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 1014 } | 1006 } |
| 1015 | 1007 |
| 1016 } // namespace aura | 1008 } // namespace aura |
| OLD | NEW |