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

Side by Side Diff: webkit/glue/event_conversion.cc

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/glue/event_conversion.h ('k') | webkit/glue/plugins/plugin_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "config.h" 5 #include "config.h"
6 #include "webkit/glue/event_conversion.h" 6 #include "webkit/glue/event_conversion.h"
7 7
8 #include "EventNames.h"
9 #include "FrameView.h"
8 #include "KeyboardCodes.h" 10 #include "KeyboardCodes.h"
11 #include "KeyboardEvent.h"
12 #include "MouseEvent.h"
9 #include "StringImpl.h" // This is so that the KJS build works 13 #include "StringImpl.h" // This is so that the KJS build works
10 #include "PlatformKeyboardEvent.h" 14 #include "PlatformKeyboardEvent.h"
11 #include "PlatformMouseEvent.h" 15 #include "PlatformMouseEvent.h"
12 #include "PlatformWheelEvent.h" 16 #include "PlatformWheelEvent.h"
13 #include "Widget.h" 17 #include "Widget.h"
14 18
15 #undef LOG 19 #undef LOG
16 #include "base/gfx/point.h" 20 #include "base/gfx/point.h"
17 #include "base/logging.h" 21 #include "base/logging.h"
18 #include "webkit/api/public/WebInputEvent.h" 22 #include "webkit/api/public/WebInputEvent.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 switch (windowsVirtualKeyCode()) { 146 switch (windowsVirtualKeyCode()) {
143 case VKEY_BACK: 147 case VKEY_BACK:
144 case VKEY_ESCAPE: 148 case VKEY_ESCAPE:
145 return false; 149 return false;
146 150
147 default: 151 default:
148 break; 152 break;
149 } 153 }
150 return true; 154 return true;
151 } 155 }
156
157 static int GetWebInputModifiers(const WebCore::UIEventWithKeyState& event) {
158 int modifiers = 0;
159 if (event.ctrlKey())
160 modifiers |= WebInputEvent::ControlKey;
161 if (event.shiftKey())
162 modifiers |= WebInputEvent::ShiftKey;
163 if (event.altKey())
164 modifiers |= WebInputEvent::AltKey;
165 if (event.metaKey())
166 modifiers |= WebInputEvent::MetaKey;
167 return modifiers;
168 }
169
170
171 bool ToWebMouseEvent(const WebCore::FrameView& view,
172 const WebCore::MouseEvent& event,
173 WebKit::WebMouseEvent* web_event) {
174 if (event.type() == WebCore::eventNames().mousemoveEvent) {
175 web_event->type = WebInputEvent::MouseMove;
176 } else if (event.type() == WebCore::eventNames().mouseoutEvent) {
177 web_event->type = WebInputEvent::MouseLeave;
178 } else if (event.type() == WebCore::eventNames().mouseoverEvent) {
179 web_event->type = WebInputEvent::MouseEnter;
180 } else if (event.type() == WebCore::eventNames().mousedownEvent) {
181 web_event->type = WebInputEvent::MouseDown;
182 } else if (event.type() == WebCore::eventNames().mouseupEvent) {
183 web_event->type = WebInputEvent::MouseUp;
184 } else {
185 // Skip all other mouse events.
186 return false;
187 }
188 web_event->timeStampSeconds = event.timeStamp() * 1.0e-3;
189 switch (event.button()) {
190 case WebCore::LeftButton:
191 web_event->button = WebMouseEvent::ButtonLeft;
192 break;
193 case WebCore::MiddleButton:
194 web_event->button = WebMouseEvent::ButtonMiddle;
195 break;
196 case WebCore::RightButton:
197 web_event->button = WebMouseEvent::ButtonRight;
198 break;
199 }
200 web_event->modifiers = GetWebInputModifiers(event);
201 if (event.buttonDown()) {
202 switch (event.button()) {
203 case WebCore::LeftButton:
204 web_event->modifiers |= WebInputEvent::LeftButtonDown;
205 break;
206 case WebCore::MiddleButton:
207 web_event->modifiers |= WebInputEvent::MiddleButtonDown;
208 break;
209 case WebCore::RightButton:
210 web_event->modifiers |= WebInputEvent::RightButtonDown;
211 break;
212 }
213 }
214 WebCore::IntPoint p = view.contentsToWindow(WebCore::IntPoint(event.pageX(),
215 event.pageY()));
216 web_event->globalX = event.screenX();
217 web_event->globalY = event.screenY();
218 web_event->windowX = p.x();
219 web_event->windowY = p.y();
220 web_event->x = event.offsetX();
221 web_event->y = event.offsetY();
222 return true;
223 }
224
225 bool ToWebKeyboardEvent(const WebCore::KeyboardEvent& event,
226 WebKeyboardEvent* web_event) {
227 if (event.type() == WebCore::eventNames().keydownEvent) {
228 web_event->type = WebInputEvent::KeyDown;
229 } else if (event.type() == WebCore::eventNames().keyupEvent) {
230 web_event->type = WebInputEvent::KeyUp;
231 } else {
232 // Skip all other keyboard events.
233 return false;
234 }
235 web_event->modifiers = GetWebInputModifiers(event);
236 web_event->timeStampSeconds = event.timeStamp() * 1.0e-3;
237 web_event->windowsKeyCode = event.keyCode();
238 web_event->nativeKeyCode = event.keyEvent()->nativeVirtualKeyCode();
239 return true;
240 }
OLDNEW
« no previous file with comments | « webkit/glue/event_conversion.h ('k') | webkit/glue/plugins/plugin_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698