Go to the documentation of this file.
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"
51 handle_ping_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
58 handle_configure_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface,
97 handle_popup_done_wl_shell_surface(
void *
data,
struct wl_shell_surface *shell_surface)
102 handle_ping_wl_shell_surface,
103 handle_configure_wl_shell_surface,
104 handle_popup_done_wl_shell_surface
111 handle_configure_zxdg_shell_surface(
void *
data,
struct zxdg_surface_v6 *zxdg,
uint32_t serial)
115 struct wl_region *region;
148 handle_configure_zxdg_shell_surface
153 handle_configure_zxdg_toplevel(
void *
data,
154 struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
157 struct wl_array *states)
164 wl_array_for_each(
state, states) {
207 handle_close_zxdg_toplevel(
void *
data,
struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
214 handle_configure_zxdg_toplevel,
215 handle_close_zxdg_toplevel
221 handle_configure_xdg_shell_surface(
void *
data,
struct xdg_surface *xdg,
uint32_t serial)
225 struct wl_region *region;
258 handle_configure_xdg_shell_surface
263 handle_configure_xdg_toplevel(
void *
data,
264 struct xdg_toplevel *xdg_toplevel,
267 struct wl_array *states)
274 wl_array_for_each(
state, states) {
317 handle_close_xdg_toplevel(
void *
data,
struct xdg_toplevel *xdg_toplevel)
324 handle_configure_xdg_toplevel,
325 handle_close_xdg_toplevel
331 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
333 handle_onscreen_visibility(
void *
data,
334 struct qt_extended_surface *qt_extended_surface,
int32_t visible)
339 handle_set_generic_property(
void *
data,
340 struct qt_extended_surface *qt_extended_surface,
const char *
name,
341 struct wl_array *
value)
346 handle_close(
void *
data,
struct qt_extended_surface *qt_extended_surface)
352 static const struct qt_extended_surface_listener extended_surface_listener = {
353 handle_onscreen_visibility,
354 handle_set_generic_property,
361 float old_factor =
window->scale_factor, new_factor = 0.0;
368 if (!
window->num_outputs) {
369 new_factor = old_factor;
376 for (
i = 0;
i <
window->num_outputs;
i++) {
378 if (factor > new_factor) {
383 if (new_factor != old_factor) {
387 window->resize.scale_factor = new_factor;
396 handle_surface_enter(
void *
data,
struct wl_surface *
surface,
397 struct wl_output *
output) {
402 update_scale_factor(
window);
406 handle_surface_leave(
void *
data,
struct wl_surface *
surface,
407 struct wl_output *
output) {
411 if (
window->num_outputs > 1) {
412 struct wl_output **new_outputs =
SDL_malloc((
window->num_outputs - 1) *
sizeof *
window->outputs), **iter = new_outputs;
413 for (
i=0;
i <
window->num_outputs;
i++) {
420 window->outputs = new_outputs;
428 update_scale_factor(
window);
432 handle_surface_enter,
454 if (version < 2000006) {
460 info->
info.
wl.display =
data->waylandData->display;
462 info->
info.
wl.shell_surface =
data->shell_surface.wl;
507 struct wl_output *
output = (
struct wl_output *)
window->fullscreen_mode.driverdata;
511 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
513 QtExtendedSurface_OnHintChanged(
void *userdata,
const char *
name,
514 const char *oldValue,
const char *newValue)
516 struct qt_extended_surface *qt_extended_surface = userdata;
523 int32_t orientation = QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION;
525 if (newValue !=
NULL) {
526 if (strcmp(newValue,
"portrait") == 0) {
527 orientation = QT_EXTENDED_SURFACE_ORIENTATION_PORTRAITORIENTATION;
528 }
else if (strcmp(newValue,
"landscape") == 0) {
529 orientation = QT_EXTENDED_SURFACE_ORIENTATION_LANDSCAPEORIENTATION;
530 }
else if (strcmp(newValue,
"inverted-portrait") == 0) {
531 orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDPORTRAITORIENTATION;
532 }
else if (strcmp(newValue,
"inverted-landscape") == 0) {
533 orientation = QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION;
537 qt_extended_surface_set_content_orientation(qt_extended_surface, orientation);
541 if (newValue !=
NULL) {
542 char *tmp =
strdup(newValue);
543 char *saveptr =
NULL;
545 char *flag = strtok_r(tmp,
" ", &saveptr);
547 if (strcmp(flag,
"OverridesSystemGestures") == 0) {
548 flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES;
549 }
else if (strcmp(flag,
"StaysOnTop") == 0) {
550 flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_STAYSONTOP;
551 }
else if (strcmp(flag,
"BypassWindowManager") == 0) {
556 flag = strtok_r(
NULL,
" ", &saveptr);
562 qt_extended_surface_set_window_flags(qt_extended_surface,
flags);
566 static void QtExtendedSurface_Subscribe(
struct qt_extended_surface *
surface,
const char *
name)
571 static void QtExtendedSurface_Unsubscribe(
struct qt_extended_surface *
surface,
const char *
name)
628 WAYLAND_wl_display_flush( viddata->
display );
635 struct wl_region *region;
658 data->waylandData =
c;
661 data->scale_factor = 1.0;
676 data->resize.scale_factor =
data->scale_factor;
679 data->num_outputs = 0;
691 }
else if (
c->shell.zxdg) {
702 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
703 if (
c->surface_extension) {
704 data->extended_surface = qt_surface_extension_get_extended_surface(
705 c->surface_extension,
data->surface);
713 data->egl_window = WAYLAND_wl_egl_window_create(
data->surface,
720 return SDL_SetError(
"failed to create an EGL window surface");
725 if (
data->shell_surface.xdg.surface) {
729 }
else if (
c->shell.zxdg) {
730 if (
data->shell_surface.zxdg.surface) {
735 if (
data->shell_surface.wl) {
741 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
742 if (
data->extended_surface) {
743 qt_extended_surface_set_user_data(
data->extended_surface,
data);
744 qt_extended_surface_add_listener(
data->extended_surface,
745 &extended_surface_listener,
data);
749 if (
c->decoration_manager &&
c->shell.xdg &&
data->shell_surface.xdg.surface) {
751 if (
data->server_decoration) {
756 }
else if (
c->kwin_server_decoration_manager) {
758 if (
data->kwin_server_decoration) {
770 if (
c->relative_mouse_mode) {
775 WAYLAND_wl_display_flush(
c->display);
780 if (
data->shell_surface.xdg.surface) {
781 while (!
data->shell_surface.xdg.initial_configure_seen) {
782 WAYLAND_wl_display_flush(
c->display);
783 WAYLAND_wl_display_dispatch(
c->display);
786 }
else if (
c->shell.zxdg) {
787 if (
data->shell_surface.zxdg.surface) {
788 while (!
data->shell_surface.zxdg.initial_configure_seen) {
789 WAYLAND_wl_display_flush(
c->display);
790 WAYLAND_wl_display_dispatch(
c->display);
804 if (
data->resize.pending) {
805 struct wl_region *region;
806 if (
data->scale_factor !=
data->resize.scale_factor) {
813 data->scale_factor =
data->resize.scale_factor;
815 if (
data->egl_window) {
816 WAYLAND_wl_egl_window_resize(
data->egl_window,
window->w *
data->scale_factor,
window->h *
data->scale_factor, 0, 0);
819 if (
data->resize.configure) {
820 if (
data->waylandData->shell.xdg) {
822 }
else if (
data->waylandData->shell.zxdg) {
841 struct wl_region *region;
883 WAYLAND_wl_egl_window_destroy(wind->
egl_window);
894 if (
data->shell.xdg) {
901 }
else if (
data->shell.zxdg) {
914 #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
924 WAYLAND_wl_display_flush(
data->display);
static void zxdg_toplevel_v6_unset_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
struct zxdg_toplevel_v6 * toplevel
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION
A variable describing the content orientation on QtWayland-based platforms.
static struct wl_surface * wl_compositor_create_surface(struct wl_compositor *wl_compositor)
static struct wl_shell_surface * wl_shell_get_shell_surface(struct wl_shell *wl_shell, struct wl_surface *surface)
@ ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE
@ SDL_WINDOW_ALLOW_HIGHDPI
#define SDL_HINT_QTWAYLAND_WINDOW_FLAGS
Flags to set on QtWayland windows to integrate with the native window manager.
GLenum GLenum GLenum GLenum GLenum scale
struct zxdg_shell_v6 * zxdg
static void * wl_output_get_user_data(struct wl_output *wl_output)
static void wl_surface_commit(struct wl_surface *wl_surface)
static void zxdg_toplevel_decoration_v1_set_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
static void wl_surface_set_opaque_region(struct wl_surface *wl_surface, struct wl_region *region)
GLint GLint GLsizei width
@ ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER
static void wl_shell_surface_pong(struct wl_shell_surface *wl_shell_surface, uint32_t serial)
static void zxdg_toplevel_v6_destroy(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
static int wl_shell_surface_add_listener(struct wl_shell_surface *wl_shell_surface, const struct wl_shell_surface_listener *listener, void *data)
@ ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE
static struct zxdg_toplevel_v6 * zxdg_surface_v6_get_toplevel(struct zxdg_surface_v6 *zxdg_surface_v6)
void Wayland_MaximizeWindow(_THIS, SDL_Window *window)
@ SDL_WINDOWEVENT_RESIZED
struct xdg_surface * surface
static void wl_region_add(struct wl_region *wl_region, int32_t x, int32_t y, int32_t width, int32_t height)
#define SDL_WINDOWPOS_UNDEFINED
static struct zxdg_toplevel_decoration_v1 * zxdg_decoration_manager_v1_get_toplevel_decoration(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, struct xdg_toplevel *toplevel)
static void xdg_toplevel_set_fullscreen(struct xdg_toplevel *xdg_toplevel, struct wl_output *output)
#define SDL_GL_LoadLibrary
struct zxdg_decoration_manager_v1 * decoration_manager
struct zxdg_surface_v6 * surface
static void xdg_toplevel_set_app_id(struct xdg_toplevel *xdg_toplevel, const char *app_id)
static void zxdg_toplevel_v6_set_maximized(struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
struct wl_shell_surface * wl
void Wayland_HandlePendingResize(SDL_Window *window)
static void xdg_surface_destroy(struct xdg_surface *xdg_surface)
static void xdg_toplevel_unset_fullscreen(struct xdg_toplevel *xdg_toplevel)
struct wl_compositor * compositor
static void zxdg_surface_v6_ack_configure(struct zxdg_surface_v6 *zxdg_surface_v6, uint32_t serial)
org_kde_kwin_server_decoration_manager_mode
@ ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE
static int xdg_toplevel_add_listener(struct xdg_toplevel *xdg_toplevel, const struct xdg_toplevel_listener *listener, void *data)
SDL_VideoData * waylandData
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
The type used to identify a window.
static int xdg_surface_add_listener(struct xdg_surface *xdg_surface, const struct xdg_surface_listener *listener, void *data)
static void xdg_toplevel_set_title(struct xdg_toplevel *xdg_toplevel, const char *title)
static int zxdg_toplevel_v6_add_listener(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const struct zxdg_toplevel_v6_listener *listener, void *data)
static void wl_region_destroy(struct wl_region *wl_region)
static void wl_shell_surface_set_class(struct wl_shell_surface *wl_shell_surface, const char *class_)
static struct wl_region * wl_compositor_create_region(struct wl_compositor *wl_compositor)
void Wayland_ShowWindow(_THIS, SDL_Window *window)
static void xdg_toplevel_destroy(struct xdg_toplevel *xdg_toplevel)
static void wl_shell_surface_destroy(struct wl_shell_surface *wl_shell_surface)
void Wayland_SetWindowTitle(_THIS, SDL_Window *window)
static SDL_VideoDevice * _this
static struct xdg_surface * xdg_wm_base_get_xdg_surface(struct xdg_wm_base *xdg_wm_base, struct wl_surface *surface)
static void wl_shell_surface_set_title(struct wl_shell_surface *wl_shell_surface, const char *title)
EGLSurface EGLNativeWindowType * window
static void xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
GLint GLint GLsizei GLsizei height
static int wl_surface_add_listener(struct wl_surface *wl_surface, const struct wl_surface_listener *listener, void *data)
GLuint const GLchar * name
SDL_VideoDisplay * displays
void Wayland_RestoreWindow(_THIS, SDL_Window *window)
SDL_bool initial_configure_seen
struct SDL_VideoData::@257 shell
static void zxdg_toplevel_v6_set_title(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *title)
static struct xdg_toplevel * xdg_surface_get_toplevel(struct xdg_surface *xdg_surface)
struct qt_extended_surface * extended_surface
@ WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT
SDL_xdg_shell_surface xdg
@ ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN
SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
static void xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
static struct org_kde_kwin_server_decoration * org_kde_kwin_server_decoration_manager_create(struct org_kde_kwin_server_decoration_manager *org_kde_kwin_server_decoration_manager, struct wl_surface *surface)
void Wayland_DestroyWindow(_THIS, SDL_Window *window)
static int zxdg_surface_v6_add_listener(struct zxdg_surface_v6 *zxdg_surface_v6, const struct zxdg_surface_v6_listener *listener, void *data)
void Wayland_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
static void wl_shell_surface_set_maximized(struct wl_shell_surface *wl_shell_surface, struct wl_output *output)
struct wl_egl_window * egl_window
#define SDL_OutOfMemory()
struct org_kde_kwin_server_decoration_manager * kwin_server_decoration_manager
static void zxdg_surface_v6_set_user_data(struct zxdg_surface_v6 *zxdg_surface_v6, void *user_data)
static void org_kde_kwin_server_decoration_release(struct org_kde_kwin_server_decoration *org_kde_kwin_server_decoration)
SDL_bool initial_configure_seen
static void wl_surface_set_buffer_scale(struct wl_surface *wl_surface, int32_t scale)
#define FULLSCREEN_VISIBLE(W)
struct wl_display * display
static void wl_shell_surface_set_fullscreen(struct wl_shell_surface *wl_shell_surface, uint32_t method, uint32_t framerate, struct wl_output *output)
#define SDL_AddHintCallback
GLsizei const GLfloat * value
static void zxdg_toplevel_decoration_v1_destroy(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
void Wayland_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen)
SDL_zxdg_shell_surface zxdg
struct SDL_WindowData::@261 resize
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
union SDL_xdg_shell_surface::@259 roleobj
struct xdg_toplevel * toplevel
int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
union SDL_SysWMinfo::@10 info
union SDL_WindowData::@260 shell_surface
GLenum GLenum GLsizei const GLuint GLboolean enabled
union SDL_zxdg_shell_surface::@258 roleobj
static struct zxdg_surface_v6 * zxdg_shell_v6_get_xdg_surface(struct zxdg_shell_v6 *zxdg_shell_v6, struct wl_surface *surface)
static void zxdg_toplevel_v6_set_app_id(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, const char *app_id)
@ XDG_TOPLEVEL_STATE_FULLSCREEN
SDL_VideoDevice * SDL_GetVideoDevice(void)
#define SDL_DelHintCallback
static void wl_surface_destroy(struct wl_surface *wl_surface)
static void xdg_toplevel_set_maximized(struct xdg_toplevel *xdg_toplevel)
static void wl_shell_surface_set_user_data(struct wl_shell_surface *wl_shell_surface, void *user_data)
static void wl_shell_surface_set_toplevel(struct wl_shell_surface *wl_shell_surface)
zxdg_toplevel_decoration_v1_mode
static void zxdg_surface_v6_destroy(struct zxdg_surface_v6 *zxdg_surface_v6)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
static void zxdg_toplevel_v6_set_fullscreen(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_output *output)
struct org_kde_kwin_server_decoration * kwin_server_decoration
static void org_kde_kwin_server_decoration_request_mode(struct org_kde_kwin_server_decoration *org_kde_kwin_server_decoration, uint32_t mode)
struct SDL_SysWMinfo::@10::@12 wl
int Wayland_CreateWindow(_THIS, SDL_Window *window)
void Wayland_SetWindowSize(_THIS, SDL_Window *window)
struct zxdg_toplevel_decoration_v1 * server_decoration