vwebp: fix window title when options are given

Options can precede the file name. This still won't be correct for
Unicode file names, but an approximation will be displayed (with '?'s)
rather than the first character if kParams.file_name were used.
glutCreateWindow() looks like it will prohibit correcting this as it
expects an ASCII string.

Change-Id: I96986a178a0bbce6971d2ac415222d4a456ce1a3
This commit is contained in:
James Zern 2024-04-01 19:34:17 -07:00
parent b3d1b2cbf7
commit d781646c29

View File

@ -498,7 +498,7 @@ static void Help(void) {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
int c; int c, file_name_argv_index = 1;
WebPDecoderConfig* const config = &kParams.config; WebPDecoderConfig* const config = &kParams.config;
WebPIterator* const curr = &kParams.curr_frame; WebPIterator* const curr = &kParams.curr_frame;
@ -545,7 +545,10 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(argv[c], "-mt")) { } else if (!strcmp(argv[c], "-mt")) {
config->options.use_threads = 1; config->options.use_threads = 1;
} else if (!strcmp(argv[c], "--")) { } else if (!strcmp(argv[c], "--")) {
if (c < argc - 1) kParams.file_name = (const char*)GET_WARGV(argv, ++c); if (c < argc - 1) {
kParams.file_name = (const char*)GET_WARGV(argv, ++c);
file_name_argv_index = c;
}
break; break;
} else if (argv[c][0] == '-') { } else if (argv[c][0] == '-') {
printf("Unknown option '%s'\n", argv[c]); printf("Unknown option '%s'\n", argv[c]);
@ -553,6 +556,7 @@ int main(int argc, char* argv[]) {
FREE_WARGV_AND_RETURN(-1); FREE_WARGV_AND_RETURN(-1);
} else { } else {
kParams.file_name = (const char*)GET_WARGV(argv, c); kParams.file_name = (const char*)GET_WARGV(argv, c);
file_name_argv_index = c;
} }
if (parse_error) { if (parse_error) {
@ -632,7 +636,7 @@ int main(int argc, char* argv[]) {
#ifdef FREEGLUT #ifdef FREEGLUT
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
#endif #endif
StartDisplay(argv[1]); StartDisplay(argv[file_name_argv_index]);
if (kParams.has_animation) glutTimerFunc(0, decode_callback, 0); if (kParams.has_animation) glutTimerFunc(0, decode_callback, 0);
glutMainLoop(); glutMainLoop();