toytoolkit: match parent surface type when adding a subsurface

When adding a subsurface (to display a tooltip) in toytoolkit,
we now get the parent window surface type (SHM or EGL) and
define the new surface type as the same.

This fixes crashes with tooltips in cases like having
Cairo-EGL available but running the X11 compositor.

Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
diff --git a/clients/window.c b/clients/window.c
index 8393424..c510f50 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -4610,6 +4610,12 @@
 	window->main_surface->buffer_type = type;
 }
 
+enum window_buffer_type
+window_get_buffer_type(struct window *window)
+{
+	return window->main_surface->buffer_type;
+}
+
 void
 window_set_preferred_format(struct window *window,
 			    enum preferred_format format)
@@ -4627,6 +4633,7 @@
 	struct wl_subcompositor *subcompo = window->display->subcompositor;
 
 	surface = surface_create(window);
+	surface->buffer_type = window_get_buffer_type(window);
 	widget = widget_create(window, surface, data);
 	wl_list_init(&widget->link);
 	surface->widget = widget;