Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: ui/events/platform/x11/x11_event_source.cc

Issue 508303002: Move touchscreen device caching to DeviceDataManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/events/platform/x11/x11_event_source.h" 5 #include "ui/events/platform/x11/x11_event_source.h"
6 6
7 #include <X11/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 #include <X11/X.h> 8 #include <X11/X.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "ui/events/event_utils.h" 13 #include "ui/events/event_utils.h"
14 #include "ui/events/platform/platform_event_dispatcher.h" 14 #include "ui/events/platform/platform_event_dispatcher.h"
15 #include "ui/events/x/device_data_manager_x11.h" 15 #include "ui/events/x/device_data_manager_x11.h"
16 #include "ui/events/x/hotplug_event_handler_x11.h"
16 #include "ui/gfx/x/x11_types.h" 17 #include "ui/gfx/x/x11_types.h"
17 18
18 namespace ui { 19 namespace ui {
19 20
20 namespace { 21 namespace {
21 22
22 int g_xinput_opcode = -1; 23 int g_xinput_opcode = -1;
23 24
24 bool InitializeXInput2(XDisplay* display) { 25 bool InitializeXInput2(XDisplay* display) {
25 if (!display) 26 if (!display)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return true; 79 return true;
79 } 80 }
80 81
81 } // namespace 82 } // namespace
82 83
83 X11EventSource::X11EventSource(XDisplay* display) 84 X11EventSource::X11EventSource(XDisplay* display)
84 : display_(display), 85 : display_(display),
85 continue_stream_(true) { 86 continue_stream_(true) {
86 CHECK(display_); 87 CHECK(display_);
87 DeviceDataManagerX11::CreateInstance(); 88 DeviceDataManagerX11::CreateInstance();
89 hotplug_event_handler_.reset(
90 new HotplugEventHandlerX11(DeviceDataManager::GetInstance()));
88 InitializeXInput2(display_); 91 InitializeXInput2(display_);
89 InitializeXkb(display_); 92 InitializeXkb(display_);
93
94 // Force the initial device query to have an update list of active devices.
95 hotplug_event_handler_->OnHotplugEvent();
90 } 96 }
91 97
92 X11EventSource::~X11EventSource() { 98 X11EventSource::~X11EventSource() {
93 } 99 }
94 100
95 // static 101 // static
96 X11EventSource* X11EventSource::GetInstance() { 102 X11EventSource* X11EventSource::GetInstance() {
97 return static_cast<X11EventSource*>(PlatformEventSource::GetInstance()); 103 return static_cast<X11EventSource*>(PlatformEventSource::GetInstance());
98 } 104 }
99 105
(...skipping 30 matching lines...) Expand all
130 bool have_cookie = false; 136 bool have_cookie = false;
131 if (xevent->type == GenericEvent && 137 if (xevent->type == GenericEvent &&
132 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) { 138 XGetEventData(xevent->xgeneric.display, &xevent->xcookie)) {
133 have_cookie = true; 139 have_cookie = true;
134 } 140 }
135 141
136 uint32_t action = PlatformEventSource::DispatchEvent(xevent); 142 uint32_t action = PlatformEventSource::DispatchEvent(xevent);
137 if (xevent->type == GenericEvent && 143 if (xevent->type == GenericEvent &&
138 xevent->xgeneric.evtype == XI_HierarchyChanged) { 144 xevent->xgeneric.evtype == XI_HierarchyChanged) {
139 ui::UpdateDeviceList(); 145 ui::UpdateDeviceList();
146 hotplug_event_handler_->OnHotplugEvent();
140 } 147 }
141 148
142 if (have_cookie) 149 if (have_cookie)
143 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); 150 XFreeEventData(xevent->xgeneric.display, &xevent->xcookie);
144 return action; 151 return action;
145 } 152 }
146 153
147 void X11EventSource::StopCurrentEventStream() { 154 void X11EventSource::StopCurrentEventStream() {
148 continue_stream_ = false; 155 continue_stream_ = false;
149 } 156 }
150 157
151 } // namespace ui 158 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698