18
18
#define _POSIX_C_SOURCE 200112L // for setenv
19
19
#endif
20
20
21
+ #include <assert.h>
21
22
#include <stdio.h>
22
23
#include <stdlib.h>
23
24
#include <string.h>
@@ -430,10 +431,13 @@ static void HandleDisplay(void) {
430
431
#endif
431
432
}
432
433
433
- static void StartDisplay (void ) {
434
+ static void StartDisplay (const char * filename ) {
434
435
int width = kParams .canvas_width ;
435
436
int height = kParams .canvas_height ;
436
437
int screen_width , screen_height ;
438
+ const char viewername [] = " - WebP viewer" ;
439
+ // max linux file len + viewername string
440
+ char title [4096 + sizeof (viewername )] = "" ;
437
441
// TODO(webp:365) GLUT_DOUBLE results in flickering / old frames to be
438
442
// partially displayed with animated webp + alpha.
439
443
#if defined(__APPLE__ ) || defined(_WIN32 )
@@ -453,8 +457,9 @@ static void StartDisplay(void) {
453
457
height = screen_height ;
454
458
}
455
459
}
460
+ snprintf (title , sizeof (title ), "%s%s" , filename , viewername );
456
461
glutInitWindowSize (width , height );
457
- glutCreateWindow ("WebP viewer" );
462
+ glutCreateWindow (title );
458
463
glutDisplayFunc (HandleDisplay );
459
464
glutReshapeFunc (HandleReshape );
460
465
glutIdleFunc (NULL );
@@ -627,7 +632,7 @@ int main(int argc, char* argv[]) {
627
632
#ifdef FREEGLUT
628
633
glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE , GLUT_ACTION_CONTINUE_EXECUTION );
629
634
#endif
630
- StartDisplay ();
635
+ StartDisplay (argv [ 1 ] );
631
636
632
637
if (kParams .has_animation ) glutTimerFunc (0 , decode_callback , 0 );
633
638
glutMainLoop ();
0 commit comments