summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-06 06:37:09 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-06 06:37:09 +0000
commit1aad332c7d47b1adc56708130d36dc1f513b67ae (patch)
tree9103e4927e301881f73e5798d4cac8f2f4986afd
parent382a064036206876b25fdd9052fe073721bebbb5 (diff)
downloadchromium_src-1aad332c7d47b1adc56708130d36dc1f513b67ae.zip
chromium_src-1aad332c7d47b1adc56708130d36dc1f513b67ae.tar.gz
chromium_src-1aad332c7d47b1adc56708130d36dc1f513b67ae.tar.bz2
Add EnvEventFilter to filter events before root window process event
Factor out CursorManager from RootWindowEventFilter Review URL: https://chromiumcodereview.appspot.com/10444107 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140714 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/accelerators/accelerator_filter_unittest.cc1
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/drag_drop/drag_drop_controller.cc15
-rw-r--r--ash/drag_drop/drag_drop_controller_unittest.cc1
-rw-r--r--ash/shell.cc83
-rw-r--r--ash/shell.h28
-rw-r--r--ash/system/tray/system_tray_bubble.cc4
-rw-r--r--ash/tooltips/tooltip_controller.cc4
-rw-r--r--ash/tooltips/tooltip_controller_unittest.cc6
-rw-r--r--ash/wm/app_list_controller.cc4
-rw-r--r--ash/wm/default_window_resizer.cc13
-rw-r--r--ash/wm/power_button_controller.cc12
-rw-r--r--ash/wm/power_button_controller_unittest.cc15
-rw-r--r--ash/wm/shelf_layout_manager.cc4
-rw-r--r--ash/wm/system_gesture_event_filter_unittest.cc2
-rw-r--r--ash/wm/system_modal_container_layout_manager.cc4
-rw-r--r--ash/wm/window_cycle_controller.cc4
-rw-r--r--ash/wm/window_manager_unittest.cc (renamed from ash/wm/root_window_event_filter_unittest.cc)65
-rw-r--r--ash/wm/workspace/frame_maximize_button.cc4
-rw-r--r--ash/wm/workspace/multi_window_resize_controller.cc4
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc11
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc5
-rw-r--r--ui/aura/aura.gyp9
-rw-r--r--ui/aura/cursor_delegate.h27
-rw-r--r--ui/aura/cursor_manager.cc58
-rw-r--r--ui/aura/cursor_manager.h59
-rw-r--r--ui/aura/env.cc7
-rw-r--r--ui/aura/env.h12
-rw-r--r--ui/aura/root_window.cc3
-rw-r--r--ui/aura/root_window.h1
-rw-r--r--ui/aura/shared/compound_event_filter.cc (renamed from ui/aura/shared/root_window_event_filter.cc)108
-rw-r--r--ui/aura/shared/compound_event_filter.h (renamed from ui/aura/shared/root_window_event_filter.h)54
-rw-r--r--ui/aura/shared/compound_event_filter_unittest.cc (renamed from ui/aura/shared/root_window_event_filter_unittest.cc)24
-rw-r--r--ui/aura/shared/input_method_event_filter_unittest.cc10
-rw-r--r--ui/views/widget/desktop_native_widget_helper_aura.cc11
-rw-r--r--ui/views/widget/desktop_native_widget_helper_aura.h4
36 files changed, 410 insertions, 268 deletions
diff --git a/ash/accelerators/accelerator_filter_unittest.cc b/ash/accelerators/accelerator_filter_unittest.cc
index 86a50fa..3240f4d 100644
--- a/ash/accelerators/accelerator_filter_unittest.cc
+++ b/ash/accelerators/accelerator_filter_unittest.cc
@@ -12,7 +12,6 @@
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/aura/shared/root_window_event_filter.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_windows.h"
diff --git a/ash/ash.gyp b/ash/ash.gyp
index dbfbe2a..d829a59 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -395,7 +395,6 @@
'wm/image_grid_unittest.cc',
'wm/panel_layout_manager_unittest.cc',
'wm/power_button_controller_unittest.cc',
- 'wm/root_window_event_filter_unittest.cc',
'wm/screen_dimmer_unittest.cc',
'wm/shadow_controller_unittest.cc',
'wm/shelf_layout_manager_unittest.cc',
@@ -407,6 +406,7 @@
'wm/visibility_controller_unittest.cc',
'wm/window_animations_unittest.cc',
'wm/window_cycle_controller_unittest.cc',
+ 'wm/window_manager_unittest.cc',
'wm/window_modality_controller_unittest.cc',
'wm/workspace_controller_test_helper.cc',
'wm/workspace_controller_test_helper.h',
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc
index 366d980..51779a5 100644
--- a/ash/drag_drop/drag_drop_controller.cc
+++ b/ash/drag_drop/drag_drop_controller.cc
@@ -8,6 +8,7 @@
#include "ash/shell.h"
#include "base/message_loop.h"
#include "ui/aura/client/drag_drop_delegate.h"
+#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -41,11 +42,11 @@ DragDropController::DragDropController()
drag_window_(NULL),
drag_drop_in_progress_(false),
should_block_during_drag_drop_(true) {
- Shell::GetInstance()->AddRootWindowEventFilter(this);
+ Shell::GetInstance()->AddEnvEventFilter(this);
}
DragDropController::~DragDropController() {
- Shell::GetInstance()->RemoveRootWindowEventFilter(this);
+ Shell::GetInstance()->RemoveEnvEventFilter(this);
Cleanup();
if (drag_image_.get())
drag_image_.reset();
@@ -55,6 +56,7 @@ int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
const gfx::Point& root_location,
int operation) {
DCHECK(!drag_drop_in_progress_);
+ // TODO(oshima): Add CaptureClient client API.
aura::Window* capture_window =
Shell::GetPrimaryRootWindow()->capture_window();
if (capture_window)
@@ -122,10 +124,7 @@ void DragDropController::DragUpdate(aura::Window* target,
cursor = ui::kCursorAlias;
else if (op & ui::DragDropTypes::DRAG_MOVE)
cursor = ui::kCursorMove;
- if (drag_window_->GetRootWindow())
- drag_window_->GetRootWindow()->SetCursor(cursor);
- else
- Shell::GetPrimaryRootWindow()->SetCursor(cursor);
+ aura::Env::GetInstance()->cursor_manager()->SetCursor(cursor);
}
}
@@ -138,7 +137,7 @@ void DragDropController::DragUpdate(aura::Window* target,
void DragDropController::Drop(aura::Window* target,
const aura::LocatedEvent& event) {
- Shell::GetPrimaryRootWindow()->SetCursor(ui::kCursorPointer);
+ aura::Env::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer);
aura::client::DragDropDelegate* delegate = NULL;
// We must guarantee that a target gets a OnDragEntered before Drop. WebKit
@@ -167,7 +166,7 @@ void DragDropController::Drop(aura::Window* target,
}
void DragDropController::DragCancel() {
- Shell::GetPrimaryRootWindow()->SetCursor(ui::kCursorPointer);
+ aura::Env::GetInstance()->cursor_manager()->SetCursor(ui::kCursorPointer);
// |drag_window_| can be NULL if we have just started the drag and have not
// received any DragUpdates, or, if the |drag_window_| gets destroyed during
diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc
index 33283db..890a3a2 100644
--- a/ash/drag_drop/drag_drop_controller_unittest.cc
+++ b/ash/drag_drop/drag_drop_controller_unittest.cc
@@ -10,7 +10,6 @@
#include "base/utf_string_conversions.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/shared/root_window_event_filter.h"
#include "ui/aura/test/event_generator.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
diff --git a/ash/shell.cc b/ash/shell.cc
index ccfa5c4..6857519 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -69,13 +69,14 @@
#include "grit/ui_resources.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/user_action_client.h"
+#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/monitor_manager.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/shared/input_method_event_filter.h"
-#include "ui/aura/shared/root_window_event_filter.h"
#include "ui/aura/ui_controls_aura.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
@@ -562,7 +563,7 @@ internal::WorkspaceController* Shell::TestApi::workspace_controller() {
Shell::Shell(ShellDelegate* delegate)
: root_window_(aura::MonitorManager::CreateRootWindowForPrimaryMonitor()),
screen_(new ScreenAsh(root_window_.get())),
- root_filter_(NULL),
+ env_filter_(NULL),
delegate_(delegate),
#if defined(OS_CHROMEOS)
output_configurator_(new chromeos::OutputConfigurator()),
@@ -584,26 +585,27 @@ Shell::Shell(ShellDelegate* delegate)
Shell::~Shell() {
views::FocusManagerFactory::Install(NULL);
+ aura::Env::GetInstance()->cursor_manager()->set_delegate(NULL);
// Please keep in same order as in Init() because it's easy to miss one.
- RemoveRootWindowEventFilter(key_rewriter_filter_.get());
- RemoveRootWindowEventFilter(partial_screenshot_filter_.get());
- RemoveRootWindowEventFilter(input_method_filter_.get());
- RemoveRootWindowEventFilter(window_modality_controller_.get());
- RemoveRootWindowEventFilter(system_gesture_filter_.get());
- RemoveRootWindowEventFilter(slow_animation_filter_.get());
+ RemoveEnvEventFilter(key_rewriter_filter_.get());
+ RemoveEnvEventFilter(partial_screenshot_filter_.get());
+ RemoveEnvEventFilter(input_method_filter_.get());
+ RemoveEnvEventFilter(window_modality_controller_.get());
+ RemoveEnvEventFilter(system_gesture_filter_.get());
+ RemoveEnvEventFilter(slow_animation_filter_.get());
#if !defined(OS_MACOSX)
- RemoveRootWindowEventFilter(accelerator_filter_.get());
+ RemoveEnvEventFilter(accelerator_filter_.get());
#endif
if (touch_observer_hud_.get())
- RemoveRootWindowEventFilter(touch_observer_hud_.get());
+ RemoveEnvEventFilter(touch_observer_hud_.get());
// Close background widget now so that the focus manager of the
// widget gets deleted in the final message loop run.
root_window_layout_->SetBackgroundWidget(NULL);
// TooltipController is deleted with the Shell so removing its references.
- RemoveRootWindowEventFilter(tooltip_controller_.get());
+ RemoveEnvEventFilter(tooltip_controller_.get());
aura::client::SetTooltipClient(GetPrimaryRootWindow(), NULL);
// Make sure we delete WorkspaceController before launcher is
@@ -708,13 +710,18 @@ void Shell::Init() {
// Launcher, and WallPaper could be created by the factory.
views::FocusManagerFactory::Install(new AshFocusManagerFactory);
+ env_filter_ = new aura::shared::CompoundEventFilter;
+ // Pass ownership of the filter to the Env.
+ aura::Env::GetInstance()->SetEventFilter(env_filter_);
+
+ aura::Env::GetInstance()->cursor_manager()->set_delegate(this);
+
aura::RootWindow* root_window = GetPrimaryRootWindow();
active_root_window_ = root_window;
focus_manager_.reset(new aura::FocusManager);
root_window_->set_focus_manager(focus_manager_.get());
- root_filter_ = new aura::shared::RootWindowEventFilter(root_window);
#if !defined(OS_MACOSX)
nested_dispatcher_controller_.reset(new NestedDispatcherController);
aura::client::SetDispatcherClient(root_window,
@@ -722,41 +729,39 @@ void Shell::Init() {
accelerator_controller_.reset(new AcceleratorController);
#endif
shell_context_menu_.reset(new internal::ShellContextMenu);
- // Pass ownership of the filter to the root window.
- root_window->SetEventFilter(root_filter_);
// KeyRewriterEventFilter must be the first one.
- DCHECK(!GetRootWindowEventFilterCount());
+ DCHECK(!GetEnvEventFilterCount());
key_rewriter_filter_.reset(new internal::KeyRewriterEventFilter);
- AddRootWindowEventFilter(key_rewriter_filter_.get());
+ AddEnvEventFilter(key_rewriter_filter_.get());
// PartialScreenshotEventFilter must be the second one to capture key
// events when the taking partial screenshot UI is there.
- DCHECK_EQ(1U, GetRootWindowEventFilterCount());
+ DCHECK_EQ(1U, GetEnvEventFilterCount());
partial_screenshot_filter_.reset(new internal::PartialScreenshotEventFilter);
- AddRootWindowEventFilter(partial_screenshot_filter_.get());
+ AddEnvEventFilter(partial_screenshot_filter_.get());
AddShellObserver(partial_screenshot_filter_.get());
// InputMethodEventFilter must be the third one. It has to be added before
// AcceleratorFilter.
- DCHECK_EQ(2U, GetRootWindowEventFilterCount());
+ DCHECK_EQ(2U, GetEnvEventFilterCount());
input_method_filter_.reset(new aura::shared::InputMethodEventFilter());
input_method_filter_->SetInputMethodPropertyInRootWindow(root_window);
- AddRootWindowEventFilter(input_method_filter_.get());
+ AddEnvEventFilter(input_method_filter_.get());
#if !defined(OS_MACOSX)
accelerator_filter_.reset(new internal::AcceleratorFilter);
- AddRootWindowEventFilter(accelerator_filter_.get());
+ AddEnvEventFilter(accelerator_filter_.get());
#endif
system_gesture_filter_.reset(new internal::SystemGestureEventFilter);
- AddRootWindowEventFilter(system_gesture_filter_.get());
+ AddEnvEventFilter(system_gesture_filter_.get());
slow_animation_filter_.reset(new internal::SlowAnimationEventFilter);
- AddRootWindowEventFilter(slow_animation_filter_.get());
+ AddEnvEventFilter(slow_animation_filter_.get());
root_window->SetCursor(ui::kCursorPointer);
if (initially_hide_cursor_)
- root_window->ShowCursor(false);
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
activation_controller_.reset(
new internal::ActivationController(focus_manager_.get()));
@@ -768,7 +773,7 @@ void Shell::Init() {
if (command_line->HasSwitch(switches::kAshTouchHud)) {
touch_observer_hud_.reset(new internal::TouchObserverHUD);
- AddRootWindowEventFilter(touch_observer_hud_.get());
+ AddEnvEventFilter(touch_observer_hud_.get());
}
stacking_controller_.reset(new internal::StackingController);
@@ -829,7 +834,7 @@ void Shell::Init() {
user_wallpaper_delegate_->SetLoggedInUserWallpaper();
window_modality_controller_.reset(new internal::WindowModalityController);
- AddRootWindowEventFilter(window_modality_controller_.get());
+ AddEnvEventFilter(window_modality_controller_.get());
visibility_controller_.reset(new internal::VisibilityController);
aura::client::SetVisibilityClient(root_window, visibility_controller_.get());
@@ -841,7 +846,7 @@ void Shell::Init() {
new internal::TooltipController(drag_drop_controller_.get()));
aura::client::SetTooltipClient(root_window, tooltip_controller_.get());
- AddRootWindowEventFilter(tooltip_controller_.get());
+ AddEnvEventFilter(tooltip_controller_.get());
magnification_controller_.reset(new internal::MagnificationController);
high_contrast_controller_.reset(new HighContrastController);
@@ -862,19 +867,16 @@ const aura::Window* Shell::GetContainer(int container_id) const {
return GetPrimaryRootWindow()->GetChildById(container_id);
}
-void Shell::AddRootWindowEventFilter(aura::EventFilter* filter) {
- static_cast<aura::shared::RootWindowEventFilter*>(
- GetPrimaryRootWindow()->event_filter())->AddFilter(filter);
+void Shell::AddEnvEventFilter(aura::EventFilter* filter) {
+ env_filter_->AddFilter(filter);
}
-void Shell::RemoveRootWindowEventFilter(aura::EventFilter* filter) {
- static_cast<aura::shared::RootWindowEventFilter*>(
- GetPrimaryRootWindow()->event_filter())->RemoveFilter(filter);
+void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) {
+ env_filter_->RemoveFilter(filter);
}
-size_t Shell::GetRootWindowEventFilterCount() const {
- return static_cast<aura::shared::RootWindowEventFilter*>(
- GetPrimaryRootWindow()->event_filter())->GetFilterCount();
+size_t Shell::GetEnvEventFilterCount() const {
+ return env_filter_->GetFilterCount();
}
void Shell::ShowBackgroundMenu(views::Widget* widget,
@@ -1071,4 +1073,13 @@ void Shell::DisableWorkspaceGridLayout() {
workspace_controller_->workspace_manager()->set_grid_size(0);
}
+void Shell::SetCursor(gfx::NativeCursor cursor) {
+ // TODO(oshima): set cursor to all root windows.
+ GetPrimaryRootWindow()->SetCursor(cursor);
+}
+
+void Shell::ShowCursor(bool visible) {
+ GetPrimaryRootWindow()->ShowCursor(visible);
+}
+
} // namespace ash
diff --git a/ash/shell.h b/ash/shell.h
index ef4cb34..d73d85c 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -17,6 +17,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
+#include "ui/aura/cursor_delegate.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/size.h"
@@ -32,8 +33,8 @@ namespace client {
class UserActionClient;
}
namespace shared {
+class CompoundEventFilter;
class InputMethodEventFilter;
-class RootWindowEventFilter;
}
}
namespace chromeos {
@@ -107,7 +108,7 @@ class WorkspaceController;
//
// Upon creation, the Shell sets itself as the RootWindow's delegate, which
// takes ownership of the Shell.
-class ASH_EXPORT Shell {
+class ASH_EXPORT Shell : aura::CursorDelegate {
public:
enum Direction {
FORWARD,
@@ -168,10 +169,10 @@ class ASH_EXPORT Shell {
aura::Window* GetContainer(int container_id);
const aura::Window* GetContainer(int container_id) const;
- // Adds or removes |filter| from the RootWindowEventFilter.
- void AddRootWindowEventFilter(aura::EventFilter* filter);
- void RemoveRootWindowEventFilter(aura::EventFilter* filter);
- size_t GetRootWindowEventFilterCount() const;
+ // Adds or removes |filter| from the aura::Env's CompoundEventFilter.
+ void AddEnvEventFilter(aura::EventFilter* filter);
+ void RemoveEnvEventFilter(aura::EventFilter* filter);
+ size_t GetEnvEventFilterCount() const;
// Shows the background menu over |widget|.
void ShowBackgroundMenu(views::Widget* widget, const gfx::Point& location);
@@ -229,8 +230,8 @@ class ASH_EXPORT Shell {
}
#endif // !defined(OS_MACOSX)
- aura::shared::RootWindowEventFilter* root_filter() {
- return root_filter_;
+ aura::shared::CompoundEventFilter* env_filter() {
+ return env_filter_;
}
internal::TooltipController* tooltip_controller() {
return tooltip_controller_.get();
@@ -332,8 +333,8 @@ class ASH_EXPORT Shell {
#endif // defined(OS_CHROMEOS)
private:
- FRIEND_TEST_ALL_PREFIXES(RootWindowEventFilterTest, MouseEventCursors);
- FRIEND_TEST_ALL_PREFIXES(RootWindowEventFilterTest, TransformActivate);
+ FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors);
+ FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, TransformActivate);
typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
@@ -348,6 +349,10 @@ class ASH_EXPORT Shell {
// Disables the workspace grid layout.
void DisableWorkspaceGridLayout();
+ // aura::CursorManager::Delegate overrides:
+ virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
+ virtual void ShowCursor(bool visible) OVERRIDE;
+
static Shell* instance_;
// If set before the Shell is initialized, the mouse cursor will be hidden
@@ -360,7 +365,8 @@ class ASH_EXPORT Shell {
// Active root window. Never become NULL.
aura::RootWindow* active_root_window_;
- aura::shared::RootWindowEventFilter* root_filter_; // not owned
+ // The CompoundEventFilter owned by aura::Env object.
+ aura::shared::CompoundEventFilter* env_filter_;
std::vector<WindowAndBoundsPair> to_restore_;
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc
index 04718d3..a15bd59 100644
--- a/ash/system/tray/system_tray_bubble.cc
+++ b/ash/system/tray/system_tray_bubble.cc
@@ -416,12 +416,12 @@ SystemTrayBubble::SystemTrayBubble(
anchor_type_(ANCHOR_TYPE_TRAY),
autoclose_delay_(0) {
if (bubble_type_ != BUBBLE_TYPE_NOTIFICATION)
- Shell::GetInstance()->AddRootWindowEventFilter(this);
+ Shell::GetInstance()->AddEnvEventFilter(this);
}
SystemTrayBubble::~SystemTrayBubble() {
if (bubble_type_ != BUBBLE_TYPE_NOTIFICATION)
- Shell::GetInstance()->RemoveRootWindowEventFilter(this);
+ Shell::GetInstance()->RemoveEnvEventFilter(this);
DestroyItemViews();
// Reset the host pointer in bubble_view_ in case its destruction is deferred.
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index bb0f55e..368603d 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -13,6 +13,8 @@
#include "base/string_split.h"
#include "base/time.h"
#include "ui/aura/client/drag_drop_client.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -375,7 +377,7 @@ void TooltipController::TooltipTimerFired() {
void TooltipController::UpdateIfRequired() {
if (!tooltips_enabled_ || mouse_pressed_ || IsDragDropInProgress() ||
- !Shell::GetPrimaryRootWindow()->cursor_shown()) {
+ !aura::Env::GetInstance()->cursor_manager()->cursor_visible()) {
tooltip_->Hide();
return;
}
diff --git a/ash/tooltips/tooltip_controller_unittest.cc b/ash/tooltips/tooltip_controller_unittest.cc
index 5cb972d5..1665f1a 100644
--- a/ash/tooltips/tooltip_controller_unittest.cc
+++ b/ash/tooltips/tooltip_controller_unittest.cc
@@ -7,6 +7,8 @@
#include "ash/tooltips/tooltip_controller.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/client/tooltip_client.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
@@ -244,12 +246,12 @@ TEST_F(TooltipControllerTest, HideTooltipWhenCursorHidden) {
EXPECT_TRUE(IsTooltipVisible());
// Hide the cursor and check again.
- Shell::GetPrimaryRootWindow()->ShowCursor(false);
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
FireTooltipTimer();
EXPECT_FALSE(IsTooltipVisible());
// Show the cursor and re-check.
- Shell::GetPrimaryRootWindow()->ShowCursor(true);
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(true);
FireTooltipTimer();
EXPECT_TRUE(IsTooltipVisible());
}
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index fb6159b..a8c227b 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -151,7 +151,7 @@ void AppListController::SetView(app_list::AppListView* view) {
view_ = view;
views::Widget* widget = view_->GetWidget();
widget->AddObserver(this);
- Shell::GetInstance()->AddRootWindowEventFilter(this);
+ Shell::GetInstance()->AddEnvEventFilter(this);
widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this);
widget->GetNativeView()->GetFocusManager()->AddObserver(this);
widget->SetOpacity(0);
@@ -170,7 +170,7 @@ void AppListController::ResetView() {
views::Widget* widget = view_->GetWidget();
widget->RemoveObserver(this);
GetLayer(widget)->GetAnimator()->RemoveObserver(this);
- Shell::GetInstance()->RemoveRootWindowEventFilter(this);
+ Shell::GetInstance()->RemoveEnvEventFilter(this);
widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this);
widget->GetNativeView()->GetFocusManager()->RemoveObserver(this);
view_ = NULL;
diff --git a/ash/wm/default_window_resizer.cc b/ash/wm/default_window_resizer.cc
index b71db4c..8b57115 100644
--- a/ash/wm/default_window_resizer.cc
+++ b/ash/wm/default_window_resizer.cc
@@ -6,8 +6,9 @@
#include "ash/shell.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/shared/root_window_event_filter.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
@@ -19,8 +20,7 @@
namespace ash {
DefaultWindowResizer::~DefaultWindowResizer() {
- if (root_filter_)
- root_filter_->UnlockCursor();
+ aura::Env::GetInstance()->cursor_manager()->UnlockCursor();
}
// static
@@ -74,12 +74,9 @@ void DefaultWindowResizer::RevertDrag() {
DefaultWindowResizer::DefaultWindowResizer(const Details& details)
: details_(details),
- did_move_or_resize_(false),
- root_filter_(NULL) {
+ did_move_or_resize_(false) {
DCHECK(details_.is_resizable);
- root_filter_ = Shell::GetInstance()->root_filter();
- if (root_filter_)
- root_filter_->LockCursor();
+ aura::Env::GetInstance()->cursor_manager()->LockCursor();
}
} // namespace aura
diff --git a/ash/wm/power_button_controller.cc b/ash/wm/power_button_controller.cc
index a3f1493..8b7deb7 100644
--- a/ash/wm/power_button_controller.cc
+++ b/ash/wm/power_button_controller.cc
@@ -11,8 +11,10 @@
#include "base/logging.h"
#include "base/time.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/shared/root_window_event_filter.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_element.h"
@@ -307,9 +309,9 @@ void PowerButtonController::OnAppTerminating() {
// can really hope for is that we'll have time to clear the screen.
if (!shutting_down_) {
shutting_down_ = true;
- ash::Shell::GetInstance()->root_filter()->
+ ash::Shell::GetInstance()->env_filter()->
set_update_cursor_visibility(false);
- Shell::GetPrimaryRootWindow()->ShowCursor(false);
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
ShowBackgroundLayer();
StartAnimation(ALL_CONTAINERS, ANIMATION_HIDE);
}
@@ -532,8 +534,8 @@ void PowerButtonController::StartShutdownAnimationAndRequestShutdown() {
DCHECK(!shutting_down_);
shutting_down_ = true;
- ash::Shell::GetInstance()->root_filter()->set_update_cursor_visibility(false);
- Shell::GetPrimaryRootWindow()->ShowCursor(false);
+ ash::Shell::GetInstance()->env_filter()->set_update_cursor_visibility(false);
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
ShowBackgroundLayer();
if (login_status_ != user::LOGGED_IN_NONE) {
diff --git a/ash/wm/power_button_controller_unittest.cc b/ash/wm/power_button_controller_unittest.cc
index e908d30..14f0232 100644
--- a/ash/wm/power_button_controller_unittest.cc
+++ b/ash/wm/power_button_controller_unittest.cc
@@ -8,12 +8,19 @@
#include "ash/test/ash_test_base.h"
#include "base/memory/scoped_ptr.h"
#include "base/time.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
namespace ash {
namespace test {
+namespace {
+bool cursor_visible() {
+ return aura::Env::GetInstance()->cursor_manager()->cursor_visible();
+}
+}
// Fake implementation of PowerButtonControllerDelegate that just logs requests
// to lock the screen and shut down the device.
@@ -114,7 +121,7 @@ TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) {
test_api_->ContainerGroupIsAnimated(
PowerButtonController::ALL_CONTAINERS,
PowerButtonController::ANIMATION_FAST_CLOSE));
- EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
+ EXPECT_FALSE(cursor_visible());
EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
test_api_->trigger_real_shutdown_timeout();
EXPECT_EQ(1, delegate_->num_shutdown_requests());
@@ -481,7 +488,7 @@ TEST_F(PowerButtonControllerTest, ShutdownWithoutButton) {
PowerButtonController::ALL_CONTAINERS,
PowerButtonController::ANIMATION_HIDE));
EXPECT_TRUE(test_api_->BackgroundLayerIsVisible());
- EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
+ EXPECT_FALSE(cursor_visible());
}
// Test that we display the fast-close animation and shut down when we get an
@@ -498,7 +505,7 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLoginScreen) {
PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS,
PowerButtonController::ANIMATION_FAST_CLOSE));
EXPECT_TRUE(test_api_->BackgroundLayerIsVisible());
- EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
+ EXPECT_FALSE(cursor_visible());
EXPECT_EQ(0, delegate_->num_shutdown_requests());
EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
@@ -519,7 +526,7 @@ TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) {
PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS,
PowerButtonController::ANIMATION_FAST_CLOSE));
EXPECT_TRUE(test_api_->BackgroundLayerIsVisible());
- EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
+ EXPECT_FALSE(cursor_visible());
EXPECT_EQ(0, delegate_->num_shutdown_requests());
EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc
index 1634557..3f2e857 100644
--- a/ash/wm/shelf_layout_manager.cc
+++ b/ash/wm/shelf_layout_manager.cc
@@ -78,11 +78,11 @@ ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter(
ShelfLayoutManager* shelf)
: shelf_(shelf),
in_mouse_drag_(false) {
- Shell::GetInstance()->AddRootWindowEventFilter(this);
+ Shell::GetInstance()->AddEnvEventFilter(this);
}
ShelfLayoutManager::AutoHideEventFilter::~AutoHideEventFilter() {
- Shell::GetInstance()->RemoveRootWindowEventFilter(this);
+ Shell::GetInstance()->RemoveEnvEventFilter(this);
}
bool ShelfLayoutManager::AutoHideEventFilter::PreHandleKeyEvent(
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index c22b168..5070b14 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -119,7 +119,7 @@ TEST_F(SystemGestureEventFilterTest, TapOutsideRootWindow) {
// Without the event filter, the touch shouldn't be consumed by the
// system event handler.
- Shell::GetInstance()->RemoveRootWindowEventFilter(
+ Shell::GetInstance()->RemoveEnvEventFilter(
shell_test.system_gesture_event_filter());
aura::GestureEvent* event2 = new aura::GestureEvent(
diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc
index ae5dd63..d07a5c7 100644
--- a/ash/wm/system_modal_container_layout_manager.cc
+++ b/ash/wm/system_modal_container_layout_manager.cc
@@ -191,7 +191,7 @@ void SystemModalContainerLayoutManager::CreateModalScreen() {
modal_screen_->SetContentsView(new ScreenView);
modal_screen_->GetNativeView()->layer()->SetOpacity(0.0f);
- Shell::GetInstance()->AddRootWindowEventFilter(modality_filter_.get());
+ Shell::GetInstance()->AddEnvEventFilter(modality_filter_.get());
}
ui::ScopedLayerAnimationSettings settings(
@@ -202,7 +202,7 @@ void SystemModalContainerLayoutManager::CreateModalScreen() {
}
void SystemModalContainerLayoutManager::DestroyModalScreen() {
- Shell::GetInstance()->RemoveRootWindowEventFilter(modality_filter_.get());
+ Shell::GetInstance()->RemoveEnvEventFilter(modality_filter_.get());
ui::ScopedLayerAnimationSettings settings(
modal_screen_->GetNativeView()->layer()->GetAnimator());
modal_screen_->Close();
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
index 771ea2b..a79ed88 100644
--- a/ash/wm/window_cycle_controller.cc
+++ b/ash/wm/window_cycle_controller.cc
@@ -159,14 +159,14 @@ void WindowCycleController::StopCycling() {
windows_.reset();
// Remove our key event filter.
if (event_filter_.get()) {
- Shell::GetInstance()->RemoveRootWindowEventFilter(event_filter_.get());
+ Shell::GetInstance()->RemoveEnvEventFilter(event_filter_.get());
event_filter_.reset();
}
}
void WindowCycleController::InstallEventFilter() {
event_filter_.reset(new WindowCycleEventFilter());
- Shell::GetInstance()->AddRootWindowEventFilter(event_filter_.get());
+ Shell::GetInstance()->AddEnvEventFilter(event_filter_.get());
}
} // namespace ash
diff --git a/ash/wm/root_window_event_filter_unittest.cc b/ash/wm/window_manager_unittest.cc
index 10fb0442..60a9617 100644
--- a/ash/wm/root_window_event_filter_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -10,11 +10,13 @@
#include "ash/wm/window_util.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/activation_delegate.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/shared/input_method_event_filter.h"
-#include "ui/aura/shared/root_window_event_filter.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_event_filter.h"
@@ -24,9 +26,6 @@
#include "ui/base/hit_test.h"
#include "ui/gfx/screen.h"
-// TODO(erg,beng): This file is misnamed; it really acts as an integration test
-// between most of the ash::Shell() objects, not just RootWindowEventFitler.
-
namespace {
base::TimeDelta getTime() {
@@ -37,7 +36,7 @@ base::TimeDelta getTime() {
namespace ash {
-typedef test::AshTestBase RootWindowEventFilterTest;
+typedef test::AshTestBase WindowManagerTest;
class NonFocusableDelegate : public aura::test::TestWindowDelegate {
public:
@@ -70,11 +69,11 @@ class HitTestWindowDelegate : public aura::test::TestWindowDelegate {
DISALLOW_COPY_AND_ASSIGN(HitTestWindowDelegate);
};
-TEST_F(RootWindowEventFilterTest, Focus) {
+TEST_F(WindowManagerTest, Focus) {
// The IME event filter interferes with the basic key event propagation we
// attempt to do here, so we remove it.
Shell::TestApi shell_test(Shell::GetInstance());
- Shell::GetInstance()->RemoveRootWindowEventFilter(
+ Shell::GetInstance()->RemoveEnvEventFilter(
shell_test.input_method_event_filter());
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
@@ -179,7 +178,7 @@ TEST_F(RootWindowEventFilterTest, Focus) {
}
// Various assertion testing for activating windows.
-TEST_F(RootWindowEventFilterTest, ActivateOnMouse) {
+TEST_F(WindowManagerTest, ActivateOnMouse) {
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
test::TestActivationDelegate d1;
@@ -295,7 +294,7 @@ TEST_F(RootWindowEventFilterTest, ActivateOnMouse) {
}
// Essentially the same as ActivateOnMouse, but for touch events.
-TEST_F(RootWindowEventFilterTest, ActivateOnTouch) {
+TEST_F(WindowManagerTest, ActivateOnTouch) {
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
test::TestActivationDelegate d1;
@@ -365,7 +364,7 @@ TEST_F(RootWindowEventFilterTest, ActivateOnTouch) {
EXPECT_EQ(0, d1.lost_active_count());
}
-TEST_F(RootWindowEventFilterTest, MouseEventCursors) {
+TEST_F(WindowManagerTest, MouseEventCursors) {
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
// Disable ash grid so that test can place a window at
// specific location.
@@ -441,7 +440,7 @@ TEST_F(RootWindowEventFilterTest, MouseEventCursors) {
#else
#define MAYBE_TransformActivate TransformActivate
#endif
-TEST_F(RootWindowEventFilterTest, MAYBE_TransformActivate) {
+TEST_F(WindowManagerTest, MAYBE_TransformActivate) {
// Disable ash grid so that test can place a window at
// specific location.
ash::Shell::GetInstance()->DisableWorkspaceGridLayout();
@@ -490,11 +489,11 @@ TEST_F(RootWindowEventFilterTest, MAYBE_TransformActivate) {
EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow());
}
-TEST_F(RootWindowEventFilterTest, AdditionalFilters) {
+TEST_F(WindowManagerTest, AdditionalFilters) {
// The IME event filter interferes with the basic key event propagation we
// attempt to do here, so we remove it.
Shell::TestApi shell_test(Shell::GetInstance());
- Shell::GetInstance()->RemoveRootWindowEventFilter(
+ Shell::GetInstance()->RemoveEnvEventFilter(
shell_test.input_method_event_filter());
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
@@ -509,11 +508,10 @@ TEST_F(RootWindowEventFilterTest, AdditionalFilters) {
scoped_ptr<aura::test::TestEventFilter> f2(new aura::test::TestEventFilter);
// Adds them to root window event filter.
- aura::shared::RootWindowEventFilter* root_window_filter =
- static_cast<aura::shared::RootWindowEventFilter*>(
- root_window->event_filter());
- root_window_filter->AddFilter(f1.get());
- root_window_filter->AddFilter(f2.get());
+ aura::shared::CompoundEventFilter* env_filter =
+ Shell::GetInstance()->env_filter();
+ env_filter->AddFilter(f1.get());
+ env_filter->AddFilter(f2.get());
// Dispatches mouse and keyboard events.
aura::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0);
@@ -551,7 +549,7 @@ TEST_F(RootWindowEventFilterTest, AdditionalFilters) {
f2->ResetCounts();
// Remove f1 from additonal filters list.
- root_window_filter->RemoveFilter(f1.get());
+ env_filter->RemoveFilter(f1.get());
// Dispatches events.
root_window->DispatchKeyEvent(&key_event);
@@ -563,20 +561,21 @@ TEST_F(RootWindowEventFilterTest, AdditionalFilters) {
EXPECT_EQ(1, f2->key_event_count());
EXPECT_EQ(1, f2->mouse_event_count());
- root_window_filter->RemoveFilter(f2.get());
+ env_filter->RemoveFilter(f2.get());
}
// We should show and hide the cursor in response to mouse and touch events as
// requested.
-TEST_F(RootWindowEventFilterTest, UpdateCursorVisibility) {
+TEST_F(WindowManagerTest, UpdateCursorVisibility) {
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
root_window->SetBounds(gfx::Rect(0, 0, 500, 500));
scoped_ptr<aura::Window> window(aura::test::CreateTestWindow(
SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500), NULL));
- aura::shared::RootWindowEventFilter* root_window_filter =
- static_cast<aura::shared::RootWindowEventFilter*>(
- root_window->event_filter());
+ aura::shared::CompoundEventFilter* env_filter =
+ Shell::GetInstance()->env_filter();
+ aura::CursorManager* cursor_manager =
+ aura::Env::GetInstance()->cursor_manager();
aura::MouseEvent mouse_moved(
ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0);
@@ -585,21 +584,21 @@ TEST_F(RootWindowEventFilterTest, UpdateCursorVisibility) {
aura::TouchEvent touch_pressed2(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime());
- root_window_filter->set_update_cursor_visibility(true);
+ env_filter->set_update_cursor_visibility(true);
root_window->DispatchMouseEvent(&mouse_moved);
- EXPECT_TRUE(root_window->cursor_shown());
+ EXPECT_TRUE(cursor_manager->cursor_visible());
root_window->DispatchTouchEvent(&touch_pressed1);
- EXPECT_FALSE(root_window->cursor_shown());
+ EXPECT_FALSE(cursor_manager->cursor_visible());
root_window->DispatchMouseEvent(&mouse_moved);
- EXPECT_TRUE(root_window->cursor_shown());
+ EXPECT_TRUE(cursor_manager->cursor_visible());
- root_window_filter->set_update_cursor_visibility(false);
- root_window->ShowCursor(false);
+ env_filter->set_update_cursor_visibility(false);
+ cursor_manager->ShowCursor(false);
root_window->DispatchMouseEvent(&mouse_moved);
- EXPECT_FALSE(root_window->cursor_shown());
- root_window->ShowCursor(true);
+ EXPECT_FALSE(cursor_manager->cursor_visible());
+ cursor_manager->ShowCursor(true);
root_window->DispatchTouchEvent(&touch_pressed2);
- EXPECT_TRUE(root_window->cursor_shown());
+ EXPECT_TRUE(cursor_manager->cursor_visible());
}
} // namespace ash
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc
index ec986ed..06afc02 100644
--- a/ash/wm/workspace/frame_maximize_button.cc
+++ b/ash/wm/workspace/frame_maximize_button.cc
@@ -62,11 +62,11 @@ class FrameMaximizeButton::EscapeEventFilter : public aura::EventFilter {
FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter(
FrameMaximizeButton* button)
: button_(button) {
- Shell::GetInstance()->AddRootWindowEventFilter(this);
+ Shell::GetInstance()->AddEnvEventFilter(this);
}
FrameMaximizeButton::EscapeEventFilter::~EscapeEventFilter() {
- Shell::GetInstance()->RemoveRootWindowEventFilter(this);
+ Shell::GetInstance()->RemoveEnvEventFilter(this);
}
bool FrameMaximizeButton::EscapeEventFilter::PreHandleKeyEvent(
diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc
index 9219027..4b3ee2d 100644
--- a/ash/wm/workspace/multi_window_resize_controller.cc
+++ b/ash/wm/workspace/multi_window_resize_controller.cc
@@ -12,7 +12,7 @@
#include "grit/ui_resources.h"
#include "ui/aura/event_filter.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/shared/root_window_event_filter.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
@@ -98,7 +98,7 @@ class MultiWindowResizeController::ResizeView : public views::View {
virtual gfx::NativeCursor GetCursor(
const views::MouseEvent& event) OVERRIDE {
int component = (direction_ == LEFT_RIGHT) ? HTRIGHT : HTBOTTOM;
- return aura::shared::RootWindowEventFilter::CursorForWindowComponent(
+ return aura::shared::CompoundEventFilter::CursorForWindowComponent(
component);
}
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 4982457..9065d8d 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -12,7 +12,8 @@
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/phantom_window_controller.h"
#include "ash/wm/workspace/snap_sizer.h"
-#include "ui/aura/shared/root_window_event_filter.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
@@ -44,8 +45,7 @@ const int WorkspaceWindowResizer::kMinOnscreenSize = 20;
const int WorkspaceWindowResizer::kMinOnscreenHeight = 32;
WorkspaceWindowResizer::~WorkspaceWindowResizer() {
- if (root_filter_)
- root_filter_->UnlockCursor();
+ aura::Env::GetInstance()->cursor_manager()->UnlockCursor();
}
// static
@@ -148,15 +148,12 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
: details_(details),
attached_windows_(attached_windows),
did_move_or_resize_(false),
- root_filter_(NULL),
total_min_(0),
total_initial_size_(0),
snap_type_(SNAP_NONE),
num_mouse_moves_since_bounds_change_(0) {
DCHECK(details_.is_resizable);
- root_filter_ = Shell::GetInstance()->root_filter();
- if (root_filter_)
- root_filter_->LockCursor();
+ aura::Env::GetInstance()->cursor_manager()->LockCursor();
// Only support attaching to the right/bottom.
DCHECK(attached_windows_.empty() ||
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 9ce939b..739b5b5 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -27,6 +27,7 @@
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/tooltip_client.h"
#include "ui/aura/client/window_types.h"
+#include "ui/aura/cursor_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
@@ -720,7 +721,7 @@ bool RenderWidgetHostViewAura::LockMouse() {
mouse_locked_ = true;
root_window->SetCapture(window_);
- root_window->ShowCursor(false);
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
synthetic_move_sent_ = true;
root_window->MoveCursorTo(window_->bounds().CenterPoint());
if (aura::client::GetTooltipClient(root_window))
@@ -737,7 +738,7 @@ void RenderWidgetHostViewAura::UnlockMouse() {
root_window->ReleaseCapture(window_);
root_window->MoveCursorTo(unlocked_global_mouse_position_);
- root_window->ShowCursor(true);
+ aura::Env::GetInstance()->cursor_manager()->ShowCursor(true);
if (aura::client::GetTooltipClient(root_window))
aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true);
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 1707e0f..f8efe8c 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -54,6 +54,9 @@
'client/window_move_client.cc',
'client/window_move_client.h',
'client/window_types.h',
+ 'cursor_delegate.h',
+ 'cursor_manager.cc',
+ 'cursor_manager.h',
'desktop/desktop_activation_client.cc',
'desktop/desktop_activation_client.h',
'desktop/desktop_dispatcher_client.cc',
@@ -99,10 +102,10 @@
'root_window_view_mac.mm',
'root_window.cc',
'root_window.h',
+ 'shared/compound_event_filter.cc',
+ 'shared/compound_event_filter.h',
'shared/input_method_event_filter.cc',
'shared/input_method_event_filter.h',
- 'shared/root_window_event_filter.cc',
- 'shared/root_window_event_filter.h',
'single_monitor_manager.cc',
'single_monitor_manager.h',
'ui_controls_win.cc',
@@ -275,8 +278,8 @@
'test/test_suite.cc',
'test/test_suite.h',
'root_window_unittest.cc',
+ 'shared/compound_event_filter_unittest.cc',
'shared/input_method_event_filter_unittest.cc',
- 'shared/root_window_event_filter_unittest.cc',
'event_filter_unittest.cc',
'event_unittest.cc',
'window_unittest.cc',
diff --git a/ui/aura/cursor_delegate.h b/ui/aura/cursor_delegate.h
new file mode 100644
index 0000000..b21bbe8
--- /dev/null
+++ b/ui/aura/cursor_delegate.h
@@ -0,0 +1,27 @@
+// 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_CURSOR_DELEGATE_H_
+#define UI_AURA_CURSOR_DELEGATE_H_
+#pragma once
+
+#include "ui/aura/aura_export.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace aura {
+
+// This interface is implmented by a platform specific object that changes
+// the cursor's image and visibility.
+class AURA_EXPORT CursorDelegate {
+ public:
+ virtual void SetCursor(gfx::NativeCursor cursor) = 0;
+ virtual void ShowCursor(bool visible) = 0;
+
+ protected:
+ virtual ~CursorDelegate() {};
+};
+
+} // namespace aura
+
+#endif // UI_AURA_CURSOR_DELEGATE_H_
diff --git a/ui/aura/cursor_manager.cc b/ui/aura/cursor_manager.cc
new file mode 100644
index 0000000..30c7af1c
--- /dev/null
+++ b/ui/aura/cursor_manager.cc
@@ -0,0 +1,58 @@
+// 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/cursor_manager.h"
+
+#include "base/logging.h"
+#include "ui/aura/cursor_delegate.h"
+#include "ui/aura/env.h"
+
+namespace aura {
+
+CursorManager::CursorManager()
+ : delegate_(NULL),
+ cursor_lock_count_(0),
+ did_cursor_change_(false),
+ cursor_to_set_on_unlock_(0),
+ cursor_visible_(true) {
+}
+
+CursorManager::~CursorManager() {
+}
+
+void CursorManager::LockCursor() {
+ cursor_lock_count_++;
+}
+
+void CursorManager::UnlockCursor() {
+ cursor_lock_count_--;
+ DCHECK_GE(cursor_lock_count_, 0);
+ if (cursor_lock_count_ == 0) {
+ if (did_cursor_change_) {
+ did_cursor_change_ = false;
+ if (delegate_)
+ delegate_->SetCursor(cursor_to_set_on_unlock_);
+ }
+ did_cursor_change_ = false;
+ cursor_to_set_on_unlock_ = gfx::kNullCursor;
+ }
+}
+
+void CursorManager::SetCursor(gfx::NativeCursor cursor) {
+ if (cursor_lock_count_ == 0) {
+ if (delegate_)
+ delegate_->SetCursor(cursor);
+ } else {
+ cursor_to_set_on_unlock_ = cursor;
+ did_cursor_change_ = true;
+ }
+}
+
+void CursorManager::ShowCursor(bool show) {
+ cursor_visible_ = show;
+ if (delegate_)
+ delegate_->ShowCursor(show);
+}
+
+} // namespace aura
diff --git a/ui/aura/cursor_manager.h b/ui/aura/cursor_manager.h
new file mode 100644
index 0000000..2ca4817
--- /dev/null
+++ b/ui/aura/cursor_manager.h
@@ -0,0 +1,59 @@
+// 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_CURSOR_MANAGER_H_
+#define UI_AURA_CURSOR_MANAGER_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "ui/aura/aura_export.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace aura {
+class CursorDelegate;
+
+// This class controls the visibility and the type of the cursor.
+// The cursor type can be locked so that the type stays the same
+// until it's unlocked.
+class AURA_EXPORT CursorManager {
+ public:
+ CursorManager();
+ ~CursorManager();
+
+ void set_delegate(CursorDelegate* delegate) { delegate_ = delegate; }
+
+ // Locks/Unlocks the cursor change.
+ void LockCursor();
+ void UnlockCursor();
+
+ void SetCursor(gfx::NativeCursor);
+
+ // Shows or hides the cursor.
+ void ShowCursor(bool show);
+ bool cursor_visible() const { return cursor_visible_; }
+
+ private:
+ CursorDelegate* delegate_;
+
+ // Number of times LockCursor() has been invoked without a corresponding
+ // UnlockCursor().
+ int cursor_lock_count_;
+
+ // Set to true if UpdateCursor() is invoked while |cursor_lock_count_| == 0.
+ bool did_cursor_change_;
+
+ // Cursor to set once |cursor_lock_count_| is set to 0. Only valid if
+ // |did_cursor_change_| is true.
+ gfx::NativeCursor cursor_to_set_on_unlock_;
+
+ // Is cursor visible?
+ bool cursor_visible_;
+
+ DISALLOW_COPY_AND_ASSIGN(CursorManager);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_CURSOR_MANAGER_H_
+
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
index ef160b0..58eea0a 100644
--- a/ui/aura/env.cc
+++ b/ui/aura/env.cc
@@ -3,7 +3,10 @@
// found in the LICENSE file.
#include "ui/aura/env.h"
+
+#include "ui/aura/cursor_manager.h"
#include "ui/aura/env_observer.h"
+#include "ui/aura/event_filter.h"
#include "ui/aura/monitor_manager.h"
#include "ui/aura/root_window_host.h"
#include "ui/aura/window.h"
@@ -62,6 +65,10 @@ void Env::SetMonitorManager(MonitorManager* monitor_manager) {
#endif
}
+void Env::SetEventFilter(EventFilter* event_filter) {
+ event_filter_.reset(event_filter);
+}
+
#if !defined(OS_MACOSX)
MessageLoop::Dispatcher* Env::GetDispatcher() {
return dispatcher_.get();
diff --git a/ui/aura/env.h b/ui/aura/env.h
index d3925c7..e8e787d8 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -10,11 +10,13 @@
#include "base/message_loop.h"
#include "base/observer_list.h"
#include "ui/aura/aura_export.h"
+#include "ui/aura/cursor_manager.h"
#include "ui/aura/client/stacking_client.h"
namespace aura {
-
+class CursorManager;
class EnvObserver;
+class EventFilter;
class MonitorManager;
class Window;
@@ -59,6 +61,12 @@ class AURA_EXPORT Env {
MonitorManager* monitor_manager() { return monitor_manager_.get(); }
void SetMonitorManager(MonitorManager* monitor_manager);
+ // Env takes ownership of the EventFilter.
+ EventFilter* event_filter() { return event_filter_.get(); }
+ void SetEventFilter(EventFilter* event_filter);
+
+ CursorManager* cursor_manager() { return &cursor_manager_; }
+
// Returns the native event dispatcher. The result should only be passed to
// MessageLoopForUI::RunWithDispatcher() or
// MessageLoopForUI::RunAllPendingWithDispatcher(), or used to dispatch
@@ -85,6 +93,8 @@ class AURA_EXPORT Env {
bool is_touch_down_;
client::StackingClient* stacking_client_;
scoped_ptr<MonitorManager> monitor_manager_;
+ scoped_ptr<EventFilter> event_filter_;
+ CursorManager cursor_manager_;
#if defined(USE_X11)
scoped_ptr<internal::MonitorChangeObserverX11> monitor_change_observer_;
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index d5130f8..0538c6f 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -72,6 +72,8 @@ void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
filters->push_back(target->event_filter());
target = target->parent();
}
+ if (Env::GetInstance()->event_filter())
+ filters->push_back(Env::GetInstance()->event_filter());
}
float GetDeviceScaleFactorFromMonitor(const aura::Window* window) {
@@ -118,7 +120,6 @@ RootWindow::RootWindow(const gfx::Rect& initial_bounds)
mouse_button_flags_(0),
touch_ids_down_(0),
last_cursor_(ui::kCursorNull),
- cursor_shown_(true),
capture_window_(NULL),
mouse_pressed_handler_(NULL),
mouse_moved_handler_(NULL),
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index 32bed2f..b5f02cf 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -92,7 +92,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
ui::Compositor* compositor() { return compositor_.get(); }
gfx::Point last_mouse_location() const { return last_mouse_location_; }
gfx::NativeCursor last_cursor() const { return last_cursor_; }
- bool cursor_shown() const { return cursor_shown_; }
Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
Window* capture_window() { return capture_window_; }
diff --git a/ui/aura/shared/root_window_event_filter.cc b/ui/aura/shared/compound_event_filter.cc
index a1454ec..66852d23e 100644
--- a/ui/aura/shared/root_window_event_filter.cc
+++ b/ui/aura/shared/compound_event_filter.cc
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura/shared/root_window_event_filter.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/client/activation_client.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/event.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
@@ -22,27 +24,28 @@ aura::Window* FindFocusableWindowFor(aura::Window* window) {
return window;
}
+aura::Window* GetActiveWindow(aura::Window* window) {
+ DCHECK(window->GetRootWindow());
+ return aura::client::GetActivationClient(window->GetRootWindow())->
+ GetActiveWindow();
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
-// RootWindowEventFilter, public:
+// CompoundEventFilter, public:
-RootWindowEventFilter::RootWindowEventFilter(aura::RootWindow* root_window)
- : root_window_(root_window),
- cursor_lock_count_(0),
- did_cursor_change_(false),
- cursor_to_set_on_unlock_(0),
- update_cursor_visibility_(true) {
+CompoundEventFilter::CompoundEventFilter() : update_cursor_visibility_(true) {
}
-RootWindowEventFilter::~RootWindowEventFilter() {
- // Additional filters are not owned by RootWindowEventFilter and they
+CompoundEventFilter::~CompoundEventFilter() {
+ // Additional filters are not owned by CompoundEventFilter and they
// should all be removed when running here. |filters_| has
// check_empty == true and will DCHECK failure if it is not empty.
}
// static
-gfx::NativeCursor RootWindowEventFilter::CursorForWindowComponent(
+gfx::NativeCursor CompoundEventFilter::CursorForWindowComponent(
int window_component) {
switch (window_component) {
case HTBOTTOM:
@@ -66,45 +69,28 @@ gfx::NativeCursor RootWindowEventFilter::CursorForWindowComponent(
}
}
-void RootWindowEventFilter::LockCursor() {
- cursor_lock_count_++;
-}
-
-void RootWindowEventFilter::UnlockCursor() {
- cursor_lock_count_--;
- DCHECK_GE(cursor_lock_count_, 0);
- if (cursor_lock_count_ == 0) {
- if (did_cursor_change_) {
- did_cursor_change_ = false;
- root_window_->SetCursor(cursor_to_set_on_unlock_);
- }
- did_cursor_change_ = false;
- cursor_to_set_on_unlock_ = 0;
- }
-}
-
-void RootWindowEventFilter::AddFilter(aura::EventFilter* filter) {
+void CompoundEventFilter::AddFilter(aura::EventFilter* filter) {
filters_.AddObserver(filter);
}
-void RootWindowEventFilter::RemoveFilter(aura::EventFilter* filter) {
+void CompoundEventFilter::RemoveFilter(aura::EventFilter* filter) {
filters_.RemoveObserver(filter);
}
-size_t RootWindowEventFilter::GetFilterCount() const {
+size_t CompoundEventFilter::GetFilterCount() const {
return filters_.size();
}
////////////////////////////////////////////////////////////////////////////////
-// RootWindowEventFilter, EventFilter implementation:
+// CompoundEventFilter, EventFilter implementation:
-bool RootWindowEventFilter::PreHandleKeyEvent(aura::Window* target,
+bool CompoundEventFilter::PreHandleKeyEvent(aura::Window* target,
aura::KeyEvent* event) {
return FilterKeyEvent(target, event);
}
-bool RootWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
- aura::MouseEvent* event) {
+bool CompoundEventFilter::PreHandleMouseEvent(aura::Window* target,
+ aura::MouseEvent* event) {
// We must always update the cursor, otherwise the cursor can get stuck if an
// event filter registered with us consumes the event.
// It should also update the cursor for clicking and wheels for ChromeOS boot.
@@ -113,23 +99,23 @@ bool RootWindowEventFilter::PreHandleMouseEvent(aura::Window* target,
if (event->type() == ui::ET_MOUSE_MOVED ||
event->type() == ui::ET_MOUSE_PRESSED ||
event->type() == ui::ET_MOUSEWHEEL) {
- if (update_cursor_visibility_)
- SetCursorVisible(target, event, true);
-
+ SetVisibilityOnEvent(event, true);
UpdateCursor(target, event);
}
if (FilterMouseEvent(target, event))
return true;
- if (event->type() == ui::ET_MOUSE_PRESSED && GetActiveWindow() != target)
+ if (event->type() == ui::ET_MOUSE_PRESSED
+ && GetActiveWindow(target) != target) {
target->GetFocusManager()->SetFocusedWindow(
FindFocusableWindowFor(target), event);
+ }
return false;
}
-ui::TouchStatus RootWindowEventFilter::PreHandleTouchEvent(
+ui::TouchStatus CompoundEventFilter::PreHandleTouchEvent(
aura::Window* target,
aura::TouchEvent* event) {
ui::TouchStatus status = FilterTouchEvent(target, event);
@@ -137,16 +123,15 @@ ui::TouchStatus RootWindowEventFilter::PreHandleTouchEvent(
return status;
if (event->type() == ui::ET_TOUCH_PRESSED) {
- if (update_cursor_visibility_)
- SetCursorVisible(target, event, false);
-
+ SetVisibilityOnEvent(event, false);
target->GetFocusManager()->SetFocusedWindow(
FindFocusableWindowFor(target), event);
}
+
return ui::TOUCH_STATUS_UNKNOWN;
}
-ui::GestureStatus RootWindowEventFilter::PreHandleGestureEvent(
+ui::GestureStatus CompoundEventFilter::PreHandleGestureEvent(
aura::Window* target,
aura::GestureEvent* event) {
ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN;
@@ -162,33 +147,21 @@ ui::GestureStatus RootWindowEventFilter::PreHandleGestureEvent(
}
////////////////////////////////////////////////////////////////////////////////
-// RootWindowEventFilter, private:
+// CompoundEventFilter, private:
-void RootWindowEventFilter::UpdateCursor(aura::Window* target,
- aura::MouseEvent* event) {
+void CompoundEventFilter::UpdateCursor(aura::Window* target,
+ aura::MouseEvent* event) {
gfx::NativeCursor cursor = target->GetCursor(event->location());
if (event->flags() & ui::EF_IS_NON_CLIENT) {
int window_component =
target->delegate()->GetNonClientComponent(event->location());
cursor = CursorForWindowComponent(window_component);
}
- if (cursor_lock_count_ == 0) {
- root_window_->SetCursor(cursor);
- } else {
- cursor_to_set_on_unlock_ = cursor;
- did_cursor_change_ = true;
- }
-}
-
-void RootWindowEventFilter::SetCursorVisible(aura::Window* target,
- aura::LocatedEvent* event,
- bool show) {
- if (!(event->flags() & ui::EF_IS_SYNTHESIZED))
- root_window_->ShowCursor(show);
+ Env::GetInstance()->cursor_manager()->SetCursor(cursor);
}
-bool RootWindowEventFilter::FilterKeyEvent(aura::Window* target,
- aura::KeyEvent* event) {
+bool CompoundEventFilter::FilterKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
bool handled = false;
if (filters_.might_have_observers()) {
ObserverListBase<aura::EventFilter>::Iterator it(filters_);
@@ -199,7 +172,7 @@ bool RootWindowEventFilter::FilterKeyEvent(aura::Window* target,
return handled;
}
-bool RootWindowEventFilter::FilterMouseEvent(aura::Window* target,
+bool CompoundEventFilter::FilterMouseEvent(aura::Window* target,
aura::MouseEvent* event) {
bool handled = false;
if (filters_.might_have_observers()) {
@@ -211,7 +184,7 @@ bool RootWindowEventFilter::FilterMouseEvent(aura::Window* target,
return handled;
}
-ui::TouchStatus RootWindowEventFilter::FilterTouchEvent(
+ui::TouchStatus CompoundEventFilter::FilterTouchEvent(
aura::Window* target,
aura::TouchEvent* event) {
ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN;
@@ -226,9 +199,10 @@ ui::TouchStatus RootWindowEventFilter::FilterTouchEvent(
return status;
}
-Window* RootWindowEventFilter::GetActiveWindow() {
- return aura::client::GetActivationClient(root_window_)->
- GetActiveWindow();
+void CompoundEventFilter::SetVisibilityOnEvent(aura::LocatedEvent* event,
+ bool show) {
+ if (update_cursor_visibility_ && !(event->flags() & ui::EF_IS_SYNTHESIZED))
+ Env::GetInstance()->cursor_manager()->ShowCursor(show);
}
} // namespace shared
diff --git a/ui/aura/shared/root_window_event_filter.h b/ui/aura/shared/compound_event_filter.h
index b579737..7788d5f 100644
--- a/ui/aura/shared/root_window_event_filter.h
+++ b/ui/aura/shared/compound_event_filter.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_AURA_SHARED_ROOT_WINDOW_EVENT_FILTER_H_
-#define UI_AURA_SHARED_ROOT_WINDOW_EVENT_FILTER_H_
+#ifndef UI_AURA_SHARED_COMPOUND_EVENT_FILTER_H_
+#define UI_AURA_SHARED_COMPOUND_EVENT_FILTER_H_
#pragma once
#include "base/compiler_specific.h"
@@ -13,32 +13,27 @@
#include "ui/aura/event_filter.h"
namespace aura {
+class CursorManager;
class RootWindow;
namespace shared {
-// RootWindowEventFilter gets all root window events first and can provide
-// actions to those events. It implements root window features such as click to
-// activate a window and cursor change when moving mouse.
-// Additional event filters can be added to RootWindowEventFilter. Events will
+// CompoundEventFilter gets all events first and can provide actions to those
+// events. It implements global features such as click to activate a window and
+// cursor change when moving mouse.
+// Additional event filters can be added to CompoundEventFilter. Events will
// pass through those additional filters in their addition order and could be
// consumed by any of those filters. If an event is consumed by a filter, the
-// rest of the filter(s) and RootWindowEventFilter will not see the consumed
+// rest of the filter(s) and CompoundEventFilter will not see the consumed
// event.
-class AURA_EXPORT RootWindowEventFilter : public aura::EventFilter {
+class AURA_EXPORT CompoundEventFilter : public aura::EventFilter {
public:
- RootWindowEventFilter(aura::RootWindow* root_window);
- virtual ~RootWindowEventFilter();
+ CompoundEventFilter();
+ virtual ~CompoundEventFilter();
// Returns the cursor for the specified component.
static gfx::NativeCursor CursorForWindowComponent(int window_component);
- // Freezes updates to the cursor until UnlockCursor() is invoked.
- void LockCursor();
-
- // Unlocks the cursor.
- void UnlockCursor();
-
void set_update_cursor_visibility(bool update) {
update_cursor_visibility_ = update;
}
@@ -65,11 +60,6 @@ class AURA_EXPORT RootWindowEventFilter : public aura::EventFilter {
// default resize cursors for window edges.
void UpdateCursor(aura::Window* target, aura::MouseEvent* event);
- // Sets the cursor invisible when the target receives touch press event.
- void SetCursorVisible(aura::Window* target,
- aura::LocatedEvent* event,
- bool show);
-
// Dispatches event to additional filters. Returns false or
// ui::TOUCH_STATUS_UNKNOWN if event is consumed.
bool FilterKeyEvent(aura::Window* target, aura::KeyEvent* event);
@@ -77,33 +67,21 @@ class AURA_EXPORT RootWindowEventFilter : public aura::EventFilter {
ui::TouchStatus FilterTouchEvent(aura::Window* target,
aura::TouchEvent* event);
- // Gets the active window from the activation client.
- aura::Window* GetActiveWindow();
-
- aura::RootWindow* root_window_;
+ // Sets the visibility of the cursor if the event is not synthesized and
+ // |update_cursor_visibility_| is true.
+ void SetVisibilityOnEvent(aura::LocatedEvent* event, bool show);
// Additional event filters that pre-handles events.
ObserverList<aura::EventFilter, true> filters_;
- // Number of times LockCursor() has been invoked without a corresponding
- // UnlockCursor().
- int cursor_lock_count_;
-
- // Set to true if UpdateCursor() is invoked while |cursor_lock_count_| == 0.
- bool did_cursor_change_;
-
- // Cursor to set once |cursor_lock_count_| is set to 0. Only valid if
- // |did_cursor_change_| is true.
- gfx::NativeCursor cursor_to_set_on_unlock_;
-
// Should we show the mouse cursor when we see mouse movement and hide it when
// we see a touch event?
bool update_cursor_visibility_;
- DISALLOW_COPY_AND_ASSIGN(RootWindowEventFilter);
+ DISALLOW_COPY_AND_ASSIGN(CompoundEventFilter);
};
} // namespace shared
} // namespace aura
-#endif // UI_AURA_ROOT_WINDOW_EVENT_FILTER_H_
+#endif // UI_AURA_COMPOUND_EVENT_FILTER_H_
diff --git a/ui/aura/shared/root_window_event_filter_unittest.cc b/ui/aura/shared/compound_event_filter_unittest.cc
index 08561e5..ef98222 100644
--- a/ui/aura/shared/root_window_event_filter_unittest.cc
+++ b/ui/aura/shared/compound_event_filter_unittest.cc
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura/shared/root_window_event_filter.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/client/activation_client.h"
+#include "ui/aura/cursor_manager.h"
+#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/test_activation_client.h"
@@ -19,13 +21,10 @@ base::TimeDelta GetTime() {
namespace aura {
namespace test {
-typedef AuraTestBase RootWindowEventFilterTest;
-
-TEST_F(RootWindowEventFilterTest, TouchHidesCursor) {
- shared::RootWindowEventFilter* root_filter =
- new shared::RootWindowEventFilter(root_window());
- root_window()->SetEventFilter(root_filter);
+typedef AuraTestBase CompoundEventFilterTest;
+TEST_F(CompoundEventFilterTest, TouchHidesCursor) {
+ aura::Env::GetInstance()->SetEventFilter(new shared::CompoundEventFilter());
aura::client::SetActivationClient(root_window(),
new TestActivationClient(root_window()));
TestWindowDelegate delegate;
@@ -33,29 +32,30 @@ TEST_F(RootWindowEventFilterTest, TouchHidesCursor) {
gfx::Rect(5, 5, 100, 100), NULL));
window->Show();
root_window()->SetCapture(window.get());
+ CursorManager* cursor_manager = aura::Env::GetInstance()->cursor_manager();
MouseEvent mouse(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
gfx::Point(15, 15), 0);
root_window()->DispatchMouseEvent(&mouse);
- EXPECT_TRUE(root_window()->cursor_shown());
+ EXPECT_TRUE(cursor_manager->cursor_visible());
// This press is required for the GestureRecognizer to associate a target
// with kTouchId
TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(90, 90), 1, GetTime());
root_window()->DispatchTouchEvent(&press);
- EXPECT_FALSE(root_window()->cursor_shown());
+ EXPECT_FALSE(cursor_manager->cursor_visible());
TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), 1,
GetTime());
root_window()->DispatchTouchEvent(&move);
- EXPECT_FALSE(root_window()->cursor_shown());
+ EXPECT_FALSE(cursor_manager->cursor_visible());
TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), 1, GetTime());
root_window()->DispatchTouchEvent(&release);
- EXPECT_FALSE(root_window()->cursor_shown());
+ EXPECT_FALSE(cursor_manager->cursor_visible());
root_window()->DispatchMouseEvent(&mouse);
- EXPECT_TRUE(root_window()->cursor_shown());
+ EXPECT_TRUE(cursor_manager->cursor_visible());
}
} // namespace test
diff --git a/ui/aura/shared/input_method_event_filter_unittest.cc b/ui/aura/shared/input_method_event_filter_unittest.cc
index 4b11c98..97fedd7 100644
--- a/ui/aura/shared/input_method_event_filter_unittest.cc
+++ b/ui/aura/shared/input_method_event_filter_unittest.cc
@@ -8,7 +8,7 @@
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/shared/root_window_event_filter.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_activation_client.h"
@@ -29,8 +29,8 @@ namespace test {
typedef AuraTestBase InputMethodEventFilterTest;
TEST_F(InputMethodEventFilterTest, TestInputMethodProperty) {
- aura::shared::RootWindowEventFilter* root_filter =
- new aura::shared::RootWindowEventFilter(root_window());
+ aura::shared::CompoundEventFilter* root_filter =
+ new aura::shared::CompoundEventFilter;
root_window()->SetEventFilter(root_filter);
// Add the InputMethodEventFilter before the TestEventFilter.
@@ -51,8 +51,8 @@ TEST_F(InputMethodEventFilterTest, TestInputMethodKeyEventPropagation) {
aura::client::SetActivationClient(root_window(),
new TestActivationClient(root_window()));
- aura::shared::RootWindowEventFilter* root_filter =
- new shared::RootWindowEventFilter(root_window());
+ aura::shared::CompoundEventFilter* root_filter =
+ new shared::CompoundEventFilter;
root_window()->SetEventFilter(root_filter);
// Add the InputMethodEventFilter before the TestEventFilter.
diff --git a/ui/views/widget/desktop_native_widget_helper_aura.cc b/ui/views/widget/desktop_native_widget_helper_aura.cc
index ab1af59..0f1b799 100644
--- a/ui/views/widget/desktop_native_widget_helper_aura.cc
+++ b/ui/views/widget/desktop_native_widget_helper_aura.cc
@@ -6,12 +6,13 @@
#include "ui/aura/client/dispatcher_client.h"
#include "ui/aura/client/screen_position_client.h"
+#include "ui/aura/cursor_manager.h"
#include "ui/aura/desktop/desktop_activation_client.h"
#include "ui/aura/desktop/desktop_dispatcher_client.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/shared/compound_event_filter.h"
#include "ui/aura/shared/input_method_event_filter.h"
-#include "ui/aura/shared/root_window_event_filter.h"
#include "ui/views/widget/native_widget_aura.h"
#if defined(OS_WIN)
@@ -109,12 +110,16 @@ void DesktopNativeWidgetHelperAura::PreInitialize(
// will probably be SetBounds()ed soon.
bounds.set_size(gfx::Size(100, 100));
}
+ // TODO(erg): Implement aura::CursorManager::Delegate to control
+ // cursor's shape and visibility.
+
root_window_.reset(new aura::RootWindow(bounds));
root_window_->Init();
root_window_->set_focus_manager(new aura::FocusManager);
- root_window_event_filter_ =
- new aura::shared::RootWindowEventFilter(root_window_.get());
+ // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow.
+ root_window_event_filter_ = new aura::shared::CompoundEventFilter;
+ // Pass ownership of the filter to the root_window.
root_window_->SetEventFilter(root_window_event_filter_);
input_method_filter_.reset(new aura::shared::InputMethodEventFilter());
diff --git a/ui/views/widget/desktop_native_widget_helper_aura.h b/ui/views/widget/desktop_native_widget_helper_aura.h
index 9126ba8..203b0d8 100644
--- a/ui/views/widget/desktop_native_widget_helper_aura.h
+++ b/ui/views/widget/desktop_native_widget_helper_aura.h
@@ -18,8 +18,8 @@ namespace client {
class ScreenPositionClient;
}
namespace shared {
+class CompoundEventFilter;
class InputMethodEventFilter;
-class RootWindowEventFilter;
}
}
@@ -66,7 +66,7 @@ class VIEWS_EXPORT DesktopNativeWidgetHelperAura
scoped_ptr<aura::RootWindow> root_window_;
// Toplevel event filter which dispatches to other event filters.
- aura::shared::RootWindowEventFilter* root_window_event_filter_;
+ aura::shared::CompoundEventFilter* root_window_event_filter_;
// An event filter that pre-handles all key events to send them to an IME.
scoped_ptr<aura::shared::InputMethodEventFilter> input_method_filter_;