| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/events/event.h" | 5 #include "ui/events/event.h" |
| 6 | 6 |
| 7 #if defined(USE_X11) | 7 #if defined(USE_X11) |
| 8 #include <X11/extensions/XInput2.h> | 8 #include <X11/extensions/XInput2.h> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 #include <X11/keysym.h> | 10 #include <X11/keysym.h> |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, | 282 MouseWheelEvent::MouseWheelEvent(const gfx::Vector2d& offset, |
| 283 const gfx::PointF& location, | 283 const gfx::PointF& location, |
| 284 const gfx::PointF& root_location, | 284 const gfx::PointF& root_location, |
| 285 int flags, | 285 int flags, |
| 286 int changed_button_flags) | 286 int changed_button_flags) |
| 287 : MouseEvent(ui::ET_MOUSEWHEEL, location, root_location, flags, | 287 : MouseEvent(ui::ET_MOUSEWHEEL, location, root_location, flags, |
| 288 changed_button_flags), | 288 changed_button_flags), |
| 289 offset_(offset) { | 289 offset_(offset) { |
| 290 } | 290 } |
| 291 | 291 |
| 292 #if defined(OS_WIN) | |
| 293 // This value matches windows WHEEL_DELTA. | |
| 294 // static | |
| 295 const int MouseWheelEvent::kWheelDelta = 120; | |
| 296 #else | |
| 297 // This value matches GTK+ wheel scroll amount. | 292 // This value matches GTK+ wheel scroll amount. |
| 298 const int MouseWheelEvent::kWheelDelta = 53; | 293 const int MouseWheelEvent::kWheelDelta = 53; |
| 299 #endif | |
| 300 | 294 |
| 301 void MouseWheelEvent::UpdateForRootTransform( | 295 void MouseWheelEvent::UpdateForRootTransform( |
| 302 const gfx::Transform& inverted_root_transform) { | 296 const gfx::Transform& inverted_root_transform) { |
| 303 LocatedEvent::UpdateForRootTransform(inverted_root_transform); | 297 LocatedEvent::UpdateForRootTransform(inverted_root_transform); |
| 304 gfx::DecomposedTransform decomp; | 298 gfx::DecomposedTransform decomp; |
| 305 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); | 299 bool success = gfx::DecomposeTransform(&decomp, inverted_root_transform); |
| 306 DCHECK(success); | 300 DCHECK(success); |
| 307 if (decomp.scale[0]) { | 301 if (decomp.scale[0]) { |
| 308 offset_.set_x( | 302 offset_.set_x( |
| 309 gfx::ToRoundedInt(SkMScalarToFloat(offset_.x() * decomp.scale[0]))); | 303 gfx::ToRoundedInt(SkMScalarToFloat(offset_.x() * decomp.scale[0]))); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 void KeyEvent::SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data) { | 440 void KeyEvent::SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data) { |
| 447 extended_key_event_data_ = data.Pass(); | 441 extended_key_event_data_ = data.Pass(); |
| 448 } | 442 } |
| 449 | 443 |
| 450 base::char16 KeyEvent::GetCharacter() const { | 444 base::char16 KeyEvent::GetCharacter() const { |
| 451 if (is_char_ || character_) | 445 if (is_char_ || character_) |
| 452 return character_; | 446 return character_; |
| 453 | 447 |
| 454 // TODO(kpschoedel): streamline these cases after settling Ozone | 448 // TODO(kpschoedel): streamline these cases after settling Ozone |
| 455 // positional coding. | 449 // positional coding. |
| 456 #if defined(OS_WIN) | 450 #if defined(USE_X11) |
| 457 // Native Windows character events always have is_char_ == true, | |
| 458 // so this is a synthetic or native keystroke event. | |
| 459 character_ = GetCharacterFromKeyCode(key_code_, flags()); | |
| 460 return character_; | |
| 461 #elif defined(USE_X11) | |
| 462 character_ = GetCharacterFromKeyCode(key_code_, flags()); | 451 character_ = GetCharacterFromKeyCode(key_code_, flags()); |
| 463 return character_; | 452 return character_; |
| 464 #else | 453 #else |
| 465 return GetCharacterFromKeyCode(key_code_, flags()); | 454 return GetCharacterFromKeyCode(key_code_, flags()); |
| 466 #endif | 455 #endif |
| 467 } | 456 } |
| 468 | 457 |
| 469 base::char16 KeyEvent::GetText() const { | 458 base::char16 KeyEvent::GetText() const { |
| 470 if ((flags() & EF_CONTROL_DOWN) != 0) { | 459 if ((flags() & EF_CONTROL_DOWN) != 0) { |
| 471 return GetControlCharacterForKeycode(key_code_, | 460 return GetControlCharacterForKeycode(key_code_, |
| 472 (flags() & EF_SHIFT_DOWN) != 0); | 461 (flags() & EF_SHIFT_DOWN) != 0); |
| 473 } | 462 } |
| 474 return GetUnmodifiedText(); | 463 return GetUnmodifiedText(); |
| 475 } | 464 } |
| 476 | 465 |
| 477 base::char16 KeyEvent::GetUnmodifiedText() const { | 466 base::char16 KeyEvent::GetUnmodifiedText() const { |
| 478 if (!is_char_ && (key_code_ == VKEY_RETURN)) | 467 if (!is_char_ && (key_code_ == VKEY_RETURN)) |
| 479 return '\r'; | 468 return '\r'; |
| 480 return GetCharacter(); | 469 return GetCharacter(); |
| 481 } | 470 } |
| 482 | 471 |
| 483 bool KeyEvent::IsUnicodeKeyCode() const { | 472 bool KeyEvent::IsUnicodeKeyCode() const { |
| 484 #if defined(OS_WIN) | |
| 485 if (!IsAltDown()) | |
| 486 return false; | |
| 487 const int key = key_code(); | |
| 488 if (key >= VKEY_NUMPAD0 && key <= VKEY_NUMPAD9) | |
| 489 return true; | |
| 490 // Check whether the user is using the numeric keypad with num-lock off. | |
| 491 // In that case, EF_EXTENDED will not be set; if it is set, the key event | |
| 492 // originated from the relevant non-numpad dedicated key, e.g. [Insert]. | |
| 493 return (!(flags() & EF_EXTENDED) && | |
| 494 (key == VKEY_INSERT || key == VKEY_END || key == VKEY_DOWN || | |
| 495 key == VKEY_NEXT || key == VKEY_LEFT || key == VKEY_CLEAR || | |
| 496 key == VKEY_RIGHT || key == VKEY_HOME || key == VKEY_UP || | |
| 497 key == VKEY_PRIOR)); | |
| 498 #else | |
| 499 return false; | 473 return false; |
| 500 #endif | |
| 501 } | 474 } |
| 502 | 475 |
| 503 void KeyEvent::NormalizeFlags() { | 476 void KeyEvent::NormalizeFlags() { |
| 504 int mask = 0; | 477 int mask = 0; |
| 505 switch (key_code()) { | 478 switch (key_code()) { |
| 506 case VKEY_CONTROL: | 479 case VKEY_CONTROL: |
| 507 mask = EF_CONTROL_DOWN; | 480 mask = EF_CONTROL_DOWN; |
| 508 break; | 481 break; |
| 509 case VKEY_SHIFT: | 482 case VKEY_SHIFT: |
| 510 mask = EF_SHIFT_DOWN; | 483 mask = EF_SHIFT_DOWN; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 gfx::PointF(x, y), | 648 gfx::PointF(x, y), |
| 676 time_stamp, | 649 time_stamp, |
| 677 flags | EF_FROM_TOUCH), | 650 flags | EF_FROM_TOUCH), |
| 678 details_(details) { | 651 details_(details) { |
| 679 } | 652 } |
| 680 | 653 |
| 681 GestureEvent::~GestureEvent() { | 654 GestureEvent::~GestureEvent() { |
| 682 } | 655 } |
| 683 | 656 |
| 684 } // namespace ui | 657 } // namespace ui |
| OLD | NEW |