Skip to content

Commit

Permalink
Window ownership -> WindowTreeHost
Browse files Browse the repository at this point in the history
Replaces Window::GetDispatcher with Window::GetHost().

Had to clear ScreenPositionClient property prior to window teardown as tests on desktop delete it prior to destroying the window hierarchy. Unhooking the property appears to have no ill-effect.

R=sky@chromium.org
http://crbug.com/308843

Review URL: https://codereview.chromium.org/184903003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254642 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ben@chromium.org committed Mar 4, 2014
1 parent b5126da commit 2374d18
Show file tree
Hide file tree
Showing 123 changed files with 517 additions and 520 deletions.
4 changes: 2 additions & 2 deletions ash/accelerators/accelerator_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ bool HandleToggleFullscreen(ui::KeyboardCode key_code) {
}

bool HandleToggleRootWindowFullScreen() {
Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->ToggleFullScreen();
Shell::GetPrimaryRootWindow()->GetHost()->ToggleFullScreen();
return true;
}

Expand Down Expand Up @@ -703,7 +703,7 @@ bool HandlePrintLayerHierarchy() {
for (size_t i = 0; i < root_windows.size(); ++i) {
ui::PrintLayerHierarchy(
root_windows[i]->layer(),
root_windows[i]->GetDispatcher()->GetLastMouseLocationInRoot());
root_windows[i]->GetHost()->dispatcher()->GetLastMouseLocationInRoot());
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion ash/accelerators/accelerator_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ TEST_F(AcceleratorControllerTest, MAYBE_ProcessOnce) {

// The accelerator is processed only once.
aura::WindowEventDispatcher* dispatcher =
Shell::GetPrimaryRootWindow()->GetDispatcher();
Shell::GetPrimaryRootWindow()->GetHost()->dispatcher();
#if defined(OS_WIN)
MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 };
ui::TranslatedKeyEvent key_event1(msg1, false);
Expand Down
2 changes: 1 addition & 1 deletion ash/accelerators/key_hold_detector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void DispatchPressedEvent(XEvent native_event,
ui::KeyEvent event(&native_event, false);
event.set_flags(event.flags() | ui::EF_IS_SYNTHESIZED);
ui::EventDispatchDetails result ALLOW_UNUSED =
target->GetDispatcher()->OnEventFromSource(&event);
target->GetHost()->dispatcher()->OnEventFromSource(&event);
}

void PostPressedEvent(ui::KeyEvent* event) {
Expand Down
7 changes: 3 additions & 4 deletions ash/accelerators/nested_dispatcher_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ void DispatchKeyReleaseA() {
#elif defined(USE_X11)
ui::ScopedXI2Event native_event;
native_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0);
aura::WindowEventDispatcher* dispatcher =
ash::Shell::GetPrimaryRootWindow()->GetDispatcher();
dispatcher->host()->PostNativeEvent(native_event);
aura::WindowTreeHost* host = ash::Shell::GetPrimaryRootWindow()->GetHost();
host->PostNativeEvent(native_event);
native_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0);
dispatcher->host()->PostNativeEvent(native_event);
host->PostNativeEvent(native_event);
#endif
// Make sure the inner message-loop terminates after dispatching the events.
base::MessageLoop::current()->PostTask(FROM_HERE,
Expand Down
8 changes: 4 additions & 4 deletions ash/autoclick/autoclick_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ void AutoclickControllerImpl::DoAutoclick() {
anchor_location_ = click_location;
wm::ConvertPointFromScreen(root_window, &click_location);

aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher();
dispatcher->host()->ConvertPointToHost(&click_location);
aura::WindowTreeHost* host = root_window->GetHost();
host->ConvertPointToHost(&click_location);

ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED,
click_location,
Expand All @@ -201,9 +201,9 @@ void AutoclickControllerImpl::DoAutoclick() {
ui::EF_LEFT_MOUSE_BUTTON);

ui::EventDispatchDetails details =
dispatcher->OnEventFromSource(&press_event);
host->dispatcher()->OnEventFromSource(&press_event);
if (!details.dispatcher_destroyed)
details = dispatcher->OnEventFromSource(&release_event);
details = host->dispatcher()->OnEventFromSource(&release_event);
if (details.dispatcher_destroyed)
return;
}
Expand Down
6 changes: 3 additions & 3 deletions ash/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void ToggleShowDebugBorders() {
scoped_ptr<bool> value;
for (aura::Window::Windows::iterator it = root_windows.begin();
it != root_windows.end(); ++it) {
ui::Compositor* compositor = (*it)->GetDispatcher()->host()->compositor();
ui::Compositor* compositor = (*it)->GetHost()->compositor();
cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
if (!value.get())
value.reset(new bool(!state.show_debug_borders));
Expand All @@ -33,7 +33,7 @@ void ToggleShowFpsCounter() {
scoped_ptr<bool> value;
for (aura::Window::Windows::iterator it = root_windows.begin();
it != root_windows.end(); ++it) {
ui::Compositor* compositor = (*it)->GetDispatcher()->host()->compositor();
ui::Compositor* compositor = (*it)->GetHost()->compositor();
cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
if (!value.get())
value.reset(new bool(!state.show_fps_counter));
Expand All @@ -48,7 +48,7 @@ void ToggleShowPaintRects() {
scoped_ptr<bool> value;
for (aura::Window::Windows::iterator it = root_windows.begin();
it != root_windows.end(); ++it) {
ui::Compositor* compositor = (*it)->GetDispatcher()->host()->compositor();
ui::Compositor* compositor = (*it)->GetHost()->compositor();
cc::LayerTreeDebugState state = compositor->GetLayerTreeDebugState();
if (!value.get())
value.reset(new bool(!state.show_paint_rects));
Expand Down
3 changes: 1 addition & 2 deletions ash/display/cursor_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ void CursorWindowController::UpdateLocation() {

gfx::Point point = aura::Env::GetInstance()->last_mouse_location();
if (!is_cursor_compositing_enabled_) {
Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->ConvertPointToHost(
&point);
Shell::GetPrimaryRootWindow()->GetHost()->ConvertPointToHost(&point);
} else {
point.Offset(-bounds_in_screen_.x(), -bounds_in_screen_.y());
}
Expand Down
23 changes: 10 additions & 13 deletions ash/display/display_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,13 @@ void DisplayController::EnsurePointerInDisplays() {
aura::client::ScreenPositionClient* client =
aura::client::GetScreenPositionClient(root_window);
client->ConvertPointFromScreen(root_window, &center);
root_window->GetDispatcher()->host()->ConvertPointToNativeScreen(&center);
root_window->GetHost()->ConvertPointToNativeScreen(&center);
dst_root_window = root_window;
target_location_in_native = center;
closest_distance_squared = distance_squared;
}
}
dst_root_window->GetDispatcher()->host()->ConvertPointFromNativeScreen(
dst_root_window->GetHost()->ConvertPointFromNativeScreen(
&target_location_in_native);
dst_root_window->MoveCursorTo(target_location_in_native);
}
Expand All @@ -542,10 +542,9 @@ void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) {
const internal::DisplayInfo& display_info =
GetDisplayManager()->GetDisplayInfo(display.id());
DCHECK(!display_info.bounds_in_native().IsEmpty());
aura::WindowEventDispatcher* dispatcher =
root_windows_[display.id()]->GetDispatcher();
dispatcher->host()->SetBounds(display_info.bounds_in_native());
SetDisplayPropertiesOnHost(dispatcher->host(), display);
aura::WindowTreeHost* host = root_windows_[display.id()]->GetHost();
host->SetBounds(display_info.bounds_in_native());
SetDisplayPropertiesOnHost(host, display);
}

void DisplayController::OnDisplayAdded(const gfx::Display& display) {
Expand All @@ -558,10 +557,9 @@ void DisplayController::OnDisplayAdded(const gfx::Display& display) {
primary_root_window_for_replace_ = NULL;
const internal::DisplayInfo& display_info =
GetDisplayManager()->GetDisplayInfo(display.id());
aura::WindowEventDispatcher* dispatcher =
root_windows_[display.id()]->GetDispatcher();
dispatcher->host()->SetBounds(display_info.bounds_in_native());
SetDisplayPropertiesOnHost(dispatcher->host(), display);
aura::WindowTreeHost* host = root_windows_[display.id()]->GetHost();
host->SetBounds(display_info.bounds_in_native());
SetDisplayPropertiesOnHost(host, display);
} else {
if (primary_display_id == gfx::Display::kInvalidDisplayID)
primary_display_id = display.id();
Expand Down Expand Up @@ -664,8 +662,7 @@ void DisplayController::PreDisplayConfigurationChange(bool clear_focus) {
aura::client::ScreenPositionClient* client =
aura::client::GetScreenPositionClient(root_window);
client->ConvertPointFromScreen(root_window, &point_in_screen);
root_window->GetDispatcher()->host()->ConvertPointToNativeScreen(
&point_in_screen);
root_window->GetHost()->ConvertPointToNativeScreen(&point_in_screen);
cursor_location_in_native_coords_for_restore_ = point_in_screen;
}

Expand Down Expand Up @@ -748,7 +745,7 @@ void DisplayController::UpdateHostWindowNames() {
std::string name =
root_windows[i] == primary ? "aura_root_0" : "aura_root_x";
gfx::AcceleratedWidget xwindow =
root_windows[i]->GetDispatcher()->host()->GetAcceleratedWidget();
root_windows[i]->GetHost()->GetAcceleratedWidget();
XStoreName(gfx::GetXDisplay(), xwindow, name.c_str());
}
#endif
Expand Down
30 changes: 15 additions & 15 deletions ash/display/display_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,11 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {

test::CursorManagerTestApi test_api(Shell::GetInstance()->cursor_manager());

EXPECT_EQ(1.0f, primary_root->GetDispatcher()->host()->compositor()->
EXPECT_EQ(1.0f, primary_root->GetHost()->compositor()->
device_scale_factor());
primary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
EXPECT_EQ(2.0f, secondary_root->GetDispatcher()->host()->compositor()->
EXPECT_EQ(2.0f, secondary_root->GetHost()->compositor()->
device_scale_factor());
secondary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor());
Expand All @@ -978,12 +978,12 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {

// Cursor's device scale factor should be updated accroding to the swap of
// primary and secondary.
EXPECT_EQ(1.0f, secondary_root->GetDispatcher()->host()->compositor()->
EXPECT_EQ(1.0f, secondary_root->GetHost()->compositor()->
device_scale_factor());
secondary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
primary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(2.0f, primary_root->GetDispatcher()->host()->compositor()->
EXPECT_EQ(2.0f, primary_root->GetHost()->compositor()->
device_scale_factor());
EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor());

Expand All @@ -995,7 +995,7 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());

primary_root->MoveCursorTo(gfx::Point(50, 50));
EXPECT_EQ(1.0f, primary_root->GetDispatcher()->host()->compositor()->
EXPECT_EQ(1.0f, primary_root->GetHost()->compositor()->
device_scale_factor());
EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor());
}
Expand Down Expand Up @@ -1037,13 +1037,13 @@ TEST_F(DisplayControllerTest, OverscanInsets) {
UpdateDisplay("400x300*2,600x400/o");
root_windows = Shell::GetAllRootWindows();
gfx::Point point;
Shell::GetAllRootWindows()[1]->GetDispatcher()->host()->
Shell::GetAllRootWindows()[1]->GetHost()->
GetRootTransform().TransformPoint(&point);
EXPECT_EQ("15,10", point.ToString());

display_controller->SwapPrimaryDisplay();
point.SetPoint(0, 0);
Shell::GetAllRootWindows()[1]->GetDispatcher()->host()->
Shell::GetAllRootWindows()[1]->GetHost()->
GetRootTransform().TransformPoint(&point);
EXPECT_EQ("15,10", point.ToString());

Expand Down Expand Up @@ -1296,41 +1296,41 @@ TEST_F(DisplayControllerTest, DockToSingle) {
display_info_list.push_back(external_display_info);
display_manager->OnNativeDisplaysChanged(display_info_list);
EXPECT_EQ(1U, display_manager->GetNumDisplays());
EXPECT_FALSE(Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->
EXPECT_FALSE(Shell::GetPrimaryRootWindow()->GetHost()->
GetRootTransform().IsIdentityOrIntegerTranslation());

// Switch to single mode and make sure the transform is the one
// for the internal display.
display_info_list.clear();
display_info_list.push_back(internal_display_info);
display_manager->OnNativeDisplaysChanged(display_info_list);
EXPECT_TRUE(Shell::GetPrimaryRootWindow()->GetDispatcher()->host()->
EXPECT_TRUE(Shell::GetPrimaryRootWindow()->GetHost()->
GetRootTransform().IsIdentityOrIntegerTranslation());
}

#if defined(USE_X11)
TEST_F(DisplayControllerTest, XWidowNameForRootWindow) {
EXPECT_EQ("aura_root_0", GetXWindowName(
Shell::GetPrimaryRootWindow()->GetDispatcher()->host()));
Shell::GetPrimaryRootWindow()->GetHost()));

// Multiple display.
UpdateDisplay("200x200,300x300");
aura::Window* primary, *secondary;
GetPrimaryAndSeconary(&primary, &secondary);
EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher()->host()));
EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher()->host()));
EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetHost()));
EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost()));

// Swap primary.
primary = secondary = NULL;
Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
GetPrimaryAndSeconary(&primary, &secondary);
EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetDispatcher()->host()));
EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetDispatcher()->host()));
EXPECT_EQ("aura_root_0", GetXWindowName(primary->GetHost()));
EXPECT_EQ("aura_root_x", GetXWindowName(secondary->GetHost()));

// Switching back to single display.
UpdateDisplay("300x400");
EXPECT_EQ("aura_root_0", GetXWindowName(
Shell::GetPrimaryRootWindow()->GetDispatcher()->host()));
Shell::GetPrimaryRootWindow()->GetHost()));
}
#endif

Expand Down
Loading

0 comments on commit 2374d18

Please sign in to comment.