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

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

Issue 492863002: mojo: Plumb through sufficient context to make real blink::WebInputEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final sky nits Created 6 years, 4 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_utils.h ('k') | ui/events/events_stub.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_utils.h" 5 #include "ui/events/event_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/gfx/display.h" 10 #include "ui/gfx/display.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 case ET_TOUCH_CANCELLED: 56 case ET_TOUCH_CANCELLED:
57 event.reset(new TouchEvent(native_event)); 57 event.reset(new TouchEvent(native_event));
58 break; 58 break;
59 59
60 default: 60 default:
61 break; 61 break;
62 } 62 }
63 return event.Pass(); 63 return event.Pass();
64 } 64 }
65 65
66 #if defined(OS_LINUX)
67 // From third_party/WebKit/Source/web/gtk/WebInputEventFactory.cpp:
68 uint16 GetControlCharacterForKeycode(int windows_key_code, bool shift) {
69 if (windows_key_code >= ui::VKEY_A &&
70 windows_key_code <= ui::VKEY_Z) {
71 // ctrl-A ~ ctrl-Z map to \x01 ~ \x1A
72 return windows_key_code - ui::VKEY_A + 1;
73 }
74 if (shift) {
75 // following graphics chars require shift key to input.
76 switch (windows_key_code) {
77 // ctrl-@ maps to \x00 (Null byte)
78 case ui::VKEY_2:
79 return 0;
80 // ctrl-^ maps to \x1E (Record separator, Information separator two)
81 case ui::VKEY_6:
82 return 0x1E;
83 // ctrl-_ maps to \x1F (Unit separator, Information separator one)
84 case ui::VKEY_OEM_MINUS:
85 return 0x1F;
86 // Returns 0 for all other keys to avoid inputting unexpected chars.
87 default:
88 break;
89 }
90 } else {
91 switch (windows_key_code) {
92 // ctrl-[ maps to \x1B (Escape)
93 case ui::VKEY_OEM_4:
94 return 0x1B;
95 // ctrl-\ maps to \x1C (File separator, Information separator four)
96 case ui::VKEY_OEM_5:
97 return 0x1C;
98 // ctrl-] maps to \x1D (Group separator, Information separator three)
99 case ui::VKEY_OEM_6:
100 return 0x1D;
101 // ctrl-Enter maps to \x0A (Line feed)
102 case ui::VKEY_RETURN:
103 return 0x0A;
104 // Returns 0 for all other keys to avoid inputting unexpected chars.
105 default:
106 break;
107 }
108 }
109 return 0;
110 }
111 #endif
112
66 int RegisterCustomEventType() { 113 int RegisterCustomEventType() {
67 return ++g_custom_event_types; 114 return ++g_custom_event_types;
68 } 115 }
69 116
70 base::TimeDelta EventTimeForNow() { 117 base::TimeDelta EventTimeForNow() {
71 return base::TimeDelta::FromInternalValue( 118 return base::TimeDelta::FromInternalValue(
72 base::TimeTicks::Now().ToInternalValue()); 119 base::TimeTicks::Now().ToInternalValue());
73 } 120 }
74 121
75 bool ShouldDefaultToNaturalScroll() { 122 bool ShouldDefaultToNaturalScroll() {
76 return GetInternalDisplayTouchSupport() == 123 return GetInternalDisplayTouchSupport() ==
77 gfx::Display::TOUCH_SUPPORT_AVAILABLE; 124 gfx::Display::TOUCH_SUPPORT_AVAILABLE;
78 } 125 }
79 126
80 gfx::Display::TouchSupport GetInternalDisplayTouchSupport() { 127 gfx::Display::TouchSupport GetInternalDisplayTouchSupport() {
81 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); 128 gfx::Screen* screen = gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
82 // No screen in some unit tests. 129 // No screen in some unit tests.
83 if (!screen) 130 if (!screen)
84 return gfx::Display::TOUCH_SUPPORT_UNKNOWN; 131 return gfx::Display::TOUCH_SUPPORT_UNKNOWN;
85 const std::vector<gfx::Display>& displays = screen->GetAllDisplays(); 132 const std::vector<gfx::Display>& displays = screen->GetAllDisplays();
86 for (std::vector<gfx::Display>::const_iterator it = displays.begin(); 133 for (std::vector<gfx::Display>::const_iterator it = displays.begin();
87 it != displays.end(); ++it) { 134 it != displays.end(); ++it) {
88 if (it->IsInternal()) 135 if (it->IsInternal())
89 return it->touch_support(); 136 return it->touch_support();
90 } 137 }
91 return gfx::Display::TOUCH_SUPPORT_UNAVAILABLE; 138 return gfx::Display::TOUCH_SUPPORT_UNAVAILABLE;
92 } 139 }
93 140
94 } // namespace ui 141 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event_utils.h ('k') | ui/events/events_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698