OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/events/event.h" | 5 #include "views/events/event.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" | 10 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); | 114 return gfx::Point(static_cast<int>(x), static_cast<int>(y)); |
115 return gfx::Point(); | 115 return gfx::Point(); |
116 } | 116 } |
117 | 117 |
118 ui::KeyboardCode KeyboardCodeFromNative(GdkEvent* gdk_event) { | 118 ui::KeyboardCode KeyboardCodeFromNative(GdkEvent* gdk_event) { |
119 DCHECK(gdk_event->type == GDK_KEY_PRESS || | 119 DCHECK(gdk_event->type == GDK_KEY_PRESS || |
120 gdk_event->type == GDK_KEY_RELEASE); | 120 gdk_event->type == GDK_KEY_RELEASE); |
121 return ui::KeyboardCodeFromGdkEventKey(&gdk_event->key); | 121 return ui::KeyboardCodeFromGdkEventKey(&gdk_event->key); |
122 } | 122 } |
123 | 123 |
124 bool IsMouseEvent(GdkEvent* gdk_event) { | |
125 return gdk_event->type == GDK_MOTION_NOTIFY || | |
126 gdk_event->type == GDK_BUTTON_PRESS || | |
127 gdk_event->type == GDK_2BUTTON_PRESS || | |
128 gdk_event->type == GDK_3BUTTON_PRESS || | |
129 gdk_event->type == GDK_BUTTON_RELEASE; | |
130 } | |
131 | |
132 int GetMouseWheelOffset(GdkEvent* gdk_event) { | 124 int GetMouseWheelOffset(GdkEvent* gdk_event) { |
133 DCHECK(gdk_event->type == GDK_SCROLL); | 125 DCHECK(gdk_event->type == GDK_SCROLL); |
134 int offset = (gdk_event->scroll.direction == GDK_SCROLL_UP || | 126 int offset = (gdk_event->scroll.direction == GDK_SCROLL_UP || |
135 gdk_event->scroll.direction == GDK_SCROLL_LEFT) ? 1 : -1; | 127 gdk_event->scroll.direction == GDK_SCROLL_LEFT) ? 1 : -1; |
136 return offset; | 128 return offset; |
137 } | 129 } |
138 | 130 |
139 } // namespace | 131 } // namespace |
140 | 132 |
141 namespace views { | 133 namespace views { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 174 |
183 //////////////////////////////////////////////////////////////////////////////// | 175 //////////////////////////////////////////////////////////////////////////////// |
184 // MouseWheelEvent, public: | 176 // MouseWheelEvent, public: |
185 | 177 |
186 MouseWheelEvent::MouseWheelEvent(GdkEvent* gdk_event) | 178 MouseWheelEvent::MouseWheelEvent(GdkEvent* gdk_event) |
187 : MouseEvent(gdk_event), | 179 : MouseEvent(gdk_event), |
188 offset_(kWheelDelta * GetMouseWheelOffset(gdk_event)) { | 180 offset_(kWheelDelta * GetMouseWheelOffset(gdk_event)) { |
189 } | 181 } |
190 | 182 |
191 } // namespace views | 183 } // namespace views |
OLD | NEW |