%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/orca/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/orca/__pycache__/ax_component.cpython-312.pyc

�

g
fB8���dZdZdZdZdZdZddlZddlZejdd	�dd
l	m
Z
ddlmZdd
l
mZddlmZGd�d�Zy)a�
Utilities for obtaining position-related information about accessible objects.
These utilities are app-type- and toolkit-agnostic. Utilities that might have
different implementations or results depending on the type of app (e.g. terminal,
chat, web) or toolkit (e.g. Qt, Gtk) should be in script_utilities.py file(s).

N.B. There are currently utilities that should never have custom implementations
that live in script_utilities.py files. These will be moved over time.
z$Id$z
$Revision$z$Date$zGCopyright (c) 2024 Igalia, S.L.Copyright (c) 2024 GNOME Foundation Inc.�LGPL�N�Atspiz2.0)r�)�debug)�AXObject)�AXUtilitiesc��eZdZdZed��Zed��Zed��Zed��Zed��Z	ed��Z
ed��Zed	��Zed
��Z
ed��Zed��Zed
��Zed��Zed��Zedd��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zed��Zy)�AXComponentzNUtilities for obtaining position-related information about accessible objects.c��tj|�}|j|jdzz|j|j
dzzfS)z;Returns the center point of obj with respect to its window.�)r
�get_rect�x�width�y�height��obj�rects  �3/usr/lib/python3/dist-packages/orca/ax_component.py�get_center_pointzAXComponent.get_center_point5sA���#�#�C�(���v�v��
�
�Q��&�������q��(@�@�@�c�P�tj|�sy	tjj	|tj
j�}|j|jfS#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)zBReturns the x, y position tuple of obj with respect to its window.����r�(AXComponent: Exception in get_position: TN)
r�supports_componentr�	Component�get_position�	CoordType�WINDOW�	Exceptionr�printMessage�
LEVEL_INFOrr�r�point�error�msgs    rrzAXComponent.get_position<s����*�*�3�/��	��O�O�0�0��e�o�o�6L�6L�M�E��w�w��������	�<�U�G�D�C����u�/�/��d�;���	���8A(�(	B%�1*B � B%c�r�tj|�stj�S	tjj|tjj�}|S#t$rH}d|��}tjtj|d�tj�cYd}~Sd}~wwxYw)z9Returns the Atspi rect of obj with respect to its window.z$AXComponent: Exception in get_rect: TN)rrr�Rectr�get_extentsrr r!rr"r#)rrr&r's    rr
zAXComponent.get_rectLs����*�*�3�/��:�:�<��	 ��?�?�.�.�s�E�O�O�4J�4J�K�D�����	 �8���@�C����u�/�/��d�;��:�:�<���	 �s�8A%�%	B6�.=B1�+B6�1B6c�D�tj�}t|j|j|jzdz�}t|j|j|jzdz�}tt
|�jt
|���}t|j|j|jzdz�}t|j|j|jzdz�}tt
|�jt
|���}|rD|rB|d|_|d|_|d|jz
|_|d|jz
|_	d|d|d|g}	tjtj|	d�|S)z@Returns a rect representing the intersection of rect1 and rect2.rrrz AXComponent: The intersection of�andzis:T)
rr*�rangerr�sorted�set�intersectionrrr�printTokensr#)
�rect1�rect2�result�	x_points1�	x_points2�x_intersection�	y_points1�	y_points2�y_intersection�tokenss
          r�get_rect_intersectionz!AXComponent.get_rect_intersection\sH��������%�'�'�5�7�7�U�[�[�#8�1�#<�=�	��%�'�'�5�7�7�U�[�[�#8�1�#<�=�	���I�� ;� ;�C�	�N� K�L���%�'�'�5�7�7�U�\�\�#9�A�#=�>�	��%�'�'�5�7�7�U�\�\�#9�A�#=�>�	���I�� ;� ;�C�	�N� K�L���n�%�a�(�F�H�%�a�(�F�H�)�"�-����8�F�L�*�2�.����9�F�M�4�e�U�E�5�RX�Y��
���%�*�*�F�D�9��
rc�P�tj|�sy	tjj	|tj
j�}|j|jfS#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)zBReturns the width, height tuple of obj with respect to its window.rrTN)
rrrr�get_sizerr r!rr"r#rrr$s    rr?zAXComponent.get_sizets����*�*�3�/��	��O�O�,�,�S�%�/�/�2H�2H�I�E��w�w�������
�	�<�U�G�D�C����u�/�/��d�;���	�r(c�b�tj|�}|jxs|jS)z0Returns True if obj has a width and height of 0.�r
r
rrrs  r�has_no_sizezAXComponent.has_no_size�s*���#�#�C�(���:�:�,����-�-rc�T�tj|�}|js
|jsy|j|j
cxk(r%|jcxk(r|jcxk(rdk(ry|jdks|jdkr�d|d|g}t
jtj|d�tj|�tj|�}|jdks|jdkr(d}t
jtj|d�yy)zDReturns True if the rect associated with obj is sizeless or invalid.Trz	WARNING: zhas a broken rect:z0AXComponent: Clearing cache did not fix the rectF)r
r
rrrrrr2r#r�clear_cacher")rrr<r's    r�has_no_size_or_invalid_rectz'AXComponent.has_no_size_or_invalid_rect�s����#�#�C�(���
�
�d�k�k���6�6�T�V�V�>�t�z�z�>�T�[�[�>�B�>��?�
�J�J��O�t�{�{�R�/�!�3�(<�d�C�F����e�.�.���=�� � ��%��'�'��,�D��
�
�R��4�;�;��#3�H���"�"�5�#3�#3�S�$�?��rc��|jdk(xr1|jdk(xr |jdk(xr|jdk(S)z9Returns True if rect's x, y, width, and height are all 0.r�rrrr)rs r�
is_empty_rectzAXComponent.is_empty_rect�s;���v�v��{�S�t�v�v��{�S�t�z�z�Q��S�4�;�;�RS�CS�Src���|j|jk(xrO|j|jk(xr4|j|jk(xr|j|jk(S)z@Returns True if rect1 and rect2 represent the same bounding box.rG)r3r4s  r�is_same_rectzAXComponent.is_same_rect�sZ���w�w�%�'�'�!�-����5�7�7�"�-����u�{�{�*�-�������,�	-rc��tj|�sytj|�ry	tjj|||tjj�}d|d|�d|�d|��g}tjtj|d�|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)	z8Returns True if obj's rect contains the specified point.Fz1AXComponent: Exception in object_contains_point: TNz
AXComponent: zcontains point �, �: )
rr�is_bogusrr�containsrr r!rr"r#r2�rrrr5r&r'r<s       r�object_contains_pointz!AXComponent.object_contains_point�s����*�*�3�/�����S�!��	��_�_�-�-�c�1�a����9O�9O�P�F�"�3�/�!��B�q�c��F�8�(L�M��
���%�*�*�F�D�9��
���	�E�e�W�M�C����u�/�/��d�;���	�s�:B�	C�&*C�Cc��tjtj|�|�}tj|�S)zCReturns True if the Atspi.Rect associated with obj intersects rect.�r
r=r
rH)rrr1s   r�object_intersects_rectz"AXComponent.object_intersects_rect�s6��#�8�8��9M�9M�c�9R�TX�Y���,�,�\�:�:�:rc�F�tj|�}t|j�dkDst|j�dkDr+d|dg}tjt
j|d�y|jdk(s|jdk(r�tj|�s+d|dg}tjt
j|d�ytj|�r+d|dg}tjt
j|d�yd|d	g}tjt
j|d�y
|j|jzdkxr|j|jzdk}d|d|��g}tjt
j|d�|S)
z:Returns True if the rect associated with obj is off-screeni'zAXComponent: Treatingzas offscreen due to positionTrz(as offscreen due to size and no childrenz!as offscreen due to size and rolezAXComponent: Treating sizelesszas onscreenFzAXComponent:zis off-screen: )r
r
�absrrrr2r#rrr�get_child_countr�is_menu)rrr<r5s    r�object_is_off_screenz AXComponent.object_is_off_screen�sb���#�#�C�(���t�v�v�;���#�d�f�f�+��"5�-�s�4R�S�F����e�.�.���=���:�:��?�d�k�k�Q�.��+�+�C�0�1�3�8b�c���!�!�%�"2�"2�F�D�A���"�"�3�'�1�3�8[�\���!�!�%�"2�"2�F�D�A��6��]�K�F����e�.�.���=�����$�*�*�$�q�(�E�T�V�V�d�k�k�-A�A�-E�� �#����'A�B��
���%�*�*�F�D�9��
rc�z�tjtj|�tj|��S)z1Returns True if obj1 and obj2 have the same rect.)r
rJr
)�obj1�obj2s  r�objects_have_same_rectz"AXComponent.objects_have_same_rect�s.���'�'��(<�(<�T�(B�;�CW�CW�X\�C]�^�^rc��tjtj|�tj|��}tj|�S)z@Returns True if the rects associated with obj1 and obj2 overlap.rS)r[r\r1s   r�objects_overlapzAXComponent.objects_overlap�sD��#�8�8�� � ��&��(<�(<�T�(B�D���,�,�\�:�:�:rc��tj|�d}tj|�d}t||z
�|kS)zNReturns True if obj1 and obj2 are on the same line based on the center points.r)r
rrV)r[r\�delta�	y1_center�	y2_centers     r�on_same_linezAXComponent.on_same_line�sC�� �0�0��6�q�9�	��0�0��6�q�9�	��9�y�(�)�U�2�2rc���tj|�stj|�rytj	|�}|j
dkDxr|jdkDS)zLReturns True if obj's rect is expected to include the rects of its children.Fr)rrX�is_page_tabr
r
rrrs  r� _object_bounds_includes_childrenz,AXComponent._object_bounds_includes_childrensM�����s�#�{�'>�'>�s�'C���#�#�C�(���z�z�A�~�1�$�+�+��/�1rc���tj|�D]O}tj|�r�tj|�D]}tj	|||�s�|ccS�Qy)zGChecks each child to see if it has a descendant at the specified point.N)r�
iter_childrenr
rgrQ�rrr�child�
descendants     r�_find_descendant_at_pointz%AXComponent._find_descendant_at_point
sf���+�+�C�0�	&�E��;�;�E�B��&�4�4�U�;�
&�
��4�4�Z��A�F�%�%�
&�	&�rc��tj|�sy	tjj	|||tj
j�}d|d|�d|�d�|g}tjtj|d�|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)zAReturns the child (or descendant?) of obj at the specified point.Nz.AXComponent: Exception in get_child_at_point: TzAXComponent: Child of�at rL� is)rrrr�get_accessible_at_pointrr r!rr"r#r2rPs       r�_get_object_at_pointz AXComponent._get_object_at_points����*�*�3�/��	��_�_�<�<�S�!�Q����H^�H^�_�F�*�3�#�a�S��1�#�S�0A�6�J��
���%�*�*�F�D�9��
���	�B�5�'�J�C����u�/�/��d�;���	���:B�	C�*B>�>Cc��tj|||�}|�4tj|||�rtj|||�}|�|S|}||k(st	j
|�s|Stj
|||�S)�=Returns the deepest descendant of obj at the specified point.)r
rrrQrmrrW�_get_descendant_at_pointrjs     rrvz$AXComponent._get_descendant_at_point(s����0�0��a��;���=�[�>�>�s�A�q�I�$�>�>�s�A�q�I�J��!��
��E��C�<�x�7�7��>��L��3�3�E�1�a�@�@rc��tj|||�}d|d|�d|�d�|g}tjtj|d�|S)ruzAXComponent: Descendant ofrorLrpT)r
rvrr2r#)rrrr5r<s     r�get_descendant_at_pointz#AXComponent.get_descendant_at_point8sR���5�5�c�1�a�@��.��s�1�#�R��s�#�5F��O��
���%�*�*�F�D�9��
rc��tj|�sy	tjj	|tj
j||�}d|d|�d|�d�|g}tjtj|d�|S#t$r4}d|��}tjtj|d�Yd}~yd}~wwxYw)	z.Attempts to scroll obj to the specified point.Fz2AXComponent: Exception in scroll_object_to_point: TN�AXComponent: Scrolledzto rL�:)rrrr�scroll_to_pointrr r!rr"r#r2rPs       r�scroll_object_to_pointz"AXComponent.scroll_object_to_pointAs����*�*�3�/��	��_�_�4�4�S�%�/�/�:P�:P�RS�UV�W�F�*�3�#�a�S��1�#�Q���H��
���%�*�*�F�D�9��
���	�F�u�g�N�C����u�/�/��d�;���	�rsc�R�tj|�sy	tjj	||�}d|d|d|��g}t
jtj|d�|S#t
$r4}d|��}t
jtj|d�Yd}~yd}~wwxYw)zBAttempts to scroll obj to the specified Atspi.ScrollType location.Fz5AXComponent: Exception in scroll_object_to_location: TNrz�torM)
rrrr�	scroll_tor!rr"r#r2)r�locationr5r&r'r<s      r�scroll_object_to_locationz%AXComponent.scroll_object_to_locationSs����*�*�3�/��	��_�_�.�.�s�H�=�F�*�3��h�"�V�H�
�N��
���%�*�*�F�D�9��
���	�I�%��Q�C����u�/�/��d�;���	�s� A)�)	B&�2*B!�!B&c�H�d�}t|tj|���S)z0Returns objects sorted from smallest to largest.c��tj|�}tj|�}|j|jz|j|jzz
S)NrA)r[r\r3r4s    r�_size_comparisonz:AXComponent.sort_objects_by_size.<locals>._size_comparisonisG���(�(��.�E��(�(��.�E��K�K�%�,�,�.�5�;�;����3M�N�Nr��key�r/�	functools�
cmp_to_key)�objectsr�s  r�sort_objects_by_sizez AXComponent.sort_objects_by_sizees#��	O�
�g�9�#7�#7�8H�#I�J�Jrc�H�d�}t|tj|���S)z5Returns objects sorted from top-left to bottom-right.c��tj|�}tj|�}|j|jz
xs|j|jz
}|sVt	j
|�t	j
|�k(r+t	j|�t	j|�z
}t|d�}t|d�}|S)Nrr)	r
r
rrr�
get_parent�get_index_in_parent�max�min)r[r\r3r4�rvs     r�_spatial_comparisonzAAXComponent.sort_objects_by_position.<locals>._spatial_comparisonts����(�(��.�E��(�(��.�E����5�7�7�"�7�e�g�g����&7�B��(�-�-�d�3�x�7J�7J�4�7P�P��1�1�$�7�(�:V�:V�W[�:\�\���R���B��R���B��Irr�r�)r�r�s  r�sort_objects_by_positionz$AXComponent.sort_objects_by_positionps"��	��g�9�#7�#7�8K�#L�M�MrN)r)�__name__�
__module__�__qualname__�__doc__�staticmethodrrr
r=r?rBrErHrJrQrTrYr]r_rdrgrmrrrvrxr}r�r�r��rrr
r
2s���X��A��A��
 ��
 ��
��
�����.� �� � �.��.�����,�T��T�
�-��-�����(�;��;�����6�_��_�
�;��;��3��3��2��2��	��	�����"�
A��
A���������"����"�K��K��N��Nrr
)r��__id__�__version__�__date__�
__copyright__�__license__r��gi�require_version�
gi.repositoryr�r�	ax_objectr�ax_utilitiesrr
r�rr�<module>r�sY��,�������;�
����	�����7�E�"����%�PN�PNr

Zerion Mini Shell 1.0