| 1 | /* |
| 2 | Simple DirectMedia Layer |
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> |
| 4 | |
| 5 | This software is provided 'as-is', without any express or implied |
| 6 | warranty. In no event will the authors be held liable for any damages |
| 7 | arising from the use of this software. |
| 8 | |
| 9 | Permission is granted to anyone to use this software for any purpose, |
| 10 | including commercial applications, and to alter it and redistribute it |
| 11 | freely, subject to the following restrictions: |
| 12 | |
| 13 | 1. The origin of this software must not be misrepresented; you must not |
| 14 | claim that you wrote the original software. If you use this software |
| 15 | in a product, an acknowledgment in the product documentation would be |
| 16 | appreciated but is not required. |
| 17 | 2. Altered source versions must be plainly marked as such, and must not be |
| 18 | misrepresented as being the original software. |
| 19 | 3. This notice may not be removed or altered from any source distribution. |
| 20 | */ |
| 21 | |
| 22 | #include "SDL_internal.h" |
| 23 | |
| 24 | #ifndef SDL_waylandvideo_h_ |
| 25 | #define SDL_waylandvideo_h_ |
| 26 | |
| 27 | #include <EGL/egl.h> |
| 28 | #include "wayland-util.h" |
| 29 | |
| 30 | #include "../SDL_sysvideo.h" |
| 31 | #include "../../core/linux/SDL_dbus.h" |
| 32 | #include "../../core/linux/SDL_ime.h" |
| 33 | |
| 34 | struct xkb_context; |
| 35 | struct SDL_WaylandInput; |
| 36 | |
| 37 | typedef struct |
| 38 | { |
| 39 | struct wl_cursor_theme *theme; |
| 40 | int size; |
| 41 | } SDL_WaylandCursorTheme; |
| 42 | |
| 43 | typedef struct |
| 44 | { |
| 45 | struct wl_list link; |
| 46 | char wl_output_name[]; |
| 47 | } SDL_WaylandConnectorName; |
| 48 | |
| 49 | struct SDL_VideoData |
| 50 | { |
| 51 | bool initializing; |
| 52 | struct wl_display *display; |
| 53 | int display_disconnected; |
| 54 | struct wl_registry *registry; |
| 55 | struct wl_compositor *compositor; |
| 56 | struct wl_shm *shm; |
| 57 | SDL_WaylandCursorTheme *cursor_themes; |
| 58 | int num_cursor_themes; |
| 59 | struct wl_pointer *pointer; |
| 60 | struct |
| 61 | { |
| 62 | struct xdg_wm_base *xdg; |
| 63 | #ifdef HAVE_LIBDECOR_H |
| 64 | struct libdecor *libdecor; |
| 65 | #endif |
| 66 | } shell; |
| 67 | struct zwp_relative_pointer_manager_v1 *relative_pointer_manager; |
| 68 | struct zwp_pointer_constraints_v1 *pointer_constraints; |
| 69 | struct wp_cursor_shape_manager_v1 *cursor_shape_manager; |
| 70 | struct wl_data_device_manager *data_device_manager; |
| 71 | struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager; |
| 72 | struct zxdg_decoration_manager_v1 *decoration_manager; |
| 73 | struct zwp_keyboard_shortcuts_inhibit_manager_v1 *key_inhibitor_manager; |
| 74 | struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; |
| 75 | struct xdg_activation_v1 *activation_manager; |
| 76 | struct zwp_text_input_manager_v3 *text_input_manager; |
| 77 | struct zxdg_output_manager_v1 *xdg_output_manager; |
| 78 | struct wp_viewporter *viewporter; |
| 79 | struct wp_fractional_scale_manager_v1 *fractional_scale_manager; |
| 80 | struct zwp_input_timestamps_manager_v1 *input_timestamps_manager; |
| 81 | struct zxdg_exporter_v2 *zxdg_exporter_v2; |
| 82 | struct xdg_wm_dialog_v1 *xdg_wm_dialog_v1; |
| 83 | struct wp_alpha_modifier_v1 *wp_alpha_modifier_v1; |
| 84 | struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1; |
| 85 | struct frog_color_management_factory_v1 *frog_color_management_factory_v1; |
| 86 | struct wp_color_manager_v1 *wp_color_manager_v1; |
| 87 | struct zwp_tablet_manager_v2 *tablet_manager; |
| 88 | |
| 89 | struct xkb_context *xkb_context; |
| 90 | struct SDL_WaylandInput *input; |
| 91 | SDL_DisplayData **output_list; |
| 92 | int output_count; |
| 93 | int output_max; |
| 94 | |
| 95 | int relative_mouse_mode; |
| 96 | bool display_externally_owned; |
| 97 | |
| 98 | bool scale_to_display_enabled; |
| 99 | }; |
| 100 | |
| 101 | struct SDL_DisplayData |
| 102 | { |
| 103 | SDL_VideoData *videodata; |
| 104 | struct wl_output *output; |
| 105 | struct zxdg_output_v1 *xdg_output; |
| 106 | struct wp_color_management_output_v1 *wp_color_management_output; |
| 107 | char *wl_output_name; |
| 108 | double scale_factor; |
| 109 | uint32_t registry_id; |
| 110 | int logical_width, logical_height; |
| 111 | int pixel_width, pixel_height; |
| 112 | int x, y, refresh, transform; |
| 113 | SDL_DisplayOrientation orientation; |
| 114 | int physical_width_mm, physical_height_mm; |
| 115 | bool has_logical_position, has_logical_size; |
| 116 | bool running_colorspace_event_queue; |
| 117 | SDL_HDROutputProperties HDR; |
| 118 | SDL_DisplayID display; |
| 119 | SDL_VideoDisplay placeholder; |
| 120 | int wl_output_done_count; |
| 121 | struct Wayland_ColorInfoState *color_info_state; |
| 122 | }; |
| 123 | |
| 124 | // Needed here to get wl_surface declaration, fixes GitHub#4594 |
| 125 | #include "SDL_waylanddyn.h" |
| 126 | |
| 127 | extern void SDL_WAYLAND_register_surface(struct wl_surface *surface); |
| 128 | extern void SDL_WAYLAND_register_output(struct wl_output *output); |
| 129 | extern bool SDL_WAYLAND_own_surface(struct wl_surface *surface); |
| 130 | extern bool SDL_WAYLAND_own_output(struct wl_output *output); |
| 131 | |
| 132 | extern SDL_WindowData *Wayland_GetWindowDataForOwnedSurface(struct wl_surface *surface); |
| 133 | void Wayland_AddWindowDataToExternalList(SDL_WindowData *data); |
| 134 | void Wayland_RemoveWindowDataFromExternalList(SDL_WindowData *data); |
| 135 | |
| 136 | extern bool Wayland_LoadLibdecor(SDL_VideoData *data, bool ignore_xdg); |
| 137 | |
| 138 | extern bool Wayland_VideoReconnect(SDL_VideoDevice *_this); |
| 139 | |
| 140 | #endif // SDL_waylandvideo_h_ |
| 141 | |