wayland: Add support for xdg-shell protocol (unstable v6).
This is meant to be the desktop-enhanced version of wl_shell. Right now we just match what the existing wl_shell code does, but there are other areas of functionality available to us now, that we can fill in later. This uses the "unstable" API, since this is what ships in Ubuntu 17.10 (as part of Wayland 1.10), but Wayland 1.12 promotes this to stable with extremely minor changes. We will add support for the stable version when it makes sense to do so.
parent
32d421d490
commit
cd53220749
|
@ -685,7 +685,7 @@ macro(CheckWayland)
|
|||
|
||||
WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_CORE_PROTOCOL_DIR}/wayland.xml" "wayland")
|
||||
|
||||
foreach(_PROTL relative-pointer-unstable-v1 pointer-constraints-unstable-v1)
|
||||
foreach(_PROTL relative-pointer-unstable-v1 pointer-constraints-unstable-v1, xdg-shell-unstable-v6)
|
||||
string(REGEX REPLACE "\\-unstable\\-.*$" "" PROTSUBDIR ${_PROTL})
|
||||
WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_PROTOCOLS_DIR}/unstable/${PROTSUBDIR}/${_PROTL}.xml" "${_PROTL}")
|
||||
endforeach()
|
||||
|
|
|
@ -19220,7 +19220,7 @@ $as_echo "#define SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1" >>confdefs.h
|
|||
|
||||
fi
|
||||
|
||||
WAYLAND_PROTOCOLS_UNSTABLE="relative-pointer-unstable-v1 pointer-constraints-unstable-v1"
|
||||
WAYLAND_PROTOCOLS_UNSTABLE="relative-pointer-unstable-v1 pointer-constraints-unstable-v1 xdg-shell-unstable-v6"
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
|
||||
|
|
|
@ -1409,7 +1409,7 @@ AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for
|
|||
AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
|
||||
fi
|
||||
|
||||
WAYLAND_PROTOCOLS_UNSTABLE="relative-pointer-unstable-v1 pointer-constraints-unstable-v1"
|
||||
WAYLAND_PROTOCOLS_UNSTABLE="relative-pointer-unstable-v1 pointer-constraints-unstable-v1 xdg-shell-unstable-v6"
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "pointer-constraints-unstable-v1-client-protocol.h"
|
||||
#include "relative-pointer-unstable-v1-client-protocol.h"
|
||||
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <sys/select.h>
|
||||
|
@ -248,15 +249,25 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
|
|||
if (window->hit_test) {
|
||||
const SDL_Point point = { wl_fixed_to_int(input->sx_w), wl_fixed_to_int(input->sy_w) };
|
||||
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
|
||||
static const uint32_t directions[] = {
|
||||
|
||||
static const uint32_t directions_wl[] = {
|
||||
WL_SHELL_SURFACE_RESIZE_TOP_LEFT, WL_SHELL_SURFACE_RESIZE_TOP,
|
||||
WL_SHELL_SURFACE_RESIZE_TOP_RIGHT, WL_SHELL_SURFACE_RESIZE_RIGHT,
|
||||
WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT, WL_SHELL_SURFACE_RESIZE_BOTTOM,
|
||||
WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT, WL_SHELL_SURFACE_RESIZE_LEFT
|
||||
};
|
||||
|
||||
/* the names are different (ZXDG_TOPLEVEL_V6_RESIZE_EDGE_* vs
|
||||
WL_SHELL_SURFACE_RESIZE_*), but the values are the same. */
|
||||
const uint32_t *directions_zxdg = directions_wl;
|
||||
|
||||
switch (rc) {
|
||||
case SDL_HITTEST_DRAGGABLE:
|
||||
wl_shell_surface_move(window_data->shell_surface, input->seat, serial);
|
||||
if (input->display->shell.zxdg) {
|
||||
zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial);
|
||||
} else {
|
||||
wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial);
|
||||
}
|
||||
return SDL_TRUE;
|
||||
|
||||
case SDL_HITTEST_RESIZE_TOPLEFT:
|
||||
|
@ -267,7 +278,11 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
|
|||
case SDL_HITTEST_RESIZE_BOTTOM:
|
||||
case SDL_HITTEST_RESIZE_BOTTOMLEFT:
|
||||
case SDL_HITTEST_RESIZE_LEFT:
|
||||
wl_shell_surface_resize(window_data->shell_surface, input->seat, serial, directions[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
|
||||
if (input->display->shell.zxdg) {
|
||||
zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
|
||||
} else {
|
||||
wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
|
||||
}
|
||||
return SDL_TRUE;
|
||||
|
||||
default: return SDL_FALSE;
|
||||
|
@ -950,6 +965,7 @@ SDL_WaylandDataDevice* Wayland_get_data_device(struct SDL_WaylandInput *input)
|
|||
return input->data_device;
|
||||
}
|
||||
|
||||
/* !!! FIXME: just merge these into display_handle_global(). */
|
||||
void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
|
||||
{
|
||||
d->relative_pointer_manager =
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#include "SDL_waylanddyn.h"
|
||||
#include <wayland-util.h>
|
||||
|
||||
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||
|
||||
#define WAYLANDVID_DRIVER_NAME "wayland"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
|
@ -64,6 +66,12 @@ Wayland_VideoQuit(_THIS);
|
|||
static char *
|
||||
get_classname()
|
||||
{
|
||||
/* !!! FIXME: this is probably wrong, albeit harmless in many common cases. From protocol spec:
|
||||
"The surface class identifies the general class of applications
|
||||
to which the surface belongs. A common convention is to use the
|
||||
file name (or the full path if it is a non-standard location) of
|
||||
the application's .desktop file as the class." */
|
||||
|
||||
char *spot;
|
||||
#if defined(__LINUX__) || defined(__FREEBSD__)
|
||||
char procfile[1024];
|
||||
|
@ -307,6 +315,18 @@ static const struct qt_windowmanager_listener windowmanager_listener = {
|
|||
};
|
||||
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
|
||||
|
||||
|
||||
static void
|
||||
handle_ping_zxdg_shell(void *data, struct zxdg_shell_v6 *zxdg, uint32_t serial)
|
||||
{
|
||||
zxdg_shell_v6_pong(zxdg, serial);
|
||||
}
|
||||
|
||||
static const struct zxdg_shell_v6_listener shell_listener_zxdg = {
|
||||
handle_ping_zxdg_shell
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
||||
const char *interface, uint32_t version)
|
||||
|
@ -319,8 +339,11 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
|||
Wayland_add_display(d, id);
|
||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||
Wayland_display_add_input(d, id);
|
||||
} else if (strcmp(interface, "zxdg_shell_v6") == 0) {
|
||||
d->shell.zxdg = wl_registry_bind(d->registry, id, &zxdg_shell_v6_interface, 1);
|
||||
zxdg_shell_v6_add_listener(d->shell.zxdg, &shell_listener_zxdg, NULL);
|
||||
} else if (strcmp(interface, "wl_shell") == 0) {
|
||||
d->shell = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
|
||||
d->shell.wl = wl_registry_bind(d->registry, id, &wl_shell_interface, 1);
|
||||
} else if (strcmp(interface, "wl_shm") == 0) {
|
||||
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
||||
d->cursor_theme = WAYLAND_wl_cursor_theme_load(NULL, 32, d->shm);
|
||||
|
@ -330,6 +353,7 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
|||
Wayland_display_add_pointer_constraints(d, id);
|
||||
} else if (strcmp(interface, "wl_data_device_manager") == 0) {
|
||||
d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, 3);
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
} else if (strcmp(interface, "qt_touch_extension") == 0) {
|
||||
Wayland_touch_create(d, id);
|
||||
|
@ -448,8 +472,11 @@ Wayland_VideoQuit(_THIS)
|
|||
if (data->cursor_theme)
|
||||
WAYLAND_wl_cursor_theme_destroy(data->cursor_theme);
|
||||
|
||||
if (data->shell)
|
||||
wl_shell_destroy(data->shell);
|
||||
if (data->shell.wl)
|
||||
wl_shell_destroy(data->shell.wl);
|
||||
|
||||
if (data->shell.zxdg)
|
||||
zxdg_shell_v6_destroy(data->shell.zxdg);
|
||||
|
||||
if (data->compositor)
|
||||
wl_compositor_destroy(data->compositor);
|
||||
|
|
|
@ -43,7 +43,11 @@ typedef struct {
|
|||
struct wl_shm *shm;
|
||||
struct wl_cursor_theme *cursor_theme;
|
||||
struct wl_pointer *pointer;
|
||||
struct wl_shell *shell;
|
||||
struct {
|
||||
/* !!! FIXME: add stable xdg_shell from 1.12 */
|
||||
struct zxdg_shell_v6 *zxdg;
|
||||
struct wl_shell *wl;
|
||||
} shell;
|
||||
struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
|
||||
struct zwp_pointer_constraints_v1 *pointer_constraints;
|
||||
struct wl_data_device_manager *data_device_manager;
|
||||
|
|
|
@ -33,15 +33,22 @@
|
|||
#include "SDL_waylanddyn.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||
|
||||
/* On modern desktops, we probably will use the xdg-shell protocol instead
|
||||
of wl_shell, but wl_shell might be useful on older Wayland installs that
|
||||
don't have the newer protocol, or embedded things that don't have a full
|
||||
window manager. */
|
||||
|
||||
static void
|
||||
handle_ping(void *data, struct wl_shell_surface *shell_surface,
|
||||
handle_ping_wl_shell_surface(void *data, struct wl_shell_surface *shell_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
wl_shell_surface_pong(shell_surface, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
||||
handle_configure_wl_shell_surface(void *data, struct wl_shell_surface *shell_surface,
|
||||
uint32_t edges, int32_t width, int32_t height)
|
||||
{
|
||||
SDL_WindowData *wind = (SDL_WindowData *)data;
|
||||
|
@ -87,16 +94,94 @@ handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
|||
}
|
||||
|
||||
static void
|
||||
handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
|
||||
handle_popup_done_wl_shell_surface(void *data, struct wl_shell_surface *shell_surface)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct wl_shell_surface_listener shell_surface_listener = {
|
||||
handle_ping,
|
||||
handle_configure,
|
||||
handle_popup_done
|
||||
static const struct wl_shell_surface_listener shell_surface_listener_wl = {
|
||||
handle_ping_wl_shell_surface,
|
||||
handle_configure_wl_shell_surface,
|
||||
handle_popup_done_wl_shell_surface
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
handle_configure_zxdg_shell_surface(void *data, struct zxdg_surface_v6 *zxdg, uint32_t serial)
|
||||
{
|
||||
SDL_WindowData *wind = (SDL_WindowData *)data;
|
||||
SDL_Window *window = wind->sdlwindow;
|
||||
struct wl_region *region;
|
||||
WAYLAND_wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
|
||||
|
||||
region = wl_compositor_create_region(wind->waylandData->compositor);
|
||||
wl_region_add(region, 0, 0, window->w, window->h);
|
||||
wl_surface_set_opaque_region(wind->surface, region);
|
||||
wl_region_destroy(region);
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, window->w, window->h);
|
||||
zxdg_surface_v6_ack_configure(zxdg, serial);
|
||||
}
|
||||
|
||||
static const struct zxdg_surface_v6_listener shell_surface_listener_zxdg = {
|
||||
handle_configure_zxdg_shell_surface
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
handle_configure_zxdg_toplevel(void *data,
|
||||
struct zxdg_toplevel_v6 *zxdg_toplevel_v6,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
struct wl_array *states)
|
||||
{
|
||||
SDL_WindowData *wind = (SDL_WindowData *)data;
|
||||
SDL_Window *window = wind->sdlwindow;
|
||||
|
||||
/* wl_shell_surface spec states that this is a suggestion.
|
||||
Ignore if less than or greater than max/min size. */
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
if ((window->flags & SDL_WINDOW_RESIZABLE)) {
|
||||
if (window->max_w > 0) {
|
||||
width = SDL_min(width, window->max_w);
|
||||
}
|
||||
width = SDL_max(width, window->min_w);
|
||||
|
||||
if (window->max_h > 0) {
|
||||
height = SDL_min(height, window->max_h);
|
||||
}
|
||||
height = SDL_max(height, window->min_h);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (width == window->w && height == window->h) {
|
||||
return;
|
||||
}
|
||||
|
||||
window->w = width;
|
||||
window->h = height;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_close_zxdg_toplevel(void *data, struct zxdg_toplevel_v6 *zxdg_toplevel_v6)
|
||||
{
|
||||
SDL_WindowData *window = (SDL_WindowData *)data;
|
||||
SDL_SendWindowEvent(window->sdlwindow, SDL_WINDOWEVENT_CLOSE, 0, 0);
|
||||
}
|
||||
|
||||
static const struct zxdg_toplevel_v6_listener toplevel_listener_zxdg = {
|
||||
handle_configure_zxdg_toplevel,
|
||||
handle_close_zxdg_toplevel
|
||||
};
|
||||
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
static void
|
||||
handle_onscreen_visibility(void *data,
|
||||
|
@ -151,7 +236,7 @@ Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
|||
|
||||
info->info.wl.display = data->waylandData->display;
|
||||
info->info.wl.surface = data->surface;
|
||||
info->info.wl.shell_surface = data->shell_surface;
|
||||
info->info.wl.shell_surface = data->shell_surface.wl;
|
||||
info->subsystem = SDL_SYSWM_WAYLAND;
|
||||
|
||||
return SDL_TRUE;
|
||||
|
@ -163,20 +248,37 @@ Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
|
|||
return 0; /* just succeed, the real work is done elsewhere. */
|
||||
}
|
||||
|
||||
void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||
static void
|
||||
SetFullscreen(_THIS, SDL_Window * window, struct wl_output *output)
|
||||
{
|
||||
const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata;
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
wl_shell_surface_set_fullscreen(wind->shell_surface,
|
||||
if (viddata->shell.zxdg) {
|
||||
if (output) {
|
||||
zxdg_toplevel_v6_set_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel, output);
|
||||
} else {
|
||||
zxdg_toplevel_v6_unset_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel);
|
||||
}
|
||||
} else {
|
||||
if (output) {
|
||||
wl_shell_surface_set_fullscreen(wind->shell_surface.wl,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
0, (struct wl_output *)window->fullscreen_mode.driverdata);
|
||||
else
|
||||
wl_shell_surface_set_toplevel(wind->shell_surface);
|
||||
0, output);
|
||||
} else {
|
||||
wl_shell_surface_set_toplevel(wind->shell_surface.wl);
|
||||
}
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
|
||||
}
|
||||
|
||||
void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||
{
|
||||
struct wl_output *output = (struct wl_output *) window->fullscreen_mode.driverdata;
|
||||
SetFullscreen(_this, window, (window->flags & SDL_WINDOW_FULLSCREEN) ? output : NULL);
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
static void SDLCALL
|
||||
QtExtendedSurface_OnHintChanged(void *userdata, const char *name,
|
||||
|
@ -247,24 +349,20 @@ void
|
|||
Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
|
||||
SDL_VideoDisplay * _display, SDL_bool fullscreen)
|
||||
{
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
|
||||
if (fullscreen)
|
||||
wl_shell_surface_set_fullscreen(wind->shell_surface,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
|
||||
0, (struct wl_output *)_display->driverdata);
|
||||
else
|
||||
wl_shell_surface_set_toplevel(wind->shell_surface);
|
||||
|
||||
WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
|
||||
struct wl_output *output = (struct wl_output *) _display->driverdata;
|
||||
SetFullscreen(_this, window, fullscreen ? output : NULL);
|
||||
}
|
||||
|
||||
void
|
||||
Wayland_RestoreWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata;
|
||||
|
||||
wl_shell_surface_set_toplevel(wind->shell_surface);
|
||||
if (viddata->shell.zxdg) {
|
||||
} else {
|
||||
wl_shell_surface_set_toplevel(wind->shell_surface.wl);
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
|
||||
}
|
||||
|
@ -273,10 +371,15 @@ void
|
|||
Wayland_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
wl_shell_surface_set_maximized(wind->shell_surface, NULL);
|
||||
if (viddata->shell.zxdg) {
|
||||
zxdg_toplevel_v6_set_maximized(wind->shell_surface.zxdg.roleobj.toplevel);
|
||||
} else {
|
||||
wl_shell_surface_set_maximized(wind->shell_surface.wl, NULL);
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
|
||||
WAYLAND_wl_display_flush( viddata->display );
|
||||
}
|
||||
|
||||
int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
||||
|
@ -310,9 +413,18 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
|||
data->surface =
|
||||
wl_compositor_create_surface(c->compositor);
|
||||
wl_surface_set_user_data(data->surface, data);
|
||||
data->shell_surface = wl_shell_get_shell_surface(c->shell,
|
||||
data->surface);
|
||||
wl_shell_surface_set_class (data->shell_surface, c->classname);
|
||||
|
||||
if (c->shell.zxdg) {
|
||||
data->shell_surface.zxdg.surface = zxdg_shell_v6_get_xdg_surface(c->shell.zxdg, data->surface);
|
||||
/* !!! FIXME: add popup role */
|
||||
data->shell_surface.zxdg.roleobj.toplevel = zxdg_surface_v6_get_toplevel(data->shell_surface.zxdg.surface);
|
||||
zxdg_toplevel_v6_add_listener(data->shell_surface.zxdg.roleobj.toplevel, &toplevel_listener_zxdg, data);
|
||||
zxdg_toplevel_v6_set_app_id(data->shell_surface.zxdg.roleobj.toplevel, c->classname);
|
||||
} else {
|
||||
data->shell_surface.wl = wl_shell_get_shell_surface(c->shell.wl, data->surface);
|
||||
wl_shell_surface_set_class(data->shell_surface.wl, c->classname);
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
if (c->surface_extension) {
|
||||
data->extended_surface = qt_surface_extension_get_extended_surface(
|
||||
|
@ -333,10 +445,16 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
|||
return SDL_SetError("failed to create a window surface");
|
||||
}
|
||||
|
||||
if (data->shell_surface) {
|
||||
wl_shell_surface_set_user_data(data->shell_surface, data);
|
||||
wl_shell_surface_add_listener(data->shell_surface,
|
||||
&shell_surface_listener, data);
|
||||
if (c->shell.zxdg) {
|
||||
if (data->shell_surface.zxdg.surface) {
|
||||
zxdg_surface_v6_set_user_data(data->shell_surface.zxdg.surface, data);
|
||||
zxdg_surface_v6_add_listener(data->shell_surface.zxdg.surface, &shell_surface_listener_zxdg, data);
|
||||
}
|
||||
} else {
|
||||
if (data->shell_surface.wl) {
|
||||
wl_shell_surface_set_user_data(data->shell_surface.wl, data);
|
||||
wl_shell_surface_add_listener(data->shell_surface.wl, &shell_surface_listener_wl, data);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
|
@ -356,6 +474,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
|||
Wayland_input_lock_pointer(c->input);
|
||||
}
|
||||
|
||||
wl_surface_commit(data->surface);
|
||||
WAYLAND_wl_display_flush(c->display);
|
||||
|
||||
return 0;
|
||||
|
@ -378,9 +497,14 @@ void Wayland_SetWindowSize(_THIS, SDL_Window * window)
|
|||
void Wayland_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (window->title != NULL) {
|
||||
wl_shell_surface_set_title(wind->shell_surface, window->title);
|
||||
if (viddata->shell.zxdg) {
|
||||
zxdg_toplevel_v6_set_title(wind->shell_surface.zxdg.roleobj.toplevel, window->title);
|
||||
} else {
|
||||
wl_shell_surface_set_title(wind->shell_surface.wl, window->title);
|
||||
}
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
|
||||
|
@ -395,8 +519,18 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window)
|
|||
SDL_EGL_DestroySurface(_this, wind->egl_surface);
|
||||
WAYLAND_wl_egl_window_destroy(wind->egl_window);
|
||||
|
||||
if (wind->shell_surface)
|
||||
wl_shell_surface_destroy(wind->shell_surface);
|
||||
if (data->shell.zxdg) {
|
||||
if (wind->shell_surface.zxdg.roleobj.toplevel) {
|
||||
zxdg_toplevel_v6_destroy(wind->shell_surface.zxdg.roleobj.toplevel);
|
||||
}
|
||||
if (wind->shell_surface.zxdg.surface) {
|
||||
zxdg_surface_v6_destroy(wind->shell_surface.zxdg.surface);
|
||||
}
|
||||
} else {
|
||||
if (wind->shell_surface.wl) {
|
||||
wl_shell_surface_destroy(wind->shell_surface.wl);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
if (wind->extended_surface) {
|
||||
|
|
|
@ -31,11 +31,23 @@
|
|||
|
||||
struct SDL_WaylandInput;
|
||||
|
||||
typedef struct {
|
||||
struct zxdg_surface_v6 *surface;
|
||||
union {
|
||||
struct zxdg_toplevel_v6 *toplevel;
|
||||
struct zxdg_popup_v6 *popup;
|
||||
} roleobj;
|
||||
} SDL_zxdg_shell_surface;
|
||||
|
||||
typedef struct {
|
||||
SDL_Window *sdlwindow;
|
||||
SDL_VideoData *waylandData;
|
||||
struct wl_surface *surface;
|
||||
struct wl_shell_surface *shell_surface;
|
||||
union {
|
||||
/* !!! FIXME: add stable xdg_shell from 1.12 */
|
||||
SDL_zxdg_shell_surface zxdg;
|
||||
struct wl_shell_surface *wl;
|
||||
} shell_surface;
|
||||
struct wl_egl_window *egl_window;
|
||||
struct SDL_WaylandInput *keyboard_device;
|
||||
EGLSurface egl_surface;
|
||||
|
|
Loading…
Reference in New Issue