1818#define _POSIX_C_SOURCE 200112L // for setenv
1919#endif
2020
21+ #include <assert.h>
2122#include <stdio.h>
2223#include <stdlib.h>
2324#include <string.h>
@@ -430,10 +431,13 @@ static void HandleDisplay(void) {
430431#endif
431432}
432433
433- static void StartDisplay (void ) {
434+ static void StartDisplay (const char * filename ) {
434435 int width = kParams .canvas_width ;
435436 int height = kParams .canvas_height ;
436437 int screen_width , screen_height ;
438+ const char viewername [] = " - WebP viewer" ;
439+ // max linux file len + viewername string
440+ char title [4096 + sizeof (viewername )] = "" ;
437441 // TODO(webp:365) GLUT_DOUBLE results in flickering / old frames to be
438442 // partially displayed with animated webp + alpha.
439443#if defined(__APPLE__ ) || defined(_WIN32 )
@@ -453,8 +457,9 @@ static void StartDisplay(void) {
453457 height = screen_height ;
454458 }
455459 }
460+ snprintf (title , sizeof (title ), "%s%s" , filename , viewername );
456461 glutInitWindowSize (width , height );
457- glutCreateWindow ("WebP viewer" );
462+ glutCreateWindow (title );
458463 glutDisplayFunc (HandleDisplay );
459464 glutReshapeFunc (HandleReshape );
460465 glutIdleFunc (NULL );
@@ -627,7 +632,7 @@ int main(int argc, char* argv[]) {
627632#ifdef FREEGLUT
628633 glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE , GLUT_ACTION_CONTINUE_EXECUTION );
629634#endif
630- StartDisplay ();
635+ StartDisplay (argv [ 1 ] );
631636
632637 if (kParams .has_animation ) glutTimerFunc (0 , decode_callback , 0 );
633638 glutMainLoop ();
0 commit comments