%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__/orca_modifier_manager.cpython-312.pyc

�

g
f�$����dZdZdZdZdZdZddlZddlZddlZddl	Z	e	jdd	�dd
lmZddl
mZdd
l
mZddl
mZddl
mZGd�d�Ze�Zd�Zy)zManages the Orca modifier key.z$Id$z
$Revision$z$Date$zGCopyright (c) 2023 Igalia, S.L.Copyright (c) 2023 GNOME Foundation Inc.�LGPL�N�Atspiz2.0)r�)�debug)�keybindings)�
orca_state)�settings_managerc�f�eZdZdZd�Zed��Zd�Zd�Zd�Z	d�Z
d�Zdd	�Zd
�Z
d�Zdd�Zd
�Zy)�OrcaModifierManagerzManages the Orca modifier.c�<�i|_d|_d|_d|_y)N�F)�_grabbed_modifiers�_original_xmodmap�_caps_lock_cleared�_need_to_restore_orca_modifier)�selfs �</usr/lib/python3/dist-packages/orca/orca_modifier_manager.py�__init__zOrcaModifierManager.__init__0s$��"$���"$���"'���.3��+�c�L�|tj�jd�vS)zAReturns True if modifier is one of the user's Orca modifier keys.�orcaModifierKeys)r	�
getManager�
getSetting)�modifiers r�is_orca_modifierz$OrcaModifierManager.is_orca_modifier8s%���+�6�6�8�C�C�DV�W�W�Wrc��||jvS)z7Returns True if there is an existing grab for modifier.)r�rrs  r�is_modifier_grabbedz'OrcaModifierManager.is_modifier_grabbed>s���4�2�2�2�2rc�v�tj�jd�D]}|j|��y)z4Adds grabs for all of the user's Orca modifier keys.rN)r	rr�add_modifier_grabrs  r�add_grabs_for_orca_modifiersz0OrcaModifierManager.add_grabs_for_orca_modifiersCs6��)�3�3�5�@�@�AS�T�	-�H��"�"�8�,�	-rc�v�tj�jd�D]}|j|��y)z6Remove grabs for all of the user's Orca modifier keys.rN)r	rr�remove_modifier_grabrs  r�remove_grabs_for_orca_modifiersz3OrcaModifierManager.remove_grabs_for_orca_modifiersIs6��)�3�3�5�@�@�AS�T�	0�H��%�%�h�/�	0rc�V�||jvrytj�)d}tjtj
|dd�yt
j�}tj|�|_
d|_tjj|�|j|<y)zAdds a grab for modifier.Nz;WARNING: Attempting to add modifier grabs without a device.Tr)
rr�devicer�printMessage�
LEVEL_WARNINGr�
KeyDefinitionr�
getKeycode�keycode�	modifiers�add_key_grab)rr�msg�kds    rr z%OrcaModifierManager.add_modifier_grabOs����t�.�.�.�����$�O�C����u�2�2�C��t�D��
�
 �
 �
"�� �+�+�H�5��
����,6�,=�,=�,J�,J�2�,N�����)rc��||jvrytj�)d}tjtj
|dd�ytjj
|j|�|j|=y)zRemoves the grab for modifier.Nz>WARNING: Attempting to remove modifier grabs without a device.T)rrr&rr'r(�remove_key_grab)rrr.s   rr#z(OrcaModifierManager.remove_modifier_grab_sp���4�2�2�2�����$�R�C����u�2�2�C��t�D�����)�)�$�*A�*A�(�*K�L��#�#�H�-rc��d}|r|d|��z
}tjtj|d�|j|�t	j
dtjddg�|_|j�y)z!Refreshes the Orca modifier keys.z0ORCA MODIFIER MANAGER: Refreshing Orca modifiers�: T�xkbcomp�DISPLAY�-N)
rr'�
LEVEL_INFO�unset_orca_modifiers�
subprocess�check_output�os�environr�_create_orca_xmodmap)r�reasonr.s   r�refresh_orca_modifiersz*OrcaModifierManager.refresh_orca_modifiersmst��A����R��x�=� �C�
���5�+�+�S�$�7��!�!�&�)�!+�!8�!8�)�R�Z�Z�PY�EZ�\_�9`�!a����!�!�#rc�B�d}tjtj|d�|j|j�r(t
jr|j�d|_y|jr)t
js|j�d|_yyy)zFUnsupported convenience method to call sad hacks which should go away.z'ORCA MODIFIER MANAGER: Updating key mapTNF)
rr'r7r�event_stringr�bypassNextCommandr8rr=)r�keyboard_eventr.s   r�update_key_mapz"OrcaModifierManager.update_key_mapys���
8��
���5�+�+�S�$�7�� � ��!<�!<�=�*�B^�B^��%�%�'�26�D�/���.�.�z�7S�7S��%�%�'�27�D�/�8T�.rc��d}tjtj|d�|jd�s|jd�r|j	d�d|_y|j
r|j	d�d|_yy)z?Makes an Orca-specific Xmodmap so that the Orca modifier works.z,ORCA MODIFIER MANAGER: Creating Orca xmodmapT�	Caps_Lock�
Shift_LockFN)rr'r7r�set_caps_lock_as_orca_modifierr)rr.s  rr=z(OrcaModifierManager._create_orca_xmodmap�sv��=��
���5�+�+�S�$�7�� � ��-��1F�1F�|�1T��/�/��5�&*�D�#�
�
$�
$��/�/��6�&+�D�#�%rc���d}|r|d|��z
}tjtj|d�|js(d}tjtj|d�yd|_tjddd	tjd
gt
jdd��}|j|j�d}tjtj|d�y)
z:Turns the Orca modifiers back into their original purpose.z=ORCA MODIFIER MANAGER: Attempting to restore original xmodmapr3Tz.ORCA MODIFIER MANAGER: No stored xmodmap foundNFr4�-w0r6r5��stdin�stdout�stderrz0ORCA MODIFIER MANAGER: Original xmodmap restored)rr'r7rrr9�Popenr;r<�PIPE�communicate)rr>r.�ps    rr8z(OrcaModifierManager.unset_orca_modifiers�s���N����R��x�=� �C�
���5�+�+�S�$�7��%�%�B�C����u�/�/��d�;��"'������i���R�Z�Z�	�5J�K��/�/�$�t�
=��	�
�
�d�,�,�-�@��
���5�+�+�S�$�7rc�<�d}tjtj|d�tjdtj
�}tjdtj
�}tjdtj
�}tjdtj
�}tjdtj
�}d}d	}	d
}
|jjd�jd�}d
}d
}
d
}t|�D]�\}}|s+|
s)|j|�rd}�|j|�s�0d}
�3|rH|r|j|�r |
||<d}n|j|�r|||<d}|jd�s�zd
}�}|
s��|r|j|�r |
||<d}n|j|�r|	||<d}|jd�s��d
}
��|r�d}tjtj|d�tjdddtjdgtj dd��}|j#t%dj'|�d��yd}tjtj|d�y)zCEnable or disable use of the caps lock key as an Orca modifier key.z=ORCA MODIFIER MANAGER: Setting caps lock as the Orca modifierTz=^\s*interpret\s+Caps[_+]Lock[_+]AnyOfOrNone\s*\(all\)\s*{\s*$zB^\s*action\s*=\s*LockMods\s*\(\s*modifiers\s*=\s*Lock\s*\)\s*;\s*$zL^\s*interpret\s+Shift[_+]Lock[_+]AnyOf\s*\(\s*Shift\s*\+\s*Lock\s*\)\s*{\s*$zC^\s*action\s*=\s*LockMods\s*\(\s*modifiers\s*=\s*Shift\s*\)\s*;\s*$z+^\s*action\s*=\s*NoAction\s*\(\s*\)\s*;\s*$z)        action= LockMods(modifiers=Lock);z*        action= LockMods(modifiers=Shift);z        action= NoAction();zUTF-8�
F�}z'ORCA MODIFIER MANAGER: Updating xmodmapr4rJr6r5NrKz+ORCA MODIFIER MANAGER: Not updating xmodmap)rr'r7�re�compile�Ir�decode�split�	enumerate�match�findr9rOr;r<rPrQ�bytes�join)r�enabler.�interpret_caps_line_prog�normal_caps_line_prog�interpret_shift_line_prog�normal_shift_line_prog�disabled_mod_line_prog�normal_caps_line�normal_shift_line�disabled_mod_line�lines�found_caps_interpret_section�found_shift_interpret_section�modified�i�linerRs                  rrHz2OrcaModifierManager.set_caps_lock_as_orca_modifier�s[��N��
���5�+�+�S�$�7�#%�:�:�L�b�d�d�$T� � "�
�
�Q�SU�SW�SW�!Y��$&�J�J�[�]_�]a�]a�%c�!�!#���R�TV�TX�TX�"Z��!#���:�B�D�D�"B��F��H��9���&�&�-�-�g�6�<�<�T�B��',�$�(-�%��� ��'�	:�G�A�t�/�8U�+�1�1�$�7�37�0�.�4�4�T�:�48�1�-��,�2�2�4�8�#4��a��#'��-�3�3�D�9�#3��a��#'���9�9�S�>�38�0�.��-�3�3�D�9�#4��a��#'��-�3�3�D�9�#4��a��#'���9�9�S�>�49�1�7	:�8�;�C����u�/�/��d�;�� � �)�U�C����I�9N�!O� �o�o�d�4�A�A�
�M�M�%��	�	�%� 0�'�:�;�?�C����u�/�/��d�;rN)r
)�__name__�
__module__�__qualname__�__doc__r�staticmethodrrr!r$r r#r?rDr=r8rH�rrrr-sS��$�4��X��X�
3�
-�0�O� .�
$�8�",�8�*;<rrc��tS)N)�_managerrtrrrr�s���Or)rr�__id__�__version__�__date__�
__copyright__�__license__r;rVr9�gi�require_version�
gi.repositoryrr
rrrr	rrvrrtrr�<module>rsn��,%�������;�
���	�	��	�����7�E�"������z<�z<�z� ��r

Zerion Mini Shell 1.0