surface_delegate.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_SURFACE_DELEGATE_H_
  5. #define COMPONENTS_EXO_SURFACE_DELEGATE_H_
  6. #include "third_party/skia/include/core/SkColor.h"
  7. #include "ui/gfx/geometry/point.h"
  8. #include "ui/gfx/geometry/size_f.h"
  9. namespace exo {
  10. class SecurityDelegate;
  11. class Surface;
  12. // Frame types that can be used to decorate a surface.
  13. enum class SurfaceFrameType { NONE, NORMAL, SHADOW, AUTOHIDE, OVERLAY };
  14. // Handles events on surfaces in context-specific ways.
  15. class SurfaceDelegate {
  16. public:
  17. // Called when surface was requested to commit all double-buffered state.
  18. virtual void OnSurfaceCommit() = 0;
  19. // Returns true if surface is in synchronized mode. ie. commit of
  20. // double-buffered state should be synchronized with parent surface.
  21. virtual bool IsSurfaceSynchronized() const = 0;
  22. // Returns true if surface should receive input events.
  23. virtual bool IsInputEnabled(Surface* surface) const = 0;
  24. // Called when surface was requested to use a specific frame type.
  25. virtual void OnSetFrame(SurfaceFrameType type) = 0;
  26. // Called when surface was requested to use a specific set of frame colors.
  27. virtual void OnSetFrameColors(SkColor active_color,
  28. SkColor inactive_color) = 0;
  29. // Called when a new "parent" was requested for this surface. |position|
  30. // is the initial position of surface relative to origin of parent.
  31. virtual void OnSetParent(Surface* parent, const gfx::Point& position) = 0;
  32. // Called when surface was requested to set a specific startup ID label.
  33. virtual void OnSetStartupId(const char* startup_id) = 0;
  34. // Called when surface was requested to set a specific application ID label.
  35. virtual void OnSetApplicationId(const char* application_id) = 0;
  36. // Whether to show/hide the shelf when fullscreen. If true, the titlebar/shelf
  37. // will show when the mouse moves to the top/bottom of the screen. If false
  38. // (plain fullscreen), the titlebar and shelf are always hidden.
  39. virtual void SetUseImmersiveForFullscreen(bool value) = 0;
  40. // Called when the surface's application wants it to be activated.
  41. virtual void OnActivationRequested() = 0;
  42. // Called when the new outoupt resource is created.
  43. virtual void OnNewOutputAdded() = 0;
  44. // Called when surface was requested to start resize.
  45. virtual void OnSetServerStartResize() = 0;
  46. // Called to show the snap preview to the primary or secondary position, or
  47. // to hide it.
  48. virtual void ShowSnapPreviewToPrimary() = 0;
  49. virtual void ShowSnapPreviewToSecondary() = 0;
  50. virtual void HideSnapPreview() = 0;
  51. // Called when the client was snapped to primary or secondary position, and
  52. // reset.
  53. virtual void SetSnappedToPrimary() = 0;
  54. virtual void SetSnappedToSecondary() = 0;
  55. virtual void UnsetSnap() = 0;
  56. // Whether the current client window can go back, as per its navigation list.
  57. virtual void SetCanGoBack() = 0;
  58. virtual void UnsetCanGoBack() = 0;
  59. // Called when surface was requested to enter pip.
  60. virtual void SetPip() = 0;
  61. virtual void UnsetPip() = 0;
  62. // Called when surface was requested to maintain an aspect ratio.
  63. virtual void SetAspectRatio(const gfx::SizeF& aspect_ratio) = 0;
  64. // Called when surface was requested to move the window to a desk at
  65. // |desk_index|.
  66. virtual void MoveToDesk(int desk_index) = 0;
  67. // Called when surface was requested to be visible on all workspaces.
  68. virtual void SetVisibleOnAllWorkspaces() = 0;
  69. // Called to set the initial workspace to restore a window to the
  70. // corresponding desk.
  71. virtual void SetInitialWorkspace(const char* initial_workspace) = 0;
  72. // Pins/locks a window to the screen so that the user cannot do anything
  73. // else before the mode is released. If trusted is set, it is an invocation
  74. // from a trusted app like a school test mode app.
  75. virtual void Pin(bool trusted) = 0;
  76. // Releases the pinned mode and allows the user to do other things again.
  77. virtual void Unpin() = 0;
  78. // Sets the system modality.
  79. virtual void SetSystemModal(bool modal) = 0;
  80. // Returns the SecurityDelegate which this surface should use to perform
  81. // security-sensitive operations. See go/secure-exo-ids for more information.
  82. virtual SecurityDelegate* GetSecurityDelegate() = 0;
  83. protected:
  84. virtual ~SurfaceDelegate() {}
  85. };
  86. } // namespace exo
  87. #endif // COMPONENTS_EXO_SURFACE_DELEGATE_H_