+
    Qi>  c                   s    R t RtRtRtRtRt^ RI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 R4      tR# )NUtilities for obtaining position-related information about accessible objects.z$Id$z
$Revision$z$Date$zGCopyright (c) 2024 Igalia, S.L.Copyright (c) 2024 GNOME Foundation Inc.ZLGPLNAtspiz2.0)r   )GLib)debug)AXObject)AXUtilitiesRolec                   s  a  ] tR t^-t o Rt]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR	 l4       t	]V 3R
 lR l4       t
]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       t]R4V 3R lR ll4       t]V 3R  lR! l4       t]V 3R" lR# l4       t]V 3R$ lR% l4       t]V 3R& lR' l4       t]V 3R( lR) l4       t]V 3R* lR+ l4       t]V 3R, lR- l4       t]V 3R. lR/ l4       t]V 3R0 lR1 l4       tR2tV tR3# )5AXComponentr    c                P   < V ^8  d   QhRS[ P                  RS[S[S[3,          /#    objreturn)r   
AccessibletupleZfloatformat__classdict__   "6/usr/lib/python3.14/site-packages/orca/ax_component.py__annotate__AXComponent.__annotate__1   s.     A Ae.. A53F A    c                s    \         P                  V 4      pVP                  VP                  ^,          ,           VP                  VP
                  ^,          ,           3# )z;Returns the center point of obj with respect to its window.)r   get_rectxwidthyheightr
   rect   & r   get_center_pointZAXComponent.get_center_point0   sA     ##C(vv

Q&q(@@@r   c                r   r   r   r   r   intr   r   r   r   r   8   s)        %**  uS#X  r   c                   \         P                  ! V 4      '       g   R#  \        P                  P	                  V \        P
                  P                  4      pTf-   RT .p\        P                  ! \        P                  TR4       R# TP                  TP                  3#   \        P                   d8   pRT 2p\        P                  ! \        P                  TR4       Ru Rp?# Rp?ii ; i)zBReturns the x, y position tuple of obj with respect to its window.(AXComponent: Exception in get_position: TNz$AXComponent: get_position failed forr$   )r   supports_componentr   	Componentget_position	CoordTypeWINDOWr   GErrorr   print_message
