Chromium Code Reviews| 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/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/extensions/Xfixes.h> | 8 #include <X11/extensions/Xfixes.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/extensions/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
| 11 #include <X11/Xatom.h> | 11 #include <X11/Xatom.h> |
| 12 #include <X11/Xcursor/Xcursor.h> | 12 #include <X11/Xcursor/Xcursor.h> |
| 13 #include <X11/Xlib.h> | 13 #include <X11/Xlib.h> |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 | 15 |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/message_loop.h" | |
| 17 #include "base/message_pump_aurax11.h" | 18 #include "base/message_pump_aurax11.h" |
| 18 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
| 19 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
| 20 #include "ui/aura/client/capture_client.h" | 21 #include "ui/aura/client/capture_client.h" |
| 21 #include "ui/aura/client/cursor_client.h" | 22 #include "ui/aura/client/cursor_client.h" |
| 22 #include "ui/aura/client/screen_position_client.h" | 23 #include "ui/aura/client/screen_position_client.h" |
| 23 #include "ui/aura/client/user_action_client.h" | 24 #include "ui/aura/client/user_action_client.h" |
| 24 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
| 25 #include "ui/aura/root_window.h" | 26 #include "ui/aura/root_window.h" |
| 26 #include "ui/base/cursor/cursor.h" | 27 #include "ui/base/cursor/cursor.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 case ui::VKEY_OEM_MINUS: | 274 case ui::VKEY_OEM_MINUS: |
| 274 case ui::VKEY_OEM_PERIOD: | 275 case ui::VKEY_OEM_PERIOD: |
| 275 return true; | 276 return true; |
| 276 default: | 277 default: |
| 277 return false; | 278 return false; |
| 278 } | 279 } |
| 279 } | 280 } |
| 280 | 281 |
| 281 } // namespace | 282 } // namespace |
| 282 | 283 |
| 284 namespace internal { | |
| 285 | |
| 286 // A very lightweight message-pump observer that routes all the touch events to | |
| 287 // the X root window so that they can be calibrated properly. | |
| 288 class TouchEventCalibrate : public base::MessagePumpObserver { | |
| 289 public: | |
| 290 TouchEventCalibrate() { | |
| 291 MessageLoopForUI::current()->AddObserver(this); | |
| 292 } | |
| 293 | |
| 294 virtual ~TouchEventCalibrate() { | |
| 295 MessageLoopForUI::current()->RemoveObserver(this); | |
| 296 } | |
| 297 | |
| 298 private: | |
| 299 // Overridden from base::MessagePumpObserver: | |
| 300 virtual base::EventStatus WillProcessEvent( | |
| 301 const base::NativeEvent& event) OVERRIDE { | |
| 302 #if defined(USE_XI2_MT) | |
| 303 if (event->type == GenericEvent && | |
| 304 (event->xgeneric.evtype == XI_TouchBegin || | |
| 305 event->xgeneric.evtype == XI_TouchUpdate || | |
| 306 event->xgeneric.evtype == XI_TouchEnd)) { | |
| 307 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data); | |
| 308 xievent->event = xievent->root; | |
| 309 xievent->event_x = xievent->root_x; | |
| 310 xievent->event_y = xievent->root_y; | |
| 311 } | |
| 312 #endif | |
| 313 return base::EVENT_CONTINUE; | |
| 314 } | |
| 315 | |
| 316 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { | |
| 317 } | |
| 318 | |
| 319 DISALLOW_COPY_AND_ASSIGN(TouchEventCalibrate); | |
| 320 }; | |
| 321 | |
| 322 } | |
|
Daniel Erat
2012/09/14 00:28:56
nit: // namespace internal
sadrul
2012/09/14 01:43:59
Done.
| |
| 323 | |
| 283 RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, | 324 RootWindowHostLinux::RootWindowHostLinux(RootWindowHostDelegate* delegate, |
| 284 const gfx::Rect& bounds) | 325 const gfx::Rect& bounds) |
| 285 : delegate_(delegate), | 326 : delegate_(delegate), |
| 286 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 327 xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), |
| 287 xwindow_(0), | 328 xwindow_(0), |
| 288 x_root_window_(DefaultRootWindow(xdisplay_)), | 329 x_root_window_(DefaultRootWindow(xdisplay_)), |
| 289 current_cursor_(ui::kCursorNull), | 330 current_cursor_(ui::kCursorNull), |
| 290 window_mapped_(false), | 331 window_mapped_(false), |
| 291 cursor_shown_(true), | 332 cursor_shown_(true), |
| 292 bounds_(bounds), | 333 bounds_(bounds), |
| 293 focus_when_shown_(false), | 334 focus_when_shown_(false), |
| 294 pointer_barriers_(NULL), | 335 pointer_barriers_(NULL), |
| 336 touch_calibrate_(new internal::TouchEventCalibrate), | |
| 295 atom_cache_(xdisplay_, kAtomsToCache) { | 337 atom_cache_(xdisplay_, kAtomsToCache) { |
| 296 XSetWindowAttributes swa; | 338 XSetWindowAttributes swa; |
| 297 memset(&swa, 0, sizeof(swa)); | 339 memset(&swa, 0, sizeof(swa)); |
| 298 swa.background_pixmap = None; | 340 swa.background_pixmap = None; |
| 299 xwindow_ = XCreateWindow( | 341 xwindow_ = XCreateWindow( |
| 300 xdisplay_, x_root_window_, | 342 xdisplay_, x_root_window_, |
| 301 bounds.x(), bounds.y(), bounds.width(), bounds.height(), | 343 bounds.x(), bounds.y(), bounds.width(), bounds.height(), |
| 302 0, // border width | 344 0, // border width |
| 303 CopyFromParent, // depth | 345 CopyFromParent, // depth |
| 304 InputOutput, | 346 InputOutput, |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 920 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); | 962 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); |
| 921 } | 963 } |
| 922 | 964 |
| 923 // static | 965 // static |
| 924 gfx::Size RootWindowHost::GetNativeScreenSize() { | 966 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 925 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 967 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
| 926 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 968 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 927 } | 969 } |
| 928 | 970 |
| 929 } // namespace aura | 971 } // namespace aura |
| OLD | NEW |