diff options
author | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 19:04:09 +0000 |
---|---|---|
committer | msw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 19:04:09 +0000 |
commit | 284145ef5545b59030bd65da2e002e54d2c1b8b6 (patch) | |
tree | bd2965395947bd846578ce437bb15c51538d2fc8 /ui/wm | |
parent | b90ab636f8cebc04e6cff488020fe28a3f4c967e (diff) | |
download | chromium_src-284145ef5545b59030bd65da2e002e54d2c1b8b6.zip chromium_src-284145ef5545b59030bd65da2e002e54d2c1b8b6.tar.gz chromium_src-284145ef5545b59030bd65da2e002e54d2c1b8b6.tar.bz2 |
Revert of Refactor and move ash independent nested accelerator code to ui/wm/core (https://codereview.chromium.org/298703007/)
Reason for revert:
caused test failures:
http://build.chromium.org/p/chromium.win/builders/Win8%20Aura/builds/19236
NestedAcceleratorTest.AcceleratorsHandled (run #1):
[ RUN ] NestedAcceleratorTest.AcceleratorsHandled
Backtrace:
ui::PlatformEventSource::OverrideDispatcher [0x0028B66D+253]
wm::test::NestedAcceleratorTest_AcceleratorsHandled_Test::TestBody [0x00455D37+215]
testing::internal::HandleExceptionsInMethodIfSupported\u003Ctesting::Test,void> [0x004D5829+329]
testing::Test::Run [0x004EFF9E+174]
testing::TestInfo::Run [0x004F023D+221]
testing::TestCase::Run [0x004F00DF+239]
testing::internal::UnitTestImpl::RunAllTests [0x004F0696+726]
testing::internal::HandleExceptionsInMethodIfSupported\u003Ctesting::internal::UnitTestImpl,bool> [0x004D5D21+337]
testing::UnitTest::Run [0x004F0393+211]
RUN_ALL_TESTS [0x004A0EDF+15]
base::TestSuite::Run [0x004A1129+233]
base::internal::RunnableAdapter\u003Cint (__thiscall base::TestSuite::*)(void)>::Run [0x004150EB+27]
base::internal::InvokeHelper\u003C0,int,base::internal::RunnableAdapter\u003Cint (__thiscall base::TestSuite::*)(void)>,void __cdecl(WMTestSuite *)>::MakeItSo [0x00414FFA+26]
base::internal::Invoker\u003C1,base::internal::BindState\u003Cbase::internal::RunnableAdapter\u003Cint (__thiscall base::TestSuite::*)(void)>,int __cdecl(base::TestSuite *),void __cdecl(base::internal::UnretainedWrapper\u003CWMTestSuite>)>,int __cdecl(base::TestSuite *)>::Ru [0x0041506A+74]
base::Callback\u003Cint __cdecl(void)>::Run [0x0049A03F+47]
base::`anonymous namespace'::LaunchUnitTestsInternal [0x004990C9+921]
base::LaunchUnitTests [0x00498D15+37]
main [0x0041681C+140]
__tmainCRTStartup [0x00647D39+409] (f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:626)
mainCRTStartup [0x00647E7D+13] (f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:466)
BaseThreadInitThunk [0x76568624+14]
RtlInitializeExceptionChain [0x773CAC69+133]
RtlInitializeExceptionChain [0x773CAC3C+88]
NestedAcceleratorTest.AssociatedWindowAboveLockScreen (run #1):
[ RUN ] NestedAcceleratorTest.AssociatedWindowAboveLockScreen
Backtrace:
ui::PlatformEventSource::OverrideDispatcher [0x0286B66D+253]
wm::test::NestedAcceleratorTest_AssociatedWindowAboveLockScreen_Test::TestBody [0x004563B5+517]
testing::internal::HandleExceptionsInMethodIfSupported\u003Ctesting::Test,void> [0x004D5829+329]
testing::Test::Run [0x004EFF9E+174]
testing::TestInfo::Run [0x004F023D+221]
testing::TestCase::Run [0x004F00DF+239]
testing::internal::UnitTestImpl::RunAllTests [0x004F0696+726]
testing::internal::HandleExceptionsInMethodIfSupported\u003Ctesting::internal::UnitTestImpl,bool> [0x004D5D21+337]
testing::UnitTest::Run [0x004F0393+211]
RUN_ALL_TESTS [0x004A0EDF+15]
base::TestSuite::Run [0x004A1129+233]
base::internal::RunnableAdapter\u003Cint (__thiscall base::TestSuite::*)(void)>::Run [0x004150EB+27]
base::internal::InvokeHelper\u003C0,int,base::internal::RunnableAdapter\u003Cint (__thiscall base::TestSuite::*)(void)>,void __cdecl(WMTestSuite *)>::MakeItSo [0x00414FFA+26]
base::internal::Invoker\u003C1,base::internal::BindState\u003Cbase::internal::RunnableAdapter\u003Cint (__thiscall base::TestSuite::*)(void)>,int __cdecl(base::TestSuite *),void __cdecl(base::internal::UnretainedWrapper\u003CWMTestSuite>)>,int __cdecl(base::TestSuite *)>::Ru [0x0041506A+74]
base::Callback\u003Cint __cdecl(void)>::Run [0x0049A03F+47]
base::`anonymous namespace'::LaunchUnitTestsInternal [0x004990C9+921]
base::LaunchUnitTests [0x00498D15+37]
main [0x0041681C+140]
__tmainCRTStartup [0x00647D39+409] (f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:626)
mainCRTStartup [0x00647E7D+13] (f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:466)
BaseThreadInitThunk [0x76568624+14]
RtlInitializeExceptionChain [0x773CAC69+133]
RtlInitializeExceptionChain [0x773CAC3C+88]
Original issue's description:
> Refactor and move ash independent accelerator handling code in nested loop to ui/wm/core
>
> I also renamed classes to NestedAcceleratorXxx. I felt this is a bit more clearer than NestedDispatcher, especially in ui/wm/core. Please let me know if you disagree or have better suggestion. I'm happy to rename them.
>
> BUG=None
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=272740
>
> R=ben@chromium.org
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=272995
TBR=ben@chromium.org,oshima@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=None
Review URL: https://codereview.chromium.org/301743002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/wm')
-rw-r--r-- | ui/wm/core/DEPS | 1 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_controller.cc | 48 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_controller.h | 43 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_controller_unittest.cc | 202 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_delegate.h | 31 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_dispatcher.cc | 21 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_dispatcher.h | 55 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_dispatcher_linux.cc | 98 | ||||
-rw-r--r-- | ui/wm/core/nested_accelerator_dispatcher_win.cc | 67 | ||||
-rw-r--r-- | ui/wm/wm.gyp | 9 |
10 files changed, 0 insertions, 575 deletions
diff --git a/ui/wm/core/DEPS b/ui/wm/core/DEPS index 8540601..54c7090 100644 --- a/ui/wm/core/DEPS +++ b/ui/wm/core/DEPS @@ -1,7 +1,6 @@ include_rules = [ "+grit/ui_resources.h", "+ui/aura", - "+ui/base/accelerators", "+ui/base/cursor", "+ui/base/hit_test.h", "+ui/base/ime", diff --git a/ui/wm/core/nested_accelerator_controller.cc b/ui/wm/core/nested_accelerator_controller.cc deleted file mode 100644 index 555b830..0000000 --- a/ui/wm/core/nested_accelerator_controller.cc +++ /dev/null @@ -1,48 +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/wm/core/nested_accelerator_controller.h" - -#include "base/auto_reset.h" -#include "base/run_loop.h" -#include "ui/wm/core/nested_accelerator_delegate.h" -#include "ui/wm/core/nested_accelerator_dispatcher.h" - -namespace wm { - -NestedAcceleratorController::NestedAcceleratorController( - NestedAcceleratorDelegate* delegate) - : dispatcher_delegate_(delegate) { - DCHECK(delegate); -} - -NestedAcceleratorController::~NestedAcceleratorController() { -} - -void NestedAcceleratorController::RunWithDispatcher( - base::MessagePumpDispatcher* nested_dispatcher) { - base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); - base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); - - scoped_ptr<NestedAcceleratorDispatcher> old_accelerator_dispatcher = - accelerator_dispatcher_.Pass(); - accelerator_dispatcher_ = NestedAcceleratorDispatcher::Create( - dispatcher_delegate_.get(), nested_dispatcher); - - // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them - // use run_loop.QuitClosure(). - scoped_ptr<base::RunLoop> run_loop = accelerator_dispatcher_->CreateRunLoop(); - base::AutoReset<base::Closure> reset_closure(&quit_closure_, - run_loop->QuitClosure()); - run_loop->Run(); - accelerator_dispatcher_ = old_accelerator_dispatcher.Pass(); -} - -void NestedAcceleratorController::QuitNestedMessageLoop() { - CHECK(!quit_closure_.is_null()); - quit_closure_.Run(); - accelerator_dispatcher_.reset(); -} - -} // namespace wm diff --git a/ui/wm/core/nested_accelerator_controller.h b/ui/wm/core/nested_accelerator_controller.h deleted file mode 100644 index 13b4a4b..0000000 --- a/ui/wm/core/nested_accelerator_controller.h +++ /dev/null @@ -1,43 +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_WM_CORE_NESTED_ACCELERATOR_CONTROLLER_H_ -#define UI_WM_CORE_NESTED_ACCELERATOR_CONTROLLER_H_ - -#include "base/callback.h" -#include "base/message_loop/message_loop.h" -#include "ui/wm/public/dispatcher_client.h" -#include "ui/wm/wm_export.h" - -namespace wm { - -class NestedAcceleratorDelegate; -class NestedAcceleratorDispatcher; - -// Creates a dispatcher which wraps another dispatcher. -// The outer dispatcher runs first and performs ash specific handling. -// If it does not consume the event it forwards the event to the nested -// dispatcher. -class WM_EXPORT NestedAcceleratorController - : public aura::client::DispatcherClient { - public: - explicit NestedAcceleratorController(NestedAcceleratorDelegate* delegate); - virtual ~NestedAcceleratorController(); - - // aura::client::DispatcherClient: - virtual void RunWithDispatcher( - base::MessagePumpDispatcher* dispatcher) OVERRIDE; - virtual void QuitNestedMessageLoop() OVERRIDE; - - private: - base::Closure quit_closure_; - scoped_ptr<NestedAcceleratorDispatcher> accelerator_dispatcher_; - scoped_ptr<NestedAcceleratorDelegate> dispatcher_delegate_; - - DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorController); -}; - -} // namespace wm - -#endif // UI_WM_CORE_NESTED_ACCELERATOR_CONTROLLER_H_ diff --git a/ui/wm/core/nested_accelerator_controller_unittest.cc b/ui/wm/core/nested_accelerator_controller_unittest.cc deleted file mode 100644 index bec5a84..0000000 --- a/ui/wm/core/nested_accelerator_controller_unittest.cc +++ /dev/null @@ -1,202 +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/wm/core/nested_accelerator_controller.h" - -#include "base/bind.h" -#include "base/event_types.h" -#include "base/message_loop/message_loop.h" -#include "ui/aura/test/aura_test_base.h" -#include "ui/aura/test/test_windows.h" -#include "ui/aura/window.h" -#include "ui/aura/window_event_dispatcher.h" -#include "ui/base/accelerators/accelerator.h" -#include "ui/base/accelerators/accelerator.h" -#include "ui/base/accelerators/accelerator_manager.h" -#include "ui/events/event_constants.h" -#include "ui/events/event_utils.h" -#include "ui/events/platform/platform_event_dispatcher.h" -#include "ui/events/platform/platform_event_source.h" -#include "ui/events/platform/scoped_event_dispatcher.h" -#include "ui/wm/core/nested_accelerator_delegate.h" -#include "ui/wm/public/dispatcher_client.h" - -#if defined(USE_X11) -#include <X11/Xlib.h> -#include "ui/events/test/events_test_utils_x11.h" -#endif // USE_X11 - -namespace wm { -namespace test { - -namespace { - -class MockDispatcher : public ui::PlatformEventDispatcher { - public: - MockDispatcher() : num_key_events_dispatched_(0) {} - - int num_key_events_dispatched() { return num_key_events_dispatched_; } - - private: - // ui::PlatformEventDispatcher: - virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE { - return true; - } - virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE { - if (ui::EventTypeFromNative(event) == ui::ET_KEY_RELEASED) - num_key_events_dispatched_++; - return ui::POST_DISPATCH_NONE; - } - - int num_key_events_dispatched_; - - DISALLOW_COPY_AND_ASSIGN(MockDispatcher); -}; - -class TestTarget : public ui::AcceleratorTarget { - public: - TestTarget() : accelerator_pressed_count_(0) {} - virtual ~TestTarget() {} - - int accelerator_pressed_count() const { return accelerator_pressed_count_; } - - // Overridden from ui::AcceleratorTarget: - virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE { - accelerator_pressed_count_++; - return true; - } - virtual bool CanHandleAccelerators() const OVERRIDE { return true; } - - private: - int accelerator_pressed_count_; - - DISALLOW_COPY_AND_ASSIGN(TestTarget); -}; - -void DispatchKeyReleaseA(aura::Window* root_window) { -// Sending both keydown and keyup is necessary here because the accelerator -// manager only checks a keyup event following a keydown event. See -// ShouldHandle() in ui/base/accelerators/accelerator_manager.cc for details. -#if defined(OS_WIN) - MSG native_event_down = {NULL, WM_KEYDOWN, ui::VKEY_A, 0}; - aura::WindowTreeHost* host = root_window->GetHost(); - host->PostNativeEvent(native_event_down); - MSG native_event_up = {NULL, WM_KEYUP, ui::VKEY_A, 0}; - host->PostNativeEvent(native_event_up); -#elif defined(USE_X11) - ui::ScopedXI2Event native_event; - native_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); - aura::WindowTreeHost* host = root_window->GetHost(); - host->PostNativeEvent(native_event); - native_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); - host->PostNativeEvent(native_event); -#endif - // Make sure the inner message-loop terminates after dispatching the events. - base::MessageLoop::current()->PostTask( - FROM_HERE, base::MessageLoop::current()->QuitClosure()); -} - -class MockNestedAcceleratorDelegate : public NestedAcceleratorDelegate { - public: - MockNestedAcceleratorDelegate() - : accelerator_manager_(new ui::AcceleratorManager) {} - virtual ~MockNestedAcceleratorDelegate() {} - - // NestedAcceleratorDelegate: - virtual bool ShouldProcessEventNow(const ui::KeyEvent& key_event) OVERRIDE { - return true; - } - virtual bool ProcessEvent(const ui::KeyEvent& key_event) OVERRIDE { - const int kModifierMask = - (ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN); - ui::Accelerator accelerator(key_event.key_code(), - key_event.flags() & kModifierMask); - if (key_event.type() == ui::ET_KEY_RELEASED) - accelerator.set_type(ui::ET_KEY_RELEASED); - return accelerator_manager_->Process(accelerator); - } - - void Register(const ui::Accelerator& accelerator, - ui::AcceleratorTarget* target) { - accelerator_manager_->Register( - accelerator, ui::AcceleratorManager::kNormalPriority, target); - } - - private: - scoped_ptr<ui::AcceleratorManager> accelerator_manager_; - - DISALLOW_COPY_AND_ASSIGN(MockNestedAcceleratorDelegate); -}; - -class NestedAcceleratorTest : public aura::test::AuraTestBase { - public: - NestedAcceleratorTest() {} - virtual ~NestedAcceleratorTest() {} - - virtual void SetUp() OVERRIDE { - AuraTestBase::SetUp(); - delegate_ = new MockNestedAcceleratorDelegate(); - nested_accelerator_controller_.reset( - new NestedAcceleratorController(delegate_)); - aura::client::SetDispatcherClient(root_window(), - nested_accelerator_controller_.get()); - } - - virtual void TearDown() OVERRIDE { - aura::client::SetDispatcherClient(root_window(), NULL); - AuraTestBase::TearDown(); - delegate_ = NULL; - nested_accelerator_controller_.reset(); - } - - MockNestedAcceleratorDelegate* delegate() { return delegate_; } - - private: - scoped_ptr<NestedAcceleratorController> nested_accelerator_controller_; - MockNestedAcceleratorDelegate* delegate_; - - DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorTest); -}; - -} // namespace - -// Aura window above lock screen in z order. -TEST_F(NestedAcceleratorTest, AssociatedWindowAboveLockScreen) { - MockDispatcher inner_dispatcher; - scoped_ptr<aura::Window> mock_lock_container( - CreateNormalWindow(0, root_window(), NULL)); - aura::test::CreateTestWindowWithId(1, mock_lock_container.get()); - - scoped_ptr<aura::Window> associated_window( - CreateNormalWindow(2, root_window(), NULL)); - EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), - mock_lock_container.get())); - - DispatchKeyReleaseA(root_window()); - scoped_ptr<ui::ScopedEventDispatcher> override_dispatcher = - ui::PlatformEventSource::GetInstance()->OverrideDispatcher( - &inner_dispatcher); - aura::client::GetDispatcherClient(root_window())->RunWithDispatcher(NULL); - EXPECT_EQ(1, inner_dispatcher.num_key_events_dispatched()); -} - -// Test that the nested dispatcher handles accelerators. -TEST_F(NestedAcceleratorTest, AcceleratorsHandled) { - MockDispatcher inner_dispatcher; - ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); - accelerator.set_type(ui::ET_KEY_RELEASED); - TestTarget target; - delegate()->Register(accelerator, &target); - - DispatchKeyReleaseA(root_window()); - scoped_ptr<ui::ScopedEventDispatcher> override_dispatcher = - ui::PlatformEventSource::GetInstance()->OverrideDispatcher( - &inner_dispatcher); - aura::client::GetDispatcherClient(root_window())->RunWithDispatcher(NULL); - EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); - EXPECT_EQ(1, target.accelerator_pressed_count()); -} - -} // namespace test -} // namespace wm diff --git a/ui/wm/core/nested_accelerator_delegate.h b/ui/wm/core/nested_accelerator_delegate.h deleted file mode 100644 index 750d92a..0000000 --- a/ui/wm/core/nested_accelerator_delegate.h +++ /dev/null @@ -1,31 +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_WM_CORE_NESTED_ACCELERATOR_DELEGATE_H_ -#define UI_WM_CORE_NESTED_ACCELERATOR_DELEGATE_H_ - -namespace ui { -class KeyEvent; -} - -namespace wm { - -// A delegate interface that implements the behavior of nested accelerator -// handling. -class NestedAcceleratorDelegate { - public: - virtual ~NestedAcceleratorDelegate() {} - - // If the key event should be ignored now and instead be reposted so that next - // event loop. - virtual bool ShouldProcessEventNow(const ui::KeyEvent& key_event) = 0; - - // Attempts to process an accelerator for the key-event. - // Returns whether an accelerator was triggered and processed. - virtual bool ProcessEvent(const ui::KeyEvent& key_event) = 0; -}; - -} // namespace wm - -#endif // UI_WM_CORE_NESTED_ACCELERATOR_DELEGATE_H_ diff --git a/ui/wm/core/nested_accelerator_dispatcher.cc b/ui/wm/core/nested_accelerator_dispatcher.cc deleted file mode 100644 index f2d98c8..0000000 --- a/ui/wm/core/nested_accelerator_dispatcher.cc +++ /dev/null @@ -1,21 +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/wm/core/nested_accelerator_dispatcher.h" - -#include "base/logging.h" -#include "ui/wm/core/nested_accelerator_delegate.h" - -namespace wm { - -NestedAcceleratorDispatcher::NestedAcceleratorDispatcher( - NestedAcceleratorDelegate* delegate) - : delegate_(delegate) { - DCHECK(delegate); -} - -NestedAcceleratorDispatcher::~NestedAcceleratorDispatcher() { -} - -} // namespace wm diff --git a/ui/wm/core/nested_accelerator_dispatcher.h b/ui/wm/core/nested_accelerator_dispatcher.h deleted file mode 100644 index 4fd8383..0000000 --- a/ui/wm/core/nested_accelerator_dispatcher.h +++ /dev/null @@ -1,55 +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_WM_CORE_NESTED_ACCELERATOR_DISPATCHER_H_ -#define UI_WM_CORE_NESTED_ACCELERATOR_DISPATCHER_H_ - -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" -#include "ui/wm/wm_export.h" - -namespace base { -class MessagePumpDispatcher; -class RunLoop; -} - -namespace ui { -class KeyEvent; -} - -namespace wm { - -class NestedAcceleratorDelegate; - -// Dispatcher for handling accelerators from menu. -// -// Wraps a nested dispatcher to which control is passed if no accelerator key -// has been pressed. If the nested dispatcher is NULL, then the control is -// passed back to the default dispatcher. -// TODO(pkotwicz): Add support for a |nested_dispatcher| which sends -// events to a system IME. -class WM_EXPORT NestedAcceleratorDispatcher { - public: - virtual ~NestedAcceleratorDispatcher(); - - static scoped_ptr<NestedAcceleratorDispatcher> Create( - NestedAcceleratorDelegate* dispatcher_delegate, - base::MessagePumpDispatcher* nested_dispatcher); - - // Creates a base::RunLoop object to run a nested message loop. - virtual scoped_ptr<base::RunLoop> CreateRunLoop() = 0; - - protected: - explicit NestedAcceleratorDispatcher(NestedAcceleratorDelegate* delegate); - - NestedAcceleratorDelegate* - delegate_; // Owned by NestedAcceleratorController. - - private: - DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcher); -}; - -} // namespace wm - -#endif // UI_WM_CORE_NESTED_ACCELERATOR_DISPATCHER_H_ diff --git a/ui/wm/core/nested_accelerator_dispatcher_linux.cc b/ui/wm/core/nested_accelerator_dispatcher_linux.cc deleted file mode 100644 index bf21d3f..0000000 --- a/ui/wm/core/nested_accelerator_dispatcher_linux.cc +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2014 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/wm/core/nested_accelerator_dispatcher.h" - -#include "base/memory/scoped_ptr.h" -#include "base/run_loop.h" -#include "ui/events/event.h" -#include "ui/events/platform/platform_event_dispatcher.h" -#include "ui/events/platform/platform_event_source.h" -#include "ui/events/platform/scoped_event_dispatcher.h" -#include "ui/wm/core/nested_accelerator_delegate.h" - -#if defined(USE_X11) -#include <X11/Xlib.h> -#endif - -namespace wm { - -namespace { - -#if defined(USE_OZONE) -bool IsKeyEvent(const base::NativeEvent& native_event) { - const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event); - return event->IsKeyEvent(); -} -#elif defined(USE_X11) -bool IsKeyEvent(const XEvent* xev) { - return xev->type == KeyPress || xev->type == KeyRelease; -} -#else -#error Unknown build platform: you should have either use_ozone or use_x11. -#endif - -scoped_ptr<ui::ScopedEventDispatcher> OverrideDispatcher( - ui::PlatformEventDispatcher* dispatcher) { - ui::PlatformEventSource* source = ui::PlatformEventSource::GetInstance(); - return source ? source->OverrideDispatcher(dispatcher) - : scoped_ptr<ui::ScopedEventDispatcher>(); -} - -} // namespace - -class NestedAcceleratorDispatcherLinux : public NestedAcceleratorDispatcher, - public ui::PlatformEventDispatcher { - public: - explicit NestedAcceleratorDispatcherLinux(NestedAcceleratorDelegate* delegate) - : NestedAcceleratorDispatcher(delegate), - restore_dispatcher_(OverrideDispatcher(this)) {} - - virtual ~NestedAcceleratorDispatcherLinux() {} - - private: - // AcceleratorDispatcher: - virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE { - return scoped_ptr<base::RunLoop>(new base::RunLoop()); - } - - // ui::PlatformEventDispatcher: - virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE { - return true; - } - - virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE { - if (IsKeyEvent(event)) { - ui::KeyEvent key_event(event, false); - if (!delegate_->ShouldProcessEventNow(key_event)) { -#if defined(USE_X11) - XPutBackEvent(event->xany.display, event); -#else - NOTIMPLEMENTED(); -#endif - return ui::POST_DISPATCH_NONE; - } - - if (delegate_->ProcessEvent(key_event)) - return ui::POST_DISPATCH_NONE; - } - ui::PlatformEventDispatcher* prev = *restore_dispatcher_; - - return prev ? prev->DispatchEvent(event) - : ui::POST_DISPATCH_PERFORM_DEFAULT; - } - - scoped_ptr<ui::ScopedEventDispatcher> restore_dispatcher_; - - DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherLinux); -}; - -scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create( - NestedAcceleratorDelegate* delegate, - base::MessagePumpDispatcher* nested_dispatcher) { - return scoped_ptr<NestedAcceleratorDispatcher>( - new NestedAcceleratorDispatcherLinux(delegate)); -} - -} // namespace wm diff --git a/ui/wm/core/nested_accelerator_dispatcher_win.cc b/ui/wm/core/nested_accelerator_dispatcher_win.cc deleted file mode 100644 index a6a5bd9..0000000 --- a/ui/wm/core/nested_accelerator_dispatcher_win.cc +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2014 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/wm/core/nested_accelerator_dispatcher.h" - -#include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_pump_dispatcher.h" -#include "base/run_loop.h" -#include "ui/events/event.h" -#include "ui/wm/core/nested_accelerator_delegate.h" - -using base::MessagePumpDispatcher; - -namespace wm { - -namespace { - -bool IsKeyEvent(const MSG& msg) { - return msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN || - msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP; -} - -} // namespace - -class NestedAcceleratorDispatcherWin : public NestedAcceleratorDispatcher, - public MessagePumpDispatcher { - public: - NestedAcceleratorDispatcherWin(NestedAcceleratorDelegate* delegate, - MessagePumpDispatcher* nested) - : NestedAcceleratorDispatcher(delegate), nested_dispatcher_(nested) {} - virtual ~NestedAcceleratorDispatcherWin() {} - - private: - // NestedAcceleratorDispatcher: - virtual scoped_ptr<base::RunLoop> CreateRunLoop() OVERRIDE { - return scoped_ptr<base::RunLoop>(new base::RunLoop(this)); - } - - // MessagePumpDispatcher: - virtual uint32_t Dispatch(const MSG& event) OVERRIDE { - if (IsKeyEvent(event)) { - ui::KeyEvent key_event(event, false); - if (!delegate_->ShouldProcessEventNow(key_event)) - return POST_DISPATCH_QUIT_LOOP; - - if (delegate_->ProcessEvent(key_event)) - return POST_DISPATCH_NONE; - } - - return nested_dispatcher_ ? nested_dispatcher_->Dispatch(event) - : POST_DISPATCH_PERFORM_DEFAULT; - } - - MessagePumpDispatcher* nested_dispatcher_; - - DISALLOW_COPY_AND_ASSIGN(NestedAcceleratorDispatcherWin); -}; - -scoped_ptr<NestedAcceleratorDispatcher> NestedAcceleratorDispatcher::Create( - NestedAcceleratorDelegate* delegate, - MessagePumpDispatcher* nested_dispatcher) { - return scoped_ptr<NestedAcceleratorDispatcher>( - new NestedAcceleratorDispatcherWin(delegate, nested_dispatcher)); -} - -} // namespace wm diff --git a/ui/wm/wm.gyp b/ui/wm/wm.gyp index 1a86102..537f67a 100644 --- a/ui/wm/wm.gyp +++ b/ui/wm/wm.gyp @@ -26,14 +26,6 @@ 'WM_IMPLEMENTATION', ], 'sources': [ - 'core/nested_accelerator_dispatcher_linux.cc', - 'core/nested_accelerator_dispatcher_win.cc', - 'core/nested_accelerator_dispatcher.cc', - 'core/nested_accelerator_dispatcher.h', - 'core/nested_accelerator_delegate.h', - 'core/nested_accelerator_controller.cc', - 'core/nested_accelerator_controller.h', - 'core/base_focus_rules.h', 'core/base_focus_rules.cc', 'core/base_focus_rules.h', 'core/capture_controller.cc', @@ -129,7 +121,6 @@ 'core/focus_controller_unittest.cc', 'core/input_method_event_filter_unittest.cc', 'core/image_grid_unittest.cc', - 'core/nested_accelerator_controller_unittest.cc', 'core/shadow_controller_unittest.cc', 'core/transient_window_manager_unittest.cc', 'core/transient_window_stacking_client_unittest.cc', |