summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 06:11:48 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 06:11:48 +0000
commit94f3d3ecb30a753a00538a71f2d1b41e42c7afad (patch)
tree9b25d7b3c7fad8cce1cc25f8b541babfbb9acb89
parent821f018576b0de208850b129e36d38898b3df7e0 (diff)
downloadchromium_src-94f3d3ecb30a753a00538a71f2d1b41e42c7afad.zip
chromium_src-94f3d3ecb30a753a00538a71f2d1b41e42c7afad.tar.gz
chromium_src-94f3d3ecb30a753a00538a71f2d1b41e42c7afad.tar.bz2
Make RootWindow not subclass Window.
Removes the #include of window.h from root_window.h too, which makes this CL a little longer bandaiding all those places. The interesting parts of this change are in root_window.* and window.* R=sky@chromium.org http://crbug.com/308843 Review URL: https://codereview.chromium.org/68313003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234428 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/display/display_controller.cc4
-rw-r--r--ash/root_window_controller.cc5
-rw-r--r--ash/root_window_controller.h1
-rw-r--r--ash/wm/boot_splash_screen_chromeos.cc3
-rw-r--r--ash/wm/sticky_keys.cc1
-rw-r--r--chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc1
-rw-r--r--chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc1
-rw-r--r--chrome/browser/ui/find_bar/find_bar_host_browsertest.cc1
-rw-r--r--chrome/browser/ui/views/external_tab_container_win.cc1
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller.cc1
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc1
-rw-r--r--content/browser/renderer_host/input/synthetic_gesture_target_aura.cc5
-rw-r--r--content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc1
-rw-r--r--ui/app_list/views/apps_grid_view.cc1
-rw-r--r--ui/aura/client/default_capture_client.cc5
-rw-r--r--ui/aura/gestures/gesture_recognizer_unittest.cc1
-rw-r--r--ui/aura/root_window.cc67
-rw-r--r--ui/aura/root_window.h28
-rw-r--r--ui/aura/root_window_host_x11.cc15
-rw-r--r--ui/aura/root_window_unittest.cc5
-rw-r--r--ui/aura/test/aura_test_base.cc1
-rw-r--r--ui/aura/test/ui_controls_factory_aurawin.cc1
-rw-r--r--ui/aura/test/ui_controls_factory_aurax11.cc11
-rw-r--r--ui/aura/window.cc58
-rw-r--r--ui/aura/window.h1
-rw-r--r--ui/aura/window_unittest.cc2
-rw-r--r--ui/oak/oak_window.cc1
-rw-r--r--ui/shell_dialogs/select_file_dialog_win.cc1
-rw-r--r--ui/views/controls/button/custom_button_unittest.cc1
-rw-r--r--ui/views/corewm/capture_controller_unittest.cc1
-rw-r--r--ui/views/corewm/compound_event_filter.cc1
-rw-r--r--ui/views/corewm/compound_event_filter_unittest.cc1
-rw-r--r--ui/views/corewm/tooltip_aura.cc1
-rw-r--r--ui/views/examples/content_client/examples_browser_main_parts.cc3
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc7
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc1
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_win.cc1
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_x11.cc1
-rw-r--r--ui/views/widget/widget_interactive_uitest.cc1
-rw-r--r--ui/views/win/hwnd_util_aurawin.cc1
40 files changed, 137 insertions, 107 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 73c1aa0..579975a 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -768,8 +768,8 @@ aura::RootWindow* DisplayController::AddRootWindowForDisplay(
display.id();
root_window->Init();
- root_windows_[display.id()] = root_window;
- SetDisplayPropertiesOnHostWindow(root_window->GetDispatcher(), display);
+ root_windows_[display.id()] = root_window->window();
+ SetDisplayPropertiesOnHostWindow(root_window, display);
#if defined(OS_CHROMEOS)
static bool force_constrain_pointer_to_root =
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 3cfb6d2..c068809 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -583,7 +583,7 @@ void RootWindowController::Init(RootWindowType root_window_type,
Shell::GetInstance()->InitRootWindow(root_window());
root_window_->SetCursor(ui::kCursorPointer);
- CreateContainersInRootWindow(root_window_.get());
+ CreateContainersInRootWindow(root_window_->window());
if (root_window_type == VIRTUAL_KEYBOARD)
return;
@@ -607,7 +607,8 @@ void RootWindowController::Init(RootWindowType root_window_type,
} else {
root_window_layout()->OnWindowResized();
shell->desktop_background_controller()->OnRootWindowAdded(root_window());
- shell->high_contrast_controller()->OnRootWindowAdded(root_window_.get());
+ shell->high_contrast_controller()->OnRootWindowAdded(
+ root_window_->window());
root_window_->ShowRootWindow();
// Create a launcher if a user is already logged.
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 980bf1e..0ccc1d3 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -14,6 +14,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
class SkBitmap;
diff --git a/ash/wm/boot_splash_screen_chromeos.cc b/ash/wm/boot_splash_screen_chromeos.cc
index 0074340..ad93865 100644
--- a/ash/wm/boot_splash_screen_chromeos.cc
+++ b/ash/wm/boot_splash_screen_chromeos.cc
@@ -6,6 +6,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_type.h"
@@ -56,7 +57,7 @@ BootSplashScreen::BootSplashScreen(aura::RootWindow* root_window)
layer_(new ui::Layer(ui::LAYER_TEXTURED)) {
layer_->set_delegate(layer_delegate_.get());
- ui::Layer* root_layer = root_window->layer();
+ ui::Layer* root_layer = root_window->window()->layer();
layer_->SetBounds(gfx::Rect(root_layer->bounds().size()));
root_layer->Add(layer_.get());
root_layer->StackAtTop(layer_.get());
diff --git a/ash/wm/sticky_keys.cc b/ash/wm/sticky_keys.cc
index 99a0eac..dfd18c6 100644
--- a/ash/wm/sticky_keys.cc
+++ b/ash/wm/sticky_keys.cc
@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/debug/stack_trace.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
index c7f47e5..5bb5d79 100644
--- a/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
+++ b/chrome/browser/renderer_host/pepper/pepper_flash_drm_host.cc
@@ -26,6 +26,7 @@
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
using content::BrowserPpapiHost;
diff --git a/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc b/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc
index 651f007..cc82b5a 100644
--- a/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc
+++ b/chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.cc
@@ -14,6 +14,7 @@
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
using content::JavaScriptDialogManager;
diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
index dcc7dae..97e2105 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -45,6 +45,7 @@
#if defined(OS_WIN) && defined(USE_AURA)
#include "content/public/browser/web_contents_view.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
using content::NavigationController;
diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc
index 9fa14db..16a1387 100644
--- a/chrome/browser/ui/views/external_tab_container_win.cc
+++ b/chrome/browser/ui/views/external_tab_container_win.cc
@@ -77,6 +77,7 @@
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h"
#endif
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
index d4d2bc1..d6fe9a4 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -55,6 +55,7 @@
#include "ash/wm/window_state.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/events/gestures/gesture_recognizer.h"
#endif
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
index 80ae155..69915f9 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
@@ -24,6 +24,7 @@
#if defined(OS_WIN) && defined(USE_AURA)
#include "content/public/browser/web_contents_view.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
namespace {
diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc b/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc
index 4db289a..a81c0b1 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_target_aura.cc
@@ -26,8 +26,7 @@ void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform(
const WebTouchEvent& web_touch,
const ui::LatencyInfo& latency_info) {
aura::Window* window = render_widget_host()->GetView()->GetNativeView();
- aura::RootWindow* root_window =
- static_cast<aura::RootWindow*>(window->GetRootWindow());
+ aura::Window* root_window = window->GetRootWindow();
aura::client::ScreenPositionClient* position_client =
aura::client::GetScreenPositionClient(root_window);
DCHECK(position_client);
@@ -51,7 +50,7 @@ void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform(
DCHECK(conversion_success);
aura::RootWindowHostDelegate* root_window_host_delegate =
- root_window->AsRootWindowHostDelegate();
+ root_window->GetDispatcher()->AsRootWindowHostDelegate();
for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
end = events.end(); iter != end; ++iter) {
root_window_host_delegate->OnHostTouchEvent(*iter);
diff --git a/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc b/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc
index 659cd99..45f0d74 100644
--- a/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc
+++ b/content/browser/renderer_host/touch_smooth_scroll_gesture_aura.cc
@@ -6,6 +6,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/transform.h"
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index 482a7ce..fb8d6da2 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -28,6 +28,7 @@
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
#if defined(OS_WIN) && !defined(USE_AURA)
diff --git a/ui/aura/client/default_capture_client.cc b/ui/aura/client/default_capture_client.cc
index 6008a89..debd86e 100644
--- a/ui/aura/client/default_capture_client.cc
+++ b/ui/aura/client/default_capture_client.cc
@@ -5,6 +5,7 @@
#include "ui/aura/client/default_capture_client.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
namespace aura {
namespace client {
@@ -12,11 +13,11 @@ namespace client {
DefaultCaptureClient::DefaultCaptureClient(Window* root_window)
: root_window_(root_window),
capture_window_(NULL) {
- client::SetCaptureClient(root_window_, this);
+ SetCaptureClient(root_window_, this);
}
DefaultCaptureClient::~DefaultCaptureClient() {
- client::SetCaptureClient(root_window_, NULL);
+ SetCaptureClient(root_window_, NULL);
}
void DefaultCaptureClient::SetCapture(Window* window) {
diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc
index 2d0a09c..096505b 100644
--- a/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -14,6 +14,7 @@
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
+#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
#include "ui/base/ui_base_switches.h"
#include "ui/events/event.h"
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index daa9a92..507f3c4 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -141,7 +141,7 @@ RootWindow::CreateParams::CreateParams(const gfx::Rect& a_initial_bounds)
// RootWindow, public:
RootWindow::RootWindow(const CreateParams& params)
- : Window(NULL),
+ : window_(new Window(NULL)),
host_(CreateHost(this, params)),
touch_ids_down_(0),
last_cursor_(ui::kCursorNull),
@@ -180,7 +180,7 @@ RootWindow::~RootWindow() {
// ~Window, but by that time any calls to virtual methods overriden here (such
// as GetRootWindow()) result in Window's implementation. By destroying here
// we ensure GetRootWindow() still returns this.
- RemoveOrDestroyChildren();
+ window()->RemoveOrDestroyChildren();
// Destroying/removing child windows may try to access |host_| (eg.
// GetAcceleratedWidget())
@@ -199,7 +199,7 @@ RootWindow* RootWindow::GetForAcceleratedWidget(
void RootWindow::Init() {
compositor()->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()),
host_->GetBounds().size());
- Window::Init(ui::LAYER_NOT_DRAWN);
+ window()->Init(ui::LAYER_NOT_DRAWN);
compositor()->SetRootLayer(window()->layer());
transformer_.reset(
new SimpleRootWindowTransformer(window(), gfx::Transform()));
@@ -525,7 +525,7 @@ void RootWindow::SetRootWindowTransformer(
scoped_ptr<RootWindowTransformer> transformer) {
transformer_ = transformer.Pass();
host_->SetInsets(transformer_->GetHostInsets());
- Window::SetTransform(transformer_->GetTransform());
+ window()->SetTransform(transformer_->GetTransform());
// If the layer is not animating, then we need to update the root window
// size immediately.
if (!window()->layer()->GetAnimator()->is_animating())
@@ -540,29 +540,14 @@ gfx::Transform RootWindow::GetRootTransform() const {
return transform;
}
-////////////////////////////////////////////////////////////////////////////////
-// RootWindow, Window overrides:
-
-Window* RootWindow::GetRootWindow() {
- return this;
-}
-
-const Window* RootWindow::GetRootWindow() const {
- return this;
-}
-
void RootWindow::SetTransform(const gfx::Transform& transform) {
scoped_ptr<RootWindowTransformer> transformer(
new SimpleRootWindowTransformer(window(), transform));
SetRootWindowTransformer(transformer.Pass());
}
-bool RootWindow::CanFocus() const {
- return IsVisible();
-}
-
-bool RootWindow::CanReceiveEvents() const {
- return IsVisible();
+void RootWindow::DeviceScaleFactorChanged(float device_scale_factor) {
+ host_->OnDeviceScaleFactorChanged(device_scale_factor);
}
////////////////////////////////////////////////////////////////////////////////
@@ -579,7 +564,7 @@ void RootWindow::MoveCursorToInternal(const gfx::Point& root_location,
client::CursorClient* cursor_client = client::GetCursorClient(window());
if (cursor_client) {
const gfx::Display& display =
- gfx::Screen::GetScreenFor(this)->GetDisplayNearestWindow(window());
+ gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window());
cursor_client->SetDisplay(display);
}
synthesize_mouse_move_ = false;
@@ -691,44 +676,6 @@ void RootWindow::UpdateRootWindowSize(const gfx::Size& host_size) {
}
////////////////////////////////////////////////////////////////////////////////
-// RootWindow, ui::EventTarget implementation:
-
-ui::EventTarget* RootWindow::GetParentTarget() {
- return client::GetEventClient(this) ?
- client::GetEventClient(this)->GetToplevelEventTarget() :
- Env::GetInstance();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// RootWindow, ui::LayerDelegate implementation:
-
-void RootWindow::OnDeviceScaleFactorChanged(
- float device_scale_factor) {
- const bool cursor_is_in_bounds =
- GetBoundsInScreen().Contains(Env::GetInstance()->last_mouse_location());
- bool cursor_visible = false;
- client::CursorClient* cursor_client = client::GetCursorClient(this);
- if (cursor_is_in_bounds && cursor_client) {
- cursor_visible = cursor_client->IsCursorVisible();
- if (cursor_visible)
- cursor_client->HideCursor();
- }
- host_->OnDeviceScaleFactorChanged(device_scale_factor);
- Window::OnDeviceScaleFactorChanged(device_scale_factor);
- // Update the device scale factor of the cursor client only when the last
- // mouse location is on this root window.
- if (cursor_is_in_bounds) {
- if (cursor_client) {
- const gfx::Display& display =
- gfx::Screen::GetScreenFor(this)->GetDisplayNearestWindow(this);
- cursor_client->SetDisplay(display);
- }
- }
- if (cursor_is_in_bounds && cursor_client && cursor_visible)
- cursor_client->ShowCursor();
-}
-
-////////////////////////////////////////////////////////////////////////////////
// RootWindow, aura::client::CaptureDelegate implementation:
void RootWindow::UpdateCapture(Window* old_capture,
diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h
index 1b81d58..f6a966b 100644
--- a/ui/aura/root_window.h
+++ b/ui/aura/root_window.h
@@ -16,7 +16,6 @@
#include "ui/aura/aura_export.h"
#include "ui/aura/client/capture_delegate.h"
#include "ui/aura/root_window_host_delegate.h"
-#include "ui/aura/window.h"
#include "ui/base/cursor/cursor.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer_animation_observer.h"
@@ -52,8 +51,7 @@ class RootWindowTransformer;
class TestScreen;
// RootWindow is responsible for hosting a set of windows.
-class AURA_EXPORT RootWindow : public Window,
- public ui::EventDispatcherDelegate,
+class AURA_EXPORT RootWindow : public ui::EventDispatcherDelegate,
public ui::GestureEventHelper,
public ui::LayerAnimationObserver,
public aura::client::CaptureDelegate,
@@ -81,7 +79,7 @@ class AURA_EXPORT RootWindow : public Window,
Window* window() {
return const_cast<Window*>(const_cast<const RootWindow*>(this)->window());
}
- const Window* window() const { return this; }
+ const Window* window() const { return window_.get(); }
ui::Compositor* compositor() { return compositor_.get(); }
gfx::NativeCursor last_cursor() const { return last_cursor_; }
Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
@@ -129,7 +127,7 @@ class AURA_EXPORT RootWindow : public Window,
void OnMouseEventsEnableStateChanged(bool enabled);
// Moves the cursor to the specified location relative to the root window.
- virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
+ void MoveCursorTo(const gfx::Point& location);
// Moves the cursor to the |host_location| given in host coordinates.
void MoveCursorToHostLocation(const gfx::Point& host_location);
@@ -244,12 +242,9 @@ class AURA_EXPORT RootWindow : public Window,
void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
gfx::Transform GetRootTransform() const;
- // Overridden from Window:
- virtual Window* GetRootWindow() OVERRIDE;
- virtual const Window* GetRootWindow() const OVERRIDE;
- virtual void SetTransform(const gfx::Transform& transform) OVERRIDE;
- virtual bool CanFocus() const OVERRIDE;
- virtual bool CanReceiveEvents() const OVERRIDE;
+ void SetTransform(const gfx::Transform& transform);
+
+ void DeviceScaleFactorChanged(float device_scale_factor);
private:
FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot);
@@ -304,12 +299,6 @@ class AURA_EXPORT RootWindow : public Window,
// transform and insets.
void UpdateRootWindowSize(const gfx::Size& host_size);
- // Overridden from ui::EventTarget:
- virtual ui::EventTarget* GetParentTarget() OVERRIDE;
-
- // Overridden from ui::LayerDelegate:
- virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
-
// Overridden from aura::client::CaptureDelegate:
virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE;
virtual void OnOtherRootGotCapture() OVERRIDE;
@@ -317,7 +306,7 @@ class AURA_EXPORT RootWindow : public Window,
virtual void ReleaseNativeCapture() OVERRIDE;
// Overridden from ui::EventDispatcherDelegate.
- virtual bool CanDispatchToTarget(EventTarget* target) OVERRIDE;
+ virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE;
// Overridden from ui::GestureEventHelper.
virtual bool CanDispatchToConsumer(ui::GestureConsumer* consumer) OVERRIDE;
@@ -380,6 +369,9 @@ class AURA_EXPORT RootWindow : public Window,
gfx::Transform GetInverseRootTransform() const;
+ // TODO(beng): evaluate the ideal ownership model.
+ scoped_ptr<Window> window_;
+
scoped_ptr<ui::Compositor> compositor_;
scoped_ptr<RootWindowHost> host_;
diff --git a/ui/aura/root_window_host_x11.cc b/ui/aura/root_window_host_x11.cc
index ec724ac..ccbf5fa 100644
--- a/ui/aura/root_window_host_x11.cc
+++ b/ui/aura/root_window_host_x11.cc
@@ -448,7 +448,7 @@ bool RootWindowHostX11::Dispatch(const base::NativeEvent& event) {
if (static_cast<int>(xev->xbutton.button) == kBackMouseButton ||
static_cast<int>(xev->xbutton.button) == kForwardMouseButton) {
client::UserActionClient* gesture_client =
- client::GetUserActionClient(delegate_->AsRootWindow());
+ client::GetUserActionClient(delegate_->AsRootWindow()->window());
if (gesture_client) {
gesture_client->OnUserAction(
static_cast<int>(xev->xbutton.button) == kBackMouseButton ?
@@ -614,8 +614,9 @@ void RootWindowHostX11::SetBounds(const gfx::Rect& bounds) {
// Even if the host window's size doesn't change, aura's root window
// size, which is in DIP, changes when the scale changes.
float current_scale = delegate_->GetDeviceScaleFactor();
- float new_scale = gfx::Screen::GetScreenFor(delegate_->AsRootWindow())->
- GetDisplayNearestWindow(delegate_->AsRootWindow()).device_scale_factor();
+ float new_scale = gfx::Screen::GetScreenFor(
+ delegate_->AsRootWindow()->window())->GetDisplayNearestWindow(
+ delegate_->AsRootWindow()->window()).device_scale_factor();
bool origin_changed = bounds_.origin() != bounds.origin();
bool size_changed = bounds_.size() != bounds.size();
XWindowChanges changes = {0};
@@ -647,8 +648,8 @@ void RootWindowHostX11::SetBounds(const gfx::Rect& bounds) {
if (size_changed || current_scale != new_scale) {
delegate_->OnHostResized(bounds.size());
} else {
- delegate_->AsRootWindow()->SchedulePaintInRect(
- delegate_->AsRootWindow()->bounds());
+ delegate_->AsRootWindow()->window()->SchedulePaintInRect(
+ delegate_->AsRootWindow()->window()->bounds());
}
}
@@ -827,7 +828,7 @@ void RootWindowHostX11::OnRootWindowInitialized(RootWindow* root_window) {
// RootWindow::Init is called.
// (set in DisplayManager::CreateRootWindowForDisplay)
// Ready when NotifyRootWindowInitialized is called from RootWindow::Init.
- if (!delegate_ || root_window != GetRootWindow()->window())
+ if (!delegate_ || root_window != GetRootWindow())
return;
UpdateIsInternalDisplay();
@@ -943,7 +944,7 @@ void RootWindowHostX11::DispatchXI2Event(const base::NativeEvent& event) {
if (type == ui::ET_MOUSE_RELEASED)
break;
client::UserActionClient* gesture_client =
- client::GetUserActionClient(delegate_->AsRootWindow());
+ client::GetUserActionClient(delegate_->AsRootWindow()->window());
if (gesture_client) {
bool reverse_direction =
ui::IsTouchpadEvent(xev) && ui::IsNaturalScrollEnabled();
diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc
index 2ef4430..3fca471 100644
--- a/ui/aura/root_window_unittest.cc
+++ b/ui/aura/root_window_unittest.cc
@@ -16,6 +16,7 @@
#include "ui/aura/test/test_event_handler.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
+#include "ui/aura/window.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/hit_test.h"
#include "ui/events/event.h"
@@ -1247,7 +1248,7 @@ namespace {
// See description above DeleteRootFromHeldMouseEvent for details.
class DeleteRootFromHeldMouseEventDelegate : public test::TestWindowDelegate {
public:
- explicit DeleteRootFromHeldMouseEventDelegate(aura::Window* root)
+ explicit DeleteRootFromHeldMouseEventDelegate(aura::RootWindow* root)
: root_(root),
got_mouse_event_(false),
got_destroy_(false) {
@@ -1269,7 +1270,7 @@ class DeleteRootFromHeldMouseEventDelegate : public test::TestWindowDelegate {
}
private:
- Window* root_;
+ RootWindow* root_;
bool got_mouse_event_;
bool got_destroy_;
diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc
index d5263e4..8393766 100644
--- a/ui/aura/test/aura_test_base.cc
+++ b/ui/aura/test/aura_test_base.cc
@@ -8,6 +8,7 @@
#include "ui/aura/root_window.h"
#include "ui/aura/test/aura_test_helper.h"
#include "ui/aura/test/test_window_delegate.h"
+#include "ui/aura/window.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/events/gestures/gesture_configuration.h"
diff --git a/ui/aura/test/ui_controls_factory_aurawin.cc b/ui/aura/test/ui_controls_factory_aurawin.cc
index 60a15c9..86f2d10 100644
--- a/ui/aura/test/ui_controls_factory_aurawin.cc
+++ b/ui/aura/test/ui_controls_factory_aurawin.cc
@@ -7,6 +7,7 @@
#include "base/message_loop/message_loop.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
+#include "ui/aura/window.h"
#include "ui/base/test/ui_controls_aura.h"
#include "ui/base/test/ui_controls_internal_win.h"
diff --git a/ui/aura/test/ui_controls_factory_aurax11.cc b/ui/aura/test/ui_controls_factory_aurax11.cc
index b672181..7926143 100644
--- a/ui/aura/test/ui_controls_factory_aurax11.cc
+++ b/ui/aura/test/ui_controls_factory_aurax11.cc
@@ -15,6 +15,7 @@
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/ui_controls_factory_aura.h"
+#include "ui/aura/window.h"
#include "ui/base/test/ui_controls_aura.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/dip_util.h"
@@ -145,7 +146,7 @@ class UIControlsX11 : public UIControlsAura {
XMotionEvent* xmotion = &xevent.xmotion;
xmotion->type = MotionNotify;
gfx::Point point = ui::ConvertPointToPixel(
- root_window_->layer(),
+ root_window_->window()->layer(),
gfx::Point(static_cast<int>(x), static_cast<int>(y)));
xmotion->x = point.x();
xmotion->y = point.y();
@@ -167,9 +168,11 @@ class UIControlsX11 : public UIControlsAura {
XButtonEvent* xbutton = &xevent.xbutton;
gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location();
aura::client::ScreenPositionClient* screen_position_client =
- aura::client::GetScreenPositionClient(root_window_);
- if (screen_position_client)
- screen_position_client->ConvertPointFromScreen(root_window_, &mouse_loc);
+ aura::client::GetScreenPositionClient(root_window_->window());
+ if (screen_position_client) {
+ screen_position_client->ConvertPointFromScreen(root_window_->window(),
+ &mouse_loc);
+ }
xbutton->x = mouse_loc.x();
xbutton->y = mouse_loc.y();
xbutton->same_screen = True;
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 0fe9a6d..3154d68 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -14,6 +14,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "ui/aura/client/capture_client.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/event_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/screen_position_client.h"
@@ -33,6 +34,47 @@
namespace aura {
+class ScopedCursorHider {
+ public:
+ explicit ScopedCursorHider(Window* window)
+ : window_(window),
+ hid_cursor_(false) {
+ if (!window_->HasDispatcher())
+ return;
+ const bool cursor_is_in_bounds = window_->GetBoundsInScreen().Contains(
+ Env::GetInstance()->last_mouse_location());
+ client::CursorClient* cursor_client = client::GetCursorClient(window_);
+ if (cursor_is_in_bounds && cursor_client &&
+ cursor_client->IsCursorVisible()) {
+ cursor_client->HideCursor();
+ hid_cursor_ = true;
+ }
+ }
+ ~ScopedCursorHider() {
+ if (!window_->HasDispatcher())
+ return;
+
+ // Update the device scale factor of the cursor client only when the last
+ // mouse location is on this root window.
+ if (hid_cursor_) {
+ client::CursorClient* cursor_client = client::GetCursorClient(window_);
+ if (cursor_client) {
+ const gfx::Display& display =
+ gfx::Screen::GetScreenFor(window_)->GetDisplayNearestWindow(
+ window_);
+ cursor_client->SetDisplay(display);
+ cursor_client->ShowCursor();
+ }
+ }
+ }
+
+ private:
+ Window* window_;
+ bool hid_cursor_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedCursorHider);
+};
+
Window::Window(WindowDelegate* delegate)
: dispatcher_(NULL),
type_(client::WINDOW_TYPE_UNKNOWN),
@@ -183,7 +225,7 @@ Window* Window::GetRootWindow() {
}
const Window* Window::GetRootWindow() const {
- return parent_ ? parent_->GetRootWindow() : NULL;
+ return dispatcher_ ? this : parent_ ? parent_->GetRootWindow() : NULL;
}
WindowEventDispatcher* Window::GetDispatcher() {
@@ -536,6 +578,9 @@ bool Window::HasFocus() const {
}
bool Window::CanFocus() const {
+ if (dispatcher_)
+ return IsVisible();
+
// NOTE: as part of focusing the window the ActivationClient may make the
// window visible (by way of making a hidden ancestor visible). For this
// reason we can't check visibility here and assume the client is doing it.
@@ -552,6 +597,9 @@ bool Window::CanFocus() const {
}
bool Window::CanReceiveEvents() const {
+ if (dispatcher_)
+ return IsVisible();
+
// The client may forbid certain windows from receiving events at a given
// point in time.
client::EventClient* client = client::GetEventClient(GetRootWindow());
@@ -602,6 +650,9 @@ void* Window::GetNativeWindowProperty(const char* key) const {
}
void Window::OnDeviceScaleFactorChanged(float device_scale_factor) {
+ ScopedCursorHider hider(this);
+ if (dispatcher_)
+ dispatcher_->DeviceScaleFactorChanged(device_scale_factor);
if (delegate_)
delegate_->OnDeviceScaleFactorChanged(device_scale_factor);
}
@@ -1122,6 +1173,11 @@ bool Window::CanAcceptEvent(const ui::Event& event) {
}
ui::EventTarget* Window::GetParentTarget() {
+ if (dispatcher_) {
+ return client::GetEventClient(this) ?
+ client::GetEventClient(this)->GetToplevelEventTarget() :
+ Env::GetInstance();
+ }
return parent_;
}
diff --git a/ui/aura/window.h b/ui/aura/window.h
index e11f83a..ea38461 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -366,6 +366,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
private:
friend class test::WindowTestApi;
friend class LayoutManager;
+ friend class RootWindow;
// Used when stacking windows.
enum StackDirection {
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index be917dd..1f18378 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -1573,7 +1573,7 @@ TEST_F(WindowTest, TransformGesture) {
gfx::Transform transform;
transform.Translate(size.height(), 0.0);
transform.Rotate(90.0);
- root_window()->SetTransform(transform);
+ dispatcher()->SetTransform(transform);
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(size.height() - 10, 10), 0, getTime());
diff --git a/ui/oak/oak_window.cc b/ui/oak/oak_window.cc
index 7d69e22..64c6e42 100644
--- a/ui/oak/oak_window.cc
+++ b/ui/oak/oak_window.cc
@@ -7,6 +7,7 @@
#include "base/strings/utf_string_conversions.h"
#include "grit/ui_resources.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
diff --git a/ui/shell_dialogs/select_file_dialog_win.cc b/ui/shell_dialogs/select_file_dialog_win.cc
index 7cec71d..fdf01d7 100644
--- a/ui/shell_dialogs/select_file_dialog_win.cc
+++ b/ui/shell_dialogs/select_file_dialog_win.cc
@@ -34,6 +34,7 @@
#if defined(USE_AURA)
#include "ui/aura/remote_root_window_host_win.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
namespace {
diff --git a/ui/views/controls/button/custom_button_unittest.cc b/ui/views/controls/button/custom_button_unittest.cc
index 88ec051..061bbd6 100644
--- a/ui/views/controls/button/custom_button_unittest.cc
+++ b/ui/views/controls/button/custom_button_unittest.cc
@@ -12,6 +12,7 @@
#if defined(USE_AURA)
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_cursor_client.h"
+#include "ui/aura/window.h"
#endif
namespace views {
diff --git a/ui/views/corewm/capture_controller_unittest.cc b/ui/views/corewm/capture_controller_unittest.cc
index 295ea3d..f6ac7b3 100644
--- a/ui/views/corewm/capture_controller_unittest.cc
+++ b/ui/views/corewm/capture_controller_unittest.cc
@@ -11,6 +11,7 @@
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_screen.h"
#include "ui/aura/test/test_window_delegate.h"
+#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/views/test/views_test_base.h"
diff --git a/ui/views/corewm/compound_event_filter.cc b/ui/views/corewm/compound_event_filter.cc
index b761618..8e42dd8 100644
--- a/ui/views/corewm/compound_event_filter.cc
+++ b/ui/views/corewm/compound_event_filter.cc
@@ -11,6 +11,7 @@
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/hit_test.h"
diff --git a/ui/views/corewm/compound_event_filter_unittest.cc b/ui/views/corewm/compound_event_filter_unittest.cc
index 932ace7..6b852e4 100644
--- a/ui/views/corewm/compound_event_filter_unittest.cc
+++ b/ui/views/corewm/compound_event_filter_unittest.cc
@@ -12,6 +12,7 @@
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_cursor_client.h"
#include "ui/aura/test/test_windows.h"
+#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
diff --git a/ui/views/corewm/tooltip_aura.cc b/ui/views/corewm/tooltip_aura.cc
index 1f7029e..8ba2393 100644
--- a/ui/views/corewm/tooltip_aura.cc
+++ b/ui/views/corewm/tooltip_aura.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/strings/string_split.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/text_elider.h"
diff --git a/ui/views/examples/content_client/examples_browser_main_parts.cc b/ui/views/examples/content_client/examples_browser_main_parts.cc
index d27baa1..87aee75 100644
--- a/ui/views/examples/content_client/examples_browser_main_parts.cc
+++ b/ui/views/examples/content_client/examples_browser_main_parts.cc
@@ -28,6 +28,7 @@
#if defined(OS_CHROMEOS)
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_screen.h"
+#include "ui/aura/window.h"
#include "ui/shell/minimal_shell.h"
#endif
@@ -53,7 +54,7 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() {
// Ensure the X window gets mapped.
minimal_shell_->root_window()->ShowRootWindow();
// Ensure Aura knows where to open new windows.
- window_context = minimal_shell_->root_window();
+ window_context = minimal_shell_->root_window()->window();
#elif defined(USE_AURA)
aura::Env::CreateInstance();
gfx::Screen::SetScreenInstance(
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index 5e22f0d..51d1229 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -444,11 +444,11 @@ void DesktopNativeWidgetAura::InitNativeWidget(
desktop_root_window_host_->CreateTooltip()));
aura::client::SetTooltipClient(root_window_->window(),
tooltip_controller_.get());
- root_window_->AddPreTargetHandler(tooltip_controller_.get());
+ root_window_->window()->AddPreTargetHandler(tooltip_controller_.get());
if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) {
visibility_controller_.reset(new views::corewm::VisibilityController);
- aura::client::SetVisibilityClient(root_window_.get(),
+ aura::client::SetVisibilityClient(root_window_->window(),
visibility_controller_.get());
views::corewm::SetChildWindowVisibilityChangesAnimated(
root_window_->window());
@@ -458,7 +458,8 @@ void DesktopNativeWidgetAura::InitNativeWidget(
if (params.type == Widget::InitParams::TYPE_WINDOW) {
focus_manager_event_handler_.reset(new FocusManagerEventHandler(this));
- root_window_->AddPreTargetHandler(focus_manager_event_handler_.get());
+ root_window_->window()->AddPreTargetHandler(
+ focus_manager_event_handler_.get());
}
event_client_.reset(new DesktopEventClient);
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
index 69b6b67..8390356 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
@@ -5,6 +5,7 @@
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
diff --git a/ui/views/widget/desktop_aura/desktop_screen_win.cc b/ui/views/widget/desktop_aura/desktop_screen_win.cc
index f1a7767..805417d 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_win.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "ui/aura/root_window.h"
#include "ui/aura/root_window_host.h"
+#include "ui/aura/window.h"
#include "ui/gfx/display.h"
#include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index 7b99790..cd5cffc 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -15,6 +15,7 @@
#include "base/x11/edid_parser_x11.h"
#include "ui/aura/root_window.h"
#include "ui/aura/root_window_host.h"
+#include "ui/aura/window.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/display.h"
#include "ui/gfx/display_observer.h"
diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc
index 544d7ab..19686de 100644
--- a/ui/views/widget/widget_interactive_uitest.cc
+++ b/ui/views/widget/widget_interactive_uitest.cc
@@ -15,6 +15,7 @@
#include "ui/aura/client/focus_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#endif
#if defined(USE_AURA) && !defined(OS_CHROMEOS)
diff --git a/ui/views/win/hwnd_util_aurawin.cc b/ui/views/win/hwnd_util_aurawin.cc
index a927df1..fc748184 100644
--- a/ui/views/win/hwnd_util_aurawin.cc
+++ b/ui/views/win/hwnd_util_aurawin.cc
@@ -5,6 +5,7 @@
#include "ui/views/win/hwnd_util.h"
#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
#include "ui/views/widget/widget.h"
namespace views {