window: Clean up buffer type choosing
Extracting it to a function makes this cleaner and more
understandable.
diff --git a/clients/window.c b/clients/window.c
index b7febed..ce0130c 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -4351,6 +4351,17 @@
return surface;
}
+static window_buffer_type
+get_preferred_buffer_type(struct display *display)
+{
+#ifdef HAVE_CAIRO_EGL
+ if (display->argb_device)
+ return WINDOW_BUFFER_TYPE_EGL_WINDOW;
+#endif
+
+ return WINDOW_BUFFER_TYPE_SHM;
+}
+
static struct window *
window_create_internal(struct display *display, int custom)
{
@@ -4369,14 +4380,7 @@
window->custom = custom;
window->preferred_format = WINDOW_PREFERRED_FORMAT_NONE;
- if (display->argb_device)
-#ifdef HAVE_CAIRO_EGL
- surface->buffer_type = WINDOW_BUFFER_TYPE_EGL_WINDOW;
-#else
- surface->buffer_type = WINDOW_BUFFER_TYPE_SHM;
-#endif
- else
- surface->buffer_type = WINDOW_BUFFER_TYPE_SHM;
+ surface->buffer_type = get_preferred_buffer_type(display);
wl_surface_set_user_data(surface->surface, window);
wl_list_insert(display->window_list.prev, &window->link);