mirror of https://github.com/encounter/SDL.git
wayland: Tag/Check wl_output objects as well, fixes crashes when libdecor is in use
This commit is contained in:
parent
871c11191b
commit
03185e748b
|
@ -127,6 +127,39 @@ get_classname()
|
||||||
return SDL_strdup("SDL_App");
|
return SDL_strdup("SDL_App");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *SDL_WAYLAND_surface_tag = "sdl-window";
|
||||||
|
static const char *SDL_WAYLAND_output_tag = "sdl-output";
|
||||||
|
|
||||||
|
void SDL_WAYLAND_register_surface(struct wl_surface *surface)
|
||||||
|
{
|
||||||
|
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||||
|
wl_proxy_set_tag((struct wl_proxy *)surface, &SDL_WAYLAND_surface_tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL_WAYLAND_register_output(struct wl_output *output)
|
||||||
|
{
|
||||||
|
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||||
|
wl_proxy_set_tag((struct wl_proxy *)output, &SDL_WAYLAND_output_tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface)
|
||||||
|
{
|
||||||
|
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||||
|
return wl_proxy_get_tag((struct wl_proxy *) surface) == &SDL_WAYLAND_surface_tag;
|
||||||
|
}
|
||||||
|
return SDL_TRUE; /* For older clients we have to assume this is us... */
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_bool SDL_WAYLAND_own_output(struct wl_output *output)
|
||||||
|
{
|
||||||
|
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||||
|
return wl_proxy_get_tag((struct wl_proxy *) output) == &SDL_WAYLAND_output_tag;
|
||||||
|
}
|
||||||
|
return SDL_TRUE; /* For older clients we have to assume this is us... */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Wayland_DeleteDevice(SDL_VideoDevice *device)
|
Wayland_DeleteDevice(SDL_VideoDevice *device)
|
||||||
{
|
{
|
||||||
|
@ -392,6 +425,7 @@ Wayland_add_display(SDL_VideoData *d, uint32_t id)
|
||||||
data->scale_factor = 1.0;
|
data->scale_factor = 1.0;
|
||||||
|
|
||||||
wl_output_add_listener(output, &output_listener, data);
|
wl_output_add_listener(output, &output_listener, data);
|
||||||
|
SDL_WAYLAND_register_output(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||||
|
|
|
@ -91,6 +91,11 @@ typedef struct {
|
||||||
SDL_bool done;
|
SDL_bool done;
|
||||||
} SDL_WaylandOutputData;
|
} SDL_WaylandOutputData;
|
||||||
|
|
||||||
|
extern void SDL_WAYLAND_register_surface(struct wl_surface *surface);
|
||||||
|
extern void SDL_WAYLAND_register_output(struct wl_output *output);
|
||||||
|
extern SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface);
|
||||||
|
extern SDL_bool SDL_WAYLAND_own_output(struct wl_output *output);
|
||||||
|
|
||||||
#endif /* SDL_waylandvideo_h_ */
|
#endif /* SDL_waylandvideo_h_ */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -42,16 +42,6 @@
|
||||||
#include <libdecor.h>
|
#include <libdecor.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *SDL_WAYLAND_surface_tag = "sdl-window";
|
|
||||||
|
|
||||||
SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface)
|
|
||||||
{
|
|
||||||
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
|
||||||
return wl_proxy_get_tag((struct wl_proxy *) surface) == &SDL_WAYLAND_surface_tag;
|
|
||||||
}
|
|
||||||
return SDL_TRUE; /* For older clients we have to assume this is us... */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CommitMinMaxDimensions(SDL_Window *window)
|
CommitMinMaxDimensions(SDL_Window *window)
|
||||||
{
|
{
|
||||||
|
@ -488,7 +478,7 @@ handle_surface_enter(void *data, struct wl_surface *surface,
|
||||||
SDL_WindowData *window = data;
|
SDL_WindowData *window = data;
|
||||||
SDL_WaylandOutputData *driverdata = wl_output_get_user_data(output);
|
SDL_WaylandOutputData *driverdata = wl_output_get_user_data(output);
|
||||||
|
|
||||||
if (!SDL_WAYLAND_own_surface(surface)) {
|
if (!SDL_WAYLAND_own_output(output) || !SDL_WAYLAND_own_surface(surface)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +498,7 @@ handle_surface_leave(void *data, struct wl_surface *surface,
|
||||||
int i, send_move_event = 0;
|
int i, send_move_event = 0;
|
||||||
SDL_WaylandOutputData *driverdata = wl_output_get_user_data(output);
|
SDL_WaylandOutputData *driverdata = wl_output_get_user_data(output);
|
||||||
|
|
||||||
if (!SDL_WAYLAND_own_surface(surface)) {
|
if (!SDL_WAYLAND_own_output(output) || !SDL_WAYLAND_own_surface(surface)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,9 +1128,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
|
||||||
wl_compositor_create_surface(c->compositor);
|
wl_compositor_create_surface(c->compositor);
|
||||||
wl_surface_add_listener(data->surface, &surface_listener, data);
|
wl_surface_add_listener(data->surface, &surface_listener, data);
|
||||||
|
|
||||||
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
SDL_WAYLAND_register_surface(data->surface);
|
||||||
wl_proxy_set_tag((struct wl_proxy *)data->surface, &SDL_WAYLAND_surface_tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fire a callback when the compositor wants a new frame rendered.
|
/* Fire a callback when the compositor wants a new frame rendered.
|
||||||
* Right now this only matters for OpenGL; we use this callback to add a
|
* Right now this only matters for OpenGL; we use this callback to add a
|
||||||
|
|
|
@ -114,8 +114,6 @@ Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
|
||||||
extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
||||||
extern int Wayland_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation);
|
extern int Wayland_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation);
|
||||||
|
|
||||||
extern SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface);
|
|
||||||
|
|
||||||
#endif /* SDL_waylandwindow_h_ */
|
#endif /* SDL_waylandwindow_h_ */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
Loading…
Reference in New Issue