Make ToplevelWindowEventFilter and WorkspaceEventFilter into event handlers.
http://crbug.com/147653 R=sky@chromium.org,sadrul@chromium.org Review URL: https://chromiumcodereview.appspot.com/10916221 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155940 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
ash
ash.gyproot_window_controller.ccshell.ccshell_unittest.cc
wm
toplevel_window_event_handler.cctoplevel_window_event_handler.htoplevel_window_event_handler_unittest.cc
workspace
multi_window_resize_controller.ccmulti_window_resize_controller_unittest.ccworkspace2.ccworkspace2.hworkspace_event_filter_test_helper.ccworkspace_event_filter_test_helper.hworkspace_event_handler.ccworkspace_event_handler.hworkspace_event_handler_test_helper.ccworkspace_event_handler_test_helper.hworkspace_event_handler_unittest.cc
workspace_controller.ccworkspace_controller.hworkspace_controller_test_helper.ccworkspace_controller_test_helper.hui/base/events
16
ash/ash.gyp
16
ash/ash.gyp
@ -320,8 +320,8 @@
|
||||
'wm/system_modal_container_event_filter_delegate.h',
|
||||
'wm/system_modal_container_layout_manager.cc',
|
||||
'wm/system_modal_container_layout_manager.h',
|
||||
'wm/toplevel_window_event_filter.cc',
|
||||
'wm/toplevel_window_event_filter.h',
|
||||
'wm/toplevel_window_event_handler.cc',
|
||||
'wm/toplevel_window_event_handler.h',
|
||||
'wm/user_activity_detector.cc',
|
||||
'wm/user_activity_detector.h',
|
||||
'wm/user_activity_observer.h',
|
||||
@ -368,8 +368,8 @@
|
||||
'wm/workspace/workspace.h',
|
||||
'wm/workspace/workspace2.cc',
|
||||
'wm/workspace/workspace2.h',
|
||||
'wm/workspace/workspace_event_filter.cc',
|
||||
'wm/workspace/workspace_event_filter.h',
|
||||
'wm/workspace/workspace_event_handler.cc',
|
||||
'wm/workspace/workspace_event_handler.h',
|
||||
'wm/workspace/workspace_layout_manager.cc',
|
||||
'wm/workspace/workspace_layout_manager.h',
|
||||
'wm/workspace/workspace_layout_manager2.cc',
|
||||
@ -502,7 +502,7 @@
|
||||
'wm/shelf_layout_manager_unittest.cc',
|
||||
'wm/system_gesture_event_filter_unittest.cc',
|
||||
'wm/system_modal_container_layout_manager_unittest.cc',
|
||||
'wm/toplevel_window_event_filter_unittest.cc',
|
||||
'wm/toplevel_window_event_handler_unittest.cc',
|
||||
'wm/user_activity_detector_unittest.cc',
|
||||
'wm/video_detector_unittest.cc',
|
||||
'wm/visibility_controller_unittest.cc',
|
||||
@ -513,9 +513,9 @@
|
||||
'wm/workspace_controller_test_helper.cc',
|
||||
'wm/workspace_controller_test_helper.h',
|
||||
'wm/workspace/multi_window_resize_controller_unittest.cc',
|
||||
'wm/workspace/workspace_event_filter_test_helper.cc',
|
||||
'wm/workspace/workspace_event_filter_test_helper.h',
|
||||
'wm/workspace/workspace_event_filter_unittest.cc',
|
||||
'wm/workspace/workspace_event_handler_test_helper.cc',
|
||||
'wm/workspace/workspace_event_handler_test_helper.h',
|
||||
'wm/workspace/workspace_event_handler_unittest.cc',
|
||||
'wm/workspace/workspace_manager_unittest.cc',
|
||||
'wm/workspace/workspace_manager2_unittest.cc',
|
||||
'wm/workspace/workspace_window_resizer_unittest.cc',
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "ash/wm/root_window_layout_manager.h"
|
||||
#include "ash/wm/screen_dimmer.h"
|
||||
#include "ash/wm/system_modal_container_layout_manager.h"
|
||||
#include "ash/wm/toplevel_window_event_filter.h"
|
||||
#include "ash/wm/toplevel_window_event_handler.h"
|
||||
#include "ash/wm/visibility_controller.h"
|
||||
#include "ash/wm/window_properties.h"
|
||||
#include "ash/wm/workspace_controller.h"
|
||||
@ -177,8 +177,10 @@ void CreateContainersInRootWindow(aura::RootWindow* root_window) {
|
||||
internal::kShellWindowId_DefaultContainer,
|
||||
"DefaultContainer",
|
||||
non_lock_screen_containers);
|
||||
default_container->SetEventFilter(
|
||||
new ToplevelWindowEventFilter(default_container));
|
||||
if (!internal::WorkspaceController::IsWorkspace2Enabled()) {
|
||||
default_container->AddPreTargetHandler(
|
||||
new ToplevelWindowEventHandler(default_container));
|
||||
}
|
||||
SetChildWindowVisibilityChangesAnimated(default_container);
|
||||
SetUsesScreenCoordinates(default_container);
|
||||
|
||||
@ -186,8 +188,8 @@ void CreateContainersInRootWindow(aura::RootWindow* root_window) {
|
||||
internal::kShellWindowId_AlwaysOnTopContainer,
|
||||
"AlwaysOnTopContainer",
|
||||
non_lock_screen_containers);
|
||||
always_on_top_container->SetEventFilter(
|
||||
new ToplevelWindowEventFilter(always_on_top_container));
|
||||
always_on_top_container->AddPreTargetHandler(
|
||||
new ToplevelWindowEventHandler(always_on_top_container));
|
||||
SetChildWindowVisibilityChangesAnimated(always_on_top_container);
|
||||
SetUsesScreenCoordinates(always_on_top_container);
|
||||
|
||||
@ -211,8 +213,8 @@ void CreateContainersInRootWindow(aura::RootWindow* root_window) {
|
||||
internal::kShellWindowId_SystemModalContainer,
|
||||
"SystemModalContainer",
|
||||
non_lock_screen_containers);
|
||||
modal_container->SetEventFilter(
|
||||
new ToplevelWindowEventFilter(modal_container));
|
||||
modal_container->AddPreTargetHandler(
|
||||
new ToplevelWindowEventHandler(modal_container));
|
||||
modal_container->SetLayoutManager(
|
||||
new internal::SystemModalContainerLayoutManager(modal_container));
|
||||
SetChildWindowVisibilityChangesAnimated(modal_container);
|
||||
@ -239,8 +241,8 @@ void CreateContainersInRootWindow(aura::RootWindow* root_window) {
|
||||
internal::kShellWindowId_LockSystemModalContainer,
|
||||
"LockSystemModalContainer",
|
||||
lock_screen_containers);
|
||||
lock_modal_container->SetEventFilter(
|
||||
new ToplevelWindowEventFilter(lock_modal_container));
|
||||
lock_modal_container->AddPreTargetHandler(
|
||||
new ToplevelWindowEventHandler(lock_modal_container));
|
||||
lock_modal_container->SetLayoutManager(
|
||||
new internal::SystemModalContainerLayoutManager(lock_modal_container));
|
||||
SetChildWindowVisibilityChangesAnimated(lock_modal_container);
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include "ash/wm/status_area_layout_manager.h"
|
||||
#include "ash/wm/system_gesture_event_filter.h"
|
||||
#include "ash/wm/system_modal_container_layout_manager.h"
|
||||
#include "ash/wm/toplevel_window_event_filter.h"
|
||||
#include "ash/wm/user_activity_detector.h"
|
||||
#include "ash/wm/video_detector.h"
|
||||
#include "ash/wm/visibility_controller.h"
|
||||
@ -64,7 +63,6 @@
|
||||
#include "ash/wm/window_modality_controller.h"
|
||||
#include "ash/wm/window_properties.h"
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "ash/wm/workspace/workspace_event_filter.h"
|
||||
#include "ash/wm/workspace/workspace_layout_manager.h"
|
||||
#include "ash/wm/workspace_controller.h"
|
||||
#include "base/bind.h"
|
||||
|
@ -300,9 +300,6 @@ TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
|
||||
widget->Show();
|
||||
EXPECT_FALSE(widget->IsMaximized());
|
||||
|
||||
// We have a default container event filter (for window drags).
|
||||
EXPECT_TRUE(widget->GetNativeWindow()->parent()->event_filter());
|
||||
|
||||
// Clean up.
|
||||
widget->Close();
|
||||
}
|
||||
|
@ -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 "ash/wm/toplevel_window_event_filter.h"
|
||||
#include "ash/wm/toplevel_window_event_handler.h"
|
||||
|
||||
#include "ash/shell.h"
|
||||
#include "ash/wm/default_window_resizer.h"
|
||||
@ -50,11 +50,11 @@ gfx::Point ConvertPointToParent(aura::Window* window,
|
||||
|
||||
// Wraps a WindowResizer and installs an observer on its target window. When
|
||||
// the window is destroyed ResizerWindowDestroyed() is invoked back on the
|
||||
// ToplevelWindowEventFilter to clean up.
|
||||
class ToplevelWindowEventFilter::ScopedWindowResizer
|
||||
// ToplevelWindowEventHandler to clean up.
|
||||
class ToplevelWindowEventHandler::ScopedWindowResizer
|
||||
: public aura::WindowObserver {
|
||||
public:
|
||||
ScopedWindowResizer(ToplevelWindowEventFilter* filter,
|
||||
ScopedWindowResizer(ToplevelWindowEventHandler* handler,
|
||||
WindowResizer* resizer);
|
||||
virtual ~ScopedWindowResizer();
|
||||
|
||||
@ -64,60 +64,60 @@ class ToplevelWindowEventFilter::ScopedWindowResizer
|
||||
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
|
||||
|
||||
private:
|
||||
ToplevelWindowEventFilter* filter_;
|
||||
ToplevelWindowEventHandler* handler_;
|
||||
scoped_ptr<WindowResizer> resizer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedWindowResizer);
|
||||
};
|
||||
|
||||
ToplevelWindowEventFilter::ScopedWindowResizer::ScopedWindowResizer(
|
||||
ToplevelWindowEventFilter* filter,
|
||||
ToplevelWindowEventHandler::ScopedWindowResizer::ScopedWindowResizer(
|
||||
ToplevelWindowEventHandler* handler,
|
||||
WindowResizer* resizer)
|
||||
: filter_(filter),
|
||||
: handler_(handler),
|
||||
resizer_(resizer) {
|
||||
if (resizer_.get())
|
||||
resizer_->GetTarget()->AddObserver(this);
|
||||
}
|
||||
|
||||
ToplevelWindowEventFilter::ScopedWindowResizer::~ScopedWindowResizer() {
|
||||
ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() {
|
||||
if (resizer_.get())
|
||||
resizer_->GetTarget()->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void ToplevelWindowEventFilter::ScopedWindowResizer::OnWindowDestroying(
|
||||
void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowDestroying(
|
||||
aura::Window* window) {
|
||||
DCHECK(resizer_.get());
|
||||
DCHECK_EQ(resizer_->GetTarget(), window);
|
||||
filter_->ResizerWindowDestroyed();
|
||||
handler_->ResizerWindowDestroyed();
|
||||
}
|
||||
|
||||
|
||||
// ToplevelWindowEventFilter ---------------------------------------------------
|
||||
// ToplevelWindowEventHandler --------------------------------------------------
|
||||
|
||||
ToplevelWindowEventFilter::ToplevelWindowEventFilter(aura::Window* owner)
|
||||
ToplevelWindowEventHandler::ToplevelWindowEventHandler(aura::Window* owner)
|
||||
: in_move_loop_(false),
|
||||
in_gesture_resize_(false) {
|
||||
aura::client::SetWindowMoveClient(owner, this);
|
||||
}
|
||||
|
||||
ToplevelWindowEventFilter::~ToplevelWindowEventFilter() {
|
||||
ToplevelWindowEventHandler::~ToplevelWindowEventHandler() {
|
||||
}
|
||||
|
||||
bool ToplevelWindowEventFilter::PreHandleKeyEvent(aura::Window* target,
|
||||
ui::KeyEvent* event) {
|
||||
ui::EventResult ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) {
|
||||
if (window_resizer_.get() && event->type() == ui::ET_KEY_PRESSED &&
|
||||
event->key_code() == ui::VKEY_ESCAPE) {
|
||||
CompleteDrag(DRAG_REVERT, event->flags());
|
||||
}
|
||||
return false;
|
||||
return ui::ER_UNHANDLED;
|
||||
}
|
||||
|
||||
bool ToplevelWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
|
||||
ui::MouseEvent* event) {
|
||||
ui::EventResult ToplevelWindowEventHandler::OnMouseEvent(
|
||||
ui::MouseEvent* event) {
|
||||
if ((event->flags() &
|
||||
(ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0)
|
||||
return false;
|
||||
return ui::ER_UNHANDLED;
|
||||
|
||||
aura::Window* target = static_cast<aura::Window*>(event->target());
|
||||
switch (event->type()) {
|
||||
case ui::ET_MOUSE_PRESSED: {
|
||||
// We also update the current window component here because for the
|
||||
@ -134,10 +134,11 @@ bool ToplevelWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
|
||||
} else {
|
||||
window_resizer_.reset();
|
||||
}
|
||||
return WindowResizer::GetBoundsChangeForWindowComponent(component) != 0;
|
||||
return WindowResizer::GetBoundsChangeForWindowComponent(component) != 0 ?
|
||||
ui::ER_CONSUMED : ui::ER_UNHANDLED;
|
||||
}
|
||||
case ui::ET_MOUSE_DRAGGED:
|
||||
return HandleDrag(target, event);
|
||||
return HandleDrag(target, event) ? ui::ER_CONSUMED : ui::ER_UNHANDLED;
|
||||
case ui::ET_MOUSE_CAPTURE_CHANGED:
|
||||
case ui::ET_MOUSE_RELEASED:
|
||||
CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
|
||||
@ -148,32 +149,38 @@ bool ToplevelWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
|
||||
in_move_loop_ = false;
|
||||
}
|
||||
// Completing the drag may result in hiding the window. If this happens
|
||||
// return true so no other filters/observers see the event. Otherwise they
|
||||
// see the event on a hidden window.
|
||||
// return true so no other handlers/observers see the event. Otherwise
|
||||
// they see the event on a hidden window.
|
||||
if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED &&
|
||||
!target->IsVisible()) {
|
||||
return true;
|
||||
return ui::ER_CONSUMED;
|
||||
}
|
||||
break;
|
||||
case ui::ET_MOUSE_MOVED:
|
||||
return HandleMouseMoved(target, event);
|
||||
return HandleMouseMoved(target, event) ?
|
||||
ui::ER_CONSUMED : ui::ER_UNHANDLED;
|
||||
case ui::ET_MOUSE_EXITED:
|
||||
return HandleMouseExited(target, event);
|
||||
return HandleMouseExited(target, event) ?
|
||||
ui::ER_CONSUMED : ui::ER_UNHANDLED;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
return ui::ER_UNHANDLED;
|
||||
}
|
||||
|
||||
ui::TouchStatus ToplevelWindowEventFilter::PreHandleTouchEvent(
|
||||
aura::Window* target,
|
||||
ui::EventResult ToplevelWindowEventHandler::OnScrollEvent(
|
||||
ui::ScrollEvent* event) {
|
||||
return ui::ER_UNHANDLED;
|
||||
}
|
||||
|
||||
ui::TouchStatus ToplevelWindowEventHandler::OnTouchEvent(
|
||||
ui::TouchEvent* event) {
|
||||
return ui::TOUCH_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
ui::EventResult ToplevelWindowEventFilter::PreHandleGestureEvent(
|
||||
aura::Window* target,
|
||||
ui::EventResult ToplevelWindowEventHandler::OnGestureEvent(
|
||||
ui::GestureEvent* event) {
|
||||
aura::Window* target = static_cast<aura::Window*>(event->target());
|
||||
switch (event->type()) {
|
||||
case ui::ET_GESTURE_SCROLL_BEGIN: {
|
||||
int component =
|
||||
@ -247,8 +254,8 @@ ui::EventResult ToplevelWindowEventFilter::PreHandleGestureEvent(
|
||||
return ui::ER_CONSUMED;
|
||||
}
|
||||
|
||||
void ToplevelWindowEventFilter::RunMoveLoop(aura::Window* source,
|
||||
const gfx::Point& drag_offset) {
|
||||
void ToplevelWindowEventHandler::RunMoveLoop(aura::Window* source,
|
||||
const gfx::Point& drag_offset) {
|
||||
DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
|
||||
in_move_loop_ = true;
|
||||
aura::RootWindow* root_window = source->GetRootWindow();
|
||||
@ -276,7 +283,7 @@ void ToplevelWindowEventFilter::RunMoveLoop(aura::Window* source,
|
||||
in_gesture_resize_ = in_move_loop_ = false;
|
||||
}
|
||||
|
||||
void ToplevelWindowEventFilter::EndMoveLoop() {
|
||||
void ToplevelWindowEventHandler::EndMoveLoop() {
|
||||
if (!in_move_loop_)
|
||||
return;
|
||||
|
||||
@ -289,7 +296,7 @@ void ToplevelWindowEventFilter::EndMoveLoop() {
|
||||
}
|
||||
|
||||
// static
|
||||
WindowResizer* ToplevelWindowEventFilter::CreateWindowResizer(
|
||||
WindowResizer* ToplevelWindowEventHandler::CreateWindowResizer(
|
||||
aura::Window* window,
|
||||
const gfx::Point& point_in_parent,
|
||||
int window_component) {
|
||||
@ -300,7 +307,7 @@ WindowResizer* ToplevelWindowEventFilter::CreateWindowResizer(
|
||||
}
|
||||
|
||||
|
||||
void ToplevelWindowEventFilter::CreateScopedWindowResizer(
|
||||
void ToplevelWindowEventHandler::CreateScopedWindowResizer(
|
||||
aura::Window* window,
|
||||
const gfx::Point& point_in_parent,
|
||||
int window_component) {
|
||||
@ -311,8 +318,8 @@ void ToplevelWindowEventFilter::CreateScopedWindowResizer(
|
||||
window_resizer_.reset(new ScopedWindowResizer(this, resizer));
|
||||
}
|
||||
|
||||
void ToplevelWindowEventFilter::CompleteDrag(DragCompletionStatus status,
|
||||
int event_flags) {
|
||||
void ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status,
|
||||
int event_flags) {
|
||||
scoped_ptr<ScopedWindowResizer> resizer(window_resizer_.release());
|
||||
if (resizer.get()) {
|
||||
if (status == DRAG_COMPLETE)
|
||||
@ -322,8 +329,8 @@ void ToplevelWindowEventFilter::CompleteDrag(DragCompletionStatus status,
|
||||
}
|
||||
}
|
||||
|
||||
bool ToplevelWindowEventFilter::HandleDrag(aura::Window* target,
|
||||
ui::LocatedEvent* event) {
|
||||
bool ToplevelWindowEventHandler::HandleDrag(aura::Window* target,
|
||||
ui::LocatedEvent* event) {
|
||||
// This function only be triggered to move window
|
||||
// by mouse drag or touch move event.
|
||||
DCHECK(event->type() == ui::ET_MOUSE_DRAGGED ||
|
||||
@ -337,8 +344,8 @@ bool ToplevelWindowEventFilter::HandleDrag(aura::Window* target,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ToplevelWindowEventFilter::HandleMouseMoved(aura::Window* target,
|
||||
ui::LocatedEvent* event) {
|
||||
bool ToplevelWindowEventHandler::HandleMouseMoved(aura::Window* target,
|
||||
ui::LocatedEvent* event) {
|
||||
// TODO(jamescook): Move the resize cursor update code into here from
|
||||
// CompoundEventFilter?
|
||||
internal::ResizeShadowController* controller =
|
||||
@ -355,8 +362,8 @@ bool ToplevelWindowEventFilter::HandleMouseMoved(aura::Window* target,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ToplevelWindowEventFilter::HandleMouseExited(aura::Window* target,
|
||||
ui::LocatedEvent* event) {
|
||||
bool ToplevelWindowEventHandler::HandleMouseExited(aura::Window* target,
|
||||
ui::LocatedEvent* event) {
|
||||
internal::ResizeShadowController* controller =
|
||||
Shell::GetInstance()->resize_shadow_controller();
|
||||
if (controller)
|
||||
@ -364,7 +371,7 @@ bool ToplevelWindowEventFilter::HandleMouseExited(aura::Window* target,
|
||||
return false;
|
||||
}
|
||||
|
||||
void ToplevelWindowEventFilter::ResizerWindowDestroyed() {
|
||||
void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
|
||||
// We explicitly don't invoke RevertDrag() since that may do things to window.
|
||||
// Instead we destroy the resizer.
|
||||
window_resizer_.reset();
|
@ -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 ASH_WM_TOPLEVEL_WINDOW_EVENT_FILTER_H_
|
||||
#define ASH_WM_TOPLEVEL_WINDOW_EVENT_FILTER_H_
|
||||
#ifndef ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
|
||||
#define ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
|
||||
|
||||
#include <set>
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "ui/aura/client/window_move_client.h"
|
||||
#include "ui/aura/event_filter.h"
|
||||
#include "ui/base/events/event_handler.h"
|
||||
#include "ui/gfx/point.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
|
||||
@ -28,24 +28,19 @@ namespace ash {
|
||||
|
||||
class WindowResizer;
|
||||
|
||||
class ASH_EXPORT ToplevelWindowEventFilter
|
||||
: public aura::EventFilter,
|
||||
class ASH_EXPORT ToplevelWindowEventHandler
|
||||
: public ui::EventHandler,
|
||||
public aura::client::WindowMoveClient {
|
||||
public:
|
||||
explicit ToplevelWindowEventFilter(aura::Window* owner);
|
||||
virtual ~ToplevelWindowEventFilter();
|
||||
explicit ToplevelWindowEventHandler(aura::Window* owner);
|
||||
virtual ~ToplevelWindowEventHandler();
|
||||
|
||||
// Overridden from aura::EventFilter:
|
||||
virtual bool PreHandleKeyEvent(aura::Window* target,
|
||||
ui::KeyEvent* event) OVERRIDE;
|
||||
virtual bool PreHandleMouseEvent(aura::Window* target,
|
||||
ui::MouseEvent* event) OVERRIDE;
|
||||
virtual ui::TouchStatus PreHandleTouchEvent(
|
||||
aura::Window* target,
|
||||
ui::TouchEvent* event) OVERRIDE;
|
||||
virtual ui::EventResult PreHandleGestureEvent(
|
||||
aura::Window* target,
|
||||
ui::GestureEvent* event) OVERRIDE;
|
||||
// Overridden from ui::EventHandler:
|
||||
virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
|
||||
virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
|
||||
virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
|
||||
virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
|
||||
virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
|
||||
|
||||
// Overridden form aura::client::WindowMoveClient:
|
||||
virtual void RunMoveLoop(aura::Window* source,
|
||||
@ -98,9 +93,9 @@ class ASH_EXPORT ToplevelWindowEventFilter
|
||||
|
||||
base::Closure quit_closure_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventFilter);
|
||||
DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandler);
|
||||
};
|
||||
|
||||
} // namespace aura
|
||||
|
||||
#endif // ASH_WM_TOPLEVEL_WINDOW_EVENT_FILTER_H_
|
||||
#endif // ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
|
68
ash/wm/toplevel_window_event_filter_unittest.cc → ash/wm/toplevel_window_event_handler_unittest.cc
68
ash/wm/toplevel_window_event_filter_unittest.cc → ash/wm/toplevel_window_event_handler_unittest.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 "ash/wm/toplevel_window_event_filter.h"
|
||||
#include "ash/wm/toplevel_window_event_handler.h"
|
||||
|
||||
#include "ash/shell.h"
|
||||
#include "ash/test/ash_test_base.h"
|
||||
@ -64,10 +64,10 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate {
|
||||
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
|
||||
};
|
||||
|
||||
class ToplevelWindowEventFilterTest : public AshTestBase {
|
||||
class ToplevelWindowEventHandlerTest : public AshTestBase {
|
||||
public:
|
||||
ToplevelWindowEventFilterTest() : filter_(NULL), parent_(NULL) {}
|
||||
virtual ~ToplevelWindowEventFilterTest() {}
|
||||
ToplevelWindowEventHandlerTest() : handler_(NULL), parent_(NULL) {}
|
||||
virtual ~ToplevelWindowEventHandlerTest() {}
|
||||
|
||||
virtual void SetUp() OVERRIDE {
|
||||
AshTestBase::SetUp();
|
||||
@ -76,12 +76,12 @@ class ToplevelWindowEventFilterTest : public AshTestBase {
|
||||
parent_->Show();
|
||||
Shell::GetPrimaryRootWindow()->AddChild(parent_);
|
||||
parent_->SetBounds(Shell::GetPrimaryRootWindow()->bounds());
|
||||
filter_ = new ToplevelWindowEventFilter(parent_);
|
||||
parent_->SetEventFilter(filter_);
|
||||
handler_ = new ToplevelWindowEventHandler(parent_);
|
||||
parent_->AddPreTargetHandler(handler_);
|
||||
}
|
||||
|
||||
virtual void TearDown() OVERRIDE {
|
||||
filter_ = NULL;
|
||||
handler_ = NULL;
|
||||
parent_ = NULL;
|
||||
AshTestBase::TearDown();
|
||||
}
|
||||
@ -108,18 +108,18 @@ class ToplevelWindowEventFilterTest : public AshTestBase {
|
||||
generator.PressMoveAndReleaseTouchBy(dx, dy);
|
||||
}
|
||||
|
||||
ToplevelWindowEventFilter* filter_;
|
||||
ToplevelWindowEventHandler* handler_;
|
||||
|
||||
private:
|
||||
// Window |filter_| is installed on. Owned by RootWindow.
|
||||
// Window |handler_| is installed on. Owned by RootWindow.
|
||||
aura::Window* parent_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventFilterTest);
|
||||
DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandlerTest);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, Caption) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, Caption) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTCAPTION));
|
||||
gfx::Size size = w1->bounds().size();
|
||||
DragFromCenterBy(w1.get(), 100, 100);
|
||||
@ -135,7 +135,7 @@ TEST_F(ToplevelWindowEventFilterTest, Caption) {
|
||||
EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, BottomRight) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, BottomRight) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMRIGHT));
|
||||
gfx::Point position = w1->bounds().origin();
|
||||
DragFromCenterBy(w1.get(), 100, 100);
|
||||
@ -145,7 +145,7 @@ TEST_F(ToplevelWindowEventFilterTest, BottomRight) {
|
||||
EXPECT_EQ(gfx::Size(200, 200), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, GrowBox) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, GrowBox) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTGROWBOX));
|
||||
TestWindowDelegate* window_delegate =
|
||||
static_cast<TestWindowDelegate*>(w1->delegate());
|
||||
@ -173,7 +173,7 @@ TEST_F(ToplevelWindowEventFilterTest, GrowBox) {
|
||||
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, Right) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, Right) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTRIGHT));
|
||||
gfx::Point position = w1->bounds().origin();
|
||||
DragFromCenterBy(w1.get(), 100, 100);
|
||||
@ -183,7 +183,7 @@ TEST_F(ToplevelWindowEventFilterTest, Right) {
|
||||
EXPECT_EQ(gfx::Size(200, 100), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, Bottom) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, Bottom) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOM));
|
||||
gfx::Point position = w1->bounds().origin();
|
||||
DragFromCenterBy(w1.get(), 100, 100);
|
||||
@ -193,7 +193,7 @@ TEST_F(ToplevelWindowEventFilterTest, Bottom) {
|
||||
EXPECT_EQ(gfx::Size(100, 200), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, TopRight) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, TopRight) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTTOPRIGHT));
|
||||
DragFromCenterBy(w1.get(), -50, 50);
|
||||
// Position should have been offset by 0,50.
|
||||
@ -202,7 +202,7 @@ TEST_F(ToplevelWindowEventFilterTest, TopRight) {
|
||||
EXPECT_EQ(gfx::Size(50, 50), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, Top) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, Top) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTTOP));
|
||||
DragFromCenterBy(w1.get(), 50, 50);
|
||||
// Position should have been offset by 0,50.
|
||||
@ -211,7 +211,7 @@ TEST_F(ToplevelWindowEventFilterTest, Top) {
|
||||
EXPECT_EQ(gfx::Size(100, 50), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, Left) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, Left) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTLEFT));
|
||||
DragFromCenterBy(w1.get(), 50, 50);
|
||||
// Position should have been offset by 50,0.
|
||||
@ -220,7 +220,7 @@ TEST_F(ToplevelWindowEventFilterTest, Left) {
|
||||
EXPECT_EQ(gfx::Size(50, 100), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, BottomLeft) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, BottomLeft) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMLEFT));
|
||||
DragFromCenterBy(w1.get(), 50, -50);
|
||||
// Position should have been offset by 50,0.
|
||||
@ -229,7 +229,7 @@ TEST_F(ToplevelWindowEventFilterTest, BottomLeft) {
|
||||
EXPECT_EQ(gfx::Size(50, 50), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, TopLeft) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, TopLeft) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTTOPLEFT));
|
||||
DragFromCenterBy(w1.get(), 50, 50);
|
||||
// Position should have been offset by 50,50.
|
||||
@ -238,7 +238,7 @@ TEST_F(ToplevelWindowEventFilterTest, TopLeft) {
|
||||
EXPECT_EQ(gfx::Size(50, 50), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, Client) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, Client) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTCLIENT));
|
||||
gfx::Rect bounds = w1->bounds();
|
||||
DragFromCenterBy(w1.get(), 100, 100);
|
||||
@ -246,7 +246,7 @@ TEST_F(ToplevelWindowEventFilterTest, Client) {
|
||||
EXPECT_EQ(bounds, w1->bounds());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, LeftPastMinimum) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, LeftPastMinimum) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTLEFT));
|
||||
TestWindowDelegate* window_delegate =
|
||||
static_cast<TestWindowDelegate*>(w1->delegate());
|
||||
@ -259,7 +259,7 @@ TEST_F(ToplevelWindowEventFilterTest, LeftPastMinimum) {
|
||||
EXPECT_EQ(gfx::Size(40, 100), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, RightPastMinimum) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, RightPastMinimum) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTRIGHT));
|
||||
TestWindowDelegate* window_delegate =
|
||||
static_cast<TestWindowDelegate*>(w1->delegate());
|
||||
@ -273,7 +273,7 @@ TEST_F(ToplevelWindowEventFilterTest, RightPastMinimum) {
|
||||
EXPECT_EQ(gfx::Size(40, 100), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, TopLeftPastMinimum) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, TopLeftPastMinimum) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTTOPLEFT));
|
||||
TestWindowDelegate* window_delegate =
|
||||
static_cast<TestWindowDelegate*>(w1->delegate());
|
||||
@ -286,7 +286,7 @@ TEST_F(ToplevelWindowEventFilterTest, TopLeftPastMinimum) {
|
||||
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, TopRightPastMinimum) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, TopRightPastMinimum) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTTOPRIGHT));
|
||||
TestWindowDelegate* window_delegate =
|
||||
static_cast<TestWindowDelegate*>(w1->delegate());
|
||||
@ -300,7 +300,7 @@ TEST_F(ToplevelWindowEventFilterTest, TopRightPastMinimum) {
|
||||
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, BottomLeftPastMinimum) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, BottomLeftPastMinimum) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMLEFT));
|
||||
TestWindowDelegate* window_delegate =
|
||||
static_cast<TestWindowDelegate*>(w1->delegate());
|
||||
@ -314,7 +314,7 @@ TEST_F(ToplevelWindowEventFilterTest, BottomLeftPastMinimum) {
|
||||
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, BottomRightPastMinimum) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, BottomRightPastMinimum) {
|
||||
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMRIGHT));
|
||||
TestWindowDelegate* window_delegate =
|
||||
static_cast<TestWindowDelegate*>(w1->delegate());
|
||||
@ -328,7 +328,7 @@ TEST_F(ToplevelWindowEventFilterTest, BottomRightPastMinimum) {
|
||||
EXPECT_EQ(gfx::Size(40, 40), w1->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, BottomRightWorkArea) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, BottomRightWorkArea) {
|
||||
scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMRIGHT));
|
||||
gfx::Rect work_area =
|
||||
gfx::Screen::GetDisplayNearestWindow(target.get()).work_area();
|
||||
@ -342,7 +342,7 @@ TEST_F(ToplevelWindowEventFilterTest, BottomRightWorkArea) {
|
||||
target->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, BottomLeftWorkArea) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, BottomLeftWorkArea) {
|
||||
scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOMLEFT));
|
||||
gfx::Rect work_area =
|
||||
gfx::Screen::GetDisplayNearestWindow(target.get()).work_area();
|
||||
@ -357,7 +357,7 @@ TEST_F(ToplevelWindowEventFilterTest, BottomLeftWorkArea) {
|
||||
target->bounds().size());
|
||||
}
|
||||
|
||||
TEST_F(ToplevelWindowEventFilterTest, BottomWorkArea) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, BottomWorkArea) {
|
||||
scoped_ptr<aura::Window> target(CreateWindow(HTBOTTOM));
|
||||
gfx::Rect work_area =
|
||||
gfx::Screen::GetDisplayNearestWindow(target.get()).work_area();
|
||||
@ -372,7 +372,7 @@ TEST_F(ToplevelWindowEventFilterTest, BottomWorkArea) {
|
||||
}
|
||||
|
||||
// Verifies we don't let windows drag to a -y location.
|
||||
TEST_F(ToplevelWindowEventFilterTest, DontDragToNegativeY) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, DontDragToNegativeY) {
|
||||
scoped_ptr<aura::Window> target(CreateWindow(HTTOP));
|
||||
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
|
||||
target.get());
|
||||
@ -384,7 +384,7 @@ TEST_F(ToplevelWindowEventFilterTest, DontDragToNegativeY) {
|
||||
}
|
||||
|
||||
// Verifies we don't let windows go bigger than the display width.
|
||||
TEST_F(ToplevelWindowEventFilterTest, DontGotWiderThanScreen) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, DontGotWiderThanScreen) {
|
||||
scoped_ptr<aura::Window> target(CreateWindow(HTRIGHT));
|
||||
gfx::Rect work_area =
|
||||
gfx::Screen::GetDisplayNearestWindow(target.get()).bounds();
|
||||
@ -394,7 +394,7 @@ TEST_F(ToplevelWindowEventFilterTest, DontGotWiderThanScreen) {
|
||||
}
|
||||
|
||||
// Verifies that touch-gestures drag the window correctly.
|
||||
TEST_F(ToplevelWindowEventFilterTest, GestureDrag) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) {
|
||||
scoped_ptr<aura::Window> target(CreateWindow(HTCAPTION));
|
||||
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
|
||||
target.get());
|
||||
@ -465,7 +465,7 @@ TEST_F(ToplevelWindowEventFilterTest, GestureDrag) {
|
||||
#else
|
||||
#define MAYBE_EscapeReverts EscapeReverts
|
||||
#endif
|
||||
TEST_F(ToplevelWindowEventFilterTest, MAYBE_EscapeReverts) {
|
||||
TEST_F(ToplevelWindowEventHandlerTest, MAYBE_EscapeReverts) {
|
||||
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
|
||||
aura::client::ActivationClient* original_client =
|
||||
aura::client::GetActivationClient(root);
|
@ -8,7 +8,7 @@
|
||||
#include "ash/shell.h"
|
||||
#include "ash/shell_window_ids.h"
|
||||
#include "ash/wm/window_animations.h"
|
||||
#include "ash/wm/workspace/workspace_event_filter.h"
|
||||
#include "ash/wm/workspace/workspace_event_handler.h"
|
||||
#include "ash/wm/workspace/workspace_window_resizer.h"
|
||||
#include "grit/ui_resources.h"
|
||||
#include "ui/aura/client/screen_position_client.h"
|
||||
@ -160,7 +160,7 @@ void MultiWindowResizeController::Show(Window* window,
|
||||
const gfx::Point& point_in_window) {
|
||||
// When the resize widget is showing we ignore Show() requests. Instead we
|
||||
// only care about mouse movements from MouseWatcher. This is necessary as
|
||||
// WorkspaceEventFilter only sees mouse movements over the windows, not all
|
||||
// WorkspaceEventHandler only sees mouse movements over the windows, not all
|
||||
// windows or over the desktop.
|
||||
if (resize_widget_.get())
|
||||
return;
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "ash/wm/workspace_controller.h"
|
||||
#include "ash/wm/workspace_controller_test_helper.h"
|
||||
#include "ash/wm/workspace/workspace_event_filter_test_helper.h"
|
||||
#include "ash/wm/workspace/workspace_event_handler_test_helper.h"
|
||||
#include "ash/wm/workspace/workspace_manager.h"
|
||||
#include "ui/aura/test/event_generator.h"
|
||||
#include "ui/aura/test/test_window_delegate.h"
|
||||
@ -30,9 +30,9 @@ class MultiWindowResizeControllerTest : public test::AshTestBase {
|
||||
test::AshTestBase::SetUp();
|
||||
WorkspaceController* wc =
|
||||
ash::Shell::TestApi(Shell::GetInstance()).workspace_controller();
|
||||
WorkspaceEventFilter* event_filter =
|
||||
WorkspaceControllerTestHelper(wc).GetFilter();
|
||||
resize_controller_ = WorkspaceEventFilterTestHelper(event_filter).
|
||||
WorkspaceEventHandler* event_handler =
|
||||
WorkspaceControllerTestHelper(wc).GetEventHandler();
|
||||
resize_controller_ = WorkspaceEventHandlerTestHelper(event_handler).
|
||||
resize_controller();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "ash/wm/property_util.h"
|
||||
#include "ash/wm/window_properties.h"
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "ash/wm/workspace/workspace_event_filter.h"
|
||||
#include "ash/wm/workspace/workspace_event_handler.h"
|
||||
#include "ash/wm/workspace/workspace_manager2.h"
|
||||
#include "ui/aura/window.h"
|
||||
|
||||
@ -21,7 +21,7 @@ Workspace2::Workspace2(WorkspaceManager2* manager,
|
||||
: is_maximized_(is_maximized),
|
||||
workspace_manager_(manager),
|
||||
window_(new aura::Window(NULL)),
|
||||
event_filter_(new WorkspaceEventFilter(window_)) {
|
||||
event_handler_(new WorkspaceEventHandler(window_)) {
|
||||
window_->SetProperty(internal::kChildWindowVisibilityChangesAnimatedKey,
|
||||
true);
|
||||
window_->set_id(kShellWindowId_WorkspaceContainer);
|
||||
@ -31,7 +31,7 @@ Workspace2::Workspace2(WorkspaceManager2* manager,
|
||||
window_->layer()->SetMasksToBounds(true);
|
||||
window_->Hide();
|
||||
window_->SetParent(parent);
|
||||
window_->SetEventFilter(event_filter_);
|
||||
window_->AddPreTargetHandler(event_handler_);
|
||||
window_->SetProperty(internal::kUsesScreenCoordinatesKey, true);
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ aura::Window* Workspace2::ReleaseWindow() {
|
||||
window_->SetEventFilter(NULL);
|
||||
aura::Window* window = window_;
|
||||
window_ = NULL;
|
||||
event_filter_ = NULL;
|
||||
event_handler_ = NULL;
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class Rect;
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
class WorkspaceEventFilter;
|
||||
class WorkspaceEventHandler;
|
||||
class WorkspaceManager2;
|
||||
|
||||
// Workspace is used to maintain either a single maximized windows (including
|
||||
@ -61,7 +61,7 @@ class ASH_EXPORT Workspace2 {
|
||||
aura::Window* window_;
|
||||
|
||||
// Owned by |window_|.
|
||||
WorkspaceEventFilter* event_filter_;
|
||||
WorkspaceEventHandler* event_handler_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Workspace2);
|
||||
};
|
||||
|
@ -1,19 +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 "ash/wm/workspace/workspace_event_filter_test_helper.h"
|
||||
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
WorkspaceEventFilterTestHelper::WorkspaceEventFilterTestHelper(
|
||||
WorkspaceEventFilter* filter)
|
||||
: filter_(filter) {
|
||||
}
|
||||
|
||||
WorkspaceEventFilterTestHelper::~WorkspaceEventFilterTestHelper() {
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ash
|
@ -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 ASH_WM_WORKSPACE_WORKSPACE_EVENT_FILTER_TEST_HELPER_H_
|
||||
#define ASH_WM_WORKSPACE_WORKSPACE_EVENT_FILTER_TEST_HELPER_H_
|
||||
|
||||
#include "ash/wm/workspace/workspace_event_filter.h"
|
||||
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
class WorkspaceEventFilterTestHelper {
|
||||
public:
|
||||
explicit WorkspaceEventFilterTestHelper(WorkspaceEventFilter* filter);
|
||||
~WorkspaceEventFilterTestHelper();
|
||||
|
||||
MultiWindowResizeController* resize_controller() {
|
||||
return &(filter_->multi_window_resize_controller_);
|
||||
}
|
||||
|
||||
private:
|
||||
WorkspaceEventFilter* filter_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventFilterTestHelper);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_WM_WORKSPACE_WORKSPACE_EVENT_FILTER_TEST_HELPER_H_
|
@ -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 "ash/wm/workspace/workspace_event_filter.h"
|
||||
#include "ash/wm/workspace/workspace_event_handler.h"
|
||||
|
||||
#include "ash/screen_ash.h"
|
||||
#include "ash/wm/property_util.h"
|
||||
@ -54,18 +54,18 @@ void ToggleMaximizedState(aura::Window* window) {
|
||||
|
||||
namespace internal {
|
||||
|
||||
WorkspaceEventFilter::WorkspaceEventFilter(aura::Window* owner)
|
||||
: ToplevelWindowEventFilter(owner),
|
||||
WorkspaceEventHandler::WorkspaceEventHandler(aura::Window* owner)
|
||||
: ToplevelWindowEventHandler(owner),
|
||||
destroyed_(NULL) {
|
||||
}
|
||||
|
||||
WorkspaceEventFilter::~WorkspaceEventFilter() {
|
||||
WorkspaceEventHandler::~WorkspaceEventHandler() {
|
||||
if (destroyed_)
|
||||
*destroyed_ = true;
|
||||
}
|
||||
|
||||
bool WorkspaceEventFilter::PreHandleMouseEvent(aura::Window* target,
|
||||
ui::MouseEvent* event) {
|
||||
ui::EventResult WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) {
|
||||
aura::Window* target = static_cast<aura::Window*>(event->target());
|
||||
switch (event->type()) {
|
||||
case ui::ET_MOUSE_MOVED: {
|
||||
int component =
|
||||
@ -87,7 +87,7 @@ bool WorkspaceEventFilter::PreHandleMouseEvent(aura::Window* target,
|
||||
destroyed_ = &destroyed;
|
||||
ToggleMaximizedState(target);
|
||||
if (destroyed)
|
||||
return false;
|
||||
return ui::ER_UNHANDLED;
|
||||
destroyed_ = NULL;
|
||||
}
|
||||
multi_window_resize_controller_.Hide();
|
||||
@ -97,22 +97,21 @@ bool WorkspaceEventFilter::PreHandleMouseEvent(aura::Window* target,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ToplevelWindowEventFilter::PreHandleMouseEvent(target, event);
|
||||
return ToplevelWindowEventHandler::OnMouseEvent(event);
|
||||
}
|
||||
|
||||
ui::EventResult WorkspaceEventFilter::PreHandleGestureEvent(
|
||||
aura::Window* target,
|
||||
ui::GestureEvent* event) {
|
||||
ui::EventResult WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
||||
aura::Window* target = static_cast<aura::Window*>(event->target());
|
||||
if (event->type() == ui::ET_GESTURE_DOUBLE_TAP &&
|
||||
target->delegate()->GetNonClientComponent(event->location()) ==
|
||||
HTCAPTION) {
|
||||
ToggleMaximizedState(target); // |this| may be destroyed from here.
|
||||
return ui::ER_CONSUMED;
|
||||
}
|
||||
return ToplevelWindowEventFilter::PreHandleGestureEvent(target, event);
|
||||
return ToplevelWindowEventHandler::OnGestureEvent(event);
|
||||
}
|
||||
|
||||
WindowResizer* WorkspaceEventFilter::CreateWindowResizer(
|
||||
WindowResizer* WorkspaceEventHandler::CreateWindowResizer(
|
||||
aura::Window* window,
|
||||
const gfx::Point& point_in_parent,
|
||||
int window_component) {
|
||||
@ -127,7 +126,7 @@ WindowResizer* WorkspaceEventFilter::CreateWindowResizer(
|
||||
std::vector<aura::Window*>());
|
||||
}
|
||||
|
||||
void WorkspaceEventFilter::HandleVerticalResizeDoubleClick(
|
||||
void WorkspaceEventHandler::HandleVerticalResizeDoubleClick(
|
||||
aura::Window* target,
|
||||
ui::MouseEvent* event) {
|
||||
if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
|
@ -2,10 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ASH_WM_WORKSPACE_WORKSPACE_EVENT_FILTER_H_
|
||||
#define ASH_WM_WORKSPACE_WORKSPACE_EVENT_FILTER_H_
|
||||
#ifndef ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_H_
|
||||
#define ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_H_
|
||||
|
||||
#include "ash/wm/toplevel_window_event_filter.h"
|
||||
#include "ash/wm/toplevel_window_event_handler.h"
|
||||
#include "ash/wm/workspace/multi_window_resize_controller.h"
|
||||
|
||||
namespace aura {
|
||||
@ -15,29 +15,26 @@ class Window;
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
class WorkspaceEventFilterTestHelper;
|
||||
class WorkspaceEventHandlerTestHelper;
|
||||
|
||||
class WorkspaceEventFilter : public ToplevelWindowEventFilter {
|
||||
class WorkspaceEventHandler : public ToplevelWindowEventHandler {
|
||||
public:
|
||||
explicit WorkspaceEventFilter(aura::Window* owner);
|
||||
virtual ~WorkspaceEventFilter();
|
||||
explicit WorkspaceEventHandler(aura::Window* owner);
|
||||
virtual ~WorkspaceEventHandler();
|
||||
|
||||
// Overridden from ToplevelWindowEventFilter:
|
||||
virtual bool PreHandleMouseEvent(aura::Window* target,
|
||||
ui::MouseEvent* event) OVERRIDE;
|
||||
virtual ui::EventResult PreHandleGestureEvent(
|
||||
aura::Window* target,
|
||||
ui::GestureEvent* event) OVERRIDE;
|
||||
// Overridden from ToplevelWindowEventHandler:
|
||||
virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
|
||||
virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
|
||||
|
||||
protected:
|
||||
// Overridden from ToplevelWindowEventFilter:
|
||||
// Overridden from ToplevelWindowEventHandler:
|
||||
virtual WindowResizer* CreateWindowResizer(
|
||||
aura::Window* window,
|
||||
const gfx::Point& point_in_parent,
|
||||
int window_component) OVERRIDE;
|
||||
|
||||
private:
|
||||
friend class WorkspaceEventFilterTestHelper;
|
||||
friend class WorkspaceEventHandlerTestHelper;
|
||||
|
||||
// Determines if |event| corresponds to a double click on either the top or
|
||||
// bottom vertical resize edge, and if so toggles the vertical height of the
|
||||
@ -51,10 +48,10 @@ class WorkspaceEventFilter : public ToplevelWindowEventFilter {
|
||||
// If non-NULL, set to true in the destructor.
|
||||
bool* destroyed_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventFilter);
|
||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventHandler);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_WM_WORKSPACE_WORKSPACE_EVENT_FILTER_H_
|
||||
#endif // ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_H_
|
19
ash/wm/workspace/workspace_event_handler_test_helper.cc
Normal file
19
ash/wm/workspace/workspace_event_handler_test_helper.cc
Normal file
@ -0,0 +1,19 @@
|
||||
// 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 "ash/wm/workspace/workspace_event_handler_test_helper.h"
|
||||
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
WorkspaceEventHandlerTestHelper::WorkspaceEventHandlerTestHelper(
|
||||
WorkspaceEventHandler* handler)
|
||||
: handler_(handler) {
|
||||
}
|
||||
|
||||
WorkspaceEventHandlerTestHelper::~WorkspaceEventHandlerTestHelper() {
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ash
|
31
ash/wm/workspace/workspace_event_handler_test_helper.h
Normal file
31
ash/wm/workspace/workspace_event_handler_test_helper.h
Normal file
@ -0,0 +1,31 @@
|
||||
// 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 ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_TEST_HELPER_H_
|
||||
#define ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_TEST_HELPER_H_
|
||||
|
||||
#include "ash/wm/workspace/workspace_event_handler.h"
|
||||
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
class WorkspaceEventHandlerTestHelper {
|
||||
public:
|
||||
explicit WorkspaceEventHandlerTestHelper(WorkspaceEventHandler* handler);
|
||||
~WorkspaceEventHandlerTestHelper();
|
||||
|
||||
MultiWindowResizeController* resize_controller() {
|
||||
return &(handler_->multi_window_resize_controller_);
|
||||
}
|
||||
|
||||
private:
|
||||
WorkspaceEventHandler* handler_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventHandlerTestHelper);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_TEST_HELPER_H_
|
@ -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 "ash/wm/workspace/workspace_event_filter.h"
|
||||
#include "ash/wm/workspace/workspace_event_handler.h"
|
||||
|
||||
#include "ash/shell.h"
|
||||
#include "ash/test/ash_test_base.h"
|
||||
@ -19,10 +19,10 @@
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
class WorkspaceEventFilterTest : public test::AshTestBase {
|
||||
class WorkspaceEventHandlerTest : public test::AshTestBase {
|
||||
public:
|
||||
WorkspaceEventFilterTest() {}
|
||||
virtual ~WorkspaceEventFilterTest() {}
|
||||
WorkspaceEventHandlerTest() {}
|
||||
virtual ~WorkspaceEventHandlerTest() {}
|
||||
|
||||
protected:
|
||||
aura::Window* CreateTestWindow(aura::WindowDelegate* delegate,
|
||||
@ -37,10 +37,10 @@ class WorkspaceEventFilterTest : public test::AshTestBase {
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventFilterTest);
|
||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventHandlerTest);
|
||||
};
|
||||
|
||||
TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
|
||||
TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) {
|
||||
// Double clicking the vertical resize edge of a window should maximize it
|
||||
// vertically.
|
||||
gfx::Rect restored_bounds(10, 10, 50, 50);
|
||||
@ -95,7 +95,7 @@ TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
|
||||
EXPECT_FALSE(wm::IsWindowMaximized(window.get()));
|
||||
}
|
||||
|
||||
TEST_F(WorkspaceEventFilterTest, DoubleClickCaptionTogglesMaximize) {
|
||||
TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
|
||||
aura::test::TestWindowDelegate wd;
|
||||
scoped_ptr<aura::Window> window(CreateTestWindow(&wd, gfx::Rect(1, 2, 3, 4)));
|
||||
wd.set_window_component(HTCAPTION);
|
||||
@ -112,7 +112,7 @@ TEST_F(WorkspaceEventFilterTest, DoubleClickCaptionTogglesMaximize) {
|
||||
EXPECT_EQ("1,2 3x4", window->bounds().ToString());
|
||||
}
|
||||
|
||||
TEST_F(WorkspaceEventFilterTest, DoubleTapCaptionTogglesMaximize) {
|
||||
TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) {
|
||||
aura::test::TestWindowDelegate wd;
|
||||
gfx::Rect bounds(10, 20, 30, 40);
|
||||
scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
|
||||
@ -134,9 +134,9 @@ TEST_F(WorkspaceEventFilterTest, DoubleTapCaptionTogglesMaximize) {
|
||||
}
|
||||
|
||||
// Verifies deleting the window while dragging doesn't crash.
|
||||
TEST_F(WorkspaceEventFilterTest, DeleteWhenDragging) {
|
||||
TEST_F(WorkspaceEventHandlerTest, DeleteWhenDragging) {
|
||||
// Create a large window in the background. This is necessary so that when we
|
||||
// delete |window| WorkspaceEventFilter is still the active EventFilter.
|
||||
// delete |window| WorkspaceEventHandler is still the active event handler.
|
||||
aura::test::TestWindowDelegate wd2;
|
||||
scoped_ptr<aura::Window> window2(
|
||||
CreateTestWindow(&wd2, gfx::Rect(0, 0, 500, 500)));
|
||||
@ -155,7 +155,7 @@ TEST_F(WorkspaceEventFilterTest, DeleteWhenDragging) {
|
||||
}
|
||||
|
||||
// Verifies deleting the window while in a run loop doesn't crash.
|
||||
TEST_F(WorkspaceEventFilterTest, DeleteWhileInRunLoop) {
|
||||
TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) {
|
||||
aura::test::TestWindowDelegate wd;
|
||||
const gfx::Rect bounds(10, 20, 30, 40);
|
||||
scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "ash/ash_switches.h"
|
||||
#include "ash/wm/window_util.h"
|
||||
#include "ash/wm/workspace/workspace_event_filter.h"
|
||||
#include "ash/wm/workspace/workspace_event_handler.h"
|
||||
#include "ash/wm/workspace/workspace_layout_manager.h"
|
||||
#include "ash/wm/workspace/workspace_manager.h"
|
||||
#include "ash/wm/workspace/workspace_manager2.h"
|
||||
@ -22,7 +22,7 @@ namespace internal {
|
||||
WorkspaceController::WorkspaceController(aura::Window* viewport)
|
||||
: viewport_(viewport),
|
||||
layout_manager_(NULL),
|
||||
event_filter_(NULL) {
|
||||
event_handler_(NULL) {
|
||||
aura::RootWindow* root_window = viewport->GetRootWindow();
|
||||
if (IsWorkspace2Enabled()) {
|
||||
WorkspaceManager2* workspace_manager = new WorkspaceManager2(viewport);
|
||||
@ -33,8 +33,8 @@ WorkspaceController::WorkspaceController(aura::Window* viewport)
|
||||
layout_manager_ = new WorkspaceLayoutManager(
|
||||
root_window, workspace_manager);
|
||||
viewport->SetLayoutManager(layout_manager_);
|
||||
event_filter_ = new WorkspaceEventFilter(viewport);
|
||||
viewport->SetEventFilter(event_filter_);
|
||||
event_handler_ = new WorkspaceEventHandler(viewport);
|
||||
viewport->AddPreTargetHandler(event_handler_);
|
||||
}
|
||||
aura::client::GetActivationClient(root_window)->AddObserver(this);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace internal {
|
||||
class BaseWorkspaceManager;
|
||||
class ShelfLayoutManager;
|
||||
class WorkspaceControllerTestHelper;
|
||||
class WorkspaceEventFilter;
|
||||
class WorkspaceEventHandler;
|
||||
class WorkspaceLayoutManager;
|
||||
|
||||
// WorkspaceController acts as a central place that ties together all the
|
||||
@ -60,14 +60,14 @@ class ASH_EXPORT WorkspaceController
|
||||
|
||||
scoped_ptr<BaseWorkspaceManager> workspace_manager_;
|
||||
|
||||
// TODO(sky): remove |layout_manager_| and |event_filter_| when Workspace2
|
||||
// TODO(sky): remove |layout_manager_| and |event_handler_| when Workspace2
|
||||
// is the default.
|
||||
|
||||
// Owned by the window its attached to.
|
||||
WorkspaceLayoutManager* layout_manager_;
|
||||
|
||||
// Owned by |viewport_|.
|
||||
WorkspaceEventFilter* event_filter_;
|
||||
WorkspaceEventHandler* event_handler_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceController);
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "ash/wm/workspace_controller_test_helper.h"
|
||||
|
||||
#include "ash/wm/workspace_controller.h"
|
||||
#include "ash/wm/workspace/workspace_event_filter_test_helper.h"
|
||||
#include "ash/wm/workspace/workspace_event_handler_test_helper.h"
|
||||
#include "ui/aura/window.h"
|
||||
|
||||
namespace ash {
|
||||
@ -19,16 +19,18 @@ WorkspaceControllerTestHelper::WorkspaceControllerTestHelper(
|
||||
WorkspaceControllerTestHelper::~WorkspaceControllerTestHelper() {
|
||||
}
|
||||
|
||||
WorkspaceEventFilter* WorkspaceControllerTestHelper::GetFilter() {
|
||||
if (WorkspaceController::IsWorkspace2Enabled())
|
||||
return static_cast<WorkspaceEventFilter*>(
|
||||
controller_->viewport_->children()[0]->event_filter());
|
||||
return controller_->event_filter_;
|
||||
WorkspaceEventHandler* WorkspaceControllerTestHelper::GetEventHandler() {
|
||||
if (WorkspaceController::IsWorkspace2Enabled()) {
|
||||
ui::EventTarget::TestApi test_api(controller_->viewport_->children()[0]);
|
||||
return static_cast<WorkspaceEventHandler*>(
|
||||
test_api.pre_target_handlers().front());
|
||||
}
|
||||
return controller_->event_handler_;
|
||||
}
|
||||
|
||||
MultiWindowResizeController*
|
||||
WorkspaceControllerTestHelper::GetMultiWindowResizeController() {
|
||||
return WorkspaceEventFilterTestHelper(GetFilter()).resize_controller();
|
||||
return WorkspaceEventHandlerTestHelper(GetEventHandler()).resize_controller();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -13,14 +13,14 @@ namespace ash {
|
||||
namespace internal {
|
||||
|
||||
class MultiWindowResizeController;
|
||||
class WorkspaceEventFilter;
|
||||
class WorkspaceEventHandler;
|
||||
|
||||
class WorkspaceControllerTestHelper {
|
||||
public:
|
||||
explicit WorkspaceControllerTestHelper(WorkspaceController* controller);
|
||||
~WorkspaceControllerTestHelper();
|
||||
|
||||
WorkspaceEventFilter* GetFilter();
|
||||
WorkspaceEventHandler* GetEventHandler();
|
||||
MultiWindowResizeController* GetMultiWindowResizeController();
|
||||
WorkspaceManager* workspace_manager() {
|
||||
return static_cast<WorkspaceManager*>(
|
||||
|
@ -40,8 +40,8 @@ void EventTarget::GetPreTargetHandlers(EventHandlerList* list) {
|
||||
EventTarget* target = this;
|
||||
while (target) {
|
||||
EventHandlerList::reverse_iterator it, rend;
|
||||
for (it = target->pre_target_list().rbegin(),
|
||||
rend = target->pre_target_list().rend();
|
||||
for (it = target->pre_target_list_.rbegin(),
|
||||
rend = target->pre_target_list_.rend();
|
||||
it != rend;
|
||||
++it) {
|
||||
list->insert(list->begin(), *it);
|
||||
@ -53,8 +53,8 @@ void EventTarget::GetPreTargetHandlers(EventHandlerList* list) {
|
||||
void EventTarget::GetPostTargetHandlers(EventHandlerList* list) {
|
||||
EventTarget* target = this;
|
||||
while (target) {
|
||||
for (EventHandlerList::iterator it = target->post_target_list().begin(),
|
||||
end = target->post_target_list().end(); it != end; ++it) {
|
||||
for (EventHandlerList::iterator it = target->post_target_list_.begin(),
|
||||
end = target->post_target_list_.end(); it != end; ++it) {
|
||||
list->push_back(*it);
|
||||
}
|
||||
target = target->GetParentTarget();
|
||||
|
@ -17,6 +17,21 @@ class UI_EXPORT EventTarget : public EventHandler {
|
||||
public:
|
||||
typedef std::vector<EventTarget*> EventTargets;
|
||||
|
||||
class TestApi {
|
||||
public:
|
||||
explicit TestApi(EventTarget* target) : target_(target) {}
|
||||
|
||||
const EventHandlerList& pre_target_handlers() {
|
||||
return target_->pre_target_list_;
|
||||
}
|
||||
|
||||
private:
|
||||
TestApi();
|
||||
EventTarget* target_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TestApi);
|
||||
};
|
||||
|
||||
EventTarget();
|
||||
virtual ~EventTarget();
|
||||
|
||||
@ -29,7 +44,7 @@ class UI_EXPORT EventTarget : public EventHandler {
|
||||
void AddPreTargetHandler(EventHandler* handler);
|
||||
void RemovePreTargetHandler(EventHandler* handler);
|
||||
|
||||
// Adds a handler to receive events after the target. The hanler must be
|
||||
// Adds a handler to receive events after the target. The handler must be
|
||||
// explicitly removed from the target before the handler is destroyed. The
|
||||
// EventTarget does not take ownership of the handler.
|
||||
void AddPostTargetHandler(EventHandler* handler);
|
||||
@ -40,9 +55,6 @@ class UI_EXPORT EventTarget : public EventHandler {
|
||||
target_handler_ = handler;
|
||||
}
|
||||
|
||||
EventHandlerList& pre_target_list() { return pre_target_list_; }
|
||||
EventHandlerList& post_target_list() { return post_target_list_; }
|
||||
|
||||
private:
|
||||
friend class EventDispatcher;
|
||||
|
||||
|
Reference in New Issue
Block a user