OLD | NEW |
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 | 6 |
7 #include "webkit/glue/webinputevent.h" | 7 #include "webkit/glue/webinputevent.h" |
8 | 8 |
9 #include "KeyboardCodes.h" | 9 #include "KeyboardCodes.h" |
10 #include "KeyCodeConversion.h" | 10 #include "KeyCodeConversion.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (event->state & GDK_BUTTON1_MASK) { | 96 if (event->state & GDK_BUTTON1_MASK) { |
97 button = BUTTON_LEFT; | 97 button = BUTTON_LEFT; |
98 } else if (event->state & GDK_BUTTON2_MASK) { | 98 } else if (event->state & GDK_BUTTON2_MASK) { |
99 button = BUTTON_MIDDLE; | 99 button = BUTTON_MIDDLE; |
100 } else if (event->state & GDK_BUTTON3_MASK) { | 100 } else if (event->state & GDK_BUTTON3_MASK) { |
101 button = BUTTON_RIGHT; | 101 button = BUTTON_RIGHT; |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 WebMouseWheelEvent::WebMouseWheelEvent(const GdkEventScroll* event) { | 105 WebMouseWheelEvent::WebMouseWheelEvent(const GdkEventScroll* event) { |
| 106 type = MOUSE_WHEEL; |
| 107 button = BUTTON_NONE; |
| 108 |
106 timestamp_sec = GdkEventTimeToWebEventTime(event->time); | 109 timestamp_sec = GdkEventTimeToWebEventTime(event->time); |
107 modifiers = GdkStateToWebEventModifiers(event->state); | 110 modifiers = GdkStateToWebEventModifiers(event->state); |
108 x = static_cast<int>(event->x); | 111 x = static_cast<int>(event->x); |
109 y = static_cast<int>(event->y); | 112 y = static_cast<int>(event->y); |
110 global_x = static_cast<int>(event->x_root); | 113 global_x = static_cast<int>(event->x_root); |
111 global_y = static_cast<int>(event->y_root); | 114 global_y = static_cast<int>(event->y_root); |
112 | 115 |
113 type = MOUSE_WHEEL; | |
114 | |
115 // How much should we scroll per mouse wheel event? | 116 // How much should we scroll per mouse wheel event? |
116 // - Windows uses 3 lines by default and obeys a system setting. | 117 // - Windows uses 3 lines by default and obeys a system setting. |
117 // - Mozilla has a pref that lets you either use the "system" number of lines | 118 // - Mozilla has a pref that lets you either use the "system" number of lines |
118 // to scroll, or lets the user override it. | 119 // to scroll, or lets the user override it. |
119 // For the "system" number of lines, it appears they've hardcoded 3. | 120 // For the "system" number of lines, it appears they've hardcoded 3. |
120 // See case NS_MOUSE_SCROLL in content/events/src/nsEventStateManager.cpp | 121 // See case NS_MOUSE_SCROLL in content/events/src/nsEventStateManager.cpp |
121 // and InitMouseScrollEvent in widget/src/gtk2/nsCommonWidget.cpp . | 122 // and InitMouseScrollEvent in widget/src/gtk2/nsCommonWidget.cpp . |
122 // - Gtk makes the scroll amount a function of the size of the scroll bar, | 123 // - Gtk makes the scroll amount a function of the size of the scroll bar, |
123 // which is not available to us here. | 124 // which is not available to us here. |
124 // Instead, we pick a number that empirically matches Firefox's behavior. | 125 // Instead, we pick a number that empirically matches Firefox's behavior. |
125 static const int kWheelDelta = 4; | 126 static const float kWheelDelta = 4; |
126 | 127 |
127 delta_x = 0; | 128 delta_x = 0; |
128 delta_y = 0; | 129 delta_y = 0; |
129 | |
130 switch (event->direction) { | 130 switch (event->direction) { |
131 case GDK_SCROLL_UP: | 131 case GDK_SCROLL_UP: |
132 delta_y = kWheelDelta; | 132 delta_y = kWheelDelta; |
133 break; | 133 break; |
134 case GDK_SCROLL_DOWN: | 134 case GDK_SCROLL_DOWN: |
135 delta_y = -kWheelDelta; | 135 delta_y = -kWheelDelta; |
136 break; | 136 break; |
137 case GDK_SCROLL_LEFT: | 137 case GDK_SCROLL_LEFT: |
138 delta_x = -kWheelDelta; | 138 delta_x = kWheelDelta; |
139 break; | 139 break; |
140 case GDK_SCROLL_RIGHT: | 140 case GDK_SCROLL_RIGHT: |
141 delta_x = kWheelDelta; | 141 delta_x = -kWheelDelta; |
142 break; | 142 break; |
143 default: | 143 default: |
144 break; | 144 break; |
145 } | 145 } |
| 146 scroll_by_page = false; |
146 } | 147 } |
147 | 148 |
148 WebKeyboardEvent::WebKeyboardEvent(const GdkEventKey* event) { | 149 WebKeyboardEvent::WebKeyboardEvent(const GdkEventKey* event) { |
149 system_key = false; | 150 system_key = false; |
150 modifiers = GdkStateToWebEventModifiers(event->state); | 151 modifiers = GdkStateToWebEventModifiers(event->state); |
151 | 152 |
152 switch (event->type) { | 153 switch (event->type) { |
153 case GDK_KEY_RELEASE: | 154 case GDK_KEY_RELEASE: |
154 type = KEY_UP; | 155 type = KEY_UP; |
155 break; | 156 break; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 break; | 188 break; |
188 } | 189 } |
189 | 190 |
190 std::string key_identifier_str = | 191 std::string key_identifier_str = |
191 webkit_glue::GetKeyIdentifierForWindowsKeyCode(windows_key_code); | 192 webkit_glue::GetKeyIdentifierForWindowsKeyCode(windows_key_code); |
192 base::strlcpy(key_identifier, key_identifier_str.c_str(), | 193 base::strlcpy(key_identifier, key_identifier_str.c_str(), |
193 kIdentifierLengthCap); | 194 kIdentifierLengthCap); |
194 | 195 |
195 // TODO(tc): Do we need to set IS_AUTO_REPEAT or IS_KEYPAD? | 196 // TODO(tc): Do we need to set IS_AUTO_REPEAT or IS_KEYPAD? |
196 } | 197 } |
OLD | NEW |