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

Side by Side Diff: ui/events/x/events_x.cc

Issue 24482004: events: Make platform specific events code into ui/events/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 2 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/x/device_list_cache_x.cc ('k') | ui/events/x/events_x_unittest.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_constants.h" 5 #include "ui/events/event_constants.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <X11/extensions/XInput.h> 8 #include <X11/extensions/XInput.h>
9 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/message_loop/message_pump_x11.h" 14 #include "base/message_loop/message_pump_x11.h"
15 #include "ui/base/touch/touch_factory_x11.h" 15 #include "ui/base/touch/touch_factory_x11.h"
16 #include "ui/base/x/device_data_manager.h"
17 #include "ui/base/x/device_list_cache_x.h"
18 #include "ui/base/x/x11_atom_cache.h"
19 #include "ui/base/x/x11_util.h"
20 #include "ui/events/event_utils.h" 16 #include "ui/events/event_utils.h"
21 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 17 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
18 #include "ui/events/x/device_data_manager.h"
19 #include "ui/events/x/device_list_cache_x.h"
22 #include "ui/gfx/display.h" 20 #include "ui/gfx/display.h"
23 #include "ui/gfx/point.h" 21 #include "ui/gfx/point.h"
24 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
25 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
24 #include "ui/gfx/x/x11_atom_cache.h"
25 #include "ui/gfx/x/x11_types.h"
26 26
27 namespace { 27 namespace {
28 28
29 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+. 29 // Scroll amount for each wheelscroll event. 53 is also the value used for GTK+.
30 const int kWheelScrollAmount = 53; 30 const int kWheelScrollAmount = 53;
31 31
32 const int kMinWheelButton = 4; 32 const int kMinWheelButton = 4;
33 const int kMaxWheelButton = 7; 33 const int kMaxWheelButton = 7;
34 34
35 // A class to track current modifier state on master device. Only track ctrl, 35 // A class to track current modifier state on master device. Only track ctrl,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 default: 166 default:
167 return 0; 167 return 0;
168 } 168 }
169 } 169 }
170 170
171 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) { 171 int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
172 int buttonflags = 0; 172 int buttonflags = 0;
173 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) { 173 for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) {
174 if (XIMaskIsSet(xievent->buttons.mask, i)) { 174 if (XIMaskIsSet(xievent->buttons.mask, i)) {
175 int button = (xievent->sourceid == xievent->deviceid) ? 175 int button = (xievent->sourceid == xievent->deviceid) ?
176 ui::GetMappedButton(i) : i; 176 ui::DeviceDataManager::GetInstance()->GetMappedButton(i) : i;
177 buttonflags |= GetEventFlagsForButton(button); 177 buttonflags |= GetEventFlagsForButton(button);
178 } 178 }
179 } 179 }
180 return buttonflags; 180 return buttonflags;
181 } 181 }
182 182
183 ui::EventType GetTouchEventType(const base::NativeEvent& native_event) { 183 ui::EventType GetTouchEventType(const base::NativeEvent& native_event) {
184 XIDeviceEvent* event = 184 XIDeviceEvent* event =
185 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 185 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
186 #if defined(USE_XI2_MT) 186 #if defined(USE_XI2_MT)
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return gfx::Point(); 494 return gfx::Point();
495 } 495 }
496 496
497 int EventButtonFromNative(const base::NativeEvent& native_event) { 497 int EventButtonFromNative(const base::NativeEvent& native_event) {
498 CHECK_EQ(GenericEvent, native_event->type); 498 CHECK_EQ(GenericEvent, native_event->type);
499 XIDeviceEvent* xievent = 499 XIDeviceEvent* xievent =
500 static_cast<XIDeviceEvent*>(native_event->xcookie.data); 500 static_cast<XIDeviceEvent*>(native_event->xcookie.data);
501 int button = xievent->detail; 501 int button = xievent->detail;
502 502
503 return (xievent->sourceid == xievent->deviceid) ? 503 return (xievent->sourceid == xievent->deviceid) ?
504 ui::GetMappedButton(button) : button; 504 DeviceDataManager::GetInstance()->GetMappedButton(button) : button;
505 } 505 }
506 506
507 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) { 507 KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
508 return KeyboardCodeFromXKeyEvent(native_event); 508 return KeyboardCodeFromXKeyEvent(native_event);
509 } 509 }
510 510
511 bool IsMouseEvent(const base::NativeEvent& native_event) { 511 bool IsMouseEvent(const base::NativeEvent& native_event) {
512 if (native_event->type == EnterNotify || 512 if (native_event->type == EnterNotify ||
513 native_event->type == LeaveNotify || 513 native_event->type == LeaveNotify ||
514 native_event->type == ButtonPress || 514 native_event->type == ButtonPress ||
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 noop->xclient.format = 8; 746 noop->xclient.format = 8;
747 DCHECK(!noop->xclient.display); 747 DCHECK(!noop->xclient.display);
748 } 748 }
749 // Make sure we use atom from current xdisplay, which may 749 // Make sure we use atom from current xdisplay, which may
750 // change during the test. 750 // change during the test.
751 noop->xclient.message_type = GetNoopEventAtom(); 751 noop->xclient.message_type = GetNoopEventAtom();
752 return noop; 752 return noop;
753 } 753 }
754 754
755 } // namespace ui 755 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/x/device_list_cache_x.cc ('k') | ui/events/x/events_x_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698