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

Side by Side Diff: webkit/api/src/gtk/WebInputEventFactory.cpp

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
« no previous file with comments | « webkit/api/public/WebInputEvent.h ('k') | webkit/api/src/mac/WebInputEventFactory.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006-2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006-2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 if (state & GDK_SHIFT_MASK) 55 if (state & GDK_SHIFT_MASK)
56 modifiers |= WebInputEvent::ShiftKey; 56 modifiers |= WebInputEvent::ShiftKey;
57 if (state & GDK_CONTROL_MASK) 57 if (state & GDK_CONTROL_MASK)
58 modifiers |= WebInputEvent::ControlKey; 58 modifiers |= WebInputEvent::ControlKey;
59 if (state & GDK_MOD1_MASK) 59 if (state & GDK_MOD1_MASK)
60 modifiers |= WebInputEvent::AltKey; 60 modifiers |= WebInputEvent::AltKey;
61 #if GTK_CHECK_VERSION(2,10,0) 61 #if GTK_CHECK_VERSION(2,10,0)
62 if (state & GDK_META_MASK) 62 if (state & GDK_META_MASK)
63 modifiers |= WebInputEvent::MetaKey; 63 modifiers |= WebInputEvent::MetaKey;
64 #endif 64 #endif
65 if (state & GDK_BUTTON1_MASK)
66 modifiers |= WebInputEvent::LeftButtonDown;
67 if (state & GDK_BUTTON2_MASK)
68 modifiers |= WebInputEvent::MiddleButtonDown;
69 if (state & GDK_BUTTON3_MASK)
70 modifiers |= WebInputEvent::RightButtonDown;
65 return modifiers; 71 return modifiers;
66 } 72 }
67 73
68 // WebKeyboardEvent ----------------------------------------------------------- 74 // WebKeyboardEvent -----------------------------------------------------------
69 75
70 WebKeyboardEvent WebInputEventFactory::keyboardEvent(const GdkEventKey* event) 76 WebKeyboardEvent WebInputEventFactory::keyboardEvent(const GdkEventKey* event)
71 { 77 {
72 WebKeyboardEvent result; 78 WebKeyboardEvent result;
73 79
80 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
74 result.modifiers = gdkStateToWebEventModifiers(event->state); 81 result.modifiers = gdkStateToWebEventModifiers(event->state);
75 82
76 switch (event->type) { 83 switch (event->type) {
77 case GDK_KEY_RELEASE: 84 case GDK_KEY_RELEASE:
78 result.type = WebInputEvent::KeyUp; 85 result.type = WebInputEvent::KeyUp;
79 break; 86 break;
80 case GDK_KEY_PRESS: 87 case GDK_KEY_PRESS:
81 result.type = WebInputEvent::KeyDown; 88 result.type = WebInputEvent::KeyDown;
82 break; 89 break;
83 default: 90 default:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 123
117 WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event) 124 WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event)
118 { 125 {
119 WebMouseEvent result; 126 WebMouseEvent result;
120 127
121 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); 128 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
122 129
123 result.modifiers = gdkStateToWebEventModifiers(event->state); 130 result.modifiers = gdkStateToWebEventModifiers(event->state);
124 result.x = static_cast<int>(event->x); 131 result.x = static_cast<int>(event->x);
125 result.y = static_cast<int>(event->y); 132 result.y = static_cast<int>(event->y);
133 result.windowX = result.x;
134 result.windowY = result.y;
126 result.globalX = static_cast<int>(event->x_root); 135 result.globalX = static_cast<int>(event->x_root);
127 result.globalY = static_cast<int>(event->y_root); 136 result.globalY = static_cast<int>(event->y_root);
128 result.clickCount = 0; 137 result.clickCount = 0;
129 138
130 switch (event->type) { 139 switch (event->type) {
131 case GDK_3BUTTON_PRESS: 140 case GDK_3BUTTON_PRESS:
132 ++result.clickCount; 141 ++result.clickCount;
133 // fallthrough 142 // fallthrough
134 case GDK_2BUTTON_PRESS: 143 case GDK_2BUTTON_PRESS:
135 ++result.clickCount; 144 ++result.clickCount;
(...skipping 22 matching lines...) Expand all
158 } 167 }
159 168
160 WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventMotion* event) 169 WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventMotion* event)
161 { 170 {
162 WebMouseEvent result; 171 WebMouseEvent result;
163 172
164 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); 173 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
165 result.modifiers = gdkStateToWebEventModifiers(event->state); 174 result.modifiers = gdkStateToWebEventModifiers(event->state);
166 result.x = static_cast<int>(event->x); 175 result.x = static_cast<int>(event->x);
167 result.y = static_cast<int>(event->y); 176 result.y = static_cast<int>(event->y);
177 result.windowX = result.x;
178 result.windowY = result.y;
168 result.globalX = static_cast<int>(event->x_root); 179 result.globalX = static_cast<int>(event->x_root);
169 result.globalY = static_cast<int>(event->y_root); 180 result.globalY = static_cast<int>(event->y_root);
170 181
171 switch (event->type) { 182 switch (event->type) {
172 case GDK_MOTION_NOTIFY: 183 case GDK_MOTION_NOTIFY:
173 result.type = WebInputEvent::MouseMove; 184 result.type = WebInputEvent::MouseMove;
174 break; 185 break;
175 default: 186 default:
176 ASSERT_NOT_REACHED(); 187 ASSERT_NOT_REACHED();
177 } 188 }
(...skipping 15 matching lines...) Expand all
193 { 204 {
194 WebMouseWheelEvent result; 205 WebMouseWheelEvent result;
195 206
196 result.type = WebInputEvent::MouseWheel; 207 result.type = WebInputEvent::MouseWheel;
197 result.button = WebMouseEvent::ButtonNone; 208 result.button = WebMouseEvent::ButtonNone;
198 209
199 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); 210 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
200 result.modifiers = gdkStateToWebEventModifiers(event->state); 211 result.modifiers = gdkStateToWebEventModifiers(event->state);
201 result.x = static_cast<int>(event->x); 212 result.x = static_cast<int>(event->x);
202 result.y = static_cast<int>(event->y); 213 result.y = static_cast<int>(event->y);
214 result.windowX = result.x;
215 result.windowY = result.y;
203 result.globalX = static_cast<int>(event->x_root); 216 result.globalX = static_cast<int>(event->x_root);
204 result.globalY = static_cast<int>(event->y_root); 217 result.globalY = static_cast<int>(event->y_root);
205 218
206 // How much should we scroll per mouse wheel event? 219 // How much should we scroll per mouse wheel event?
207 // - Windows uses 3 lines by default and obeys a system setting. 220 // - Windows uses 3 lines by default and obeys a system setting.
208 // - Mozilla has a pref that lets you either use the "system" number of lines 221 // - Mozilla has a pref that lets you either use the "system" number of lines
209 // to scroll, or lets the user override it. 222 // to scroll, or lets the user override it.
210 // For the "system" number of lines, it appears they've hardcoded 3. 223 // For the "system" number of lines, it appears they've hardcoded 3.
211 // See case NS_MOUSE_SCROLL in content/events/src/nsEventStateManager.cpp 224 // See case NS_MOUSE_SCROLL in content/events/src/nsEventStateManager.cpp
212 // and InitMouseScrollEvent in widget/src/gtk2/nsCommonWidget.cpp . 225 // and InitMouseScrollEvent in widget/src/gtk2/nsCommonWidget.cpp .
(...skipping 18 matching lines...) Expand all
231 case GDK_SCROLL_RIGHT: 244 case GDK_SCROLL_RIGHT:
232 result.deltaX = -scrollbarPixelsPerTick; 245 result.deltaX = -scrollbarPixelsPerTick;
233 result.wheelTicksX = 1; 246 result.wheelTicksX = 1;
234 break; 247 break;
235 } 248 }
236 249
237 return result; 250 return result;
238 } 251 }
239 252
240 } // namespace WebKit 253 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/api/public/WebInputEvent.h ('k') | webkit/api/src/mac/WebInputEventFactory.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698