Commit f5beba8b authored by yoshiki iguchi's avatar yoshiki iguchi Committed by Commit Bot

Set WindowStateType::PIP for Chrome PIP window

This CL adds ash window type (WindowStateType::PIP) to Chrome PIP window
only in Chrome OS.

This window type is used for distinguish PIP windows and manages them in
Chrome OS ash shell.

Bug: b/112060145
Change-Id: I9fb51e50577b8ebe9d690b6c2d83e300951d9846
Reviewed-on: https://chromium-review.googlesource.com/c/1242726
Commit-Queue: Yoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarEliot Courtney <edcourtney@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604494}
parent e6e678e6
...@@ -196,4 +196,5 @@ DEFINE_UI_CLASS_PROPERTY_KEY(mojom::WindowStateType, ...@@ -196,4 +196,5 @@ DEFINE_UI_CLASS_PROPERTY_KEY(mojom::WindowStateType,
kWindowStateTypeKey, kWindowStateTypeKey,
mojom::WindowStateType::DEFAULT); mojom::WindowStateType::DEFAULT);
DEFINE_UI_CLASS_PROPERTY_KEY(bool, kWindowPipTypeKey, false);
} // namespace ash } // namespace ash
...@@ -185,6 +185,10 @@ ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const ...@@ -185,6 +185,10 @@ ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
ASH_PUBLIC_EXPORT extern const aura::WindowProperty< ASH_PUBLIC_EXPORT extern const aura::WindowProperty<
mojom::WindowStateType>* const kWindowStateTypeKey; mojom::WindowStateType>* const kWindowStateTypeKey;
// A property key to indicate pip window state.
ASH_PUBLIC_EXPORT extern const aura::WindowProperty<bool>* const
kWindowPipTypeKey;
// Alphabetical sort. // Alphabetical sort.
} // namespace ash } // namespace ash
......
...@@ -72,6 +72,8 @@ mojom::WindowStateType BaseState::GetStateForTransitionEvent( ...@@ -72,6 +72,8 @@ mojom::WindowStateType BaseState::GetStateForTransitionEvent(
return mojom::WindowStateType::INACTIVE; return mojom::WindowStateType::INACTIVE;
case WM_EVENT_PIN: case WM_EVENT_PIN:
return mojom::WindowStateType::PINNED; return mojom::WindowStateType::PINNED;
case WM_EVENT_PIP:
return mojom::WindowStateType::PIP;
case WM_EVENT_TRUSTED_PIN: case WM_EVENT_TRUSTED_PIN:
return mojom::WindowStateType::TRUSTED_PINNED; return mojom::WindowStateType::TRUSTED_PINNED;
default: default:
......
...@@ -37,6 +37,7 @@ void LockWindowState::OnWMEvent(wm::WindowState* window_state, ...@@ -37,6 +37,7 @@ void LockWindowState::OnWMEvent(wm::WindowState* window_state,
case wm::WM_EVENT_FULLSCREEN: case wm::WM_EVENT_FULLSCREEN:
UpdateWindow(window_state, mojom::WindowStateType::FULLSCREEN); UpdateWindow(window_state, mojom::WindowStateType::FULLSCREEN);
break; break;
case wm::WM_EVENT_PIP:
case wm::WM_EVENT_PIN: case wm::WM_EVENT_PIN:
case wm::WM_EVENT_TRUSTED_PIN: case wm::WM_EVENT_TRUSTED_PIN:
NOTREACHED(); NOTREACHED();
......
...@@ -223,6 +223,12 @@ void TabletModeWindowState::OnWMEvent(wm::WindowState* window_state, ...@@ -223,6 +223,12 @@ void TabletModeWindowState::OnWMEvent(wm::WindowState* window_state,
UpdateWindow(window_state, mojom::WindowStateType::PINNED, UpdateWindow(window_state, mojom::WindowStateType::PINNED,
true /* animated */); true /* animated */);
break; break;
case wm::WM_EVENT_PIP:
if (!window_state->IsPip()) {
UpdateWindow(window_state, mojom::WindowStateType::PIP,
true /* animated */);
}
break;
case wm::WM_EVENT_TRUSTED_PIN: case wm::WM_EVENT_TRUSTED_PIN:
if (!Shell::Get()->screen_pinning_controller()->IsPinned()) if (!Shell::Get()->screen_pinning_controller()->IsPinned())
UpdateWindow(window_state, mojom::WindowStateType::TRUSTED_PINNED, UpdateWindow(window_state, mojom::WindowStateType::TRUSTED_PINNED,
......
...@@ -747,6 +747,16 @@ void WindowState::OnWindowPropertyChanged(aura::Window* window, ...@@ -747,6 +747,16 @@ void WindowState::OnWindowPropertyChanged(aura::Window* window,
} }
return; return;
} }
if (key == kWindowPipTypeKey) {
if (window->GetProperty(kWindowPipTypeKey)) {
WMEvent event(WM_EVENT_PIP);
OnWMEvent(&event);
} else {
// Currently "restore" is not implemented.
NOTIMPLEMENTED();
}
return;
}
if (key == kWindowStateTypeKey) { if (key == kWindowStateTypeKey) {
if (!ignore_property_change_) { if (!ignore_property_change_) {
// This change came from somewhere else. Revert it. // This change came from somewhere else. Revert it.
......
...@@ -76,6 +76,7 @@ bool WMEvent::IsTransitionEvent() const { ...@@ -76,6 +76,7 @@ bool WMEvent::IsTransitionEvent() const {
case WM_EVENT_SHOW_INACTIVE: case WM_EVENT_SHOW_INACTIVE:
case WM_EVENT_PIN: case WM_EVENT_PIN:
case WM_EVENT_TRUSTED_PIN: case WM_EVENT_TRUSTED_PIN:
case WM_EVENT_PIP:
return true; return true;
default: default:
break; break;
......
...@@ -91,6 +91,9 @@ enum WMEventType { ...@@ -91,6 +91,9 @@ enum WMEventType {
// A user requested to pin a window. // A user requested to pin a window.
WM_EVENT_PIN, WM_EVENT_PIN,
// A user requested to pip a window.
WM_EVENT_PIP,
// A user requested to pin a window for a trusted application. This is similar // A user requested to pin a window for a trusted application. This is similar
// WM_EVENT_PIN but does not allow user to exit the mode by shortcut key. // WM_EVENT_PIN but does not allow user to exit the mode by shortcut key.
WM_EVENT_TRUSTED_PIN, WM_EVENT_TRUSTED_PIN,
......
...@@ -33,6 +33,11 @@ ...@@ -33,6 +33,11 @@
#include "ui/views/window/non_client_view.h" #include "ui/views/window/non_client_view.h"
#include "ui/views/window/window_resize_utils.h" #include "ui/views/window/window_resize_utils.h"
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/window_properties.h" // nogncheck
#include "ui/aura/window.h"
#endif
// static // static
std::unique_ptr<content::OverlayWindow> content::OverlayWindow::Create( std::unique_ptr<content::OverlayWindow> content::OverlayWindow::Create(
content::PictureInPictureWindowController* controller) { content::PictureInPictureWindowController* controller) {
...@@ -183,6 +188,7 @@ OverlayWindowViews::OverlayWindowViews( ...@@ -183,6 +188,7 @@ OverlayWindowViews::OverlayWindowViews(
params.keep_on_top = true; params.keep_on_top = true;
params.visible_on_all_workspaces = true; params.visible_on_all_workspaces = true;
params.remove_standard_frame = true; params.remove_standard_frame = true;
params.name = "PictureInPictureWindow";
// Set WidgetDelegate for more control over |widget_|. // Set WidgetDelegate for more control over |widget_|.
params.delegate = new OverlayWindowWidgetDelegate(this); params.delegate = new OverlayWindowWidgetDelegate(this);
...@@ -190,6 +196,10 @@ OverlayWindowViews::OverlayWindowViews( ...@@ -190,6 +196,10 @@ OverlayWindowViews::OverlayWindowViews(
Init(params); Init(params);
SetUpViews(); SetUpViews();
#if defined(OS_CHROMEOS)
GetNativeWindow()->SetProperty(ash::kWindowPipTypeKey, true);
#endif // defined(OS_CHROMEOS)
is_initialized_ = true; is_initialized_ = true;
} }
......
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