Commit 18bf11a9 authored by Kazuki Takise's avatar Kazuki Takise Committed by Commit Bot

Take hotseat into account in collision detection

The hotseat affects the position of the PIP window, so this CL
includes the following changes to take it into consideration in
collision detection.

- Add the hotseat to collision rects. We adjust the bounds of the
  hotseat a bit so that we can slide the PIP window along the
  hotseat smoothly.
- Make hotseat state change trigger a system ui area change event
  in workspace layout manager.

Note we still have the PIP initial bounds issue as Android still
doesn't know the correct initial position.
BUG=b:147790853
TEST=Manually confirmed the PIP window was placed at the correct
TEST=position (once dragged) and was moved smoothly.
TEST=Manually confirmed toggling in-app state properly adjusted the
TEST=PIP window.

Change-Id: Idefc2877aa4aaf8996a016b64721bae4a74b3cea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014357Reviewed-by: default avatarMitsuru Oshima (slow in TOK) <oshima@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Kazuki Takise <takise@chromium.org>
Auto-Submit: Kazuki Takise <takise@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737243}
parent 8e6c2815
......@@ -532,6 +532,12 @@ void Shelf::OnBackgroundUpdated(ShelfBackgroundType background_type,
observer.OnBackgroundTypeChanged(background_type, change_type);
}
void Shelf::OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) {
for (auto& observer : observers_)
observer.OnHotseatStateChanged(old_state, new_state);
}
void Shelf::OnWorkAreaInsetsChanged() {
for (auto& observer : observers_)
observer.OnShelfWorkAreaInsetsChanged();
......
......@@ -234,6 +234,8 @@ class ASH_EXPORT Shelf : public ShelfLayoutManagerObserver {
void OnAutoHideStateChanged(ShelfAutoHideState new_state) override;
void OnBackgroundUpdated(ShelfBackgroundType background_type,
AnimationChangeType change_type) override;
void OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) override;
void OnWorkAreaInsetsChanged() override;
private:
......
......@@ -28,6 +28,10 @@ class ASH_EXPORT ShelfObserver {
// Invoked when the positions of Shelf Icons are changed.
virtual void OnShelfIconPositionsChanged() {}
// Invoked when the hotseat state is changed.
virtual void OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) {}
// Invoked when the Shelf has updated its insets in work area insets.
virtual void OnShelfWorkAreaInsetsChanged() {}
......
......@@ -5,8 +5,10 @@
#include "ash/wm/collision_detection/collision_detection_utils.h"
#include "ash/keyboard/ui/keyboard_ui_controller.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/wm/work_area_insets.h"
#include "base/macros.h"
......@@ -87,6 +89,23 @@ std::vector<gfx::Rect> CollectCollisionRects(
rects.push_back(ComputeCollisionRectFromBounds(
shelf_window->GetTargetBounds(), shelf_window->parent()));
// The hotseat doesn't span the whole width of the display, but to allow
// a PIP window to be slided horizontally along the hotseat, we extend the
// width of the hotseat to that of the display.
auto* hotseat_widget = shelf->shelf_widget()->hotseat_widget();
if (hotseat_widget) {
auto* hotseat_window = hotseat_widget->GetNativeWindow();
gfx::Rect hotseat_rect{root_window->bounds().x(),
hotseat_window->GetTargetBounds().y(),
root_window->bounds().width(),
hotseat_window->GetTargetBounds().height()};
if (hotseat_widget->state() != HotseatState::kHidden &&
!ShouldIgnoreWindowForCollision(hotseat_window, priority)) {
rects.push_back(ComputeCollisionRectFromBounds(
hotseat_rect, hotseat_window->parent()));
}
}
// Check the Automatic Clicks windows.
// TODO(Katie): The PIP isn't re-triggered to check the autoclick window
// when the autoclick window moves, just when the PIP moves or another
......
......@@ -460,6 +460,11 @@ void WorkspaceLayoutManager::OnAutoHideStateChanged(
NotifySystemUiAreaChanged();
}
void WorkspaceLayoutManager::OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) {
NotifySystemUiAreaChanged();
}
//////////////////////////////////////////////////////////////////////////////
// WorkspaceLayoutManager, private:
......
......@@ -96,6 +96,8 @@ class ASH_EXPORT WorkspaceLayoutManager : public aura::LayoutManager,
// ShelfObserver:
void OnAutoHideStateChanged(ShelfAutoHideState new_state) override;
void OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) override;
private:
friend class WorkspaceControllerTestApi;
......
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