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/base/touch/touch_factory.h" | 5 #include "ui/base/touch/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/XInput.h> |
9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
10 #include <X11/extensions/XIproto.h> | 10 #include <X11/extensions/XIproto.h> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #endif | 46 #endif |
47 | 47 |
48 Display* display = GetXDisplay(); | 48 Display* display = GetXDisplay(); |
49 | 49 |
50 invisible_cursor_ = CreateInvisibleCursor(); | 50 invisible_cursor_ = CreateInvisibleCursor(); |
51 arrow_cursor_ = XCreateFontCursor(display, XC_arrow); | 51 arrow_cursor_ = XCreateFontCursor(display, XC_arrow); |
52 | 52 |
53 SetCursorVisible(false, false); | 53 SetCursorVisible(false, false); |
54 UpdateDeviceList(display); | 54 UpdateDeviceList(display); |
55 | 55 |
56 // Make sure the list of devices is kept up-to-date by listening for | |
57 // XI_HierarchyChanged event on the root window. | |
58 unsigned char mask[XIMaskLen(XI_LASTEVENT)]; | |
59 memset(mask, 0, sizeof(mask)); | |
60 | |
61 XISetMask(mask, XI_HierarchyChanged); | |
62 | |
63 XIEventMask evmask; | |
64 evmask.deviceid = XIAllDevices; | |
65 evmask.mask_len = sizeof(mask); | |
66 evmask.mask = mask; | |
67 XISelectEvents(display, ui::GetX11RootWindow(), &evmask, 1); | |
68 | |
69 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 56 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
70 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && | 57 touch_events_disabled_ = cmdline->HasSwitch(switches::kTouchEvents) && |
71 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == | 58 cmdline->GetSwitchValueASCII(switches::kTouchEvents) == |
72 switches::kTouchEventsDisabled; | 59 switches::kTouchEventsDisabled; |
73 } | 60 } |
74 | 61 |
75 TouchFactory::~TouchFactory() { | 62 TouchFactory::~TouchFactory() { |
76 #if defined(USE_AURA) | 63 #if defined(USE_AURA) |
77 if (!base::MessagePumpForUI::HasXInput2()) | 64 if (!base::MessagePumpForUI::HasXInput2()) |
78 return; | 65 return; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 XDefineCursor(display, window, arrow_cursor_); | 382 XDefineCursor(display, window, arrow_cursor_); |
396 else if (touch_device_available_) | 383 else if (touch_device_available_) |
397 XDefineCursor(display, window, invisible_cursor_); | 384 XDefineCursor(display, window, invisible_cursor_); |
398 } | 385 } |
399 | 386 |
400 bool TouchFactory::IsTouchDevicePresent() { | 387 bool TouchFactory::IsTouchDevicePresent() { |
401 return !touch_events_disabled_ && touch_device_available_; | 388 return !touch_events_disabled_ && touch_device_available_; |
402 } | 389 } |
403 | 390 |
404 } // namespace ui | 391 } // namespace ui |
OLD | NEW |