+
    Qi6F  c                  sP  a  0 t $ R t^ RIHt RtRtRtRtRt^ RI	H
t
 ^ RIt]P                  ! R	R
4       ^ RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt ]
'       d   ^RIHt ^RIHt Rt Rt!Rt"Rt#Rt$Rt% ! R R4      t&]&! 4       t'R](R&   R R  lt)R# )!z1Module to manage the focused object, window, etc.)annotationsz$Id$z
$Revision$z$Date$zQCopyright (c) 2005-2008 Sun Microsystems Inc.Copyright (c) 2016-2023 Igalia, S.L.ZLGPL)TYPE_CHECKINGNAtspiz2.0)r   )braille)dbus_service)debug)script_manager)AXObject)AXTable)AXText)AXUtilities)
InputEvent)defaultzcaret-trackingzfocus-trackingzflat-reviewzmouse-reviewzobject-navigatorzsay-allc                  sz   ] tR t^BtRtR R ltR<R R lltR R ltR R	 ltR
 R lt	R R lt
R R ltR=R R lltR R ltR R ltR R ltR R ltR R ltR R ltR R  ltR! R" ltR>R# R$ lltR% R& ltR' R( ltR?R) R* llt]P4                  R@R+ R, ll4       t]P4                  R@R- R. ll4       t]P4                  R@R/ R0 ll4       t]P4                  R@R1 R2 ll4       t]P>                  R3 R4 l4       t ]P>                  R5 R6 l4       t!]P>                  R7 R8 l4       t"]P>                  R9 R: l4       t#R;t$R# )AFocusManagerz(Manages the focused object, window, etc.c                   V ^8  d   QhRR/# )   returnNone Zformat   "7/usr/lib/python3.14/site-packages/orca/focus_manager.py__annotate__FocusManager.__annotate__E   s     C C$ C    c                	s   R V n         R V n        R V n        R V n        RV n        RV n        RV n        Rp\        P                  ! \        P                  VR4       \        P                  ! 4       pVP                  RV 4       R # )Nz*FOCUS MANAGER: Registering D-Bus commands.Tr   )r   )Nr   )_window_focus_object_of_interest_active_mode_last_cell_coordinates_last_cursor_position_penultimate_cursor_positionr   print_message
LEVEL_INFOr   Zget_remote_controllerZregister_decorated_module)selfmsgZ
controller   &  r   __init__ZFocusManager.__init__E   ss    04/3<@ (,7?#JT"Q[):E,,c48!779
,,^TBr   c               s     V ^8  d   QhRRRR/# )r   reasonZstrr   r   r   r   r   r   r   r   S   s     
! 
!# 
!t 
!r   c                s    RpV'       d   VRV 2,          p\         P                  ! \         P                  VR4       RV n        RV n        RV n        RV n        R# )z!Clears everything we're tracking.z!FOCUS MANAGER: Clearing all statez: TN)r   r!   r"   r   r   r   r   )r#   r'   r$   s   && r   clear_stateZFocusManager.clear_stateS   sR     2Rx= CE,,c48#'  r   c               r   r   r   Atspi.Accessible | Noner   r   r   r   r   r   _   s      %< r   c                s    \         P                  ! V P                  4      pRV P                  RV.p\        P                  ! \        P
                  VR4       V# )z0Returns the focused object in the active window.z FOCUS MANAGER: Focused object inZisT)r
   Zget_focused_objectr   r   print_tokensr"   )r#   resulttokensr%   r   find_focused_objectZ FocusManager.find_focused_object_   sG     //=4dllD&Q5++VT:r   c               r   r   r   boolr   r   r   r   r   r   g   s      d r   c                s    V P                   RJ ;'       d    V P                  RJ pV'       d)   Rp\        P                  ! \        P                  VR4       V# )z;Returns True if we have no knowledge about what is focused.Nz+FOCUS MANAGER: Focus and window are unknownT)r   r   r   r!   r"   )r#   r,   r$   r%   r   focus_and_window_are_unknownZ)FocusManager.focus_and_window_are_unknowng   sH     $==)=?C 0 0#t<r   c               r   r/   r   r   r   r   r   r   q   s      t r   c                s    \         P                  ! V P                  4      '       g   R# Rp\        P                  ! \        P
                  VR4       R# )z+Returns True if the locus of focus is dead.FzFOCUS MANAGER: Focus is deadT)r   is_deadr   r   r!   r"   )r#   r$      & r   focus_is_deadZFocusManager.focus_is_deadq   s<     ,,,E,,c48r   c               r   r/   r   r   r   r   r   r   {   s     + + +r   c                sT    V P                   f   R# V P                   V P                  8H  # )z8Returns True if the locus of focus is the active window.F)r   r   r#      &r   focus_is_active_windowZ#FocusManager.focus_is_active_window{   s$     ;;{{dll**r   c               r   r/   r   r   r   r   r   r      s     [ [4 [r   c                s    V P                   RJ;'       d,    \        P                  ! V P                   V P                  4      # )z@Returns True if the locus of focus is inside the current window.N)r   r   Zis_ancestorr   r5   r6   r   focus_is_in_active_windowZ&FocusManager.focus_is_in_active_window   s0     {{$&ZZ8+?+?T\\+ZZr   Nc          
     s,    V ^8  d   QhRRRRRRRRRR	/# )
