Skip to content

Commit

Permalink
Removes most aura dependencies from WindowResizer
Browse files Browse the repository at this point in the history
Last remaining one is for DockedWindowLayoutManager, which will be
converted later.

BUG=603369
TEST=covered by other tests
R=jamescook@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#388414}
  • Loading branch information
sky authored and Commit bot committed Apr 20, 2016
1 parent 6a18734 commit a6d587a
Show file tree
Hide file tree
Showing 38 changed files with 286 additions and 231 deletions.
4 changes: 2 additions & 2 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@
'wm/aura/wm_window_aura.h',
'wm/boot_splash_screen_chromeos.cc',
'wm/boot_splash_screen_chromeos.h',
'wm/common/root_window_finder.cc',
'wm/common/root_window_finder.h',
'wm/common/window_animation_types.h',
'wm/common/window_parenting_utils.cc',
'wm/common/window_parenting_utils.h',
Expand All @@ -556,8 +558,6 @@
'wm/common/wm_window_property.h',
'wm/common/workspace/workspace_layout_manager_delegate.h',
'wm/common/workspace/workspace_types.h',
'wm/coordinate_conversion.cc',
'wm/coordinate_conversion.h',
'wm/cursor_manager_chromeos.cc',
'wm/cursor_manager_chromeos.h',
'wm/default_state.cc',
Expand Down
6 changes: 4 additions & 2 deletions ash/autoclick/autoclick_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include "ash/autoclick/autoclick_controller.h"

#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/root_window_finder.h"
#include "base/timer/timer.h"
#include "ui/aura/env.h"
#include "ui/aura/window_tree_host.h"
Expand Down Expand Up @@ -178,7 +179,8 @@ void AutoclickControllerImpl::OnScrollEvent(ui::ScrollEvent* event) {
void AutoclickControllerImpl::DoAutoclick() {
gfx::Point screen_location =
aura::Env::GetInstance()->last_mouse_location();
aura::Window* root_window = wm::GetRootWindowAt(screen_location);
aura::Window* root_window =
wm::WmWindowAura::GetAuraWindow(wm::GetRootWindowAt(screen_location));
DCHECK(root_window) << "Root window not found while attempting autoclick.";

gfx::Point click_location(screen_location);
Expand Down
6 changes: 4 additions & 2 deletions ash/display/screen_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/root_window_finder.h"
#include "base/logging.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
Expand Down Expand Up @@ -104,7 +105,8 @@ gfx::NativeWindow ScreenAsh::GetWindowUnderCursor() {
}

gfx::NativeWindow ScreenAsh::GetWindowAtScreenPoint(const gfx::Point& point) {
aura::Window* root_window = wm::GetRootWindowAt(point);
aura::Window* root_window =
wm::WmWindowAura::GetAuraWindow(wm::GetRootWindowAt(point));
aura::client::ScreenPositionClient* position_client =
aura::client::GetScreenPositionClient(root_window);

Expand Down
1 change: 0 additions & 1 deletion ash/display/screen_position_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/system_modal_container_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_state.h"
Expand Down
1 change: 0 additions & 1 deletion ash/display/shared_display_edge_indicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_event_dispatcher.h"
Expand Down
1 change: 0 additions & 1 deletion ash/display/window_tree_host_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/system/tray/system_tray.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/stl_util.h"
Expand Down
7 changes: 4 additions & 3 deletions ash/drag_drop/drag_drop_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/root_window_finder.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
Expand Down Expand Up @@ -72,7 +73,7 @@ aura::Window* DragDropTracker::GetTarget(const ui::LocatedEvent& event) {
gfx::Point location_in_screen = event.location();
::wm::ConvertPointToScreen(capture_window_.get(), &location_in_screen);
aura::Window* root_window_at_point =
wm::GetRootWindowAt(location_in_screen);
wm::WmWindowAura::GetAuraWindow(wm::GetRootWindowAt(location_in_screen));
gfx::Point location_in_root = location_in_screen;
::wm::ConvertPointFromScreen(root_window_at_point, &location_in_root);
return root_window_at_point->GetEventHandlerForPoint(location_in_root);
Expand All @@ -90,7 +91,7 @@ ui::LocatedEvent* DragDropTracker::ConvertEvent(
gfx::Point target_root_location = event.root_location();
aura::Window::ConvertPointToTarget(
capture_window_->GetRootWindow(),
ash::wm::GetRootWindowAt(location_in_screen),
wm::WmWindowAura::GetAuraWindow(wm::GetRootWindowAt(location_in_screen)),
&target_root_location);
return new ui::MouseEvent(
event.type(), target_location, target_root_location,
Expand Down
3 changes: 1 addition & 2 deletions ash/drag_drop/drag_drop_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace ash {
// Provides functions for handling drag events inside and outside the root
// window where drag is started. This internally sets up a capture window for
// tracking drag events outside the root window where drag is initiated.
// ash/wm/coordinate_conversion.h is used internally and only X11 environment
// is supported for now.
// Only X11 environment is supported for now.
class ASH_EXPORT DragDropTracker {
public:
DragDropTracker(aura::Window* context_root,
Expand Down
54 changes: 36 additions & 18 deletions ash/extended_desktop_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/root_window_finder.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/strings/string_util.h"
Expand Down Expand Up @@ -314,17 +315,24 @@ TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT);
aura::Window::Windows root_windows = Shell::GetAllRootWindows();

EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100)));
EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100)));
EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300)));
EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700, 300)));
EXPECT_EQ(root_windows[1], wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowAt(gfx::Point(-400, 100))));
EXPECT_EQ(root_windows[1], wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowAt(gfx::Point(-1, 100))));
EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowAt(gfx::Point(0, 300))));
EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowAt(gfx::Point(700, 300))));

