desk_extension.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2021 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_DESK_EXTENSION_H_
  5. #define UI_PLATFORM_WINDOW_EXTENSIONS_DESK_EXTENSION_H_
  6. #include <string>
  7. #include "base/component_export.h"
  8. namespace ui {
  9. class PlatformWindow;
  10. // A desk extension that platforms can use to add support for virtual desktop.
  11. // The APIs currently match with what ash provides from desks_controller to
  12. // support "Move window to desk" menu in LaCrOS.
  13. // TODO(crbug.com/1214795): Support virtual desktop protocol for linux/wayland
  14. // as well.
  15. class COMPONENT_EXPORT(PLATFORM_WINDOW) DeskExtension {
  16. public:
  17. // Returns the current number of desks.
  18. virtual int GetNumberOfDesks() const = 0;
  19. // Returns the active desk index for window.
  20. virtual int GetActiveDeskIndex() const = 0;
  21. // Returns the name of the desk at |index|.
  22. virtual std::u16string GetDeskName(int index) const = 0;
  23. // Requests the underneath platform to send the window to a desk at |index|.
  24. // |index| must be valid.
  25. virtual void SendToDeskAtIndex(int index) = 0;
  26. protected:
  27. virtual ~DeskExtension();
  28. // Sets the pointer to the extension as a property of the PlatformWindow.
  29. void SetDeskExtension(PlatformWindow* window, DeskExtension* extension);
  30. };
  31. COMPONENT_EXPORT(PLATFORM_WINDOW)
  32. DeskExtension* GetDeskExtension(const PlatformWindow& window);
  33. } // namespace ui
  34. #endif // UI_PLATFORM_WINDOW_EXTENSIONS_DESK_EXTENSION_H_