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

Side by Side Diff: ui/events/x/touch_factory_x11.cc

Issue 400213002: Refcount touch tracking ids to prevent freeing them too early. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ui::TouchEvents in test. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/events/x/touch_factory_x11.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/events/x/touch_factory_x11.h" 5 #include "ui/events/x/touch_factory_x11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/cursorfont.h> 8 #include <X11/cursorfont.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 #include <X11/extensions/XInput2.h> 10 #include <X11/extensions/XInput2.h>
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (!id_generator_.HasGeneratedIDFor(tracking_id)) 247 if (!id_generator_.HasGeneratedIDFor(tracking_id))
248 return false; 248 return false;
249 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id)); 249 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id));
250 return true; 250 return true;
251 } 251 }
252 252
253 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) { 253 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) {
254 return id_generator_.GetGeneratedID(tracking_id); 254 return id_generator_.GetGeneratedID(tracking_id);
255 } 255 }
256 256
257 void TouchFactory::AcquireSlotForTrackingID(uint32 tracking_id) {
258 tracking_id_refcounts_[tracking_id]++;
259 }
260
257 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) { 261 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) {
258 id_generator_.ReleaseNumber(tracking_id); 262 tracking_id_refcounts_[tracking_id]--;
263 if (tracking_id_refcounts_[tracking_id] == 0)
264 id_generator_.ReleaseNumber(tracking_id);
259 } 265 }
260 266
261 bool TouchFactory::IsTouchDevicePresent() { 267 bool TouchFactory::IsTouchDevicePresent() {
262 return !touch_events_disabled_ && touch_device_available_; 268 return !touch_events_disabled_ && touch_device_available_;
263 } 269 }
264 270
265 int TouchFactory::GetMaxTouchPoints() const { 271 int TouchFactory::GetMaxTouchPoints() const {
266 return max_touch_points_; 272 return max_touch_points_;
267 } 273 }
268 274
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 if (ptr[0] || ptr[1]) 328 if (ptr[0] || ptr[1])
323 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); 329 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
324 } 330 }
325 XFree(prop_return); 331 XFree(prop_return);
326 } 332 }
327 333
328 XCloseDevice(display, device); 334 XCloseDevice(display, device);
329 } 335 }
330 336
331 } // namespace ui 337 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/touch_factory_x11.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698