+
   /F]c                   s   a  R t0 t ^ RIHt ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	Rt
 ^ RItRt
]	P                  ! R4      t ! R R4      tRs] ^ k R	 R
 ltR R ltR R ltR R lt]R8X  dz   ]	P,                  ! ]P.                  R7      t]P3                  ]	P4                  4       ]P7                  ]4       ]P9                  R]! 4       4       ]! 4       t]P=                  4        R# R#   ]3 d    Rt
 Li ; i)    Any)TupleNFTzibus-typing-boosterc                   sz   a  ] tR t^Wt o V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltRt	V t
R# )AtspiMonitorc                   < V ^8  d   QhRR/#    returnN format__classdict__   ":/usr/share/ibus-typing-booster/engine/itb_active_window.py__annotate__AtspiMonitor.__annotate__[   s     I I$ I    c                s   R V n         R V n        RV n        \        '       g   \        P                  R4       R#  \        P                  P                  V P                  R4       \        P                  P                  V P                  R4       RV n        \        P                  R4       R#   \         d7   p\        P                  RTP                  P                  T4        Rp?R# Rp?ii ; i)	 Fu   “import pyatspi” failed.Nzwindow:activatezwindow:deactivateTzAtspiMonitor events registered.z%s: %s )_active_program_name_active_window_title_events_registeredIMPORT_PYATSPI_SUCCESSFULLOGGERinfopyatspiRegistryZregisterEventListener_on_window_activate_on_window_deactivate	Exception	exception	__class____name__)selferrors   & r   __init__ZAtspiMonitor.__init__[   s    $&!$&!"'((KK67	I22((*;=22**,?A&*D#KK9: 	IY(@(@%HH	Is   A0B, ,C-7+C((C-c                r   r   r	   r
   r   r   r   r   n   s     % %t %r   c                s    V P                   '       d6   \        P                  R 4       \        P                  P                  4        R# R# )zStarting AtspiMonitor.N)r   r   r   r   r   startr!      &r   r$   ZAtspiMonitor.startn   s2    """KK01""$ #r   c                s6   < V ^8  d   QhRS[ S[S[3,          /# r   r   r   strr
   r   r   r   r   t   s     F F5c? Fr   c                s2    V P                   V P                  3# )N)r   r   r%   r&   r   get_active_windowZAtspiMonitor.get_active_windowt   s     ))4+D+DEEr   c                $   < V ^8  d   QhRS[ RR/# r   eventr   Nr   r
   r   r   r   r   }   s     / / / /r   c                s   \         P                  R \        V4      4        VP                  P                  V n        VP                  V n        \         P                  RV P
                  V P
                  V P                  4       R#   \         d6   p\         P                  RTP                  P                  T4        Rp?LsRp?ii ; i)%s%s: %sNz3window activated: %s currently active: %s title: %s)r   debugr)   host_applicationnamer   Zsource_namer   r   r   r   r    r   )r!   r-   r"   s   && r   r   Z AtspiMonitor._on_window_activate}   s    T3u:&	H(-(>(>(C(CD%(-(9(9D% 	I------	/  	HXu'?'?GG	Hs   ,B C+C  Cc                r+   r,   r   r
   r   r   r   r      s     0/ 0/3 0/4 0/r   c                s   \         P                  R \        V4      4       Rp VP                  P                  pV P                  V8X  d   RV n	        RV n
        \         P                  RVV P                  V P                  4       R#   \
         d6   p\         P                  RTP                  P                  T4        Rp?LRp?ii ; i)r.   r   r/   Nz5window deactivated: %s currently active: %s title: %s)r   r0   r)   r1   r2   r   r   r   r    r   r   r   )r!   r-   program_namer"   s   &&  r   r   Z"AtspiMonitor._on_window_deactivate   s    T3u:&	H 1166LJ $$4(*D%(*D%K ----	/O  	HXu'?'?GG	Hs   B C+CC)r   r   r   N)r    Z
__module__Z__qualname__Z__firstlineno__r#   r$   r*   r   r   Z__static_attributes__Z__classdictcell__)r      @r   r   r   W   s;     I I&% %F F/ /0/ 0/r   r   c                s    V ^8  d   QhRR/# r   r	   r      "r   r   r      s      $ r   c                  s    \         P                  P                  ^ 4      p V  F  pVP                  4       P	                  \         P
                  4      '       d   K8  V FR  pVP                  4       P	                  \         P                  4      '       g   K8  VP                  VP                  3s	  R# 	  K  	  Rs	R#   \         d6   p\        P                  RTP                  P                  T4        Rp?L?Rp?ii ; i)r    Nr/   r   r   )r   r   Z
