sub_surface.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_EXO_SUB_SURFACE_H_
  5. #define COMPONENTS_EXO_SUB_SURFACE_H_
  6. #include <memory>
  7. #include "base/observer_list.h"
  8. #include "components/exo/surface_delegate.h"
  9. #include "components/exo/surface_observer.h"
  10. #include "ui/base/class_property.h"
  11. #include "ui/gfx/geometry/point.h"
  12. #include "ui/gfx/geometry/point_f.h"
  13. #include "ui/gfx/geometry/size_f.h"
  14. namespace base {
  15. namespace trace_event {
  16. class TracedValue;
  17. }
  18. } // namespace base
  19. namespace exo {
  20. class Surface;
  21. class SubSurfaceObserver;
  22. // This class provides functions for treating a surface as a sub-surface. A
  23. // sub-surface has one parent surface.
  24. class SubSurface : public SurfaceDelegate,
  25. public SurfaceObserver,
  26. public ui::PropertyHandler {
  27. public:
  28. SubSurface(Surface* surface, Surface* parent);
  29. SubSurface(const SubSurface&) = delete;
  30. SubSurface& operator=(const SubSurface&) = delete;
  31. ~SubSurface() override;
  32. // This schedules a sub-surface position change. The sub-surface will be
  33. // moved so, that its origin (top-left corner pixel) will be at the |position|
  34. // of the parent surface coordinate system.
  35. void SetPosition(const gfx::PointF& position);
  36. // This removes sub-surface from the stack, and puts it back just above the
  37. // reference surface, changing the z-order of the sub-surfaces. The reference
  38. // surface must be one of the sibling surfaces, or the parent surface.
  39. void PlaceAbove(Surface* reference);
  40. // This removes sub-surface from the stack, and puts it back just below the
  41. // sibling surface.
  42. void PlaceBelow(Surface* sibiling);
  43. // Change the commit behaviour of the sub-surface.
  44. void SetCommitBehavior(bool synchronized);
  45. // Returns a trace value representing the state of the surface.
  46. std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
  47. // Overridden from SurfaceDelegate:
  48. void OnSurfaceCommit() override;
  49. bool IsSurfaceSynchronized() const override;
  50. bool IsInputEnabled(Surface* surface) const override;
  51. void OnSetFrame(SurfaceFrameType type) override {}
  52. void OnSetFrameColors(SkColor active_color, SkColor inactive_color) override {
  53. }
  54. void OnSetParent(Surface* parent, const gfx::Point& position) override;
  55. void OnSetStartupId(const char* startup_id) override {}
  56. void OnSetApplicationId(const char* application_id) override {}
  57. void SetUseImmersiveForFullscreen(bool value) override {}
  58. void OnActivationRequested() override {}
  59. void OnNewOutputAdded() override {}
  60. void OnSetServerStartResize() override {}
  61. void ShowSnapPreviewToPrimary() override {}
  62. void ShowSnapPreviewToSecondary() override {}
  63. void HideSnapPreview() override {}
  64. void SetSnappedToPrimary() override {}
  65. void SetSnappedToSecondary() override {}
  66. void UnsetSnap() override {}
  67. void SetCanGoBack() override {}
  68. void UnsetCanGoBack() override {}
  69. void SetPip() override {}
  70. void UnsetPip() override {}
  71. void SetAspectRatio(const gfx::SizeF& aspect_ratio) override {}
  72. void MoveToDesk(int desk_index) override {}
  73. void SetVisibleOnAllWorkspaces() override {}
  74. void SetInitialWorkspace(const char* initial_workspace) override {}
  75. void Pin(bool trusted) override {}
  76. void Unpin() override {}
  77. void SetSystemModal(bool system_modal) override {}
  78. SecurityDelegate* GetSecurityDelegate() override;
  79. // Overridden from SurfaceObserver:
  80. void OnSurfaceDestroying(Surface* surface) override;
  81. // SubSurface Observers
  82. void AddSubSurfaceObserver(SubSurfaceObserver* observer);
  83. void RemoveSubSurfaceObserver(SubSurfaceObserver* observer);
  84. private:
  85. Surface* surface_;
  86. Surface* parent_;
  87. bool is_synchronized_ = true;
  88. // Surface observer list. Surface does not own the observers.
  89. base::ObserverList<SubSurfaceObserver> observers_;
  90. };
  91. } // namespace exo
  92. #endif // COMPONENTS_EXO_SUB_SURFACE_H_