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

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: Fix non-linux platforms. 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
« ui/events/x/events_x.cc ('K') | « 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (!id_generator_.HasGeneratedIDFor(tracking_id)) 243 if (!id_generator_.HasGeneratedIDFor(tracking_id))
244 return false; 244 return false;
245 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id)); 245 *slot = static_cast<int>(id_generator_.GetGeneratedID(tracking_id));
246 return true; 246 return true;
247 } 247 }
248 248
249 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) { 249 int TouchFactory::GetSlotForTrackingID(uint32 tracking_id) {
250 return id_generator_.GetGeneratedID(tracking_id); 250 return id_generator_.GetGeneratedID(tracking_id);
251 } 251 }
252 252
253 void TouchFactory::AcquireSlotForTrackingID(uint32 tracking_id) {
254 tracking_id_refcounts_[tracking_id]++;
255 }
256
253 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) { 257 void TouchFactory::ReleaseSlotForTrackingID(uint32 tracking_id) {
254 id_generator_.ReleaseNumber(tracking_id); 258 tracking_id_refcounts_[tracking_id]--;
259 if (tracking_id_refcounts_[tracking_id] == 0)
260 id_generator_.ReleaseNumber(tracking_id);
255 } 261 }
256 262
257 bool TouchFactory::IsTouchDevicePresent() { 263 bool TouchFactory::IsTouchDevicePresent() {
258 return !touch_events_disabled_ && touch_device_available_; 264 return !touch_events_disabled_ && touch_device_available_;
259 } 265 }
260 266
261 int TouchFactory::GetMaxTouchPoints() const { 267 int TouchFactory::GetMaxTouchPoints() const {
262 return max_touch_points_; 268 return max_touch_points_;
263 } 269 }
264 270
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 if (ptr[0] || ptr[1]) 324 if (ptr[0] || ptr[1])
319 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1])); 325 touchscreen_ids_.insert(std::make_pair(ptr[0], ptr[1]));
320 } 326 }
321 XFree(prop_return); 327 XFree(prop_return);
322 } 328 }
323 329
324 XCloseDevice(display, device); 330 XCloseDevice(display, device);
325 } 331 }
326 332
327 } // namespace ui 333 } // namespace ui
OLDNEW
« ui/events/x/events_x.cc ('K') | « 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