wayland_extension.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2020 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 UI_PLATFORM_WINDOW_EXTENSIONS_WAYLAND_EXTENSION_H_
  5. #define UI_PLATFORM_WINDOW_EXTENSIONS_WAYLAND_EXTENSION_H_
  6. #include "base/component_export.h"
  7. namespace ui {
  8. class PlatformWindow;
  9. enum class WaylandWindowSnapDirection {
  10. kNone,
  11. kPrimary,
  12. kSecondary,
  13. };
  14. enum class WaylandOrientationLockType {
  15. kAny,
  16. kNatural,
  17. kPortrait,
  18. kLandscape,
  19. kPortraitPrimary,
  20. kLandscapePrimary,
  21. kPortraitSecondary,
  22. kLandscapeSecondary,
  23. };
  24. class COMPONENT_EXPORT(PLATFORM_WINDOW) WaylandExtension {
  25. public:
  26. // Starts a window dragging session for the owning platform window, if
  27. // it is not running yet. Under Wayland, window dragging is backed by a
  28. // platform drag-and-drop session. `allow_system_drag` indicates whether it is
  29. // allowed to use a regular drag-and-drop session if the compositor does not
  30. // support the extended drag protocol needed to implement all window dragging
  31. // features.
  32. virtual void StartWindowDraggingSessionIfNeeded(bool allow_system_drag) = 0;
  33. // Signals the underneath platform that browser is entering (or exiting)
  34. // 'immersive fullscreen mode'.
  35. // Under lacros, it controls for instance interaction with the system shelf
  36. // widget, when browser goes in fullscreen.
  37. virtual void SetImmersiveFullscreenStatus(bool status) = 0;
  38. // Signals the underneath platform to shows a preview for the given window
  39. // snap direction. `allow_haptic_feedback` indicates if it should send haptic
  40. // feedback.
  41. virtual void ShowSnapPreview(WaylandWindowSnapDirection snap,
  42. bool allow_haptic_feedback) = 0;
  43. // Requests the underneath platform to snap the window in the given direction,
  44. // if not WaylandWindowSnapDirection::kNone, otherwise cancels the window
  45. // snapping.
  46. virtual void CommitSnap(WaylandWindowSnapDirection snap) = 0;
  47. // Signals the underneath platform whether the current tab of the browser
  48. // window can go back. The underneath platform might react, for example,
  49. // by minimizing the window upon a system wide back gesture.
  50. virtual void SetCanGoBack(bool value) = 0;
  51. // Requests the underneath platform to set the window to picture-in-picture
  52. // (PIP).
  53. virtual void SetPip() = 0;
  54. // Whether or not the underlying platform supports native pointer locking.
  55. virtual bool SupportsPointerLock() = 0;
  56. virtual void LockPointer(bool enabled) = 0;
  57. // Lock and unlock the window rotation.
  58. virtual void Lock(WaylandOrientationLockType lock_Type) = 0;
  59. virtual void Unlock() = 0;
  60. // Retrieve current layout state.
  61. virtual bool GetTabletMode() = 0;
  62. // Signals the underneath platform to float the browser window on top other
  63. // windows.
  64. virtual void SetFloat(bool value) = 0;
  65. protected:
  66. virtual ~WaylandExtension();
  67. // Sets the pointer to the extension as a property of the PlatformWindow.
  68. void SetWaylandExtension(PlatformWindow* window, WaylandExtension* extension);
  69. };
  70. COMPONENT_EXPORT(PLATFORM_WINDOW)
  71. WaylandExtension* GetWaylandExtension(const PlatformWindow& window);
  72. } // namespace ui
  73. #endif // UI_PLATFORM_WINDOW_EXTENSIONS_WAYLAND_EXTENSION_H_