xdg_shell.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2018 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_WAYLAND_XDG_SHELL_H_
  5. #define COMPONENTS_EXO_WAYLAND_XDG_SHELL_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. struct wl_client;
  9. struct wl_resource;
  10. namespace exo {
  11. class Display;
  12. class ShellSurfaceBase;
  13. class ShellSurface;
  14. class XdgShellSurface;
  15. namespace wayland {
  16. class SerialTracker;
  17. struct WaylandXdgShell {
  18. WaylandXdgShell(Display* display, SerialTracker* serial_tracker)
  19. : display(display), serial_tracker(serial_tracker) {}
  20. WaylandXdgShell(const WaylandXdgShell&) = delete;
  21. WaylandXdgShell& operator=(const WaylandXdgShell&) = delete;
  22. // Owned by WaylandServerController, which always outlives xdg_shell.
  23. Display* const display;
  24. // Owned by Server, which always outlives xdg_shell.
  25. SerialTracker* const serial_tracker;
  26. };
  27. struct WaylandXdgSurface {
  28. WaylandXdgSurface(std::unique_ptr<XdgShellSurface> shell_surface,
  29. SerialTracker* const serial_tracker);
  30. ~WaylandXdgSurface();
  31. WaylandXdgSurface(const WaylandXdgSurface&) = delete;
  32. WaylandXdgSurface& operator=(const WaylandXdgSurface&) = delete;
  33. std::unique_ptr<XdgShellSurface> shell_surface;
  34. // Owned by Server, which always outlives this surface.
  35. SerialTracker* const serial_tracker;
  36. };
  37. void bind_xdg_shell(wl_client* client,
  38. void* data,
  39. uint32_t version,
  40. uint32_t id);
  41. struct ShellSurfaceData {
  42. ShellSurfaceData(ShellSurface* shell_surface,
  43. SerialTracker* serial_tracker,
  44. wl_resource* surface_resource)
  45. : shell_surface(shell_surface),
  46. serial_tracker(serial_tracker),
  47. surface_resource(surface_resource) {}
  48. ShellSurfaceData(const ShellSurfaceData&) = delete;
  49. ShellSurfaceData& operator=(const ShellSurfaceData&) = delete;
  50. ShellSurface* const shell_surface;
  51. // Owned by Server, which always outlives xdg_shell.
  52. SerialTracker* const serial_tracker;
  53. wl_resource* const surface_resource;
  54. };
  55. ShellSurfaceData GetShellSurfaceFromToplevelResource(
  56. wl_resource* surface_resource);
  57. ShellSurfaceBase* GetShellSurfaceFromPopupResource(
  58. wl_resource* surface_resource);
  59. } // namespace wayland
  60. } // namespace exo
  61. #endif // COMPONENTS_EXO_WAYLAND_XDG_SHELL_H_