LEVEL_INFOprint_tokensr   r   r
   Zpointerrormsgtokens   &    r   r'   ZAXComponent.get_position7   s     **3//M	OO00eoo6L6LME =<cBFu//>Mww {{ 	<UGDC 0 0#t<M	   8B   C,5,C'!C,'C,c                sN   < V ^8  d   QhRS[ P                  RS[ P                  /# r   )r   r   Rectr   r   r   r   r   M   s%      e&& 5:: r   c                s   \         P                  ! V 4      '       g   \        P                  ! 4       #  \        P                  P                  V \        P                  P                  4      pV#   \        P                   dK   pRT 2p\        P                  ! \        P                  TR4       \        P                  ! 4       u Rp?# Rp?ii ; i)z9Returns the Atspi rect of obj with respect to its window.z$AXComponent: Exception in get_rect: TN)r   r%   r   r4   r&   Zget_extentsr(   r)   r   r*   r   r+   r,   )r
   r   r/   r0      &   r   r   ZAXComponent.get_rectL   s     **3//::<	 ??..sEOO4J4JKD  {{ 	 8@C 0 0#t<::<	 s   8A- -C?CCCc                sh   < V ^8  d   QhRS[ P                  RS[ P                  RS[ P                  /# r	   rect1rect2r   )r   r4   r   r   r   r   r   ]   s.      UZZ 

 uzz r   c                sx   \         P                  ! 4       p\        V P                  VP                  4      p\        V P                  VP                  4      p\        V P                  V P                  ,           VP                  VP                  ,           4      p\        V P                  V P                  ,           VP                  VP                  ,           4      pWS8  d-   Wd8  d'   W2n        WBn        WS,
          Vn        Wd,
          Vn        RV RVRV.p\        P                  ! \        P                  VR4       V# )z@Returns a rect representing the intersection of rect1 and rect2.z AXComponent: The intersection ofZandzis:T)r   r4   maxr   r   minr   r   r   r-   r,   )r7   r8   resultZdest_xZdest_yZdest_x2Zdest_y2r1   s   &&      r   get_rect_intersectionZ!AXComponent.get_rect_intersection\   s     UWWegg&UWWegg&egg+UWWu{{-BCegg,egg.DE!2HH"+FL#,FM4eUE5RXY5++VT:r   c                r   r   r   r   r   r   r   r   r   s)        e&&  5c?  r   c                r!   )zBReturns the width, height tuple of obj with respect to its window.r"   TNz AXComponent: get_size failed forr#   )r   r%   r   r&   get_sizer(   r)   r   r*   r   r+   r,   r-   r   r   r.   r2   r   r=   ZAXComponent.get_sizeq   s     **3//M	OO,,S%//2H2HIE =8#>Fu//>M ww {{ 	<UGDC 0 0#t<M	r3   c                :   < V ^8  d   QhRS[ P                  RS[/# r   r   r   boolr   r   r   r   r      s!     . .)) .d .r   c                sv    \         P                  V 4      pVP                  ;'       g    VP                  '       * # )z0Returns True if obj has a width and height of 0.r   r   r   r   r   r   r   has_no_sizeZAXComponent.has_no_size   s-     ##C(::,,--r   c                r>   r   r?   r   r   r   r   r      s!      )9)9 d r   c                s   \         P                  V 4      pVP                  '       g   VP                  '       g   R# VP                  VP
                  u;8X  d.   VP                  u;8X  d   VP                  u;8X  d
   R8X  d    R#  VP                  R8  g   VP                  R8  d   RV RV.p\        P                  ! \        P                  VR4       \        P                  ! V 4       \         P                  V 4      pVP                  R8  g   VP                  R8  d+   Rp\        P                  ! \        P                  VR4       R# R# )zDReturns True if the rect associated with obj is sizeless or invalid.Tz	WARNING: zhas a broken rect:z0AXComponent: Clearing cache did not fix the rectFr$   )r   r   r   r   r   r   r   r-   r,   r   Zclear_cacher+   )r
   r   r1   r0   r5   r   has_no_size_or_invalid_rectZ'AXComponent.has_no_size_or_invalid_rect   s     ##C(


