forked from nvaccess/nvda
/
lockapp.py
99 lines (90 loc) · 4.33 KB
/
lockapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2015 NV Access Limited
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
import appModuleHandler
import controlTypes
import inputCore
import api
import eventHandler
import config
from NVDAObjects.UIA import UIA
from globalCommands import GlobalCommands
"""App module for the Windows 10 lock screen.
The lock screen runs as the logged in user on the default desktop,
so we need to explicitly stop people from accessing/changing things outside of the lock screen.
"""
# Windows 10 lock screen container
class LockAppContainer(UIA):
# Make sure the user can get to this so they can dismiss the lock screen from a touch screen.
presentationType=UIA.presType_content
class AppModule(appModuleHandler.AppModule):
def chooseNVDAObjectOverlayClasses(self,obj,clsList):
if isinstance(obj,UIA) and obj.role==controlTypes.ROLE_PANE and obj.UIAElement.cachedClassName=="LockAppContainer":
clsList.insert(0,LockAppContainer)
def event_NVDAObject_init(self, obj):
if obj.role == controlTypes.ROLE_WINDOW:
# Stop users from being able to object navigate out of the lock screen.
obj.parent = None
SAFE_SCRIPTS = {
GlobalCommands.script_reportCurrentFocus.__func__,
GlobalCommands.script_title.__func__,
GlobalCommands.script_dateTime.__func__,
GlobalCommands.script_say_battery_status.__func__,
GlobalCommands.script_navigatorObject_current.__func__,
GlobalCommands.script_navigatorObject_currentDimensions.__func__,
GlobalCommands.script_navigatorObject_toFocus.__func__,
GlobalCommands.script_navigatorObject_moveFocus.__func__,
GlobalCommands.script_navigatorObject_parent.__func__,
GlobalCommands.script_navigatorObject_next.__func__,
GlobalCommands.script_navigatorObject_previous.__func__,
GlobalCommands.script_navigatorObject_firstChild.__func__,
GlobalCommands.script_review_activate.__func__,
GlobalCommands.script_review_top.__func__,
GlobalCommands.script_review_previousLine.__func__,
GlobalCommands.script_review_currentLine.__func__,
GlobalCommands.script_review_nextLine.__func__,
GlobalCommands.script_review_bottom.__func__,
GlobalCommands.script_review_previousWord.__func__,
GlobalCommands.script_review_currentWord.__func__,
GlobalCommands.script_review_nextWord.__func__,
GlobalCommands.script_review_startOfLine.__func__,
GlobalCommands.script_review_previousCharacter.__func__,
GlobalCommands.script_review_currentCharacter.__func__,
GlobalCommands.script_review_nextCharacter.__func__,
GlobalCommands.script_review_endOfLine.__func__,
GlobalCommands.script_review_sayAll.__func__,
GlobalCommands.script_braille_scrollBack.__func__,
GlobalCommands.script_braille_scrollForward.__func__,
GlobalCommands.script_braille_routeTo.__func__,
GlobalCommands.script_braille_previousLine.__func__,
GlobalCommands.script_braille_nextLine.__func__,
GlobalCommands.script_navigatorObject_nextInFlow.__func__,
GlobalCommands.script_navigatorObject_previousInFlow.__func__,
GlobalCommands.script_touch_changeMode.__func__,
GlobalCommands.script_touch_newExplore.__func__,
GlobalCommands.script_touch_explore.__func__,
GlobalCommands.script_touch_hoverUp.__func__,
GlobalCommands.script_moveMouseToNavigatorObject.__func__,
GlobalCommands.script_moveNavigatorObjectToMouse.__func__,
GlobalCommands.script_leftMouseClick.__func__,
GlobalCommands.script_rightMouseClick.__func__,
}
def _inputCaptor(self, gesture):
script = gesture.script
if not script:
return True
# Only allow specific scripts so people can't touch the clipboard, change NVDA config, etc.
return script.__func__ in self.SAFE_SCRIPTS
def event_appModule_gainFocus(self):
inputCore.manager._captureFunc = self._inputCaptor
if not config.conf["reviewCursor"]["followFocus"]:
# Move the review cursor so others can't access its previous position.
self._oldReviewPos = api.getReviewPosition()
self._oldReviewObj = self._oldReviewPos.obj
api.setNavigatorObject(eventHandler.lastQueuedFocusObject, isFocus=True)
def event_appModule_loseFocus(self):
if not config.conf["reviewCursor"]["followFocus"]:
api.setReviewPosition(self._oldReviewPos)
del self._oldReviewPos, self._oldReviewObj
inputCore.manager._captureFunc = None