// Zero origin.
EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0)));
EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowAt(gfx::Point(0, 0))));

// Out of range point should return the nearest root window
EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-600, 0)));
EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100)));
EXPECT_EQ(root_windows[1], wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowAt(gfx::Point(-600, 0))));
EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowAt(gfx::Point(701, 100))));
}

TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
Expand All @@ -338,33 +346,43 @@ TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {

// Containing rect.
EXPECT_EQ(root_windows[1],
wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))));
EXPECT_EQ(root_windows[0],
wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))));

// Intersecting rect.
EXPECT_EQ(root_windows[1],
wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))));
EXPECT_EQ(root_windows[0],
wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300))));

// Zero origin.
EXPECT_EQ(root_windows[0],
wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0))));
EXPECT_EQ(root_windows[0],
wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1))));

// Empty rect.
EXPECT_EQ(root_windows[1],
wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))));
EXPECT_EQ(root_windows[0],
wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))));

// Out of range rect should return the primary root window.
EXPECT_EQ(root_windows[0],
wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))));
EXPECT_EQ(root_windows[0],
wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))));
}

TEST_F(ExtendedDesktopTest, Capture) {
Expand Down
1 change: 0 additions & 1 deletion ash/screen_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "base/logging.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_event_dispatcher.h"
Expand Down
11 changes: 8 additions & 3 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/root_window_finder.h"
#include "base/auto_reset.h"
#include "base/metrics/histogram.h"
#include "grit/ash_strings.h"
Expand Down Expand Up @@ -651,7 +652,9 @@ bool ShelfView::StartDrag(const std::string& app_id,
views::View::ConvertPointFromScreen(drag_and_drop_view, &pt);
gfx::Point point_in_root = location_in_screen_coordinates;
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
wm::WmWindowAura::GetAuraWindow(
ash::wm::GetRootWindowAt(location_in_screen_coordinates)),
&point_in_root);
ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root,
ui::EventTimeForNow(), 0, 0);
PointerPressedOnButton(drag_and_drop_view, DRAG_AND_DROP, event);
Expand All @@ -672,7 +675,9 @@ bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) {
ConvertPointFromScreen(drag_and_drop_view, &pt);
gfx::Point point_in_root = location_in_screen_coordinates;
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
wm::WmWindowAura::GetAuraWindow(
ash::wm::GetRootWindowAt(location_in_screen_coordinates)),
&point_in_root);
ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root,
ui::EventTimeForNow(), 0, 0);
PointerDraggedOnButton(drag_and_drop_view, DRAG_AND_DROP, event);
Expand Down
6 changes: 3 additions & 3 deletions ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#include "ash/wm/ash_focus_rules.h"
#include "ash/wm/ash_native_cursor_manager.h"
#include "ash/wm/aura/wm_globals_aura.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/common/root_window_finder.h"
#include "ash/wm/event_client_impl.h"
#include "ash/wm/lock_state_controller.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
Expand Down Expand Up @@ -299,8 +299,8 @@ void Shell::ShowContextMenu(const gfx::Point& location_in_screen,
if (session_state_delegate_->IsScreenLocked())
return;

aura::Window* root =
wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size()));
aura::Window* root = wm::WmWindowAura::GetAuraWindow(
wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())));
GetRootWindowController(root)
->ShowContextMenu(location_in_screen, source_type);
}
Expand Down
6 changes: 4 additions & 2 deletions ash/test/ui_controls_factory_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include "ash/shell.h"
#include "ash/shell_factory.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/root_window_finder.h"
#include "ash/wm/window_properties.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/screen_position_client.h"
Expand Down Expand Up @@ -45,7 +46,8 @@ UIControlsAura* GetUIControlsForRootWindow(aura::Window* root_window) {
// Returns the UIControls object for the RootWindow at |point_in_screen|.
UIControlsAura* GetUIControlsAt(const gfx::Point& point_in_screen) {
// TODO(mazda): Support the case passive grab is taken.
return GetUIControlsForRootWindow(ash::wm::GetRootWindowAt(point_in_screen));
return GetUIControlsForRootWindow(wm::WmWindowAura::GetAuraWindow(
ash::wm::GetRootWindowAt(point_in_screen)));
}

} // namespace
Expand Down
8 changes: 8 additions & 0 deletions ash/wm/aura/wm_globals_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ bool WmGlobalsAura::IsForceMaximizeOnFirstRun() {
return Shell::GetInstance()->delegate()->IsForceMaximizeOnFirstRun();
}