r   objzAtspi.Accessiblestart_offsetz
int | None
end_offsetmodez
str | Noner   r   r   r   r   r   r   r      s:     $+ $+#$+ $+ $+ 	$+
 
$+r   c                s   Vf   ^ pVf   TpVf   \         pVe   VP                  RV,           ^R4       W@P                  8w  d   RV P                  RV.p\        P                  ! \        P
                  VR4       W@n        V\        8X  d&   \        P                  ! \        P                  4       M\        P                  ! 4        RVRV R	V R
2.p\        P                  ! \        P
                  VR4       Ve   VP                  RW#4       WP                  8w  d?   RV P                  RV.p\        P                  ! \        P
                  VR4       Wn
        R# R# )zLNotifies interested clients that the current region of interest has changed.Nzmode-changed:: z"FOCUS MANAGER: Switching mode fromtoTz"FOCUS MANAGER: Region of interest:Z(z, Z)zregion-changedz0FOCUS MANAGER: Switching object of interest from)FOCUS_TRACKINGZemitr   r   r+   r"   FLAT_REVIEWr   ZsetBrlapiPriorityZBRLAPI_PRIORITY_HIGHr   )r#   r9   r:   r;   r<   r-   s   &&&&& r   emit_region_changedZ FocusManager.emit_region_changed   s6    L%J<!D?HH%,a4$$$:D<M<MtUYZFu//> ${"))'*F*FG))+6qbQ[P\\]=^_5++VT:?HH%|@***H..c;Fu//>'*$	 +r   c               r   r/   r   r   r   r   r   r      s     , ,D ,r   c                s(    V P                   \        8H  # )z'Returns True if we are in say-all mode.)r   SAY_ALLr5   r6   r   
