From 8ca778197c80725429d98548f429835f2656f2dd Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Mon, 24 Feb 2020 10:58:07 +0000 Subject: framebuffer: Use new enumerate feature of libnsfb 1. Select as default the most useful compiled in surface 2. If the selected surface is unavailable, report the valid surface list to the user. Also do this if the user specifies -f ? on the CLI. Signed-off-by: Daniel Silverstone --- frontends/framebuffer/gui.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'frontends/framebuffer') diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index e51705bac..8f59fefe1 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -449,13 +449,29 @@ static int fb_browser_window_destroy(fbtk_widget_t *widget, return 0; } +static void +framebuffer_surface_iterator(void *ctx, const char *name, enum nsfb_type_e type) +{ + const char *arg0 = ctx; + + fprintf(stderr, "%s: %s\n", arg0, name); +} +static enum nsfb_type_e fetype = NSFB_SURFACE_COUNT; static const char *fename; static int febpp; static int fewidth; static int feheight; static const char *feurl; +static void +framebuffer_pick_default_fename(void *ctx, const char *name, enum nsfb_type_e type) +{ + if (type < fetype) { + fename = name; + } +} + static bool process_cmdline(int argc, char** argv) { @@ -467,7 +483,8 @@ process_cmdline(int argc, char** argv) NSLOG(netsurf, INFO, "argc %d, argv %p", argc, argv); - fename = "sdl"; + nsfb_enumerate_surface_types(framebuffer_pick_default_fename, NULL); + febpp = 32; fewidth = nsoption_int(window_width); @@ -517,6 +534,16 @@ process_cmdline(int argc, char** argv) feurl = argv[optind]; } + if (nsfb_type_from_name(fename) == NSFB_SURFACE_NONE) { + if (strcmp(fename, "?") != 0) { + fprintf(stderr, + "%s: Unknown surface `%s`\n", argv[0], fename); + } + fprintf(stderr, "%s: Valid surface names are:\n", argv[0]); + nsfb_enumerate_surface_types(framebuffer_surface_iterator, argv[0]); + return false; + } + return true; } -- cgit v1.2.3