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 "views/focus/accelerator_handler.h" | 5 #include "views/focus/accelerator_handler.h" |
| 6 | 6 |
| 7 #include <bitset> | 7 #include <bitset> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 bool DispatchX2Event(Widget* widget, XEvent* xev) { | 42 bool DispatchX2Event(Widget* widget, XEvent* xev) { |
| 43 XGenericEventCookie* cookie = &xev->xcookie; | 43 XGenericEventCookie* cookie = &xev->xcookie; |
| 44 switch (cookie->evtype) { | 44 switch (cookie->evtype) { |
| 45 case XI_KeyPress: | 45 case XI_KeyPress: |
| 46 case XI_KeyRelease: { | 46 case XI_KeyRelease: { |
| 47 // TODO(sad): We don't capture XInput2 events from keyboard yet. | 47 // TODO(sad): We don't capture XInput2 events from keyboard yet. |
| 48 break; | 48 break; |
| 49 } | 49 } |
| 50 #if defined(USE_XI2_1) | |
| 51 case XI_TouchBegin: | |
| 52 case XI_TouchEnd: | |
| 53 case XI_TouchUpdate: { | |
| 54 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); | |
| 55 Event::FromNativeEvent2 from_native; | |
| 56 | |
| 57 // Is the event coming from a touch device? | |
| 58 if (TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid)) { | |
|
sadrul
2011/09/07 14:56:37
This check is probably not necessary here. If some
ningxin.hu
2011/09/08 08:24:50
Agree. I am removing the check.
| |
| 59 // Hide the cursor when a touch event comes in. | |
| 60 TouchFactory::GetInstance()->SetCursorVisible(false, false); | |
| 61 | |
| 62 // If the TouchEvent is processed by |root|, then return. Otherwise let | |
| 63 // it fall through so it can be used as a MouseEvent, if desired. | |
|
sadrul
2011/09/07 14:56:37
|root| should become |widget| (and possibly correc
ningxin.hu
2011/09/08 08:24:50
Will correct the comments. Thanks.
| |
| 64 TouchEvent touch(xev, from_native); | |
| 65 if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN) | |
| 66 return true; | |
| 67 | |
| 68 // We do not want to generate a mouse event for an unprocessed touch | |
| 69 // event here. That is already done by the gesture manager in | |
| 70 // RootView::OnTouchEvent. | |
| 71 return false; | |
| 72 } else { | |
| 73 return false; | |
| 74 } | |
| 75 } | |
| 76 #else | |
| 50 case XI_ButtonPress: | 77 case XI_ButtonPress: |
| 51 case XI_ButtonRelease: | 78 case XI_ButtonRelease: |
| 52 case XI_Motion: { | 79 case XI_Motion: { |
| 53 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); | 80 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); |
| 54 Event::FromNativeEvent2 from_native; | 81 Event::FromNativeEvent2 from_native; |
| 55 | 82 |
| 56 // Scrolling the wheel generates press/release events with button id's 4 | 83 // Scrolling the wheel generates press/release events with button id's 4 |
| 57 // and 5. In case of a wheelscroll, we do not want to show the cursor. | 84 // and 5. In case of a wheelscroll, we do not want to show the cursor. |
| 58 if (xievent->detail == 4 || xievent->detail == 5) { | 85 if (xievent->detail == 4 || xievent->detail == 5) { |
| 59 MouseWheelEvent wheelev(xev, from_native); | 86 MouseWheelEvent wheelev(xev, from_native); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 90 bool start_timer = mouseev.type() == ui::ET_MOUSE_MOVED; | 117 bool start_timer = mouseev.type() == ui::ET_MOUSE_MOVED; |
| 91 start_timer |= mouseev.type() == ui::ET_MOUSE_RELEASED && | 118 start_timer |= mouseev.type() == ui::ET_MOUSE_RELEASED && |
| 92 (mouseev.IsOnlyLeftMouseButton() || | 119 (mouseev.IsOnlyLeftMouseButton() || |
| 93 mouseev.IsOnlyMiddleMouseButton() || | 120 mouseev.IsOnlyMiddleMouseButton() || |
| 94 mouseev.IsOnlyRightMouseButton()); | 121 mouseev.IsOnlyRightMouseButton()); |
| 95 TouchFactory::GetInstance()->SetCursorVisible(true, start_timer); | 122 TouchFactory::GetInstance()->SetCursorVisible(true, start_timer); |
| 96 | 123 |
| 97 return widget->OnMouseEvent(mouseev); | 124 return widget->OnMouseEvent(mouseev); |
| 98 } | 125 } |
| 99 } | 126 } |
| 127 #endif | |
|
sadrul
2011/09/07 14:56:37
#endif // defined(USE_XI2_1)
ningxin.hu
2011/09/08 08:24:50
Added. Thanks.
| |
| 100 } | 128 } |
| 101 return false; | 129 return false; |
| 102 } | 130 } |
| 103 | 131 |
| 104 bool DispatchXEvent(XEvent* xev) { | 132 bool DispatchXEvent(XEvent* xev) { |
| 105 GdkDisplay* gdisp = gdk_display_get_default(); | 133 GdkDisplay* gdisp = gdk_display_get_default(); |
| 106 XID xwindow = xev->xany.window; | 134 XID xwindow = xev->xany.window; |
| 107 | 135 |
| 108 if (xev->type == GenericEvent) { | 136 if (xev->type == GenericEvent) { |
| 109 if (!TouchFactory::GetInstance()->ShouldProcessXI2Event(xev)) | 137 if (!TouchFactory::GetInstance()->ShouldProcessXI2Event(xev)) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 AcceleratorHandler::AcceleratorHandler() {} | 193 AcceleratorHandler::AcceleratorHandler() {} |
| 166 | 194 |
| 167 base::MessagePumpDispatcher::DispatchStatus | 195 base::MessagePumpDispatcher::DispatchStatus |
| 168 AcceleratorHandler::Dispatch(XEvent* xev) { | 196 AcceleratorHandler::Dispatch(XEvent* xev) { |
| 169 return DispatchXEvent(xev) ? | 197 return DispatchXEvent(xev) ? |
| 170 base::MessagePumpDispatcher::EVENT_PROCESSED : | 198 base::MessagePumpDispatcher::EVENT_PROCESSED : |
| 171 base::MessagePumpDispatcher::EVENT_IGNORED; | 199 base::MessagePumpDispatcher::EVENT_IGNORED; |
| 172 } | 200 } |
| 173 | 201 |
| 174 } // namespace views | 202 } // namespace views |
| OLD | NEW |