diff options
author | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 23:40:13 +0000 |
---|---|---|
committer | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-06 23:40:13 +0000 |
commit | b58419fd72fd62502af0d1fdd905020d78eb52a0 (patch) | |
tree | c91373621a770234eb17b62623cfaec8d9231cdf | |
parent | a9dc7a06ab0608806a76ff9dfafa8f09126eeefd (diff) | |
download | chromium_src-b58419fd72fd62502af0d1fdd905020d78eb52a0.zip chromium_src-b58419fd72fd62502af0d1fdd905020d78eb52a0.tar.gz chromium_src-b58419fd72fd62502af0d1fdd905020d78eb52a0.tar.bz2 |
Revert 233414 "x11: Move XInput2 availability information out of..."
> x11: Move XInput2 availability information out of the message pump.
>
> BUG=302696
> R=darin@chromium.org, derat@chromium.org
>
> Review URL: https://codereview.chromium.org/52823002
TBR=sadrul@chromium.org
Review URL: https://codereview.chromium.org/63443002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233416 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/message_loop/message_pump_x11.cc | 12 | ||||
-rw-r--r-- | base/message_loop/message_pump_x11.h | 3 | ||||
-rw-r--r-- | ui/aura/root_window_host_x11.cc | 6 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 4 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 4 | ||||
-rw-r--r-- | ui/events/x/device_data_manager.cc | 20 | ||||
-rw-r--r-- | ui/events/x/device_data_manager.h | 3 | ||||
-rw-r--r-- | ui/events/x/device_list_cache_x.cc | 12 | ||||
-rw-r--r-- | ui/events/x/device_list_cache_x.h | 9 | ||||
-rw-r--r-- | ui/events/x/touch_factory_x11.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc | 3 |
11 files changed, 30 insertions, 54 deletions
diff --git a/base/message_loop/message_pump_x11.cc b/base/message_loop/message_pump_x11.cc index 35dcc04..dd8b965e 100644 --- a/base/message_loop/message_pump_x11.cc +++ b/base/message_loop/message_pump_x11.cc @@ -53,7 +53,7 @@ GSourceFuncs XSourceFuncs = { Display* g_xdisplay = NULL; int g_xinput_opcode = -1; -bool InitializeXInput2() { +bool InitializeXInput2Internal() { Display* display = MessagePumpX11::GetDefaultXDisplay(); if (!display) return false; @@ -97,6 +97,11 @@ Window FindEventTarget(const NativeEvent& xev) { return target; } +bool InitializeXInput2() { + static bool xinput2_supported = InitializeXInput2Internal(); + return xinput2_supported; +} + bool InitializeXkb() { Display* display = MessagePumpX11::GetDefaultXDisplay(); if (!display) @@ -148,6 +153,11 @@ Display* MessagePumpX11::GetDefaultXDisplay() { return g_xdisplay; } +// static +bool MessagePumpX11::HasXInput2() { + return InitializeXInput2(); +} + #if defined(TOOLKIT_GTK) // static MessagePumpX11* MessagePumpX11::Current() { diff --git a/base/message_loop/message_pump_x11.h b/base/message_loop/message_pump_x11.h index 015c230..f1f678a 100644 --- a/base/message_loop/message_pump_x11.h +++ b/base/message_loop/message_pump_x11.h @@ -40,6 +40,9 @@ class BASE_EXPORT MessagePumpX11 : public MessagePumpGlib, // Returns default X Display. static Display* GetDefaultXDisplay(); + // Returns true if the system supports XINPUT2. + static bool HasXInput2(); + // Returns the UI or GPU message pump. static MessagePumpX11* Current(); diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc index 4e7e774..65dde3b 100644 --- a/ui/aura/root_window_host_x11.cc +++ b/ui/aura/root_window_host_x11.cc @@ -97,7 +97,7 @@ void SelectEventsForRootWindow() { StructureNotifyMask | attr.your_event_mask); } - if (!ui::IsXInput2Available()) + if (!base::MessagePumpForUI::HasXInput2()) return; unsigned char mask[XIMaskLen(XI_LASTEVENT)] = {}; @@ -398,7 +398,7 @@ RootWindowHostX11::RootWindowHostX11(const gfx::Rect& bounds) XSelectInput(xdisplay_, xwindow_, event_mask); XFlush(xdisplay_); - if (ui::IsXInput2Available()) + if (base::MessagePumpForUI::HasXInput2()) ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); SelectEventsForRootWindow(); @@ -1057,8 +1057,6 @@ void RootWindowHostX11::UpdateIsInternalDisplay() { void RootWindowHostX11::SetCrOSTapPaused(bool state) { #if defined(OS_CHROMEOS) - if (!ui::IsXInput2Available()) - return; // Temporarily pause tap-to-click when the cursor is hidden. Atom prop = atom_cache_.GetAtom("Tap Paused"); unsigned char value = state; diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 3d051dd..812fcf5 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -266,10 +266,6 @@ bool XDisplayExists() { return (gfx::GetXDisplay() != NULL); } -bool IsXInput2Available() { - return DeviceDataManager::GetInstance()->IsXInput2Available(); -} - static SharedMemorySupport DoQuerySharedMemorySupport(XDisplay* dpy) { int dummy; Bool pixmaps_supported; diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index 9cc8e4d9..5f3e502 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -51,9 +51,7 @@ namespace ui { // Check if there's an open connection to an X server. UI_EXPORT bool XDisplayExists(); - -// Returns true if the system supports XINPUT2. -UI_EXPORT bool IsXInput2Available(); +// Return an X11 connection for the current, primary display. // X shared memory comes in three flavors: // 1) No SHM support, diff --git a/ui/events/x/device_data_manager.cc b/ui/events/x/device_data_manager.cc index 9858ccc..d97b7f3 100644 --- a/ui/events/x/device_data_manager.cc +++ b/ui/events/x/device_data_manager.cc @@ -112,10 +112,8 @@ DeviceDataManager* DeviceDataManager::GetInstance() { DeviceDataManager::DeviceDataManager() : natural_scroll_enabled_(false), - xi_opcode_(-1), atom_cache_(gfx::GetXDisplay(), kCachedAtoms), button_map_count_(0) { - CHECK(gfx::GetXDisplay()); InitializeXInputInternal(); // Make sure the sizes of enum and kCachedAtoms are aligned. @@ -136,6 +134,7 @@ bool DeviceDataManager::InitializeXInputInternal() { VLOG(1) << "X Input extension not available: error=" << error; return false; } + xi_opcode_ = opcode; // Check the XInput version. #if defined(USE_XI2_MT) @@ -147,16 +146,6 @@ bool DeviceDataManager::InitializeXInputInternal() { VLOG(1) << "XInput2 not supported in the server."; return false; } -#if defined(USE_XI2_MT) - if (major < 2 || (major == 2 && minor < USE_XI2_MT)) { - DVLOG(1) << "XI version on server is " << major << "." << minor << ". " - << "But 2." << USE_XI2_MT << " is required."; - return false; - } -#endif - - xi_opcode_ = opcode; - CHECK_NE(-1, xi_opcode_); // Possible XI event types for XIDeviceEvent. See the XI2 protocol // specification. @@ -174,10 +163,6 @@ bool DeviceDataManager::InitializeXInputInternal() { return true; } -bool DeviceDataManager::IsXInput2Available() const { - return xi_opcode_ != -1; -} - float DeviceDataManager::GetNaturalScrollFactor(int sourceid) const { // Natural scroll is touchpad-only. if (sourceid >= kMaxDeviceNum || !touchpads_[sourceid]) @@ -207,9 +192,6 @@ void DeviceDataManager::UpdateDeviceList(Display* display) { if (dev_list[i].type == xi_touchpad) touchpads_[dev_list[i].id] = true; - if (!IsXInput2Available()) - return; - // Update the structs with new valuator information XIDeviceList info_list = ui::DeviceListCacheX::GetInstance()->GetXI2DeviceList(display); diff --git a/ui/events/x/device_data_manager.h b/ui/events/x/device_data_manager.h index 8fed194..399bef9 100644 --- a/ui/events/x/device_data_manager.h +++ b/ui/events/x/device_data_manager.h @@ -103,9 +103,6 @@ class EVENTS_EXPORT DeviceDataManager { natural_scroll_enabled_ = enabled; } - // Returns if XInput2 is available on the system. - bool IsXInput2Available() const; - // Get the natural scroll direction multiplier (1.0f or -1.0f). float GetNaturalScrollFactor(int sourceid) const; diff --git a/ui/events/x/device_list_cache_x.cc b/ui/events/x/device_list_cache_x.cc index 266ee6a..e2eb5ee 100644 --- a/ui/events/x/device_list_cache_x.cc +++ b/ui/events/x/device_list_cache_x.cc @@ -8,13 +8,12 @@ #include "base/memory/singleton.h" #include "base/message_loop/message_loop.h" -#include "ui/events/x/device_data_manager.h" namespace { bool IsXI2Available() { #if defined(USE_AURA) - return ui::DeviceDataManager::GetInstance()->IsXInput2Available(); + return base::MessagePumpForUI::HasXInput2(); #else return false; #endif @@ -24,7 +23,8 @@ bool IsXI2Available() { namespace ui { -DeviceListCacheX::DeviceListCacheX() { +DeviceListCacheX::DeviceListCacheX() + : xi2_(IsXI2Available()) { } DeviceListCacheX::~DeviceListCacheX() { @@ -53,8 +53,8 @@ void DeviceListCacheX::UpdateDeviceList(Display* display) { XIDeviceList& new_xi_dev_list = xi_dev_list_map_[display]; if (new_xi_dev_list.devices) XIFreeDeviceInfo(new_xi_dev_list.devices); - new_xi_dev_list.devices = IsXI2Available() ? - XIQueryDevice(display, XIAllDevices, &new_xi_dev_list.count) : NULL; + new_xi_dev_list.devices = xi2_ ? XIQueryDevice(display, XIAllDevices, + &new_xi_dev_list.count) : NULL; } const XDeviceList& DeviceListCacheX::GetXDeviceList(Display* display) { @@ -67,7 +67,7 @@ const XDeviceList& DeviceListCacheX::GetXDeviceList(Display* display) { const XIDeviceList& DeviceListCacheX::GetXI2DeviceList(Display* display) { XIDeviceList& xi_dev_list = xi_dev_list_map_[display]; - if (!xi_dev_list.devices && !xi_dev_list.count) { + if (xi2_ && !xi_dev_list.devices && !xi_dev_list.count) { xi_dev_list.devices = XIQueryDevice(display, XIAllDevices, &xi_dev_list.count); } diff --git a/ui/events/x/device_list_cache_x.h b/ui/events/x/device_list_cache_x.h index 8a31c06..12ce718 100644 --- a/ui/events/x/device_list_cache_x.h +++ b/ui/events/x/device_list_cache_x.h @@ -42,14 +42,7 @@ class EVENTS_EXPORT DeviceListCacheX { void UpdateDeviceList(Display* display); - // Returns the list of devices associated with |display|. Uses the old X11 - // protocol to get the list of the devices. const XDeviceList& GetXDeviceList(Display* display); - - // Returns the list of devices associated with |display|. Uses the newer - // XINPUT2 protocol to get the list of devices. Before making this call, make - // sure that XInput2 support is available (e.g. by calling - // IsXInput2Available()). const XIDeviceList& GetXI2DeviceList(Display* display); private: @@ -61,6 +54,8 @@ class EVENTS_EXPORT DeviceListCacheX { std::map<Display*, XDeviceList> x_dev_list_map_; std::map<Display*, XIDeviceList> xi_dev_list_map_; + bool xi2_; + DISALLOW_COPY_AND_ASSIGN(DeviceListCacheX); }; diff --git a/ui/events/x/touch_factory_x11.cc b/ui/events/x/touch_factory_x11.cc index 84066e3..59fc8f1 100644 --- a/ui/events/x/touch_factory_x11.cc +++ b/ui/events/x/touch_factory_x11.cc @@ -18,7 +18,6 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "ui/events/event_switches.h" -#include "ui/events/x/device_data_manager.h" #include "ui/events/x/device_list_cache_x.h" #include "ui/gfx/x/x11_types.h" @@ -30,8 +29,10 @@ TouchFactory::TouchFactory() touch_events_disabled_(false), touch_device_list_(), id_generator_(0) { - if (!DeviceDataManager::GetInstance()->IsXInput2Available()) +#if defined(USE_AURA) + if (!base::MessagePumpForUI::HasXInput2()) return; +#endif XDisplay* display = gfx::GetXDisplay(); UpdateDeviceList(display); @@ -100,9 +101,6 @@ void TouchFactory::UpdateDeviceList(Display* display) { } #endif - if (!DeviceDataManager::GetInstance()->IsXInput2Available()) - return; - // Instead of asking X for the list of devices all the time, let's maintain a // list of pointer devices we care about. // It should not be necessary to select for slave devices. XInput2 provides 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 3fc6c98..757b509 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 @@ -25,7 +25,6 @@ #include "ui/base/x/x11_util.h" #include "ui/events/event_utils.h" #include "ui/events/x/device_data_manager.h" -#include "ui/events/x/device_list_cache_x.h" #include "ui/events/x/touch_factory_x11.h" #include "ui/gfx/insets.h" #include "ui/gfx/path.h" @@ -935,7 +934,7 @@ void DesktopRootWindowHostX11::InitX11Window( XSelectInput(xdisplay_, xwindow_, event_mask); XFlush(xdisplay_); - if (ui::IsXInput2Available()) + if (base::MessagePumpForUI::HasXInput2()) ui::TouchFactory::GetInstance()->SetupXI2ForXWindow(xwindow_); // TODO(erg): We currently only request window deletion events. We also |