@@ -432,10 +432,10 @@ def _step2():
432432 return False
433433
434434 def _step3 ():
435- subprocess .Popen (["xdotool" , "windowmove" , wid_rdp , "0" , "0" ],
436- stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
437- subprocess .Popen (["xdotool" , "windowsize" , wid_rdp , str (w ), str (h )],
438- stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
435+ subprocess .run (["xdotool" , "windowmove" , wid_rdp , "0" , "0" ],
436+ timeout = 2 , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
437+ subprocess .run (["xdotool" , "windowsize" , wid_rdp , str (w ), str (h )],
438+ timeout = 2 , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
439439 GLib .timeout_add (100 , _step4 )
440440 return False
441441
@@ -449,8 +449,8 @@ def _step4():
449449 return False
450450
451451 def _step5 ():
452- subprocess .Popen (["xdotool" , "windowfocus" , wid_rdp ],
453- stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
452+ subprocess .run (["xdotool" , "windowfocus" , wid_rdp ],
453+ timeout = 2 , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
454454 self ._reparented = True
455455 host = self ._rdp_host
456456 self ._info .set_text (f" ● RDP → { host } " )
@@ -467,15 +467,26 @@ def do_size_allocate(self, allocation):
467467 Gtk .Box .do_size_allocate (self , allocation )
468468 if not self ._reparented or not self ._wid_rdp :
469469 return
470- # Ottieni dimensioni del socket
471470 if hasattr (self , "_socket" ):
472471 a = self ._socket .get_allocation ()
473472 w = max (a .width , 320 )
474473 h = max (a .height , 240 )
475- subprocess .Popen (
476- ["xdotool" , "windowsize" , self ._wid_rdp , str (w ), str (h )],
477- stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL
478- )
474+ if hasattr (self , "_resize_pending" ) and self ._resize_pending :
475+ return
476+ self ._resize_pending = True
477+
478+ def _do_resize ():
479+ self ._resize_pending = False
480+ if self ._reparented and self ._wid_rdp and hasattr (self , "_socket" ):
481+ a = self ._socket .get_allocation ()
482+ w2 = max (a .width , 320 )
483+ h2 = max (a .height , 240 )
484+ subprocess .run (
485+ ["xdotool" , "windowsize" , self ._wid_rdp , str (w2 ), str (h2 )],
486+ timeout = 2 , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL
487+ )
488+ return False
489+ GLib .timeout_add (150 , _do_resize )
479490
480491 # ------------------------------------------------------------------
481492 # Monitor processo
0 commit comments