Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Toshiki Kikuchi | 87e9510 | 2020-07-09 03:32:58 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "components/exo/toast_surface.h" |
| 6 | |
| 7 | #include "ash/public/cpp/shell_window_ids.h" |
| 8 | #include "components/exo/toast_surface_manager.h" |
| 9 | #include "components/exo/wm_helper.h" |
| 10 | #include "ui/base/class_property.h" |
| 11 | #include "ui/gfx/geometry/dip_util.h" |
| 12 | #include "ui/gfx/geometry/rect.h" |
| 13 | #include "ui/views/accessibility/view_accessibility.h" |
| 14 | |
| 15 | namespace exo { |
| 16 | |
| 17 | ToastSurface::ToastSurface(ToastSurfaceManager* manager, |
| 18 | Surface* surface, |
Prabir Pradhan | 875083e | 2020-07-22 20:06:27 | [diff] [blame] | 19 | bool default_scale_cancellation) |
Toshiki Kikuchi | 87e9510 | 2020-07-09 03:32:58 | [diff] [blame] | 20 | : ClientControlledShellSurface(surface, |
| 21 | false /* can_minimize */, |
Prabir Pradhan | 875083e | 2020-07-22 20:06:27 | [diff] [blame] | 22 | ash::kShellWindowId_OverlayContainer, |
Toshiki Kikuchi | bfd314bb | 2023-04-20 03:52:14 | [diff] [blame] | 23 | default_scale_cancellation, |
| 24 | /*supports_floated_state=*/false), |
Toshiki Kikuchi | 87e9510 | 2020-07-09 03:32:58 | [diff] [blame] | 25 | manager_(manager) { |
Toshiki Kikuchi | 87e9510 | 2020-07-09 03:32:58 | [diff] [blame] | 26 | SetActivatable(false); |
| 27 | DisableMovement(); |
| 28 | host_window()->SetName("ExoToastSurface"); |
| 29 | } |
| 30 | |
| 31 | ToastSurface::~ToastSurface() { |
| 32 | if (added_to_manager_) |
| 33 | manager_->RemoveSurface(this); |
| 34 | } |
| 35 | |
| 36 | void ToastSurface::OnSurfaceCommit() { |
| 37 | ClientControlledShellSurface::OnSurfaceCommit(); |
| 38 | |
| 39 | if (!added_to_manager_) { |
| 40 | added_to_manager_ = true; |
| 41 | manager_->AddSurface(this); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | } // namespace exo |