OLD | NEW |
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 if (event->state & GDK_BUTTON1_MASK) | 374 if (event->state & GDK_BUTTON1_MASK) |
375 result.button = WebMouseEvent::ButtonLeft; | 375 result.button = WebMouseEvent::ButtonLeft; |
376 else if (event->state & GDK_BUTTON2_MASK) | 376 else if (event->state & GDK_BUTTON2_MASK) |
377 result.button = WebMouseEvent::ButtonMiddle; | 377 result.button = WebMouseEvent::ButtonMiddle; |
378 else if (event->state & GDK_BUTTON3_MASK) | 378 else if (event->state & GDK_BUTTON3_MASK) |
379 result.button = WebMouseEvent::ButtonRight; | 379 result.button = WebMouseEvent::ButtonRight; |
380 | 380 |
381 return result; | 381 return result; |
382 } | 382 } |
383 | 383 |
| 384 WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventCrossing* event) |
| 385 { |
| 386 WebMouseEvent result; |
| 387 |
| 388 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); |
| 389 result.modifiers = gdkStateToWebEventModifiers(event->state); |
| 390 result.x = static_cast<int>(event->x); |
| 391 result.y = static_cast<int>(event->y); |
| 392 result.windowX = result.x; |
| 393 result.windowY = result.y; |
| 394 result.globalX = static_cast<int>(event->x_root); |
| 395 result.globalY = static_cast<int>(event->y_root); |
| 396 |
| 397 switch (event->type) { |
| 398 case GDK_ENTER_NOTIFY: |
| 399 case GDK_LEAVE_NOTIFY: |
| 400 // Note that if we sent MouseEnter or MouseLeave to WebKit, it |
| 401 // wouldn't work - they don't result in the proper JavaScript events. |
| 402 // MouseMove does the right thing. |
| 403 result.type = WebInputEvent::MouseMove; |
| 404 break; |
| 405 default: |
| 406 ASSERT_NOT_REACHED(); |
| 407 } |
| 408 |
| 409 result.button = WebMouseEvent::ButtonNone; |
| 410 if (event->state & GDK_BUTTON1_MASK) |
| 411 result.button = WebMouseEvent::ButtonLeft; |
| 412 else if (event->state & GDK_BUTTON2_MASK) |
| 413 result.button = WebMouseEvent::ButtonMiddle; |
| 414 else if (event->state & GDK_BUTTON3_MASK) |
| 415 result.button = WebMouseEvent::ButtonRight; |
| 416 |
| 417 return result; |
| 418 } |
| 419 |
384 // WebMouseWheelEvent --------------------------------------------------------- | 420 // WebMouseWheelEvent --------------------------------------------------------- |
385 | 421 |
386 WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(const GdkEventScroll* event) | 422 WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(const GdkEventScroll* event) |
387 { | 423 { |
388 WebMouseWheelEvent result; | 424 WebMouseWheelEvent result; |
389 | 425 |
390 result.type = WebInputEvent::MouseWheel; | 426 result.type = WebInputEvent::MouseWheel; |
391 result.button = WebMouseEvent::ButtonNone; | 427 result.button = WebMouseEvent::ButtonNone; |
392 | 428 |
393 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); | 429 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 case GDK_SCROLL_RIGHT: | 463 case GDK_SCROLL_RIGHT: |
428 result.deltaX = -scrollbarPixelsPerTick; | 464 result.deltaX = -scrollbarPixelsPerTick; |
429 result.wheelTicksX = 1; | 465 result.wheelTicksX = 1; |
430 break; | 466 break; |
431 } | 467 } |
432 | 468 |
433 return result; | 469 return result; |
434 } | 470 } |
435 | 471 |
436 } // namespace WebKit | 472 } // namespace WebKit |
OLD | NEW |