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

Side by Side Diff: ui/events/event.cc

Issue 267723008: Retires ui::TranslatedKeyEvent and replaces it with KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « ui/events/event.h ('k') | ui/keyboard/keyboard_util.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) 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 #endif 10 #endif
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 break; 584 break;
585 default: 585 default:
586 return; 586 return;
587 } 587 }
588 if (type() == ET_KEY_PRESSED) 588 if (type() == ET_KEY_PRESSED)
589 set_flags(flags() | mask); 589 set_flags(flags() | mask);
590 else 590 else
591 set_flags(flags() & ~mask); 591 set_flags(flags() & ~mask);
592 } 592 }
593 593
594 //////////////////////////////////////////////////////////////////////////////// 594 bool KeyEvent::IsTranslated() const {
595 // TranslatedKeyEvent 595 switch (type()) {
596 596 case ET_KEY_PRESSED:
597 TranslatedKeyEvent::TranslatedKeyEvent(const base::NativeEvent& native_event, 597 case ET_KEY_RELEASED:
598 bool is_char) 598 return false;
599 : KeyEvent(native_event, is_char) { 599 case ET_TRANSLATED_KEY_PRESS:
600 SetType(type() == ET_KEY_PRESSED ? 600 case ET_TRANSLATED_KEY_RELEASE:
sadrul 2014/05/05 06:43:47 Can we remove the _TRANSLATED_ types, and use a Ke
Yuki 2014/05/08 05:28:26 ui::Accelerator seems distinguishing a translated
601 ET_TRANSLATED_KEY_PRESS : ET_TRANSLATED_KEY_RELEASE); 601 return true;
602 default:
603 NOTREACHED();
604 return false;
605 }
602 } 606 }
603 607
604 TranslatedKeyEvent::TranslatedKeyEvent(bool is_press, 608 void KeyEvent::SetTranslated(bool translated) {
605 KeyboardCode key_code, 609 switch (type()) {
606 int flags) 610 case ET_KEY_PRESSED:
607 : KeyEvent((is_press ? ET_TRANSLATED_KEY_PRESS : ET_TRANSLATED_KEY_RELEASE), 611 case ET_TRANSLATED_KEY_PRESS:
608 key_code, 612 SetType(translated ? ET_TRANSLATED_KEY_PRESS : ET_KEY_PRESSED);
609 flags, 613 break;
610 false) { 614 case ET_KEY_RELEASED:
611 } 615 case ET_TRANSLATED_KEY_RELEASE:
612 616 SetType(translated ? ET_TRANSLATED_KEY_RELEASE : ET_KEY_RELEASED);
613 TranslatedKeyEvent::TranslatedKeyEvent(const KeyEvent& key_event) 617 break;
614 : KeyEvent(key_event) { 618 default:
615 SetType(type() == ET_KEY_PRESSED ? 619 NOTREACHED();
616 ET_TRANSLATED_KEY_PRESS : ET_TRANSLATED_KEY_RELEASE); 620 }
617 set_is_char(false);
618 }
619
620 void TranslatedKeyEvent::ConvertToKeyEvent() {
621 SetType(type() == ET_TRANSLATED_KEY_PRESS ?
622 ET_KEY_PRESSED : ET_KEY_RELEASED);
623 } 621 }
624 622
625 //////////////////////////////////////////////////////////////////////////////// 623 ////////////////////////////////////////////////////////////////////////////////
626 // ScrollEvent 624 // ScrollEvent
627 625
628 ScrollEvent::ScrollEvent(const base::NativeEvent& native_event) 626 ScrollEvent::ScrollEvent(const base::NativeEvent& native_event)
629 : MouseEvent(native_event) { 627 : MouseEvent(native_event) {
630 if (type() == ET_SCROLL) { 628 if (type() == ET_SCROLL) {
631 GetScrollOffsets(native_event, 629 GetScrollOffsets(native_event,
632 &x_offset_, &y_offset_, 630 &x_offset_, &y_offset_,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 int GestureEvent::GetLowestTouchId() const { 693 int GestureEvent::GetLowestTouchId() const {
696 if (touch_ids_bitfield_ == 0) 694 if (touch_ids_bitfield_ == 0)
697 return -1; 695 return -1;
698 int i = -1; 696 int i = -1;
699 // Find the index of the least significant 1 bit 697 // Find the index of the least significant 1 bit
700 while (!(1 << ++i & touch_ids_bitfield_)); 698 while (!(1 << ++i & touch_ids_bitfield_));
701 return i; 699 return i;
702 } 700 }
703 701
704 } // namespace ui 702 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.h ('k') | ui/keyboard/keyboard_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698