Chromium Code Reviews| 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 "ui/base/events.h" | 5 #include "ui/base/events.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 10 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 if (state & Button1Mask) | 29 if (state & Button1Mask) |
| 30 flags |= ui::EF_LEFT_BUTTON_DOWN; | 30 flags |= ui::EF_LEFT_BUTTON_DOWN; |
| 31 if (state & Button2Mask) | 31 if (state & Button2Mask) |
| 32 flags |= ui::EF_MIDDLE_BUTTON_DOWN; | 32 flags |= ui::EF_MIDDLE_BUTTON_DOWN; |
| 33 if (state & Button3Mask) | 33 if (state & Button3Mask) |
| 34 flags |= ui::EF_RIGHT_BUTTON_DOWN; | 34 flags |= ui::EF_RIGHT_BUTTON_DOWN; |
| 35 | 35 |
| 36 return flags; | 36 return flags; |
| 37 } | 37 } |
| 38 | 38 |
| 39 int GetButtonEventFlagsFromNativeEvent(const ui::NativeEvent& native_event) { | 39 int GetButtonEventFlagsFromNativeEvent(const base::NativeEvent& native_event) { |
|
msw
2011/10/04 18:10:37
I don't know what this will do in a Wayland build
| |
| 40 // TODO(dnicoara): Need to add double click. | 40 // TODO(dnicoara): Need to add double click. |
| 41 int flags = 0; | 41 int flags = 0; |
| 42 switch (native_event->button.button) { | 42 switch (native_event->button.button) { |
| 43 case ui::LEFT_BUTTON: | 43 case ui::LEFT_BUTTON: |
| 44 return flags | ui::EF_LEFT_BUTTON_DOWN; | 44 return flags | ui::EF_LEFT_BUTTON_DOWN; |
| 45 case ui::MIDDLE_BUTTON: | 45 case ui::MIDDLE_BUTTON: |
| 46 return flags | ui::EF_MIDDLE_BUTTON_DOWN; | 46 return flags | ui::EF_MIDDLE_BUTTON_DOWN; |
| 47 case ui::RIGHT_BUTTON: | 47 case ui::RIGHT_BUTTON: |
| 48 return flags | ui::EF_RIGHT_BUTTON_DOWN; | 48 return flags | ui::EF_RIGHT_BUTTON_DOWN; |
| 49 } | 49 } |
| 50 return flags; | 50 return flags; |
| 51 } | 51 } |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 namespace ui { | 55 namespace ui { |
| 56 | 56 |
| 57 EventType EventTypeFromNative(const NativeEvent& native_event) { | 57 EventType EventTypeFromNative(const NativeEvent& native_event) { |
|
msw
2011/10/04 18:10:37
How is this (and the functions below) building if
| |
| 58 switch (native_event->type) { | 58 switch (native_event->type) { |
| 59 case WAYLAND_BUTTON: | 59 case WAYLAND_BUTTON: |
| 60 switch (native_event->button.button) { | 60 switch (native_event->button.button) { |
| 61 case LEFT_BUTTON: | 61 case LEFT_BUTTON: |
| 62 case RIGHT_BUTTON: | 62 case RIGHT_BUTTON: |
| 63 case MIDDLE_BUTTON: | 63 case MIDDLE_BUTTON: |
| 64 return native_event->button.state ? ET_MOUSE_PRESSED | 64 return native_event->button.state ? ET_MOUSE_PRESSED |
| 65 : ET_MOUSE_RELEASED; | 65 : ET_MOUSE_RELEASED; |
| 66 case SCROLL_UP: | 66 case SCROLL_UP: |
| 67 case SCROLL_DOWN: | 67 case SCROLL_DOWN: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 native_event->type == WAYLAND_MOTION || | 124 native_event->type == WAYLAND_MOTION || |
| 125 native_event->type == WAYLAND_POINTER_FOCUS; | 125 native_event->type == WAYLAND_POINTER_FOCUS; |
| 126 } | 126 } |
| 127 | 127 |
| 128 int GetMouseWheelOffset(const NativeEvent& native_event) { | 128 int GetMouseWheelOffset(const NativeEvent& native_event) { |
| 129 return native_event->button.button == ui::SCROLL_UP ? | 129 return native_event->button.button == ui::SCROLL_UP ? |
| 130 kWheelScrollAmount : -kWheelScrollAmount; | 130 kWheelScrollAmount : -kWheelScrollAmount; |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace ui | 133 } // namespace ui |
| OLD | NEW |