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

Side by Side Diff: webkit/api/src/mac/WebInputEventFactory.mm

Issue 115330: linux: Adding events to windowless plugins on Linux (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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
OLDNEW
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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 int modifiers = 0; 829 int modifiers = 0;
830 830
831 if ([event modifierFlags] & NSControlKeyMask) 831 if ([event modifierFlags] & NSControlKeyMask)
832 modifiers |= WebInputEvent::ControlKey; 832 modifiers |= WebInputEvent::ControlKey;
833 if ([event modifierFlags] & NSShiftKeyMask) 833 if ([event modifierFlags] & NSShiftKeyMask)
834 modifiers |= WebInputEvent::ShiftKey; 834 modifiers |= WebInputEvent::ShiftKey;
835 if ([event modifierFlags] & NSAlternateKeyMask) 835 if ([event modifierFlags] & NSAlternateKeyMask)
836 modifiers |= WebInputEvent::AltKey; 836 modifiers |= WebInputEvent::AltKey;
837 if ([event modifierFlags] & NSCommandKeyMask) 837 if ([event modifierFlags] & NSCommandKeyMask)
838 modifiers |= WebInputEvent::MetaKey; 838 modifiers |= WebInputEvent::MetaKey;
839 // TODO(port): Set mouse button states
839 840
840 return modifiers; 841 return modifiers;
841 } 842 }
842 843
843 WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event) 844 WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event)
844 { 845 {
845 WebKeyboardEvent result; 846 WebKeyboardEvent result;
846 847
847 result.type = 848 result.type =
848 isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::KeyDown; 849 isKeyUpEvent(event) ? WebInputEvent::KeyUp : WebInputEvent::KeyDown;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 [unmodifiedStr length] < WebKeyboardEvent::textLengthCap) { 893 [unmodifiedStr length] < WebKeyboardEvent::textLengthCap) {
893 [textStr getCharacters:&result.text[0]]; 894 [textStr getCharacters:&result.text[0]];
894 [unmodifiedStr getCharacters:&result.unmodifiedText[0]]; 895 [unmodifiedStr getCharacters:&result.unmodifiedText[0]];
895 } else 896 } else
896 ASSERT_NOT_REACHED(); 897 ASSERT_NOT_REACHED();
897 898
898 [identifierStr getCString:&result.keyIdentifier[0] 899 [identifierStr getCString:&result.keyIdentifier[0]
899 maxLength:sizeof(result.keyIdentifier) 900 maxLength:sizeof(result.keyIdentifier)
900 encoding:NSASCIIStringEncoding]; 901 encoding:NSASCIIStringEncoding];
901 902
903 result.timeStampSeconds = [event timestamp];
904
902 return result; 905 return result;
903 } 906 }
904 907
905 // WebMouseEvent -------------------------------------------------------------- 908 // WebMouseEvent --------------------------------------------------------------
906 909
907 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view) 910 WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view)
908 { 911 {
909 WebMouseEvent result; 912 WebMouseEvent result;
910 913
911 result.clickCount = 0; 914 result.clickCount = 0;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 } 966 }
964 967
965 NSPoint location = [NSEvent mouseLocation]; // global coordinates 968 NSPoint location = [NSEvent mouseLocation]; // global coordinates
966 result.globalX = location.x; 969 result.globalX = location.x;
967 result.globalY = location.y; 970 result.globalY = location.y;
968 971
969 NSPoint windowLocal = [event locationInWindow]; 972 NSPoint windowLocal = [event locationInWindow];
970 location = [view convertPoint:windowLocal fromView:nil]; 973 location = [view convertPoint:windowLocal fromView:nil];
971 result.y = [view frame].size.height - location.y; // flip y 974 result.y = [view frame].size.height - location.y; // flip y
972 result.x = location.x; 975 result.x = location.x;
976 result.windowX = result.x;
977 result.windowY = result.y;
973 978
974 result.modifiers = modifiersFromEvent(event); 979 result.modifiers = modifiersFromEvent(event);
975 980
976 result.timeStampSeconds = [event timestamp]; 981 result.timeStampSeconds = [event timestamp];
977 982
978 return result; 983 return result;
979 } 984 }
980 985
981 // WebMouseWheelEvent --------------------------------------------------------- 986 // WebMouseWheelEvent ---------------------------------------------------------
982 987
983 WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(NSEvent* event, NSView* view) 988 WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(NSEvent* event, NSView* view)
984 { 989 {
985 WebMouseWheelEvent result; 990 WebMouseWheelEvent result;
986 991
987 result.type = WebInputEvent::MouseWheel; 992 result.type = WebInputEvent::MouseWheel;
988 result.button = WebMouseEvent::ButtonNone; 993 result.button = WebMouseEvent::ButtonNone;
989 994
990 result.modifiers = modifiersFromEvent(event); 995 result.modifiers = modifiersFromEvent(event);
991 996
992 // Set coordinates by translating event coordinates from screen to client. 997 // Set coordinates by translating event coordinates from screen to client.
993 NSPoint location = [NSEvent mouseLocation]; // global coordinates 998 NSPoint location = [NSEvent mouseLocation]; // global coordinates
994 result.globalX = location.x; 999 result.globalX = location.x;
995 result.globalY = location.y; 1000 result.globalY = location.y;
996 NSPoint windowLocal = [event locationInWindow]; 1001 NSPoint windowLocal = [event locationInWindow];
997 location = [view convertPoint:windowLocal fromView:nil]; 1002 location = [view convertPoint:windowLocal fromView:nil];
998 result.x = location.x; 1003 result.x = location.x;
999 result.y = [view frame].size.height - location.y; // flip y 1004 result.y = [view frame].size.height - location.y; // flip y
1005 result.windowX = result.x;
1006 result.windowY = result.y;
1000 1007
1001 // Of Mice and Men 1008 // Of Mice and Men
1002 // --------------- 1009 // ---------------
1003 // 1010 //
1004 // There are three types of scroll data available on a scroll wheel CGEvent. 1011 // There are three types of scroll data available on a scroll wheel CGEvent.
1005 // Apple's documentation ([1]) is rather vague in their differences, and not 1012 // Apple's documentation ([1]) is rather vague in their differences, and not
1006 // terribly helpful in deciding which to use. This is what's really going on. 1013 // terribly helpful in deciding which to use. This is what's really going on.
1007 // 1014 //
1008 // First, these events behave very differently depending on whether a standard 1015 // First, these events behave very differently depending on whether a standard
1009 // wheel mouse is used (one that scrolls in discrete units) or a 1016 // wheel mouse is used (one that scrolls in discrete units) or a
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 result.deltaX = 1125 result.deltaX =
1119 CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2); 1126 CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2);
1120 } else { 1127 } else {
1121 // Convert wheel delta amount to a number of pixels to scroll. 1128 // Convert wheel delta amount to a number of pixels to scroll.
1122 static const double scrollbarPixelsPerCocoaTick = 40.0; 1129 static const double scrollbarPixelsPerCocoaTick = 40.0;
1123 1130
1124 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick; 1131 result.deltaX = [event deltaX] * scrollbarPixelsPerCocoaTick;
1125 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick; 1132 result.deltaY = [event deltaY] * scrollbarPixelsPerCocoaTick;
1126 } 1133 }
1127 1134
1135 result.timeStampSeconds = [event timestamp];
1136
1128 return result; 1137 return result;
1129 } 1138 }
1130 1139
1131 } // namespace WebKit 1140 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/api/src/gtk/WebInputEventFactory.cpp ('k') | webkit/api/src/win/WebInputEventFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698