summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-25 09:15:17 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-25 09:15:17 +0000
commit10cc8ed528d01ec178705deaf0d280c83b9fa71c (patch)
treece1268b05dc0471d5ffd0e6fac60282176fb42c2 /ui
parent1f4696c82c247e23c4fb1387f90e62424707e515 (diff)
downloadchromium_src-10cc8ed528d01ec178705deaf0d280c83b9fa71c.zip
chromium_src-10cc8ed528d01ec178705deaf0d280c83b9fa71c.tar.gz
chromium_src-10cc8ed528d01ec178705deaf0d280c83b9fa71c.tar.bz2
events: Make platform specific events code into ui/events/.
Notable changes: * Move events_win and events_x from ui/base/ into ui/events/ * Move DeviceDataManager, and DeviceListCache into ui/events/ * Move X11AtomCache from ui/base/x into ui/gfx/x * Move some X11 util functions from ui/base/ into ui/events/ BUG=none R=ben@chromium.org Review URL: https://codereview.chromium.org/24482004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/root_window_host_x11.cc5
-rw-r--r--ui/aura/root_window_host_x11.h2
-rw-r--r--ui/aura/test/event_generator.cc6
-rw-r--r--ui/base/clipboard/clipboard_aurax11.cc2
-rw-r--r--ui/base/dragdrop/os_exchange_data_provider_aurax11.h2
-rw-r--r--ui/base/touch/touch_factory_x11.cc2
-rw-r--r--ui/base/x/selection_owner.h2
-rw-r--r--ui/base/x/selection_requestor.h2
-rw-r--r--ui/base/x/selection_utils.cc2
-rw-r--r--ui/base/x/selection_utils.h2
-rw-r--r--ui/base/x/x11_util.cc107
-rw-r--r--ui/base/x/x11_util.h17
-rw-r--r--ui/events/event_unittest.cc3
-rw-r--r--ui/events/win/events_win.cc (renamed from ui/base/win/events_win.cc)0
-rw-r--r--ui/events/x/device_data_manager.cc (renamed from ui/base/x/device_data_manager.cc)21
-rw-r--r--ui/events/x/device_data_manager.h (renamed from ui/base/x/device_data_manager.h)22
-rw-r--r--ui/events/x/device_list_cache_x.cc (renamed from ui/base/x/device_list_cache_x.cc)3
-rw-r--r--ui/events/x/device_list_cache_x.h (renamed from ui/base/x/device_list_cache_x.h)10
-rw-r--r--ui/events/x/events_x.cc (renamed from ui/base/x/events_x.cc)12
-rw-r--r--ui/events/x/events_x_unittest.cc (renamed from ui/base/x/events_x_unittest.cc)2
-rw-r--r--ui/events/x/events_x_utils.cc80
-rw-r--r--ui/events/x/events_x_utils.h21
-rw-r--r--ui/gfx/x/x11_atom_cache.cc (renamed from ui/base/x/x11_atom_cache.cc)2
-rw-r--r--ui/gfx/x/x11_atom_cache.h (renamed from ui/base/x/x11_atom_cache.h)14
-rw-r--r--ui/ui.gyp21
-rw-r--r--ui/ui_unittests.gypi2
-rw-r--r--ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h2
-rw-r--r--ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc3
-rw-r--r--ui/views/widget/desktop_aura/desktop_root_window_host_x11.h2
-rw-r--r--ui/views/widget/desktop_aura/x11_desktop_handler.h2
-rw-r--r--ui/views/widget/desktop_aura/x11_window_event_filter.h2
31 files changed, 188 insertions, 187 deletions
diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc
index abf1da0..0bec120 100644
--- a/ui/aura/root_window_host_x11.cc
+++ b/ui/aura/root_window_host_x11.cc
@@ -35,13 +35,14 @@
#include "ui/base/touch/touch_factory_x11.h"
#include "ui/base/ui_base_switches.h"
#include "ui/base/view_prop.h"
-#include "ui/base/x/device_list_cache_x.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/dip_util.h"
#include "ui/compositor/layer.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
+#include "ui/events/x/device_data_manager.h"
+#include "ui/events/x/device_list_cache_x.h"
#include "ui/gfx/screen.h"
#if defined(OS_CHROMEOS)
@@ -566,7 +567,7 @@ bool RootWindowHostX11::Dispatch(const base::NativeEvent& event) {
delegate_->AsRootWindow()->OnKeyboardMappingChanged();
break;
case MappingPointer:
- ui::UpdateButtonMap();
+ ui::DeviceDataManager::GetInstance()->UpdateButtonMap();
break;
default:
NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request;
diff --git a/ui/aura/root_window_host_x11.h b/ui/aura/root_window_host_x11.h
index 77d97b9..91d8bca 100644
--- a/ui/aura/root_window_host_x11.h
+++ b/ui/aura/root_window_host_x11.h
@@ -17,10 +17,10 @@
#include "ui/aura/aura_export.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/root_window_host.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/x/x11_atom_cache.h"
namespace ui {
class MouseEvent;
diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc
index ba8392d..ac46df1 100644
--- a/ui/aura/test/event_generator.cc
+++ b/ui/aura/test/event_generator.cc
@@ -448,13 +448,7 @@ void EventGenerator::DispatchKeyEvent(bool is_press,
TestKeyEvent keyev(native_event, flags, key_press == WM_CHAR);
#else
ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
-#if defined(USE_X11)
- scoped_ptr<XEvent> native_event(new XEvent);
- ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get());
- TestKeyEvent keyev(native_event.get(), flags, false);
-#else
ui::KeyEvent keyev(type, key_code, flags, false);
-#endif // USE_X11
#endif // OS_WIN
Dispatch(&keyev);
}
diff --git a/ui/base/clipboard/clipboard_aurax11.cc b/ui/base/clipboard/clipboard_aurax11.cc
index 5c6ebb8..e8d263e 100644
--- a/ui/base/clipboard/clipboard_aurax11.cc
+++ b/ui/base/clipboard/clipboard_aurax11.cc
@@ -24,10 +24,10 @@
#include "ui/base/x/selection_owner.h"
#include "ui/base/x/selection_requestor.h"
#include "ui/base/x/selection_utils.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/size.h"
+#include "ui/gfx/x/x11_atom_cache.h"
namespace ui {
diff --git a/ui/base/dragdrop/os_exchange_data_provider_aurax11.h b/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
index f55138a..76cfad3 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
+++ b/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
@@ -19,9 +19,9 @@
#include "ui/base/x/selection_owner.h"
#include "ui/base/x/selection_requestor.h"
#include "ui/base/x/selection_utils.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/vector2d.h"
+#include "ui/gfx/x/x11_atom_cache.h"
#include "url/gurl.h"
namespace ui {
diff --git a/ui/base/touch/touch_factory_x11.cc b/ui/base/touch/touch_factory_x11.cc
index 21fa6a2..4314eed 100644
--- a/ui/base/touch/touch_factory_x11.cc
+++ b/ui/base/touch/touch_factory_x11.cc
@@ -18,7 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "ui/base/ui_base_switches.h"
-#include "ui/base/x/device_list_cache_x.h"
+#include "ui/events/x/device_list_cache_x.h"
#include "ui/gfx/x/x11_types.h"
namespace ui {
diff --git a/ui/base/x/selection_owner.h b/ui/base/x/selection_owner.h
index 6c5c7f8..8cecc62 100644
--- a/ui/base/x/selection_owner.h
+++ b/ui/base/x/selection_owner.h
@@ -16,7 +16,7 @@
#include "base/callback.h"
#include "ui/base/ui_export.h"
#include "ui/base/x/selection_utils.h"
-#include "ui/base/x/x11_atom_cache.h"
+#include "ui/gfx/x/x11_atom_cache.h"
namespace ui {
diff --git a/ui/base/x/selection_requestor.h b/ui/base/x/selection_requestor.h
index 318533a..fb6cc1a 100644
--- a/ui/base/x/selection_requestor.h
+++ b/ui/base/x/selection_requestor.h
@@ -16,7 +16,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted_memory.h"
#include "ui/base/ui_export.h"
-#include "ui/base/x/x11_atom_cache.h"
+#include "ui/gfx/x/x11_atom_cache.h"
namespace ui {
class SelectionData;
diff --git a/ui/base/x/selection_utils.cc b/ui/base/x/selection_utils.cc
index e0f1d9b..b4aac34 100644
--- a/ui/base/x/selection_utils.cc
+++ b/ui/base/x/selection_utils.cc
@@ -10,8 +10,8 @@
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/clipboard/clipboard.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/base/x/x11_util.h"
+#include "ui/gfx/x/x11_atom_cache.h"
namespace ui {
diff --git a/ui/base/x/selection_utils.h b/ui/base/x/selection_utils.h
index 609ee9d..c0d7b80 100644
--- a/ui/base/x/selection_utils.h
+++ b/ui/base/x/selection_utils.h
@@ -16,7 +16,7 @@
#include "base/memory/ref_counted_memory.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/ui_export.h"
-#include "ui/base/x/x11_atom_cache.h"
+#include "ui/gfx/x/x11_atom_cache.h"
namespace ui {
class SelectionData;
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index accd4f9..a02e59d 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -35,11 +35,11 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkPostConfig.h"
#include "ui/base/touch/touch_factory_x11.h"
-#include "ui/base/x/device_data_manager.h"
#include "ui/base/x/x11_error_tracker.h"
#include "ui/base/x/x11_util_internal.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
+#include "ui/events/x/device_data_manager.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
@@ -135,39 +135,6 @@ bool GetProperty(XID window, const std::string& property_name, long max_length,
property);
}
-// Converts ui::EventType to XKeyEvent state.
-unsigned int XKeyEventState(int flags) {
- return
- ((flags & ui::EF_SHIFT_DOWN) ? ShiftMask : 0) |
- ((flags & ui::EF_CONTROL_DOWN) ? ControlMask : 0) |
- ((flags & ui::EF_ALT_DOWN) ? Mod1Mask : 0) |
- ((flags & ui::EF_CAPS_LOCK_DOWN) ? LockMask : 0);
-}
-
-// Converts EventType to XKeyEvent type.
-int XKeyEventType(ui::EventType type) {
- switch (type) {
- case ui::ET_KEY_PRESSED:
- return KeyPress;
- case ui::ET_KEY_RELEASED:
- return KeyRelease;
- default:
- return 0;
- }
-}
-
-// Converts KeyboardCode to XKeyEvent keycode.
-unsigned int XKeyEventKeyCode(ui::KeyboardCode key_code,
- int flags,
- XDisplay* display) {
- const int keysym = XKeysymForWindowsKeyCode(key_code,
- flags & ui::EF_SHIFT_DOWN);
- // Tests assume the keycode for XK_less is equal to the one of XK_comma,
- // but XKeysymToKeycode returns 94 for XK_less while it returns 59 for
- // XK_comma. Here we convert the value for XK_less to the value for XK_comma.
- return (keysym == XK_less) ? 59 : XKeysymToKeycode(display, keysym);
-}
-
// A process wide singleton that manages the usage of X cursors.
class XCursorCache {
public:
@@ -284,36 +251,6 @@ class XCustomCursorCache {
};
#endif // defined(USE_AURA)
-// A singleton object that remembers remappings of mouse buttons.
-class XButtonMap {
- public:
- static XButtonMap* GetInstance() {
- return Singleton<XButtonMap>::get();
- }
-
- void UpdateMapping() {
- count_ = XGetPointerMapping(gfx::GetXDisplay(), map_, arraysize(map_));
- }
-
- int GetMappedButton(int button) {
- return button > 0 && button <= count_ ? map_[button - 1] : button;
- }
-
- private:
- friend struct DefaultSingletonTraits<XButtonMap>;
-
- XButtonMap() {
- UpdateMapping();
- }
-
- ~XButtonMap() {}
-
- unsigned char map_[256];
- int count_;
-
- DISALLOW_COPY_AND_ASSIGN(XButtonMap);
-};
-
bool IsShapeAvailable() {
int dummy;
static bool is_shape_available =
@@ -1375,48 +1312,6 @@ bool IsX11WindowFullScreen(XID window) {
#endif
}
-bool IsMotionEvent(XEvent* event) {
- int type = event->type;
- if (type == GenericEvent)
- type = event->xgeneric.evtype;
- return type == MotionNotify;
-}
-
-int GetMappedButton(int button) {
- return XButtonMap::GetInstance()->GetMappedButton(button);
-}
-
-void UpdateButtonMap() {
- XButtonMap::GetInstance()->UpdateMapping();
-}
-
-void InitXKeyEventForTesting(EventType type,
- KeyboardCode key_code,
- int flags,
- XEvent* event) {
- CHECK(event);
- XDisplay* display = gfx::GetXDisplay();
- XKeyEvent key_event;
- key_event.type = XKeyEventType(type);
- CHECK_NE(0, key_event.type);
- key_event.serial = 0;
- key_event.send_event = 0;
- key_event.display = display;
- key_event.time = 0;
- key_event.window = 0;
- key_event.root = 0;
- key_event.subwindow = 0;
- key_event.x = 0;
- key_event.y = 0;
- key_event.x_root = 0;
- key_event.y_root = 0;
- key_event.state = XKeyEventState(flags);
- key_event.keycode = XKeyEventKeyCode(key_code, flags, display);
- key_event.same_screen = 1;
- event->type = key_event.type;
- event->xkey = key_event;
-}
-
const unsigned char* XRefcountedMemory::front() const {
return x11_data_;
}
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h
index 0193730..5f3e502 100644
--- a/ui/base/x/x11_util.h
+++ b/ui/base/x/x11_util.h
@@ -302,23 +302,6 @@ UI_EXPORT void SetDefaultX11ErrorHandlers();
// Return true if a given window is in full-screen mode.
UI_EXPORT bool IsX11WindowFullScreen(XID window);
-// Return true if event type is MotionNotify.
-UI_EXPORT bool IsMotionEvent(XEvent* event);
-
-// Returns the mapped button.
-int GetMappedButton(int button);
-
-// Updates button mapping. This is usually called when a MappingNotify event is
-// received.
-UI_EXPORT void UpdateButtonMap();
-
-// Initializes a XEvent that holds XKeyEvent for testing. Note that ui::EF_
-// flags should be passed as |flags|, not the native ones in <X11/X.h>.
-UI_EXPORT void InitXKeyEventForTesting(EventType type,
- KeyboardCode key_code,
- int flags,
- XEvent* event);
-
// Manages a piece of X11 allocated memory as a RefCountedMemory segment. This
// object takes ownership over the passed in memory and will free it with the
// X11 allocator when done.
diff --git a/ui/events/event_unittest.cc b/ui/events/event_unittest.cc
index 43fbf9a..249acb6 100644
--- a/ui/events/event_unittest.cc
+++ b/ui/events/event_unittest.cc
@@ -8,7 +8,8 @@
#if defined(USE_X11)
#include <X11/Xlib.h>
-#include "ui/base/x/x11_util.h"
+#include "ui/events/x/events_x_utils.h"
+#include "ui/gfx/x/x11_types.h"
#endif
namespace ui {
diff --git a/ui/base/win/events_win.cc b/ui/events/win/events_win.cc
index 04b9cd0..04b9cd0 100644
--- a/ui/base/win/events_win.cc
+++ b/ui/events/win/events_win.cc
diff --git a/ui/base/x/device_data_manager.cc b/ui/events/x/device_data_manager.cc
index 784819f..e6a4222 100644
--- a/ui/base/x/device_data_manager.cc
+++ b/ui/events/x/device_data_manager.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/x/device_data_manager.h"
+#include "ui/events/x/device_data_manager.h"
#include <X11/extensions/XInput.h>
#include <X11/extensions/XInput2.h>
@@ -11,10 +11,10 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "ui/base/touch/touch_factory_x11.h"
-#include "ui/base/x/device_list_cache_x.h"
-#include "ui/base/x/x11_util.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
+#include "ui/events/x/device_list_cache_x.h"
+#include "ui/gfx/x/x11_types.h"
// XIScrollClass was introduced in XI 2.1 so we need to define it here
// for backward-compatibility with older versions of XInput.
@@ -116,12 +116,14 @@ DeviceDataManager* DeviceDataManager::GetInstance() {
DeviceDataManager::DeviceDataManager()
: natural_scroll_enabled_(false),
- atom_cache_(gfx::GetXDisplay(), kCachedAtoms) {
+ atom_cache_(gfx::GetXDisplay(), kCachedAtoms),
+ button_map_count_(0) {
InitializeXInputInternal();
// Make sure the sizes of enum and kCachedAtoms are aligned.
CHECK(arraysize(kCachedAtoms) == static_cast<size_t>(DT_LAST_ENTRY) + 1);
UpdateDeviceList(gfx::GetXDisplay());
+ UpdateButtonMap();
}
DeviceDataManager::~DeviceDataManager() {
@@ -509,6 +511,17 @@ void DeviceDataManager::GetMetricsData(const base::NativeEvent& native_event,
*data2 = data[DT_CMT_METRICS_DATA2];
}
+int DeviceDataManager::GetMappedButton(int button) {
+ return button > 0 && button <= button_map_count_ ? button_map_[button - 1] :
+ button;
+}
+
+void DeviceDataManager::UpdateButtonMap() {
+ button_map_count_ = XGetPointerMapping(gfx::GetXDisplay(),
+ button_map_,
+ arraysize(button_map_));
+}
+
void DeviceDataManager::GetGestureTimes(const base::NativeEvent& native_event,
double* start_time,
double* end_time) {
diff --git a/ui/base/x/device_data_manager.h b/ui/events/x/device_data_manager.h
index f07012f..1d78b14 100644
--- a/ui/base/x/device_data_manager.h
+++ b/ui/events/x/device_data_manager.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_BASE_X_DEVICE_DATA_MANAGER_H_
-#define UI_BASE_X_DEVICE_DATA_MANAGER_H_
+#ifndef UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
+#define UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
#include <X11/extensions/XInput2.h>
@@ -13,9 +13,9 @@
#include "base/basictypes.h"
#include "base/event_types.h"
-#include "ui/base/ui_export.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/events/event_constants.h"
+#include "ui/events/events_export.h"
+#include "ui/gfx/x/x11_atom_cache.h"
template <typename T> struct DefaultSingletonTraits;
@@ -31,7 +31,7 @@ enum GestureMetricsType {
// A class that extracts and tracks the input events data. It currently handles
// mouse, touchpad and touchscreen devices.
-class UI_EXPORT DeviceDataManager {
+class EVENTS_EXPORT DeviceDataManager {
public:
// Enumerate additional data that one might be interested on an input event,
// which are usually wrapped in X valuators. If you modify any of this,
@@ -193,6 +193,13 @@ class UI_EXPORT DeviceDataManager {
float* data1,
float* data2);
+ // Returns the mapped button.
+ int GetMappedButton(int button);
+
+ // Updates button mapping. This is usually called when a MappingNotify event
+ // is received.
+ void UpdateButtonMap();
+
// Extract the start/end timestamps from CMT events. User must first verify
// the event with HasGestureTimes. Pointers shouldn't be NULL.
void GetGestureTimes(const base::NativeEvent& native_event,
@@ -285,9 +292,12 @@ class UI_EXPORT DeviceDataManager {
// X11 atoms cache.
X11AtomCache atom_cache_;
+ unsigned char button_map_[256];
+ int button_map_count_;
+
DISALLOW_COPY_AND_ASSIGN(DeviceDataManager);
};
} // namespace ui
-#endif // UI_BASE_X_DEVICE_DATA_MANAGER_H_
+#endif // UI_EVENTS_X_DEVICE_DATA_MANAGER_H_
diff --git a/ui/base/x/device_list_cache_x.cc b/ui/events/x/device_list_cache_x.cc
index 9fcb9db..db0846d 100644
--- a/ui/base/x/device_list_cache_x.cc
+++ b/ui/events/x/device_list_cache_x.cc
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/x/device_list_cache_x.h"
+#include "ui/events/x/device_list_cache_x.h"
#include <algorithm>
#include "base/memory/singleton.h"
-#include "ui/base/x/x11_util.h"
namespace ui {
diff --git a/ui/base/x/device_list_cache_x.h b/ui/events/x/device_list_cache_x.h
index 2b3cefa..f68803a 100644
--- a/ui/base/x/device_list_cache_x.h
+++ b/ui/events/x/device_list_cache_x.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_BASE_X_DEVICE_LIST_CACHE_X_H_
-#define UI_BASE_X_DEVICE_LIST_CACHE_X_H_
+#ifndef UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_
+#define UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_
#include <X11/extensions/XInput.h>
#include <X11/extensions/XInput2.h>
@@ -11,7 +11,7 @@
#include <map>
#include "base/basictypes.h"
-#include "ui/base/ui_export.h"
+#include "ui/events/events_export.h"
template <typename T> struct DefaultSingletonTraits;
@@ -36,7 +36,7 @@ namespace ui {
// A class to cache the current XInput device list. This minimized the
// round-trip time to the X server whenever such a device list is needed. The
// update function will be called on each incoming XI_HierarchyChanged event.
-class UI_EXPORT DeviceListCacheX {
+class EVENTS_EXPORT DeviceListCacheX {
public:
static DeviceListCacheX* GetInstance();
@@ -59,5 +59,5 @@ class UI_EXPORT DeviceListCacheX {
} // namespace ui
-#endif // UI_BASE_X_DEVICE_LIST_CACHE_X_H_
+#endif // UI_EVENTS_X_DEVICE_LIST_CACHE_X_H_
diff --git a/ui/base/x/events_x.cc b/ui/events/x/events_x.cc
index 06301a9..4317a7b 100644
--- a/ui/base/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -13,16 +13,16 @@
#include "base/memory/singleton.h"
#include "base/message_loop/message_pump_x11.h"
#include "ui/base/touch/touch_factory_x11.h"
-#include "ui/base/x/device_data_manager.h"
-#include "ui/base/x/device_list_cache_x.h"
-#include "ui/base/x/x11_atom_cache.h"
-#include "ui/base/x/x11_util.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
+#include "ui/events/x/device_data_manager.h"
+#include "ui/events/x/device_list_cache_x.h"
#include "ui/gfx/display.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
+#include "ui/gfx/x/x11_atom_cache.h"
+#include "ui/gfx/x/x11_types.h"
namespace {
@@ -173,7 +173,7 @@ int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) {
if (XIMaskIsSet(xievent->buttons.mask, i)) {
int button = (xievent->sourceid == xievent->deviceid) ?
- ui::GetMappedButton(i) : i;
+ ui::DeviceDataManager::GetInstance()->GetMappedButton(i) : i;
buttonflags |= GetEventFlagsForButton(button);
}
}
@@ -501,7 +501,7 @@ int EventButtonFromNative(const base::NativeEvent& native_event) {
int button = xievent->detail;
return (xievent->sourceid == xievent->deviceid) ?
- ui::GetMappedButton(button) : button;
+ DeviceDataManager::GetInstance()->GetMappedButton(button) : button;
}
KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
diff --git a/ui/base/x/events_x_unittest.cc b/ui/events/x/events_x_unittest.cc
index 3a85a0a..c3e2d22 100644
--- a/ui/base/x/events_x_unittest.cc
+++ b/ui/events/x/events_x_unittest.cc
@@ -13,10 +13,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/touch/touch_factory_x11.h"
-#include "ui/base/x/device_data_manager.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
+#include "ui/events/x/device_data_manager.h"
#include "ui/gfx/point.h"
namespace ui {
diff --git a/ui/events/x/events_x_utils.cc b/ui/events/x/events_x_utils.cc
new file mode 100644
index 0000000..6fe9e2d
--- /dev/null
+++ b/ui/events/x/events_x_utils.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/x/events_x_utils.h"
+
+#include <X11/keysym.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+
+#include "base/logging.h"
+#include "ui/events/keycodes/keyboard_code_conversion_x.h"
+
+namespace {
+
+// Converts ui::EventType to XKeyEvent state.
+unsigned int XKeyEventState(int flags) {
+ return
+ ((flags & ui::EF_SHIFT_DOWN) ? ShiftMask : 0) |
+ ((flags & ui::EF_CONTROL_DOWN) ? ControlMask : 0) |
+ ((flags & ui::EF_ALT_DOWN) ? Mod1Mask : 0) |
+ ((flags & ui::EF_CAPS_LOCK_DOWN) ? LockMask : 0);
+}
+
+// Converts EventType to XKeyEvent type.
+int XKeyEventType(ui::EventType type) {
+ switch (type) {
+ case ui::ET_KEY_PRESSED:
+ return KeyPress;
+ case ui::ET_KEY_RELEASED:
+ return KeyRelease;
+ default:
+ return 0;
+ }
+}
+
+// Converts KeyboardCode to XKeyEvent keycode.
+unsigned int XKeyEventKeyCode(ui::KeyboardCode key_code,
+ int flags,
+ XDisplay* display) {
+ const int keysym = XKeysymForWindowsKeyCode(key_code,
+ flags & ui::EF_SHIFT_DOWN);
+ // Tests assume the keycode for XK_less is equal to the one of XK_comma,
+ // but XKeysymToKeycode returns 94 for XK_less while it returns 59 for
+ // XK_comma. Here we convert the value for XK_less to the value for XK_comma.
+ return (keysym == XK_less) ? 59 : XKeysymToKeycode(display, keysym);
+}
+
+} // namespace ui
+
+namespace ui {
+
+void InitXKeyEventForTesting(EventType type,
+ KeyboardCode key_code,
+ int flags,
+ XEvent* event) {
+ CHECK(event);
+ XDisplay* display = gfx::GetXDisplay();
+ XKeyEvent key_event;
+ key_event.type = XKeyEventType(type);
+ CHECK_NE(0, key_event.type);
+ key_event.serial = 0;
+ key_event.send_event = 0;
+ key_event.display = display;
+ key_event.time = 0;
+ key_event.window = 0;
+ key_event.root = 0;
+ key_event.subwindow = 0;
+ key_event.x = 0;
+ key_event.y = 0;
+ key_event.x_root = 0;
+ key_event.y_root = 0;
+ key_event.state = XKeyEventState(flags);
+ key_event.keycode = XKeyEventKeyCode(key_code, flags, display);
+ key_event.same_screen = 1;
+ event->type = key_event.type;
+ event->xkey = key_event;
+}
+
+} // namespace ui
diff --git a/ui/events/x/events_x_utils.h b/ui/events/x/events_x_utils.h
new file mode 100644
index 0000000..2e1a441
--- /dev/null
+++ b/ui/events/x/events_x_utils.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/event_constants.h"
+#include "ui/events/events_export.h"
+#include "ui/events/keycodes/keyboard_codes.h"
+#include "ui/gfx/x/x11_types.h"
+
+typedef union _XEvent XEvent;
+
+namespace ui {
+
+// Initializes a XEvent that holds XKeyEvent for testing. Note that ui::EF_
+// flags should be passed as |flags|, not the native ones in <X11/X.h>.
+EVENTS_EXPORT void InitXKeyEventForTesting(EventType type,
+ KeyboardCode key_code,
+ int flags,
+ XEvent* event);
+
+} // namespace ui
diff --git a/ui/base/x/x11_atom_cache.cc b/ui/gfx/x/x11_atom_cache.cc
index 09e59f1..da75c0be 100644
--- a/ui/base/x/x11_atom_cache.cc
+++ b/ui/gfx/x/x11_atom_cache.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/x/x11_atom_cache.h"
+#include "ui/gfx/x/x11_atom_cache.h"
#include <X11/Xatom.h>
diff --git a/ui/base/x/x11_atom_cache.h b/ui/gfx/x/x11_atom_cache.h
index b15744b..fefa642 100644
--- a/ui/base/x/x11_atom_cache.h
+++ b/ui/gfx/x/x11_atom_cache.h
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_BASE_X_X11_ATOM_CACHE_H_
-#define UI_BASE_X_X11_ATOM_CACHE_H_
+#ifndef UI_GFX_X_X11_ATOM_CACHE_H_
+#define UI_GFX_X_X11_ATOM_CACHE_H_
#include "base/basictypes.h"
-#include "ui/base/ui_export.h"
-
-#include <X11/Xlib.h>
+#include "ui/gfx/gfx_export.h"
#include <map>
#include <string>
+#include <X11/Xlib.h>
+
// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
#undef RootWindow
@@ -22,7 +22,7 @@ namespace ui {
// server. By default, GetAtom() will CHECK() that atoms accessed through
// GetAtom() were passed to the constructor, but this behaviour can be changed
// with allow_uncached_atoms().
-class UI_EXPORT X11AtomCache {
+class GFX_EXPORT X11AtomCache {
public:
// Preinterns the NULL terminated list of string |to_cache_ on |xdisplay|.
X11AtomCache(Display* xdisplay, const char** to_cache);
@@ -47,4 +47,4 @@ class UI_EXPORT X11AtomCache {
} // namespace ui
-#endif // UI_BASE_X_X11_ATOM_CACHE_H_
+#endif // UI_GFX_X_X11_ATOM_CACHE_H_
diff --git a/ui/ui.gyp b/ui/ui.gyp
index 316617a..137b5f0 100644
--- a/ui/ui.gyp
+++ b/ui/ui.gyp
@@ -297,7 +297,7 @@
'base/win/accessibility_misc_utils.cc',
'base/win/accessibility_misc_utils.h',
'base/win/atl_module.h',
- 'base/win/events_win.cc',
+ 'events/win/events_win.cc',
'base/win/extra_sdk_defines.h',
'base/win/foreground_helper.cc',
'base/win/foreground_helper.h',
@@ -321,11 +321,13 @@
'base/x/active_window_watcher_x.cc',
'base/x/active_window_watcher_x.h',
'base/x/active_window_watcher_x_observer.h',
- 'base/x/device_data_manager.cc',
- 'base/x/device_data_manager.h',
- 'base/x/device_list_cache_x.cc',
- 'base/x/device_list_cache_x.h',
- 'base/x/events_x.cc',
+ 'events/x/device_data_manager.cc',
+ 'events/x/device_data_manager.h',
+ 'events/x/device_list_cache_x.cc',
+ 'events/x/device_list_cache_x.h',
+ 'events/x/events_x.cc',
+ 'events/x/events_x_utils.cc',
+ 'events/x/events_x_utils.h',
'base/x/root_window_property_watcher_x.cc',
'base/x/root_window_property_watcher_x.h',
'base/x/selection_owner.cc',
@@ -336,8 +338,6 @@
'base/x/selection_utils.h',
'base/x/work_area_watcher_x.cc',
'base/x/work_area_watcher_x.h',
- 'base/x/x11_atom_cache.cc',
- 'base/x/x11_atom_cache.h',
'base/x/x11_error_tracker.cc',
'base/x/x11_error_tracker.h',
'base/x/x11_error_tracker_gtk.cc',
@@ -609,6 +609,8 @@
'gfx/win/singleton_hwnd.h',
'gfx/win/window_impl.cc',
'gfx/win/window_impl.h',
+ 'gfx/x/x11_atom_cache.cc',
+ 'gfx/x/x11_atom_cache.h',
'gfx/x/x11_types.cc',
'gfx/x/x11_types.h',
'webui/jstemplate_builder.cc',
@@ -879,6 +881,7 @@
'sources/': [
['exclude', 'events/keycodes/keyboard_code_conversion_x.*'],
['exclude', 'base/x/*'],
+ ['exclude', 'events/x/*'],
],
}],
['use_ozone==0', {
@@ -890,7 +893,6 @@
}],
['toolkit_views==0', {
'sources!': [
- 'base/x/events_x.cc',
'base/dragdrop/drop_target_event.cc',
'base/dragdrop/drop_target_event.h',
'events/event.cc',
@@ -901,6 +903,7 @@
'events/event_handler.h',
'events/event_target.cc',
'events/event_target.h',
+ 'events/x/events_x.cc',
],
}],
['OS=="android"', {
diff --git a/ui/ui_unittests.gypi b/ui/ui_unittests.gypi
index 18265d4..3cd7477 100644
--- a/ui/ui_unittests.gypi
+++ b/ui/ui_unittests.gypi
@@ -240,7 +240,7 @@
}],
['OS == "linux" and toolkit_views==1', {
'sources': [
- 'base/x/events_x_unittest.cc',
+ 'events/x/events_x_unittest.cc',
],
}],
['OS != "mac" and OS != "ios"', {
diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h
index 0ebbb95..5913972 100644
--- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h
+++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h
@@ -18,8 +18,8 @@
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/window_observer.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/gfx/point.h"
+#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h"
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
index 1610558..eaf36e4 100644
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
@@ -23,6 +23,7 @@
#include "ui/base/touch/touch_factory_x11.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/event_utils.h"
+#include "ui/events/x/device_data_manager.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/path_x11.h"
#include "ui/native_theme/native_theme.h"
@@ -1264,7 +1265,7 @@ bool DesktopRootWindowHostX11::Dispatch(const base::NativeEvent& event) {
root_window_->OnKeyboardMappingChanged();
break;
case MappingPointer:
- ui::UpdateButtonMap();
+ ui::DeviceDataManager::GetInstance()->UpdateButtonMap();
break;
default:
NOTIMPLEMENTED() << " Unknown request: " << xev->xmapping.request;
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h
index ded7e98..1c5e196 100644
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h
@@ -16,8 +16,8 @@
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/root_window_host.h"
#include "ui/base/cursor/cursor_loader_x11.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/desktop_root_window_host.h"
diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.h b/ui/views/widget/desktop_aura/x11_desktop_handler.h
index e84b6d4..577827e 100644
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.h
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.h
@@ -11,7 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "ui/aura/env_observer.h"
-#include "ui/base/x/x11_atom_cache.h"
+#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/views_export.h"
diff --git a/ui/views/widget/desktop_aura/x11_window_event_filter.h b/ui/views/widget/desktop_aura/x11_window_event_filter.h
index 9fab5a6..ee4d37b 100644
--- a/ui/views/widget/desktop_aura/x11_window_event_filter.h
+++ b/ui/views/widget/desktop_aura/x11_window_event_filter.h
@@ -11,8 +11,8 @@
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
-#include "ui/base/x/x11_atom_cache.h"
#include "ui/events/event_handler.h"
+#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/views_export.h"