22 #include "../../SDL_internal.h" 24 #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL 26 #include "../SDL_sysvideo.h" 27 #include "../../events/SDL_windowevents_c.h" 28 #include "../SDL_egl_c.h" 36 #include "xdg-shell-client-protocol.h" 37 #include "xdg-shell-unstable-v6-client-protocol.h" 45 handle_ping_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
48 wl_shell_surface_pong(shell_surface, serial);
52 handle_configure_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
57 struct wl_region *region;
62 if (width == 0 || height == 0) {
68 if (window->
max_w > 0) {
73 if (window->
max_h > 0) {
82 WAYLAND_wl_egl_window_resize(wind->
egl_window, width, height, 0, 0);
84 wl_region_add(region, 0, 0, width, height);
85 wl_surface_set_opaque_region(wind->
surface, region);
86 wl_region_destroy(region);
94 handle_popup_done_wl_shell_surface(
void *data,
struct wl_shell_surface *shell_surface)
98 static const struct wl_shell_surface_listener shell_surface_listener_wl = {
99 handle_ping_wl_shell_surface,
100 handle_configure_wl_shell_surface,
101 handle_popup_done_wl_shell_surface
108 handle_configure_zxdg_shell_surface(
void *data,
struct zxdg_surface_v6 *zxdg,
uint32_t serial)
112 struct wl_region *region;
116 WAYLAND_wl_egl_window_resize(wind->
egl_window, window->
w, window->
h, 0, 0);
119 wl_region_add(region, 0, 0, window->
w, window->
h);
120 wl_surface_set_opaque_region(wind->
surface, region);
121 wl_region_destroy(region);
122 zxdg_surface_v6_ack_configure(zxdg, serial);
125 static const struct zxdg_surface_v6_listener shell_surface_listener_zxdg = {
126 handle_configure_zxdg_shell_surface
131 handle_configure_zxdg_toplevel(
void *data,
132 struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
135 struct wl_array *states)
143 if (width == 0 || height == 0) {
149 if (window->
max_w > 0) {
154 if (window->
max_h > 0) {
169 handle_close_zxdg_toplevel(
void *data,
struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
175 static const struct zxdg_toplevel_v6_listener toplevel_listener_zxdg = {
176 handle_configure_zxdg_toplevel,
177 handle_close_zxdg_toplevel
183 handle_configure_xdg_shell_surface(
void *data,
struct xdg_surface *xdg,
uint32_t serial)
187 struct wl_region *region;
191 WAYLAND_wl_egl_window_resize(wind->
egl_window, window->
w, window->
h, 0, 0);
194 wl_region_add(region, 0, 0, window->
w, window->
h);
195 wl_surface_set_opaque_region(wind->
surface, region);
196 wl_region_destroy(region);
197 xdg_surface_ack_configure(xdg, serial);
200 static const struct xdg_surface_listener shell_surface_listener_xdg = {
201 handle_configure_xdg_shell_surface
206 handle_configure_xdg_toplevel(
void *data,
207 struct xdg_toplevel *xdg_toplevel,
210 struct wl_array *states)
218 if (width == 0 || height == 0) {
224 if (window->
max_w > 0) {
229 if (window->
max_h > 0) {
238 if (width == window->
w && height == window->
h) {
248 handle_close_xdg_toplevel(
void *data,
struct xdg_toplevel *xdg_toplevel)
254 static const struct xdg_toplevel_listener toplevel_listener_xdg = {
255 handle_configure_xdg_toplevel,
256 handle_close_xdg_toplevel
262 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 264 handle_onscreen_visibility(
void *data,
265 struct qt_extended_surface *qt_extended_surface,
int32_t visible)
270 handle_set_generic_property(
void *data,
271 struct qt_extended_surface *qt_extended_surface,
const char *
name,
272 struct wl_array *
value)
277 handle_close(
void *data,
struct qt_extended_surface *qt_extended_surface)
283 static const struct qt_extended_surface_listener extended_surface_listener = {
284 handle_onscreen_visibility,
285 handle_set_generic_property,
308 if (version < 2000006) {
349 WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
365 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 367 QtExtendedSurface_OnHintChanged(
void *userdata,
const char *
name,
368 const char *oldValue,
const char *newValue)
370 struct qt_extended_surface *qt_extended_surface = userdata;
377 int32_t orientation = QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION;
379 if (newValue !=
NULL) {
380 if (strcmp(newValue,
"portrait") == 0) {
381 orientation = QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION;
382 }
else if (strcmp(newValue,
"landscape") == 0) {
383 orientation = QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION;
384 }
else if (strcmp(newValue,
"inverted-portrait") == 0) {
385 orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION;
386 }
else if (strcmp(newValue,
"inverted-landscape") == 0) {
387 orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION;
391 qt_extended_surface_set_content_orientation(qt_extended_surface, orientation);
395 if (newValue !=
NULL) {
396 char *tmp = strdup(newValue);
397 char *saveptr =
NULL;
399 char *flag = strtok_r(tmp,
" ", &saveptr);
401 if (strcmp(flag,
"OverridesSystemGestures") == 0) {
402 flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES;
403 }
else if (strcmp(flag,
"StaysOnTop") == 0) {
404 flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP;
405 }
else if (strcmp(flag,
"BypassWindowManager") == 0) {
410 flag = strtok_r(
NULL,
" ", &saveptr);
416 qt_extended_surface_set_window_flags(qt_extended_surface, flags);
420 static void QtExtendedSurface_Subscribe(
struct qt_extended_surface *
surface,
const char *name)
425 static void QtExtendedSurface_Unsubscribe(
struct qt_extended_surface *
surface,
const char *name)
435 struct wl_output *output = (
struct wl_output *) _display->
driverdata;
436 SetFullscreen(
_this, window, fullscreen ? output :
NULL);
468 WAYLAND_wl_display_flush( viddata->
display );
475 struct wl_region *region;
477 data = calloc(1,
sizeof *data);
501 wl_surface_set_user_data(data->
surface, data);
520 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 521 if (c->surface_extension) {
522 data->extended_surface = qt_surface_extension_get_extended_surface(
523 c->surface_extension, data->
surface);
531 window->
w, window->
h);
537 return SDL_SetError(
"failed to create a window surface");
553 wl_shell_surface_add_listener(data->
shell_surface.
wl, &shell_surface_listener_wl, data);
557 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 558 if (data->extended_surface) {
559 qt_extended_surface_set_user_data(data->extended_surface, data);
560 qt_extended_surface_add_listener(data->extended_surface,
561 &extended_surface_listener, data);
565 region = wl_compositor_create_region(c->
compositor);
566 wl_region_add(region, 0, 0, window->
w, window->
h);
567 wl_surface_set_opaque_region(data->
surface, region);
568 wl_region_destroy(region);
574 wl_surface_commit(data->
surface);
575 WAYLAND_wl_display_flush(c->
display);
582 WAYLAND_wl_display_flush(c->
display);
583 WAYLAND_wl_display_dispatch(c->
display);
589 WAYLAND_wl_display_flush(c->
display);
590 WAYLAND_wl_display_dispatch(c->
display);
602 struct wl_region *region;
604 WAYLAND_wl_egl_window_resize(wind->
egl_window, window->
w, window->
h, 0, 0);
606 region =wl_compositor_create_region(data->
compositor);
607 wl_region_add(region, 0, 0, window->
w, window->
h);
608 wl_surface_set_opaque_region(wind->
surface, region);
609 wl_region_destroy(region);
637 WAYLAND_wl_egl_window_destroy(wind->
egl_window);
659 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 660 if (wind->extended_surface) {
663 qt_extended_surface_destroy(wind->extended_surface);
666 wl_surface_destroy(wind->
surface);
669 WAYLAND_wl_display_flush(data->
display);
#define SDL_HINT_QTWAYLAND_WINDOW_FLAGS
Flags to set on QtWayland windows to integrate with the native window manager.
void Wayland_SetWindowSize(_THIS, SDL_Window *window)
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION
A variable describing the content orientation on QtWayland-based platforms.
struct zxdg_toplevel_v6 * toplevel
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
SDL_DisplayMode fullscreen_mode
struct zxdg_surface_v6 * surface
struct wl_shell_surface * wl
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
struct wl_display * display
void Wayland_MaximizeWindow(_THIS, SDL_Window *window)
SDL_bool initial_configure_seen
SDL_bool initial_configure_seen
void Wayland_ShowWindow(_THIS, SDL_Window *window)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
union SDL_zxdg_shell_surface::@36 roleobj
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
#define SDL_WINDOWPOS_UNDEFINED
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
#define SDL_GL_LoadLibrary
struct SDL_WaylandInput * input
int Wayland_CreateWindow(_THIS, SDL_Window *window)
GLuint const GLchar * name
GLint GLint GLsizei width
struct SDL_VideoData::@35 shell
static SDL_VideoDevice * _this
SDL_xdg_shell_surface xdg
void Wayland_SetWindowTitle(_THIS, SDL_Window *window)
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
struct xdg_toplevel * toplevel
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
SDL_VideoData * waylandData
GLsizei const GLfloat * value
GLenum GLenum GLsizei const GLuint GLboolean enabled
union SDL_WindowData::@38 shell_surface
#define SDL_OutOfMemory()
struct wl_compositor * compositor
GLint GLint GLsizei GLsizei height
void Wayland_RestoreWindow(_THIS, SDL_Window *window)
SDL_zxdg_shell_surface zxdg
EGLSurface EGLNativeWindowType * window
The type used to identify a window.
struct xdg_surface * surface
#define SDL_AddHintCallback
#define SDL_DelHintCallback
union SDL_SysWMinfo::@18 info
struct zxdg_shell_v6 * zxdg
struct SDL_SysWMinfo::@18::@20 wl
union SDL_xdg_shell_surface::@37 roleobj
struct wl_egl_window * egl_window