dkkk66TVV>tzz>T[[>B> ? JJOt{{R/!3(<dCFu//>  %'',D

R4;;#3H##E$4$4c4@r   c                r>   )r	   r   r   r   r4   r@   r   r   r   r   r      s#     T TEJJ T4 Tr   c                s    V P                   ^ 8H  ;'       d>    V P                  ^ 8H  ;'       d'    V P                  ^ 8H  ;'       d    V P                  ^ 8H  # )z9Returns True if rect's x, y, width, and height are all 0.r   r   r   r   )r   s   &r   is_empty_rectZAXComponent.is_empty_rect   sD     vv{SStvv{SStzzQSS4;;RSCSSr   c                T   < V ^8  d   QhRS[ P                  RS[ P                  RS[/# r6   rD   r   r   r   r   r      s*     - -EJJ -uzz -d -r   c                s    V P                   VP                   8H  ;'       d\    V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P                  VP                  8H  # )z@Returns True if rect1 and rect2 represent the same bounding box.rE   )r7   r8      &&r   is_same_rectZAXComponent.is_same_rect   si     ww%''! - -577"- -u{{*- - ,	-r   c                F   < V ^8  d   QhRS[ P                  RS[RS[RS[/# r	   r
   r   r   r   r   r   r    r@   r   r   r   r   r      s/      5#3#3    r   c                s   \         P                  ! V 4      '       g   R# \         P                  ! V 4      '       d   R#  \        P                  P                  WV\        P                  P                  4      pRT RT RT RT 2.p\        P                  ! \        P                  TR4       T#   \        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)	z8Returns True if obj's rect contains the specified point.Fz1AXComponent: Exception in object_contains_point: TNzAXComponent: zcontains point , : )r   r%   Zis_bogusr   r&   Zcontainsr(   r)   r   r*   r   r+   r,   r-   r
   r   r   r;   r/   r0   r1      &&&    r   object_contains_pointZ!AXComponent.object_contains_point   s     **3//S!!	__--ca9O9OPF "3/!BqcF8(LM5++VT: {{ 	EeWMC 0 0#t<	s   9B- -C8+C33C8c                T   < V ^8  d   QhRS[ P                  RS[ P                  RS[/# )r	   r
   r   r   )r   r   r4   r@   r   r   r   r   r      s,     ; ;E$4$4 ;EJJ ;4 ;r   c                s    \         P                  \         P                  V 4      V4      p\         P                  V4      '       * # )zCReturns True if the Atspi.Rect associated with obj intersects rect.r   r<   r   rF   )r
   r   intersection   && r   object_intersects_rectZ"AXComponent.object_intersects_rect   s6     #889M9Mc9RTXY,,\:::r   c                r>   r   r?   r   r   r   r   r      s!      %"2"2 t r   c                s   \         P                  V 4      p\        VP                  4      R8  g   \        VP                  4      R8  d.   RV R.p\
        P                  ! \
        P                  VR4       R# VP                  ^ 8X  g   VP                  ^ 8X  d   \        P                  ! V 4      '       g.   RV R.p\
        P                  ! \
        P                  VR4       R# \        P                  ! V 4      '       d.   RV R.p\
        P                  ! \
        P                  VR4       R# RV R.p\
        P                  ! \
        P                  VR4       R	# VP                  VP                  ,           ^ 8  ;'       d!    VP                  VP                  ,           ^ 8  pR
V RV 2.p\
        P                  ! \
        P                  VR4       V# )z:Returns True if the rect associated with obj is off-screeni'  zAXComponent: Treatingzas offscreen due to positionTz(as offscreen due to size and no childrenz!as offscreen due to size and rolezAXComponent: Treating sizelesszas onscreenFzAXComponent:zis off-screen: )r   r   absr   r   r   r-   r,   r   r   r   get_child_countr   is_menu)r
   r   r1   r;   r5   r   object_is_off_screenZ AXComponent.object_is_off_screen   sk    ##C(tvv;#dff+"5-s4RSFu//>::?dkkQ.++C00138bc""5#3#3VTB&&s++138[\""5#3#3VTB6]KFu//>$**$q(EETVVdkk-AA-E #'AB5++VT:r   c                rG   r	   obj1obj2r   r?   r   r   r   r   r      s4     _ _U%5%5 _U=M=M _RV _r   c                sz    \         P                  \         P                  V 4      \         P                  V4      4      # )z1Returns True if obj1 and obj2 have the same rect.)r   rI   r   )r\   r]   rH   r   objects_have_same_rectZ"AXComponent.objects_have_same_rect   s.     ''(<(<T(B;CWCWX\C]^^r   c                rG   r[   r?   r   r   r   r   r      s.     ; ;e.. ;e6F6F ;4 ;r   c                s    \         P                  \         P                  V 4      \         P                  V4      4      p\         P                  V4      '       * # )z@Returns True if the rects associated with obj1 and obj2 overlap.rS   )r\   r]   rT   rU   r   objects_overlapZAXComponent.objects_overlap   sD     #88  &(<(<T(BD,,\:::r   c                sZ   < V ^8  d   QhRS[ P                  RS[ P                  RS[RS[/# )r	   r\   r]   deltar   rL   r   r   r   r   r      s6      5++ 53C3C C X\ r   c                s   \         P                  V 4      p\         P                  V4      pVP                  VP                  ^,          ,           pVP                  VP                  ^,          ,           p\	        WV,
          4      V8  d   R# \        VP                  VP                  4      p\        VP                  VP                  4      pV^ 8  d   W,          R8  d   R# R# )z3Returns True if obj1 and obj2 are on the same line.Fg       @T)r   r   r   r   rW   r:   r9   )	r\   r]   r`   r7   r8   Z	y1_centerZ	y2_centerZ
min_heightZ
max_heights	   &&&      r   on_same_lineZAXComponent.on_same_line   s     $$T*$$T*GGellQ..	GGellQ..	 y$%- u||4
u||4
>j5;r   c                r>   r   r?   r   r   r   r   r     s!     2 2e.>.> 24 2r   c                s    \         P                  ! V 4      '       g   \         P                  ! V 4      '       d   R# \        P	                  V 4      pVP
                  ^ 8  ;'       d    VP                  ^ 8  # )zLReturns True if obj's rect is expected to include the rects of its children.F)r   rY   Zis_page_tabr   r   r   r   r   r   r    _object_bounds_includes_childrenZ,AXComponent._object_bounds_includes_children  sV     ""3''?+F+Fs+K+K##C(zzA~11$++/1r   c          	      h   < V ^8  d   QhRS[ P                  RS[RS[RS[ P                  R,          /# r	   r
   r   r   r   Nr   r   r    r   r   r   r   r     s>      "%*-			D	 r   c                s    \         P                  ! V 4       F_  p\        P                  V4      '       d   K   \         P                  ! V4       F%  p\        P	                  WAV4      '       g   K!  Vu u # 	  Ka  	  R# )zGChecks each child to see if it has a descendant at the specified point.N)r   Ziter_childrenr   rb   rQ   )r
   r   r   child
descendant   &&&  r   _find_descendant_at_pointZ%AXComponent._find_descendant_at_point  s`     ++C0E;;EBB&44U;
44ZAFF%% < 1 r   c          	      rc   rd   re   r   r   r   r   r   (  s;      %"2"2 s s uGWGWZ^G^ r   c                s   \         P                  ! V 4      '       g   R#  \        P                  P	                  WV\        P
                  P                  4      pRT RT RT R2T.p\        P                  ! \        P                  TR4       T#   \        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)zAReturns the child (or descendant?) of obj at the specified point.Nz.AXComponent: Exception in get_child_at_point: TzAXComponent: Child ofat rM    is)r   r%   r   r&   Zget_accessible_at_pointr(   r)   r   r*   r   r+   r,   r-   rO   rP   r   _get_object_at_pointZ AXComponent._get_object_at_point'  s     **3//	__<<SQH^H^_F *3#aS1#S0A6J5++VT: {{ 	B5'JC 0 0#t<	   9B C#+CCc          	      rc   rd   re   r   r   r   r   r   :  s>      "%*-			D	 r   c                sn   \         P                  WV4      pVf;   \         P                  WV4      '       d   \         P                  WV4      pVf   V # TpW08X  g   \        P
                  ! V4      '       g   V# \         P                  W1V4      pV'       d   \        P                  ! V4      '       g   V# V# )=Returns the deepest descendant of obj at the specified point.)r   rl   rQ   ri   r   rX   _get_descendant_at_pointZis_dead)r
   r   r   rf   rg   r;   s   &&&   r   ro   Z$AXComponent._get_descendant_at_point9  s     00;=[>>sqII$>>sqIJ!
E<x77>>L55eB(**622Mr   c          	      rc   rd   re   r   r   r   r   r   O  s>      "%*-			D	 r   c                s    \         P                  WV4      pRV RV RV R2V.p\        P                  ! \        P                  VR4       V# )rn   zAXComponent: Descendant ofrj   rM   rk   T)r   ro   r   r-   r,   )r
   r   r   r;   r1   rh   r   get_descendant_at_pointZ#AXComponent.get_descendant_at_pointN  sP     55ca@.s1#Rs#5FO5++VT:r   c                rJ   rK   rL   r   r   r   r   r   Z  s/      E$4$4    r   c                s   \         P                  ! V 4      '       g   R#  \        P                  P	                  V \        P
                  P                  W4      pRT RT RT R2T.p\        P                  ! \        P                  TR4       T#   \        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)	z.Attempts to scroll obj to the specified point.Fz2AXComponent: Exception in scroll_object_to_point: TNAXComponent: Scrolledzto rM   Z:)r   r%   r   r&   Zscroll_to_pointr(   r)   r   r*   r   r+   r,   r-   rO   rP   r   scroll_object_to_pointZ"AXComponent.scroll_object_to_pointY  s     **3//	__44S%//:P:PRSWF *3#aS1#QH5++VT: {{ 	FugNC 0 0#t<	rm   c                rR   )r	   r
   locationr   )r   r   Z
ScrollTyper@   r   r   r   r   r   l  s/      u'7'7 5CSCS X\ r   c                s~   \         P                  ! V 4      '       g   R#  \        P                  P	                  W4      pRT RTRT 2.p\        P                  ! \        P                  TR4       T#   \
        P                   d7   pRT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)zBAttempts to scroll obj to the specified Atspi.ScrollType location.Fz5AXComponent: Exception in scroll_object_to_location: TNrq   ZtorN   )r   r%   r   r&   Z	scroll_tor   r*   r   r+   r,   r-   )r
   rs   r;   r/   r0   r1   s   &&    r   scroll_object_to_locationZ%AXComponent.scroll_object_to_locationk  s     **3//	__..s=F *3h"VHN5++VT: {{ 	I%QC 0 0#t<	s   A1 1B<+B77B<c                n   < V ^8  d   QhRS[ S[P                  ,          RS[ S[P                  ,          /# r	   objectsr   Zlistr   r   r   r   r   r   r   ~  s5     K Kd5+;+;&< KeFVFVAW Kr   c                P    R R lp\        V \        P                  ! V4      R7      # )z0Returns objects sorted from smallest to largest.c                d    V ^8  d   QhR\         P                  R\         P                  R\        /# r[   re   r      "r   r   Z6AXComponent.sort_objects_by_size.<locals>.__annotate__  s3     	O 	O5#3#3 	O5;K;K 	OPS 	Or   c                 s    \         P                  V 4      p\         P                  V4      pVP                  VP                  ,          VP                  VP                  ,          ,
          # )NrA   )r\   r]   r7   r8   s   &&  r   _size_comparisonZ:AXComponent.sort_objects_by_size.<locals>._size_comparison  sG    ((.E((.EKK%,,.5;;3MNNr   ZkeyZsorted	functoolsZ
cmp_to_key)rw   r}   r   r   sort_objects_by_sizeZ AXComponent.sort_objects_by_size}  s#    	O
 g9#7#78H#IJJr   c                ru   rv   rx   r   r   r   r   r     s5     N N$u/?/?*@ NT%JZJZE[ Nr   c                ry   )z5Returns objects sorted from top-left to bottom-right.c                rz   r[   re   r{   r|   r   r   Z:AXComponent.sort_objects_by_position.<locals>.__annotate__  s.     	 	e&6&6 	e>N>N 	SV 	r   c                 s   \         P                  V 4      p\         P                  V4      pVP                  VP                  ,
          ;'       g    VP                  VP                  ,
          pV'       ga   \        P
                  ! V 4      \        P
                  ! V4      8X  d2   \        P                  ! V 4      \        P                  ! V4      ,
          p\        VR4      p\        V^4      pV# )i   r$   )	r   r   r   r   r   Z
get_parentZget_index_in_parentr9   r:   )r\   r]   r7   r8   Zrvs   &&   r   _spatial_comparisonZAAXComponent.sort_objects_by_position.<locals>._spatial_comparison  s    ((.E((.E577"77egg&7B (--d3x7J7J47PP11$7(:V:VW[:\\RBRBIr   r~   r   )rw   r   r   r   sort_objects_by_positionZ$AXComponent.sort_objects_by_position  s"    	 g9#7#78K#LMMr    N)i    ) Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__Zstaticmethodr   r'   r   r<   r=   rB   rC   rF   rI   rQ   rV   rZ   r^   r_   ra   rb   ri   rl   ro   rp   rr   rt   r   r   Z__static_attributes__Z__classdictcell__)r   s   @r   r   r   -   s    XA A    (    (    * . .  , T T
 - -  ( ; ;  6 _ _
 ; ;   ( 2 2    "  (    "  " K K N Nr   r   )r   Z__id__Z__version__Z__date__Z__copyright__Z__license__r   ZgiZrequire_versionZgi.repositoryr   r   Z r   Z	ax_objectr   Zax_utilities_roler   r   r   r   r   <module>r      sY   0 U;  	   7E "     .mN mNr   