diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-24 10:58:07 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-24 10:58:07 +0000 |
commit | 8ca778197c80725429d98548f429835f2656f2dd (patch) | |
tree | 0db6724dcbcbabf106d2ea2613c9405865f101aa /frontends/framebuffer | |
parent | b6d33785a089b99bd84ce7637c0a6f6529ad1fa5 (diff) | |
download | netsurf-8ca778197c80725429d98548f429835f2656f2dd.tar.gz netsurf-8ca778197c80725429d98548f429835f2656f2dd.tar.bz2 |
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 <dsilvers@digital-scurf.org>
Diffstat (limited to 'frontends/framebuffer')
-rw-r--r-- | frontends/framebuffer/gui.c | 29 |
1 files changed, 28 insertions, 1 deletions
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; } |