OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /* | 5 /* |
6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
7 * Copyright (C) 2006-2009 Google Inc. | 7 * Copyright (C) 2006-2009 Google Inc. |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 default: | 314 default: |
315 NOTIMPLEMENTED(); | 315 NOTIMPLEMENTED(); |
316 } | 316 } |
317 | 317 |
318 blink::WebMouseEvent result(event_type, ModifiersFromEvent(event), | 318 blink::WebMouseEvent result(event_type, ModifiersFromEvent(event), |
319 [event timestamp]); | 319 [event timestamp]); |
320 result.clickCount = click_count; | 320 result.clickCount = click_count; |
321 result.button = button; | 321 result.button = button; |
322 SetWebEventLocationFromEventInView(&result, event, view); | 322 SetWebEventLocationFromEventInView(&result, event, view); |
323 | 323 |
324 // For NSMouseExited and NSMouseEntered events, they do not have a subtype. | 324 result.pointerType = pointerType; |
325 // We decide their pointer types by checking if we recevied a | 325 if ((type == NSMouseExited || type == NSMouseEntered) || |
326 // NSTabletProximity event. | 326 ([event subtype] != NSTabletPointEventSubtype && |
327 if (type == NSMouseExited || type == NSMouseEntered) { | 327 [event subtype] != NSTabletProximityEventSubtype)) { |
328 result.pointerType = pointerType; | |
329 return result; | |
330 } | |
331 | |
332 // For other mouse events and touchpad events, the pointer type is mouse. | |
333 // For all other tablet events, the pointer type will be just pen. | |
334 NSEventSubtype subtype = [event subtype]; | |
335 if (subtype != NSTabletPointEventSubtype && | |
336 subtype != NSTabletProximityEventSubtype) { | |
337 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; | |
338 return result; | 328 return result; |
339 } | 329 } |
340 | 330 |
341 // Set stylus properties for events with a subtype of | 331 // Set stylus properties for events with a subtype of |
342 // NSTabletPointEventSubtype. | 332 // NSTabletPointEventSubtype. |
343 result.pointerType = blink::WebPointerProperties::PointerType::Pen; | 333 NSEventSubtype subtype = [event subtype]; |
344 result.id = [event deviceID]; | 334 result.id = [event deviceID]; |
345 if (subtype == NSTabletPointEventSubtype) { | 335 if (subtype == NSTabletPointEventSubtype) { |
346 result.force = [event pressure]; | 336 result.force = [event pressure]; |
347 NSPoint tilt = [event tilt]; | 337 NSPoint tilt = [event tilt]; |
348 result.tiltX = lround(tilt.x * 90); | 338 result.tiltX = lround(tilt.x * 90); |
349 result.tiltY = lround(tilt.y * 90); | 339 result.tiltY = lround(tilt.y * 90); |
350 result.tangentialPressure = [event tangentialPressure]; | 340 result.tangentialPressure = [event tangentialPressure]; |
351 // NSEvent spec doesn't specify the range of rotation, we make sure that | 341 // NSEvent spec doesn't specify the range of rotation, we make sure that |
352 // this value is in the range of [0,359]. | 342 // this value is in the range of [0,359]. |
353 int twist = (int)[event rotation]; | 343 int twist = (int)[event rotation]; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 // to specify them when the gesture is differentiated. | 539 // to specify them when the gesture is differentiated. |
550 break; | 540 break; |
551 default: | 541 default: |
552 NOTIMPLEMENTED(); | 542 NOTIMPLEMENTED(); |
553 } | 543 } |
554 | 544 |
555 return result; | 545 return result; |
556 } | 546 } |
557 | 547 |
558 } // namespace content | 548 } // namespace content |
OLD | NEW |