in_say_allZFocusManager.in_say_all   s       G++r   c               r   )r   r   z*tuple[str | None, Atspi.Accessible | None]r   r   r   r   r   r      s     ; ;	3;r   c                s    RV P                   RV P                  .p\        P                  ! \        P                  VR4       V P                   V P                  3# )z:Returns the current mode and associated object of interestzFOCUS MANAGER: Active mode:zObject of interest:T)r   r   r   r+   r"   r#   r-   r3   r   &get_active_mode_and_object_of_interestZ3FocusManager.get_active_mode_and_object_of_interest   sQ    
 01B1B')A)AC5++VT:  $":":::r   c               r   r   r   z#tuple[Atspi.Accessible | None, int]r   r   r   r   r   r      s      1T r   c                x    V P                   w  rRW.p\        P                  ! \        P                  VR4       W3# )zGReturns the penultimate cursor position as a tuple of (object, offset).z+FOCUS MANAGER: Penultimate cursor position:T)r    r   r+   r"   r#   r9   offsetr-      &   r   get_penultimate_cursor_positionZ,FocusManager.get_penultimate_cursor_position   s;     77?M5++VT:{r   c               r   rF   r   r   r   r   r   r      s      *M r   c                rG   )z@Returns the last cursor position as a tuple of (object, offset).z$FOCUS MANAGER: Last cursor position:T)r   r   r+   r"   rH   rJ   r   get_last_cursor_positionZ%FocusManager.get_last_cursor_position   s;     008#F5++VT:{r   c               s$    V ^8  d   QhRRRRRR/# )r   r9   r*   rI   intr   r   r   r   r   r   r   r      s#     1 1,C 1S 1UY 1r   c                s    RW.p\         P                  ! \         P                  VR4       V P                  V n        W3V n        R# )z=Sets the last cursor position as a tuple of (object, offset).z.FOCUS MANAGER: Setting last cursor position toTN)r   r+   r"   r   r    rH      &&& r   set_last_cursor_positionZ%FocusManager.set_last_cursor_position   s?     CCP5++VT:,0,F,F)%(["r   c               r   )r   r   ztuple[int, int]r   r   r   r   r   r      s      ? r   c                s    V P                   w  rRV RV 2p\        P                  ! \        P                  VR4       W3# )zDReturns the last known cell coordinates as a tuple of (row, column).z0FOCUS MANAGER: Last known cell coordinates: row=	, column=T)r   r   r!   r"   r#   rowcolumnr$   rJ   r   get_last_cell_coordinatesZ&FocusManager.get_last_cell_coordinates   sC     11@YvhWE,,c48{r   c               s$    V ^8  d   QhRRRRRR/# )r   rR   rM   rS   r   r   r   r   r   r   r   r      s!     2 2S 2# 2$ 2r   c                sr    RV RV 2p\         P                  ! \         P                  VR4       W3V n        R# )zASets the last known cell coordinates as a tuple of (row, column).z4FOCUS MANAGER: Setting last cell coordinates to row=rP   TN)r   r!   r"   r   rQ   rN   r   set_last_cell_coordinatesZ&FocusManager.set_last_cell_coordinates   s;     ESESYRZ[E,,c48&)k#r   c               r   r)   r   r   r   r   r   r      s      $; r   c                s    RV P                   .p\        P                  ! \        P                  VR4       V P                   # )zGReturns the current locus of focus (i.e. the object with visual focus).z FOCUS MANAGER: Locus of focus isT)r   r   r+   r"   rD   r3   r   get_locus_of_focusZFocusManager.get_locus_of_focus   s4     5dkkB5++VT:{{r   c          
     s,    V ^8  d   QhRRRRRRRRRR	/# )
r   eventzAtspi.Event | Noner9   r*   notify_scriptr0   forcer   r   r   r   r   r   r   r      sJ     QE QE!QE %QE 	QE
 QE 
QEr   c                s   RV.p\         P                  ! \         P                  VRR4       \        P                  ! V4      p\
        P                  ! W&R4       V'       g;   W P                  8X  d+   Rp\         P                  ! \         P                  VR4       R# \        P                  ! VRR7      w  rV P                  W4       V P                  V\        P                  ! V4      4       \        P                  ! V4       \        P                   ! V4       \"        P$                  ! 4       P'                  4       p
