exo: Add toast shell for ARC++ toasts
This CL introduces a new shell type for ARC++ toasts in remote-shell.
Since the purpose of toasts is a notification for users and the toast
appears and disappears quickly without any user interaction, so toasts
are supposed to be shown over Chrome OS's virtual keyboard.
ARC++ side CL: ag/11272597
design overview: go/vk-overlays-toasts
BUG=b:109717200
TEST=ToastSurfaceTest
Change-Id: I3cec22a031a7046ff63770ff308b6d0695c313e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2167792
Commit-Queue: Toshiki Kikuchi <[email protected]>
Reviewed-by: Mitsuru Oshima <[email protected]>
Reviewed-by: Yuichiro Hanada <[email protected]>
Cr-Commit-Position: refs/heads/master@{#786617}
diff --git a/components/exo/toast_surface.cc b/components/exo/toast_surface.cc
new file mode 100644
index 0000000..d474c4f
--- /dev/null
+++ b/components/exo/toast_surface.cc
@@ -0,0 +1,44 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/exo/toast_surface.h"
+
+#include "ash/public/cpp/shell_window_ids.h"
+#include "components/exo/toast_surface_manager.h"
+#include "components/exo/wm_helper.h"
+#include "ui/base/class_property.h"
+#include "ui/gfx/geometry/dip_util.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/views/accessibility/view_accessibility.h"
+
+namespace exo {
+
+ToastSurface::ToastSurface(ToastSurfaceManager* manager,
+ Surface* surface,
+ double default_device_scale_factor)
+ : ClientControlledShellSurface(surface,
+ false /* can_minimize */,
+ ash::kShellWindowId_OverlayContainer),
+ manager_(manager) {
+ SetScale(default_device_scale_factor);
+ SetActivatable(false);
+ DisableMovement();
+ host_window()->SetName("ExoToastSurface");
+}
+
+ToastSurface::~ToastSurface() {
+ if (added_to_manager_)
+ manager_->RemoveSurface(this);
+}
+
+void ToastSurface::OnSurfaceCommit() {
+ ClientControlledShellSurface::OnSurfaceCommit();
+
+ if (!added_to_manager_) {
+ added_to_manager_ = true;
+ manager_->AddSurface(this);
+ }
+}
+
+} // namespace exo