VTK  9.7.1
vtkWaylandHardwareWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
16 #ifndef vtkWaylandHardwareWindow_h
17 #define vtkWaylandHardwareWindow_h
18 
19 #include "vtkHardwareWindow.h"
20 #include "vtkRenderingUIModule.h" // For export macro
21 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
22 
23 // Forward declarations for Wayland types to keep the header clean.
24 // The actual headers will be included in the .cxx file.
25 struct wl_array;
26 struct wl_callback;
27 struct wl_display;
28 struct wl_compositor;
29 struct wl_surface;
30 struct wl_registry;
31 struct wl_seat;
32 struct wl_pointer;
33 struct wl_shm;
34 struct xdg_wm_base;
35 struct xdg_surface;
36 struct xdg_toplevel;
37 struct zxdg_decoration_manager_v1;
38 
39 VTK_ABI_NAMESPACE_BEGIN
40 
41 class VTKRENDERINGUI_EXPORT VTK_MARSHALAUTO vtkWaylandHardwareWindow : public vtkHardwareWindow
42 {
43 public:
44  static vtkWaylandHardwareWindow* New();
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
51  wl_display* GetDisplayId();
52 
56  wl_surface* GetWindowId();
57 
58  // vtkHardwareWindow overrides
59  void Create() override;
60  void Destroy() override;
61 
62  void* GetGenericDisplayId() override;
63  void* GetGenericWindowId() override;
64 
66 
71  void SetSize(int, int) override;
74 
76 
80  void SetPosition(int, int) override;
83 
87  void SetWindowName(const char*) override;
88 
94  void HideCursor() override;
95  void ShowCursor() override;
96 
101  void SetCurrentCursor(int) override;
102 
103  // Listener callbacks for Wayland events
104  static void RegistryHandleGlobal(
105  void* data, wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
106  static void RegistryHandleGlobalRemove(void* data, wl_registry* registry, uint32_t name);
107 
108  static void XdgWmBaseHandlePing(void* data, xdg_wm_base* xdg_wm_base, uint32_t serial);
109 
110  static void XdgSurfaceHandleConfigure(void* data, xdg_surface* xdg_surface, uint32_t serial);
111 
112  static void XdgToplevelHandleConfigure(
113  void* data, xdg_toplevel* xdg_toplevel, int32_t width, int32_t height, wl_array* states);
114  static void XdgToplevelHandleClose(void* data, xdg_toplevel* xdg_toplevel);
115 
116  static void FrameHandleDone(void* data, wl_callback* callback, uint32_t time);
117 
118  // Request a redraw for the next frame.
119  void ScheduleRedraw();
120 
121 protected:
123  ~vtkWaylandHardwareWindow() override;
124 
125  // Wayland-specific members
126  wl_display* DisplayId = nullptr;
127  wl_registry* Registry = nullptr;
128  wl_compositor* Compositor = nullptr;
129  wl_surface* Surface = nullptr;
130  wl_shm* Shm = nullptr;
131  wl_seat* Seat = nullptr;
132  wl_pointer* Pointer = nullptr;
133  xdg_wm_base* XdgWmBase = nullptr;
134  xdg_surface* XdgSurface = nullptr;
135  xdg_toplevel* XdgToplevel = nullptr;
136  zxdg_decoration_manager_v1* DecorationManager = nullptr;
137 
138  bool OwnDisplay = false;
139  bool CursorHidden = false;
140 
141  wl_callback* FrameCallback = nullptr;
142  bool RedrawPending = false;
143 
144 private:
146  void operator=(const vtkWaylandHardwareWindow&) = delete;
147 
148  // Internal state to track window configuration
149  bool IsConfigured = false;
150 };
151 
152 VTK_ABI_NAMESPACE_END
153 #endif // vtkWaylandHardwareWindow_h
create a window for renderers to draw into
virtual void HideCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
Definition: vtkWindow.h:295
static vtkHardwareWindow * New()
virtual void Create()
virtual void SetPosition(int x, int y)
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
represents a window in a Wayland GUI
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void Destroy()
virtual void * GetGenericWindowId()
These are window system independent methods that are used to help interface vtkWindow to native windo...
Definition: vtkWindow.h:56
virtual void SetWindowName(const char *)
Get name of rendering window.
virtual void * GetGenericDisplayId()
These are window system independent methods that are used to help interface vtkWindow to native windo...
Definition: vtkWindow.h:55
virtual void ShowCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
Definition: vtkWindow.h:296
#define VTK_MARSHALAUTO
virtual void SetCurrentCursor(int)
Change the shape of the cursor.