V'       d   V
'       d   V
P(                  '       gt   \        P*                  ! VP,                  4      p\"        P$                  ! 4       P/                  WP,                  4      p
\"        P$                  ! 4       P1                  V
R4       V P                  p\
        P2                  ! V4      '       d   RpVf2   Rp\         P                  ! \         P                  VR4       RV n        R# \
        P2                  ! V4      '       d.   R	VR
.p\         P                  ! \         P                  VR4       R# V
eJ   \
        P4                  ! V4      '       g.   R	VR.p\         P                  ! \         P                  VR4       R# RVRVRV.p\         P                  ! \         P                  VR4       W n        V'       g   R# V
f+   Rp\         P                  ! \         P                  VR4       R# V P7                  V\8        R7       V
P;                  WV P                  4       R# )z=Sets the locus of focus (i.e., the object with visual focus).z/FOCUS MANAGER: Request to set locus of focus toTzSetting locus of focus.z@FOCUS MANAGER: Setting locus of focus to existing locus of focusN)Z	find_cellzSetting locus of focusz9FOCUS MANAGER: New locus of focus is null (being cleared)z#FOCUS MANAGER: New locus of focus (z) is dead. Not updating.z) is invalid. Not updating.z+FOCUS MANAGER: Changing locus of focus fromr>   z	. Notify:zBFOCUS MANAGER: Cannot notify active script because there isn't one)r<   )r   r+   r"   r
   Zis_table_cellr   clear_cacher   r!   r   Zget_cell_coordinatesrU   rO   r	   Zget_caret_offsetZupdate_cached_selected_textZsave_object_info_for_eventsr   get_managerget_active_scriptappget_applicationZsource
get_scriptset_active_scriptr2   Zis_validrA   r?   Zlocus_of_focus_changed)r#   rW   r9   rX   rY   r-   Z	recursiver$   rR   rS   scriptr]   Z	old_focuss   &&&&&        r   set_locus_of_focusZFocusManager.set_locus_of_focus   s    DSI5++VT4@
  --c2	S-FG+TC 0 0#t< 223$G&&s3 	%%c6+B+B3+GH**3/ 	//4  ++-??AfVZZZ--ell;C#//1<<S,,OF&&(::6C[\KK	I&&I;MC 0 0#t<DKC  ;SB\]Fu//>$$S))?Fcd""5#3#3VTB?[-95++VT:>VC 0 0#t<  > :%%eDr   c               r   r/   r   r   r   r   r   r   >  s       r   c                s    \         P                  ! V P                  RR4       \        P                  ! V P                  4      pRV P                  RV.p\
        P                  ! \
        P                  VR4       V# )zKReturns True if the window we think is currently active is actually active.Fz,Ensuring the active window is really active.zFOCUS MANAGER:z
is active:T)r   rZ   r   r
   	is_activer   r+   r"   )r#   rc   r-   r%   r   active_window_is_activeZ$FocusManager.active_window_is_active>  s_     	T\\52`a))$,,7	"DLL,	J5++VT:r   c               r   r)   r   r   r   r   r   r   G  s      #: r   c                s    RV P                   .p\        P                  ! \        P                  VRR4       V P                   # )zJReturns the currently-active window (i.e. without searching or verifying).zFOCUS MANAGER: Active window isT)r   r   r+   r"   rD   r3   r   get_active_windowZFocusManager.get_active_windowG  s6     4T\\B5++VT4@||r   c          
     s,    V ^8  d   QhRRRRRRRRRR/# )	r   framer*   r]   set_window_as_focusr0   rX   r   r   r   r   r   r   r   r   N  sC     #X #X&#X %#X "	#X
 #X 
#Xr   c                s   RV.pVe   VP                  RV.4       \        P                  ! \        P                  VR4       WP                  8X  d*   Rp\        P
                  ! \        P                  VR4       MVf	   RV n        MWn        V'       d   V P                  RV P                  V4       MV P                  4       '       g   V P                  4       '       g   RV P                  RV P                  .p\        P                  ! \        P                  VRR4       \        P                  ! V P                  4      '       g   V P                  RV P                  RR7       \        P                  ! V P                  4      p\        P                  ! 4       P!                  W P                  4      p\        P                  ! 4       P#                  VR	4       R# )
