From 72219879d9b13592db9d0c0c118fa9be1254c157 Mon Sep 17 00:00:00 2001 From: "sadrul@chromium.org" Date: Mon, 7 Apr 2014 13:35:37 +0000 Subject: [PATCH] aura: Remove DeviceListUpdaterAuraX11. Have the X11EventSource take care of updating the device-list when it receives an XI_HierarchyChanged event from the X server, instead of installing an observer on the message-pump from Env. BUG=354062 R=sky@chromium.org Review URL: https://codereview.chromium.org/225093014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262119 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/aura/aura.gyp | 2 -- ui/aura/device_list_updater_aurax11.cc | 30 ------------------------------ ui/aura/device_list_updater_aurax11.h | 30 ------------------------------ ui/aura/env.cc | 15 --------------- ui/aura/env.h | 8 -------- ui/events/platform/x11/x11_event_source.cc | 6 ++++++ 6 files changed, 6 insertions(+), 85 deletions(-) delete mode 100644 ui/aura/device_list_updater_aurax11.cc delete mode 100644 ui/aura/device_list_updater_aurax11.h diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 6bf7b2efdc9b..9a910a28ba79 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -54,8 +54,6 @@ 'client/window_stacking_client.h', 'client/window_tree_client.cc', 'client/window_tree_client.h', - 'device_list_updater_aurax11.cc', - 'device_list_updater_aurax11.h', 'env.cc', 'env.h', 'env_observer.h', diff --git a/ui/aura/device_list_updater_aurax11.cc b/ui/aura/device_list_updater_aurax11.cc deleted file mode 100644 index 0bbde9edadcd..000000000000 --- a/ui/aura/device_list_updater_aurax11.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2012 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/aura/device_list_updater_aurax11.h" - -#include - -#include "ui/events/event_utils.h" - -namespace aura { - -DeviceListUpdaterAuraX11::DeviceListUpdaterAuraX11() {} - -DeviceListUpdaterAuraX11::~DeviceListUpdaterAuraX11() {} - -void DeviceListUpdaterAuraX11::WillProcessEvent( - const base::NativeEvent& event) { - // XI_HierarchyChanged events are special. There is no window associated with - // these events. So process them directly from here. - if (event->type == GenericEvent && - event->xgeneric.evtype == XI_HierarchyChanged) { - ui::UpdateDeviceList(); - } -} - -void DeviceListUpdaterAuraX11::DidProcessEvent(const base::NativeEvent& event) { -} - -} // namespace aura diff --git a/ui/aura/device_list_updater_aurax11.h b/ui/aura/device_list_updater_aurax11.h deleted file mode 100644 index 015dcb1aa118..000000000000 --- a/ui/aura/device_list_updater_aurax11.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef UI_AURA_DEVICE_LIST_UPDATER_AURAX11_H_ -#define UI_AURA_DEVICE_LIST_UPDATER_AURAX11_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/message_loop/message_pump_observer.h" - -namespace aura { - -// Filters out global XInput notifications and updates the DeviceList. -class DeviceListUpdaterAuraX11 : public base::MessagePumpObserver { - public: - DeviceListUpdaterAuraX11(); - virtual ~DeviceListUpdaterAuraX11(); - - // Overridden from base::MessagePumpObserver: - virtual void WillProcessEvent(const base::NativeEvent& event) OVERRIDE; - virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(DeviceListUpdaterAuraX11); -}; - -} // namespace aura - -#endif // UI_AURA_DEVICE_LIST_UPDATER_AURAX11_H_ diff --git a/ui/aura/env.cc b/ui/aura/env.cc index 21b4213d33f2..7e25c4c5b2ce 100644 --- a/ui/aura/env.cc +++ b/ui/aura/env.cc @@ -13,10 +13,6 @@ #include "ui/compositor/compositor_switches.h" #include "ui/events/event_target_iterator.h" -#if defined(USE_X11) -#include "base/message_loop/message_pump_x11.h" -#endif - namespace aura { // static @@ -32,11 +28,6 @@ Env::Env() } Env::~Env() { -#if defined(USE_X11) - base::MessagePumpX11::Current()->RemoveObserver( - &device_list_updater_aurax11_); -#endif - FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); ui::Compositor::Terminate(); @@ -80,12 +71,6 @@ bool Env::IsMouseButtonDown() const { // Env, private: void Env::Init() { -#if defined(USE_X11) - // We can't do this with a root window listener because XI_HierarchyChanged - // messages don't have a target window. - base::MessagePumpX11::Current()->AddObserver( - &device_list_updater_aurax11_); -#endif ui::Compositor::Initialize(); } diff --git a/ui/aura/env.h b/ui/aura/env.h index 901078181d3f..68576ec51af2 100644 --- a/ui/aura/env.h +++ b/ui/aura/env.h @@ -12,10 +12,6 @@ #include "ui/events/event_target.h" #include "ui/gfx/point.h" -#if defined(USE_X11) -#include "ui/aura/device_list_updater_aurax11.h" -#endif - namespace aura { namespace test { @@ -88,10 +84,6 @@ class AURA_EXPORT Env : public ui::EventTarget { gfx::Point last_mouse_location_; bool is_touch_down_; -#if defined(USE_X11) - DeviceListUpdaterAuraX11 device_list_updater_aurax11_; -#endif - scoped_ptr input_state_lookup_; DISALLOW_COPY_AND_ASSIGN(Env); diff --git a/ui/events/platform/x11/x11_event_source.cc b/ui/events/platform/x11/x11_event_source.cc index 71a3fb5a93f6..865fdb1a2c67 100644 --- a/ui/events/platform/x11/x11_event_source.cc +++ b/ui/events/platform/x11/x11_event_source.cc @@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/message_loop/message_loop.h" +#include "ui/events/event_utils.h" #include "ui/events/platform/platform_event_dispatcher.h" #include "ui/gfx/x/x11_types.h" @@ -200,6 +201,11 @@ uint32_t X11EventSource::DispatchEvent(XEvent* xevent) { uint32_t action = PlatformEventSource::DispatchEvent(xevent); base::MessagePumpX11::Current()->DidProcessXEvent(xevent); + if (xevent->type == GenericEvent && + xevent->xgeneric.evtype == XI_HierarchyChanged) { + ui::UpdateDeviceList(); + } + if (have_cookie) XFreeEventData(xevent->xgeneric.display, &xevent->xcookie); return action; -- 2.11.4.GIT