| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/touchui/touch_factory.h" | 5 #include "views/touchui/touch_factory.h" |
| 6 | 6 |
| 7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/extensions/XInput.h> |
| 8 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 #include <X11/extensions/XIproto.h> |
| 9 | 11 |
| 10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 12 #include "ui/base/x/x11_util.h" | 14 #include "ui/base/x/x11_util.h" |
| 13 | 15 |
| 14 // The X cursor is hidden if it is idle for kCursorIdleSeconds seconds. | 16 // The X cursor is hidden if it is idle for kCursorIdleSeconds seconds. |
| 15 static int kCursorIdleSeconds = 5; | 17 static int kCursorIdleSeconds = 5; |
| 16 | 18 |
| 17 namespace views { | 19 namespace views { |
| 18 | 20 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 29 XColor black; | 31 XColor black; |
| 30 black.red = black.green = black.blue = 0; | 32 black.red = black.green = black.blue = 0; |
| 31 Display* display = ui::GetXDisplay(); | 33 Display* display = ui::GetXDisplay(); |
| 32 Pixmap blank = XCreateBitmapFromData(display, ui::GetX11RootWindow(), | 34 Pixmap blank = XCreateBitmapFromData(display, ui::GetX11RootWindow(), |
| 33 nodata, 8, 8); | 35 nodata, 8, 8); |
| 34 invisible_cursor_ = XCreatePixmapCursor(display, blank, blank, | 36 invisible_cursor_ = XCreatePixmapCursor(display, blank, blank, |
| 35 &black, &black, 0, 0); | 37 &black, &black, 0, 0); |
| 36 arrow_cursor_ = XCreateFontCursor(display, XC_arrow); | 38 arrow_cursor_ = XCreateFontCursor(display, XC_arrow); |
| 37 | 39 |
| 38 SetCursorVisible(false, false); | 40 SetCursorVisible(false, false); |
| 41 |
| 42 // Detect touch devices. |
| 43 // NOTE: The new API for retrieving the list of devices (XIQueryDevice) does |
| 44 // not provide enough information to detect a touch device. As a result, the |
| 45 // old version of query function (XListInputDevices) is used instead. |
| 46 int count = 0; |
| 47 XDeviceInfo* devlist = XListInputDevices(display, &count); |
| 48 for (int i = 0; i < count; i++) { |
| 49 const char* devtype = XGetAtomName(display, devlist[i].type); |
| 50 if (devtype && !strcmp(devtype, XI_TOUCHSCREEN)) { |
| 51 touch_device_lookup_[devlist[i].id] = true; |
| 52 touch_device_list_.push_back(devlist[i].id); |
| 53 } |
| 54 } |
| 55 XFreeDeviceList(devlist); |
| 39 } | 56 } |
| 40 | 57 |
| 41 TouchFactory::~TouchFactory() { | 58 TouchFactory::~TouchFactory() { |
| 42 SetCursorVisible(true, false); | 59 SetCursorVisible(true, false); |
| 43 Display* display = ui::GetXDisplay(); | 60 Display* display = ui::GetXDisplay(); |
| 44 XFreeCursor(display, invisible_cursor_); | 61 XFreeCursor(display, invisible_cursor_); |
| 45 XFreeCursor(display, arrow_cursor_); | 62 XFreeCursor(display, arrow_cursor_); |
| 46 } | 63 } |
| 47 | 64 |
| 48 void TouchFactory::SetTouchDeviceList( | 65 void TouchFactory::SetTouchDeviceList( |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 Window window = DefaultRootWindow(display); | 136 Window window = DefaultRootWindow(display); |
| 120 | 137 |
| 121 if (is_cursor_visible_) { | 138 if (is_cursor_visible_) { |
| 122 XDefineCursor(display, window, arrow_cursor_); | 139 XDefineCursor(display, window, arrow_cursor_); |
| 123 } else { | 140 } else { |
| 124 XDefineCursor(display, window, invisible_cursor_); | 141 XDefineCursor(display, window, invisible_cursor_); |
| 125 } | 142 } |
| 126 } | 143 } |
| 127 | 144 |
| 128 } // namespace views | 145 } // namespace views |
| OLD | NEW |