void WmGlobalsAura::LockCursor() {
ash::Shell::GetInstance()->cursor_manager()->LockCursor();
}

void WmGlobalsAura::UnlockCursor() {
ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
}

std::vector<WmWindow*> WmGlobalsAura::GetAllRootWindows() {
aura::Window::Windows root_windows = Shell::GetAllRootWindows();
std::vector<WmWindow*> wm_windows(root_windows.size());
Expand Down
2 changes: 2 additions & 0 deletions ash/wm/aura/wm_globals_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class ASH_EXPORT WmGlobalsAura : public WmGlobals {
WmWindow* GetRootWindowForNewWindows() override;
std::vector<WmWindow*> GetMruWindowListIgnoreModals() override;
bool IsForceMaximizeOnFirstRun() override;
void LockCursor() override;
void UnlockCursor() override;
std::vector<WmWindow*> GetAllRootWindows() override;

private:
Expand Down
14 changes: 14 additions & 0 deletions ash/wm/aura/wm_root_window_controller_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

#include "ash/wm/aura/wm_root_window_controller_aura.h"

#include "ash/display/window_tree_host_manager.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/wm/aura/wm_globals_aura.h"
#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/workspace_controller.h"
#include "ui/aura/window.h"
#include "ui/aura/window_property.h"
Expand All @@ -20,6 +23,13 @@ DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::wm::WmRootWindowControllerAura,
kWmRootWindowControllerKey,
nullptr);

// static
WmRootWindowController* WmRootWindowController::GetWithDisplayId(int64_t id) {
return WmRootWindowControllerAura::Get(Shell::GetInstance()
->window_tree_host_manager()
->GetRootWindowForDisplayId(id));
}

WmRootWindowControllerAura::WmRootWindowControllerAura(
RootWindowController* root_window_controller)
: root_window_controller_(root_window_controller) {
Expand Down Expand Up @@ -62,5 +72,9 @@ WorkspaceWindowState WmRootWindowControllerAura::GetWorkspaceWindowState() {
return root_window_controller_->workspace_controller()->GetWindowState();
}

WmWindow* WmRootWindowControllerAura::GetWindow() {
return WmWindowAura::Get(root_window_controller_->GetRootWindow());
}

} // namespace wm
} // namespace ash
1 change: 1 addition & 0 deletions ash/wm/aura/wm_root_window_controller_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ASH_EXPORT WmRootWindowControllerAura : public WmRootWindowController {
bool HasShelf() override;
WmGlobals* GetGlobals() override;
WorkspaceWindowState GetWorkspaceWindowState() override;
WmWindow* GetWindow() override;

private:
RootWindowController* root_window_controller_;
Expand Down
Loading

0 comments on commit a6d587a

Please sign in to comment.