Commit 6728fa85 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

wm: Use CursorManager::GetDisplay for display id only

The Display object returned by CursorManager::GetDisplay can be stale,
particularly if you change display resolution. So it shall be used only
for the display id, which can be used to get a current Display object.

Test: manual
Bug: 995413, b/149273461
Change-Id: I7624ec5f09aefd55703412bb053d5204461eca43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2088237Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746971}
parent a12312aa
......@@ -128,15 +128,19 @@ void DragWindowResizer::EndDragImpl() {
if (details().source == wm::WINDOW_MOVE_SOURCE_TOUCH)
return;
aura::Window* root_window = GetTarget()->GetRootWindow();
const display::Display dst_display =
Shell::Get()->cursor_manager()->GetDisplay();
if (dst_display.id() ==
display::Screen::GetScreen()->GetDisplayNearestWindow(root_window).id()) {
// The |Display| object returned by |CursorManager::GetDisplay| may be stale,
// but will have the correct id.
// TODO(oshima): Change the API so |GetDisplay| just returns a display id.
const int64_t dst_display_id =
Shell::Get()->cursor_manager()->GetDisplay().id();
display::Screen* screen = display::Screen::GetScreen();
if (dst_display_id == screen->GetDisplayNearestWindow(root_window).id())
return;
}
// Adjust the size and position so that it doesn't exceed the size of work
// area.
display::Display dst_display;
screen->GetDisplayWithDisplayId(dst_display_id, &dst_display);
const gfx::Size& size = dst_display.work_area().size();
gfx::Rect bounds = GetTarget()->bounds();
if (bounds.width() > size.width()) {
......
......@@ -635,20 +635,13 @@ aura::Window* OverviewWindowDragController::GetRootWindowBeingDraggedIn()
Shell::Get()->cursor_manager()->GetDisplay().id());
}
gfx::Rect OverviewWindowDragController::GetWorkAreaOfDisplayBeingDraggedIn()
const {
return is_touch_dragging_
? screen_util::
GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
item_->root_window())
: Shell::Get()->cursor_manager()->GetDisplay().work_area();
}
SplitViewController::SnapPosition OverviewWindowDragController::GetSnapPosition(
const gfx::PointF& location_in_screen) const {
DCHECK(item_);
DCHECK(should_allow_split_view_);
gfx::Rect area = GetWorkAreaOfDisplayBeingDraggedIn();
gfx::Rect area =
screen_util::GetDisplayWorkAreaBoundsInScreenForActiveDeskContainer(
GetRootWindowBeingDraggedIn());
// If split view mode is active at the moment, and dragging an overview window
// to snap it to a position that already has a snapped window in place, we
......
......@@ -106,7 +106,6 @@ class ASH_EXPORT OverviewWindowDragController {
const gfx::PointF& location_in_screen);
aura::Window* GetRootWindowBeingDraggedIn() const;
gfx::Rect GetWorkAreaOfDisplayBeingDraggedIn() const;
SplitViewController::SnapPosition GetSnapPosition(
const gfx::PointF& location_in_screen) const;
......
......@@ -1032,11 +1032,19 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(
if (!did_move_or_resize_ || details().window_component != HTCAPTION)
return;
const display::Display& display =
details().source == ::wm::WINDOW_MOVE_SOURCE_TOUCH
? display::Screen::GetScreen()->GetDisplayNearestWindow(GetTarget())
: Shell::Get()->cursor_manager()->GetDisplay();
display::Screen* screen = display::Screen::GetScreen();
display::Display display;
if (details().source == ::wm::WINDOW_MOVE_SOURCE_TOUCH) {
display = screen->GetDisplayNearestWindow(GetTarget());
} else {
// The |Display| object returned by |CursorManager::GetDisplay| may be
// stale, but will have the correct id.
// TODO(oshima): Change the API so |GetDisplay| just returns a display id.
screen->GetDisplayWithDisplayId(
Shell::Get()->cursor_manager()->GetDisplay().id(), &display);
}
SnapType last_type = snap_type_;
DCHECK(display.is_valid());
snap_type_ = GetSnapType(display, location_in_screen);
if (snap_type_ == SNAP_NONE || snap_type_ != last_type) {
snap_phantom_window_controller_.reset();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment