linux_ui_delegate.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_LINUX_LINUX_UI_DELEGATE_H_
  5. #define UI_LINUX_LINUX_UI_DELEGATE_H_
  6. #include <cstdint>
  7. #include <string>
  8. #include "base/callback_forward.h"
  9. #include "base/component_export.h"
  10. namespace gfx {
  11. using AcceleratedWidget = uint32_t;
  12. }
  13. namespace ui {
  14. enum class LinuxUiBackend {
  15. kStub,
  16. kX11,
  17. kWayland,
  18. };
  19. class COMPONENT_EXPORT(LINUX_UI) LinuxUiDelegate {
  20. public:
  21. static LinuxUiDelegate* GetInstance();
  22. LinuxUiDelegate();
  23. virtual ~LinuxUiDelegate();
  24. virtual LinuxUiBackend GetBackend() const = 0;
  25. // Only implemented on Wayland.
  26. virtual bool ExportWindowHandle(
  27. uint32_t parent_widget,
  28. base::OnceCallback<void(const std::string&)> callback);
  29. // Only implemented on X11.
  30. virtual void SetTransientWindowForParent(gfx::AcceleratedWidget parent,
  31. gfx::AcceleratedWidget transient);
  32. // Exports a prefixed, platform-dependent (X11 or Wayland) window handle for
  33. // an Aura window id, then calls the given callback with the handle. Returns
  34. // true on success. |callback| may be run synchronously or asynchronously.
  35. virtual bool ExportWindowHandle(
  36. gfx::AcceleratedWidget window_id,
  37. base::OnceCallback<void(std::string)> callback) = 0;
  38. private:
  39. static LinuxUiDelegate* instance_;
  40. };
  41. } // namespace ui
  42. #endif // UI_LINUX_LINUX_UI_DELEGATE_H_