@@ -360,7 +360,7 @@ void feh_event_handle_stdin(void)
360360 keysym = XStringToKeysym (stdin_buf );
361361
362362 if (window_num && keysym )
363- feh_event_handle_generic (windows [0 ], is_esc * Mod1Mask , keysym , 0 );
363+ feh_event_handle_generic (windows [0 ], is_esc * Mod1Mask , keysym , 0 , NULL , 0 );
364364
365365 is_esc = 0 ;
366366}
@@ -383,7 +383,13 @@ void feh_event_handle_keypress(XEvent * ev)
383383 }
384384
385385 kev = (XKeyEvent * ) ev ;
386- XLookupString (& ev -> xkey , (char * ) kbuf , sizeof (kbuf ), & keysym , NULL );
386+ int kbuf_used = Xutf8LookupString (input_context , kev , (char * ) kbuf , sizeof (kbuf ), & keysym , NULL );
387+ if (kbuf_used < sizeof (kbuf )) {
388+ kbuf [kbuf_used ] = 0 ;
389+ } else {
390+ kbuf [19 ] = 0 ;
391+ }
392+ D (("Xutf8LookupString set kbuf = %s, keysym = %08x\n" , kbuf , keysym ));
387393 state = kev -> state & (ControlMask | ShiftMask | Mod1Mask | Mod4Mask );
388394
389395 if (ignore_space (keysym ))
@@ -410,7 +416,12 @@ void feh_event_handle_keypress(XEvent * ev)
410416 if (winwid == NULL )
411417 return ;
412418
413- feh_event_handle_generic (winwid , state , keysym , 0 );
419+ if (XFilterEvent (ev , None )) {
420+ D (("Event filtered\n" ));
421+ return ;
422+ }
423+
424+ feh_event_handle_generic (winwid , state , keysym , 0 , kbuf , kbuf_used );
414425}
415426
416427fehkey * feh_str_to_kb (char * action )
@@ -423,7 +434,7 @@ fehkey *feh_str_to_kb(char *action)
423434 return NULL ;
424435}
425436
426- void feh_event_handle_generic (winwidget winwid , unsigned int state , KeySym keysym , unsigned int button ) {
437+ void feh_event_handle_generic (winwidget winwid , unsigned int state , KeySym keysym , unsigned int button , char * buf , unsigned int buf_len ) {
427438 int curr_screen = 0 ;
428439
429440 if (winwid -> caption_entry && (keysym != NoSymbol )) {
@@ -468,11 +479,14 @@ void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysy
468479 winwidget_render_image_cached (winwid );
469480 break ;
470481 default :
471- if (isascii (keysym )) {
472- /* append to caption */
482+ /* append to caption */
483+ if ((buf != NULL ) && buf_len ) {
484+ ESTRAPPEND (FEH_FILE (winwid -> file -> data )-> caption , buf );
485+ } else if (isascii (keysym )) {
486+ // TODO update feh_event_handle_stdin to pass buf as well.
473487 ESTRAPPEND_CHAR (FEH_FILE (winwid -> file -> data )-> caption , keysym );
474- winwidget_render_image_cached (winwid );
475488 }
489+ winwidget_render_image_cached (winwid );
476490 break ;
477491 }
478492 return ;
0 commit comments