@@ -127,7 +127,6 @@ Sint32 vdi_stream_client__render_text(void *opaque, char *text) {
127
127
Sint32 vdi_stream_client__event_loop (vdi_config_s * vdi_config ) {
128
128
struct parsec_context_s parsec_context = {0 };
129
129
struct redirect_context_s redirect_context [USB_MAX ] = {0 };
130
- SDL_bool focus = SDL_FALSE ;
131
130
SDL_bool grab_forced = SDL_FALSE ;
132
131
Uint32 wait_time = 0 ;
133
132
Uint32 last_time = 0 ;
@@ -421,10 +420,6 @@ Sint32 vdi_stream_client__event_loop(vdi_config_s *vdi_config) {
421
420
vdi_stream_client__render_text (& parsec_context , "Closing..." );
422
421
break ;
423
422
case SDL_KEYUP :
424
-
425
- /* TODO: we need to re-grab keyboard later. (workaround for buggy x11 and sdl) */
426
- focus = SDL_FALSE ;
427
-
428
423
pmsg .type = MESSAGE_KEYBOARD ;
429
424
pmsg .keyboard .code = (ParsecKeycode ) msg .key .keysym .scancode ;
430
425
pmsg .keyboard .mod = msg .key .keysym .mod ;
@@ -574,27 +569,15 @@ Sint32 vdi_stream_client__event_loop(vdi_config_s *vdi_config) {
574
569
break ;
575
570
case SDL_WINDOWEVENT :
576
571
switch (msg .window .event ) {
577
- case SDL_WINDOWEVENT_FOCUS_GAINED :
572
+ case SDL_WINDOWEVENT_ENTER :
578
573
SDL_EventState (SDL_KEYDOWN , SDL_ENABLE );
579
574
SDL_EventState (SDL_KEYUP , SDL_ENABLE );
580
- XGrabKeyboard (wm_info .info .x11 .display , wm_info .info .x11 .window , False , GrabModeAsync , GrabModeAsync , CurrentTime );
581
-
582
- /* TODO: copy client to host clipboard. (workaround for buggy x11 and sdl) */
583
- if (vdi_config -> clipboard == 1 && SDL_HasClipboardText () == SDL_TRUE ) {
584
- ParsecClientSendUserData (parsec_context .parsec , PARSEC_CLIPBOARD_MSG , SDL_GetClipboardText ());
585
- }
586
-
575
+ SDL_SetWindowKeyboardGrab (parsec_context .window , SDL_TRUE );
587
576
break ;
588
- case SDL_WINDOWEVENT_FOCUS_LOST :
577
+ case SDL_WINDOWEVENT_LEAVE :
589
578
SDL_EventState (SDL_KEYDOWN , SDL_DISABLE );
590
579
SDL_EventState (SDL_KEYUP , SDL_DISABLE );
591
- XUngrabKeyboard (wm_info .info .x11 .display , CurrentTime );
592
- break ;
593
- case SDL_WINDOWEVENT_ENTER :
594
- parsec_context .focus = SDL_TRUE ;
595
- break ;
596
- case SDL_WINDOWEVENT_LEAVE :
597
- parsec_context .focus = SDL_FALSE ;
580
+ SDL_SetWindowKeyboardGrab (parsec_context .window , SDL_FALSE );
598
581
break ;
599
582
}
600
583
break ;
@@ -663,9 +646,6 @@ Sint32 vdi_stream_client__event_loop(vdi_config_s *vdi_config) {
663
646
default :
664
647
break ;
665
648
}
666
-
667
- /* TODO: we need to re-grab keyboard later. (workaround for buggy x11 and sdl) */
668
- focus = SDL_FALSE ;
669
649
}
670
650
671
651
/* TODO: check if we need to grab input to force decoder initialization. (workaround for buggy parsec sdk) */
@@ -711,17 +691,11 @@ Sint32 vdi_stream_client__event_loop(vdi_config_s *vdi_config) {
711
691
parsec_context .window_height = parsec_context .client_status .decoder -> height ;
712
692
}
713
693
714
- /* check if we need to regrab keyboard on modifier keypress. */
715
- if (focus == SDL_FALSE && (SDL_GetWindowFlags (parsec_context .window ) & SDL_WINDOW_INPUT_FOCUS ) != 0 ) {
716
- XGrabKeyboard (wm_info .info .x11 .display , wm_info .info .x11 .window , False , GrabModeAsync , GrabModeAsync , CurrentTime );
717
- focus = SDL_TRUE ;
718
- }
719
-
720
694
SDL_Delay (1 );
721
695
}
722
696
723
697
/* already release any grabbed keyboard because thread termination can take some time. */
724
- XUngrabKeyboard ( wm_info . info . x11 . display , CurrentTime );
698
+ SDL_SetWindowGrab ( parsec_context . window , SDL_FALSE );
725
699
726
700
/* stop network threads for usb redirection. */
727
701
if (vdi_config -> usb_devices [0 ].vendor != 0 ) {
0 commit comments