getDesktopZgetStateZcontainsZSTATE_DEFUNCTZget_state_setZSTATE_ACTIVEr2   _ACTIVE_WINDOWr   r   r   r   r    )ZdesktopZapplicationZwindowr"   s       r   _get_active_window_atspir9      s    
D""--a0"K##%..w/D/DEE%'')2273G3GHH&1&6&6%DN & # N  D5??#;#;UCCDs$   BB; B; 1B; ;C;+C66C;c                F    V ^8  d   QhR\         \        \        3,          /# r'   r(   r5   r6   r   r   r      s      sCx r   c                  s   Rs \        '       g   R# \        P                  ! R\        R7      p V P                  4        V P                  RR7       V P                  4       '       d   \        P                  R4       R# \         # )r   T)ZdaemonZtargetg      ?)Ztimeoutztimeout getting active window.r7   )
r8   r   	threadingZThreadr9   r$   ZjoinZis_aliver   r"   )Zactive_window_threads    r   get_active_window_atspir<      so     N$$$++46 c*$$&&56r   c                r:   r'   r(   r5   r6   r   r   r      s     N( N(sCx N(r   c            	      s   R p R pR\         P                  9  g   \         P                  R,          '       g   W3# \        P                  ! R4      pV'       g   W3#  \        P
                  ! VRRRRRR.\        P                  \        P                  RR	R
7      p\        TP                  P                  4       4      ^8  d   \        P!                  R4       Y3# TP                  P                  4       RR ^ ,          pTR8X  d   Y3#  \        P
                  ! TRTRRRR.\        P                  \        P                  RR	R
7      pRTP                  9  g   RTP                  9  d   \        P!                  R4       Y3# TP                  P                  R^R7      ^,          P                  R4      ^,          P#                  4       ^R P%                  4       p  \        P
                  ! TRTRRRR.\        P                  \        P                  RR	R
7      pRTP                  9  d   \        P!                  R4       Y3# TP                  P                  R^R7      ^,          P#                  4       ^R pY3#   \        P                   dC   p\        P                  RTP                  P                  YDP                  4       Y3u Rp?# Rp?ii ; i  \        P                   dC   p\        P                  RTP                  P                  YDP                  4       Y3u Rp?# Rp?ii ; i  \        P                   dC   p\        P                  RTP                  P                  YDP                  4       Y3u Rp?# Rp?ii ; i)r   ZDISPLAYZxpropz-rootz-fZ_NET_ACTIVE_WINDOWZ0xz $0Tzutf-8)stdoutstderrZcheckZencodingz/Exception when calling xprop: %s: %s stderr: %sNz/Unexpected xprop output for id of active windowZ0x0z-idZWM_CLASSZ0sZ=Z,z9Unexpected xprop output for program name of active window)ZmaxsplitZ_NET_WM_NAMEZ0tz2Unexpected xprop output for title of active windowi)osenvironshutilZwhich
subprocessZrunZPIPEZCalledProcessErrorr   r   r   r    r>   Zlenr=   Zsplitr"   Zstriplower)r3   window_titleZxprop_binaryZresultr"   Z	window_ids         r   get_active_window_xproprE      s    LL

""**Y*?*?++<<(L++,7D!40DF????* 6== !A%FG++##%bc*1-IE++,ItZzC????* &--3fmm#;G	I++==&&a ' !E#Jq**/%'!B88= ,It^T>K????* &--IJ++==&&sQ&7:@@B1RHL''m (( ,=__%%ull	< ++	,* (( ,=__%%u||	= ++	,* (( ,=__%%ull	< ++	,sZ   >I: 	>K >L. :K7KKKL+)7L& L+&L+.N7N :N Nc                r:   r'   r(   r5   r6   r   r   r   8  s     ( (5c? (r   c                  sh   R R rR\         P                  9   dL   R\         P                  9   d7   \         P                  R,          P                  4       R8X  d   \        4       w  rV '       d   \        P                  RW34       W3# \        4       w  rV '       d   \        P                  RW34       W3# )r   ZWAYLAND_DISPLAYZXDG_SESSION_TYPEZwaylandz!Got active window from AT-SPI: %sz Got active window from xprop: %s)r?   r@   rC   r<   r   r0   rE   )r3   rD   s     r   r*   r*   8  s     %'<RZZ'"**,JJ)*002i?'>'@$/,1M	O++#:#< \.0L	N''r   Z__main__)Zstreamr.   c                sb    V ^8  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   # )r   r8   )__conditional_annotations__r   r)   r5   r6   r   r   r   F   s$      l + *c3h *m r   r7   ) rF   Ztypingr   r   Zsysr?   rB   rA   r;   Zloggingr   r   ZImportErrorZ	getLoggerr   r   r8   r9   r<   rE   r*   r    ZStreamHandlerr>   ZLOG_HANDLERZsetLevelZDEBUGZ
addHandlerr   Zatspi_monitorr$   r   )rF   r4   r   <module>rG      s   L    
 	    ! & $ 
		0	1c/ c/J #+ **(N(b(2 z''szz:K
OOGMM"
k"
KK')* NM  	~ & %&s   C0 0
C=<C=