OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2006-2009 Google Inc. | 3 * Copyright (C) 2006-2009 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]
) : 0; | 359 code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]
) : 0; |
360 if (code) | 360 if (code) |
361 return code; | 361 return code; |
362 } | 362 } |
363 | 363 |
364 // Map Mac virtual key code directly to Windows one for any keys not handled
above. | 364 // Map Mac virtual key code directly to Windows one for any keys not handled
above. |
365 // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboar
d ('A') and on Russian keyboard (CYRILLIC LETTER EF). | 365 // E.g. the key next to Caps Lock has the same Event.keyCode on U.S. keyboar
d ('A') and on Russian keyboard (CYRILLIC LETTER EF). |
366 return windowsKeyCodeForKeyCode([event keyCode]); | 366 return windowsKeyCodeForKeyCode([event keyCode]); |
367 } | 367 } |
368 | 368 |
369 static WebInputEvent::Type gestureEventTypeForEvent(NSEvent *event) | |
370 { | |
371 switch ([event type]) { | |
372 case NSEventTypeBeginGesture: | |
373 return WebInputEvent::GestureScrollBegin; | |
374 case NSEventTypeEndGesture: | |
375 return WebInputEvent::GestureScrollEnd; | |
376 default: | |
377 ASSERT_NOT_REACHED(); | |
378 return WebInputEvent::GestureScrollEnd; | |
379 } | |
380 } | |
381 | |
382 static inline NSString* textFromEvent(NSEvent* event) | 369 static inline NSString* textFromEvent(NSEvent* event) |
383 { | 370 { |
384 if ([event type] == NSFlagsChanged) | 371 if ([event type] == NSFlagsChanged) |
385 return @""; | 372 return @""; |
386 return [event characters]; | 373 return [event characters]; |
387 } | 374 } |
388 | 375 |
389 static inline NSString* unmodifiedTextFromEvent(NSEvent* event) | 376 static inline NSString* unmodifiedTextFromEvent(NSEvent* event) |
390 { | 377 { |
391 if ([event type] == NSFlagsChanged) | 378 if ([event type] == NSFlagsChanged) |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 | 1118 |
1132 // Use a temporary WebMouseEvent to get the location. | 1119 // Use a temporary WebMouseEvent to get the location. |
1133 WebMouseEvent temp; | 1120 WebMouseEvent temp; |
1134 | 1121 |
1135 setWebEventLocationFromEventInView(&temp, event, view); | 1122 setWebEventLocationFromEventInView(&temp, event, view); |
1136 result.x = temp.x; | 1123 result.x = temp.x; |
1137 result.y = temp.y; | 1124 result.y = temp.y; |
1138 result.globalX = temp.globalX; | 1125 result.globalX = temp.globalX; |
1139 result.globalY = temp.globalY; | 1126 result.globalY = temp.globalY; |
1140 | 1127 |
1141 result.type = gestureEventTypeForEvent(event); | |
1142 result.modifiers = modifiersFromEvent(event); | 1128 result.modifiers = modifiersFromEvent(event); |
1143 result.timeStampSeconds = [event timestamp]; | 1129 result.timeStampSeconds = [event timestamp]; |
1144 | 1130 |
| 1131 // MacOS X gestures are used only for pinch support. |
| 1132 result.sourceDevice = WebGestureEvent::Touchpad; |
| 1133 switch ([event type]) { |
| 1134 case NSEventTypeMagnify: |
| 1135 result.type = WebInputEvent::GesturePinchUpdate; |
| 1136 result.data.pinchUpdate.scale = [event magnification]; |
| 1137 break; |
| 1138 default: |
| 1139 ASSERT_NOT_REACHED(); |
| 1140 result.type = WebInputEvent::Undefined; |
| 1141 } |
| 1142 |
1145 return result; | 1143 return result; |
1146 } | 1144 } |
1147 | 1145 |
1148 } // namespace blink | 1146 } // namespace blink |
OLD | NEW |