zSets the active window.z.FOCUS MANAGER: Request to set active window toNZinTz>FOCUS MANAGER: Setting active window to existing active windowzFOCUS MANAGER: Focusz	is not in)rX   zSetting active window)Zextendr   r+   r"   r   r!   rb   r7   r8   r   r   Zhas_broken_ancestryr
   r^   r   r[   r_   r`   )r#   rf   r]   rg   rX   r-   r$   ra   s   &&&&&   r   set_active_windowZFocusManager.set_active_windowN  sU    CEJ?MM4+&5++VT:LL RC 0 0#t<]DL L##D$,,F--//43Q3Q3S3S,dkk;UFu//tD //<<''dll$'O))$++6++-88kkJ""$66v?VWr   c               (    V ^8  d   QhRRRRRRRR/# r   ra   zdefault.ScriptrW   zInputEvent | Nonenotify_userr0   r   r   r   r   r   r   r   t  s8     ^ ^^ !^ 	^
 
^r   c                s*    VP                  VRVR7      # )z?Switches between browse mode and focus mode (web content only).N)Zdocumentrk   )toggle_presentation_moder#   ra   rW   rk      &&&&r   rl   Z%FocusManager.toggle_presentation_modes  s     ..utQ\.]]r   c               ri   rj   r   r   r   r   r   r     s8     I II !I 	I
 
Ir   c                &    VP                  W#R7      # )zVSwitches between object mode and layout mode for line presentation (web content only).)rk   )toggle_layout_moderm   rn   r   rp   ZFocusManager.toggle_layout_mode~  s     (((HHr   c               ri   rj   r   r   r   r   r   r     s8     R RR !R 	R
 
Rr   c                ro   )z.Enables sticky browse mode (web content only).Zforce_message)enable_sticky_browse_moderm   rn   r   rr   Z&FocusManager.enable_sticky_browse_mode  s     ///QQr   c               ri   rj   r   r   r   r   r   r     s8     Q QQ !Q 	Q
 
Qr   c                ro   )z-Enables sticky focus mode (web content only).rq   )enable_sticky_focus_moderm   rn   r   rs   Z%FocusManager.enable_sticky_focus_mode  s     ..u.PPr   c               r   r/   r   r   r   r   r   r     s      D r   c                |    \         P                  ! 4       P                  4       ;p'       d   VP                  4       # R# )zUReturns True if layout mode (as opposed to object mode) is active (web content only).F)r   r[   r\   Zin_layout_moder#   ra   r3   r   get_in_layout_modeZFocusManager.get_in_layout_mode  s3     $//1CCEE6E((**r   c               r   r/   r   r   r   r   r   r     s      4 r   c                rt   )z8Returns True if focus mode is active (web content only).F)r   r[   r\   Zin_focus_moderu   r3   r   get_in_focus_modeZFocusManager.get_in_focus_mode  s3     $//1CCEE6E''))r   c               r   r/   r   r   r   r   r   r     s      $ r   c                rt   )zEReturns True if focus mode is active and 'sticky' (web content only).F)r   r[   r\   Zfocus_mode_is_stickyru   r3   r   get_focus_mode_is_stickyZ%FocusManager.get_focus_mode_is_sticky  s3     $//1CCEE6E..00r   c               r   r/   r   r   r   r   r   r     s      4 r   c                rt   )zFReturns True if browse mode is active and 'sticky' (web content only).F)r   r[   r\   Zbrowse_mode_is_stickyru   r3   r   get_browse_mode_is_stickyZ&FocusManager.get_browse_mode_is_sticky  s3     $//1CCEE6E//11r   )r   r   r   r   r   r    r   )r=   )NNN)TF)NFF)NT)%Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r&   r(   r.   r1   r4   r7   r8   rA   rC   rE   rK   rL   rO   rT   rU   rV   rb   rd   re   rh   r   Zcommandrl   rp   rr   rs   Zgetterrv   rw   rx   ry   Z__static_attributes__r   r   r   r   r   B   sI   2C
!+[
$+L,
;12QEf#XJ ^ ^ I I R R Q Q        r   r   _managerc               r   )r   r   r   r   r   r   r   r   r     s      \ r   c                 s    \         # )z$Returns the focus manager singleton.)r{   r   r   r   r[   r[     s    Or   )*__conditional_annotations__rz   Z
__future__r    Z__id__Z__version__Z__date__Z__copyright__Z__license__Ztypingr   ZgiZrequire_versionZgi.repositoryr   r=   r   r   r   r   Z	ax_objectr   Zax_tabler   Zax_textr	   Zax_utilitiesr
   Zinput_eventr   Zscriptsr   ZCARET_TRACKINGr?   r@   ZMOUSE_REVIEWZOBJECT_NAVIGATORrB   r   r{   Z__annotations__r[   )r|   s   @r   <module>r}      s   6 8 #7   	   7E "         %' !!% 
{ {z &, 'r   