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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_mac.mm

Issue 2739773004: Make stylus's eraser button work on Mac (Closed)
Patch Set: Created 3 years, 9 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 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
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 result.pointerType = pointerType;
324 // For NSMouseExited and NSMouseEntered events, they do not have a subtype. 325 // For NSMouseExited and NSMouseEntered events, they do not have a subtype.
mustaq 2017/03/13 14:41:38 This comment and the comment in the next block no
325 // We decide their pointer types by checking if we recevied a 326 // We decide their pointer types by checking if we recevied a
326 // NSTabletProximity event. 327 // NSTabletProximity event.
327 if (type == NSMouseExited || type == NSMouseEntered) { 328 if (type == NSMouseExited || type == NSMouseEntered) {
328 result.pointerType = pointerType;
329 return result; 329 return result;
330 } 330 }
331 331
332 // For other mouse events and touchpad events, the pointer type is mouse. 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. 333 // For all other tablet events, the pointer type will be just pen.
334 NSEventSubtype subtype = [event subtype]; 334 NSEventSubtype subtype = [event subtype];
335 if (subtype != NSTabletPointEventSubtype && 335 if (subtype != NSTabletPointEventSubtype &&
336 subtype != NSTabletProximityEventSubtype) { 336 subtype != NSTabletProximityEventSubtype) {
337 result.pointerType = blink::WebPointerProperties::PointerType::Mouse;
338 return result; 337 return result;
339 } 338 }
340 339
341 // Set stylus properties for events with a subtype of 340 // Set stylus properties for events with a subtype of
342 // NSTabletPointEventSubtype. 341 // NSTabletPointEventSubtype.
343 result.pointerType = blink::WebPointerProperties::PointerType::Pen;
344 result.id = [event deviceID]; 342 result.id = [event deviceID];
345 if (subtype == NSTabletPointEventSubtype) { 343 if (subtype == NSTabletPointEventSubtype) {
346 result.force = [event pressure]; 344 result.force = [event pressure];
347 NSPoint tilt = [event tilt]; 345 NSPoint tilt = [event tilt];
348 result.tiltX = lround(tilt.x * 90); 346 result.tiltX = lround(tilt.x * 90);
349 result.tiltY = lround(tilt.y * 90); 347 result.tiltY = lround(tilt.y * 90);
350 result.tangentialPressure = [event tangentialPressure]; 348 result.tangentialPressure = [event tangentialPressure];
351 // NSEvent spec doesn't specify the range of rotation, we make sure that 349 // NSEvent spec doesn't specify the range of rotation, we make sure that
352 // this value is in the range of [0,359]. 350 // this value is in the range of [0,359].
353 int twist = (int)[event rotation]; 351 int twist = (int)[event rotation];
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // to specify them when the gesture is differentiated. 547 // to specify them when the gesture is differentiated.
550 break; 548 break;
551 default: 549 default:
552 NOTIMPLEMENTED(); 550 NOTIMPLEMENTED();
553 } 551 }
554 552
555 return result; 553 return result;
556 } 554 }
557 555
558 } // namespace content 556 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698