grab/ungrab on ignorescreen, stop speech
This commit is contained in:
parent
101004a5f9
commit
eacb26f340
@ -110,7 +110,10 @@ class inputManager():
|
||||
def grabAllDevices(self):
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||
self.env['runtime']['inputDriver'].grabAllDevices()
|
||||
|
||||
def ungrabAllDevices(self):
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
|
||||
self.env['runtime']['inputDriver'].ungrabAllDevices()
|
||||
|
||||
def updateInputDevices(self):
|
||||
try:
|
||||
self.env['runtime']['inputDriver'].updateInputDevices()
|
||||
|
@ -228,8 +228,11 @@ class outputManager():
|
||||
offsetText = offsetText[offsetStart: offsetEnd]
|
||||
return offsetText
|
||||
def interruptOutput(self):
|
||||
self.env['runtime']['speechDriver'].cancel()
|
||||
self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO)
|
||||
try:
|
||||
self.env['runtime']['speechDriver'].cancel()
|
||||
self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO)
|
||||
except:
|
||||
pass
|
||||
|
||||
def clearFlushTime(self):
|
||||
self.setFlushTime(0.0)
|
||||
|
@ -10,7 +10,8 @@ import time, os, re, difflib
|
||||
|
||||
class screenManager():
|
||||
def __init__(self):
|
||||
pass
|
||||
self.currScreenIgnored = False
|
||||
self.prevScreenIgnored = False
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.env['runtime']['settingsManager'].loadDriver(\
|
||||
@ -40,15 +41,28 @@ class screenManager():
|
||||
self.update(eventData, 'onScreenChange')
|
||||
self.env['screen']['lastScreenUpdate'] = time.time()
|
||||
def handleScreenUpdate(self, eventData):
|
||||
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
|
||||
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
|
||||
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
|
||||
self.updateScreenIgnored()
|
||||
if self.getCurrScreenIgnored() != self.getPrevScreenIgnored():
|
||||
if self.getCurrScreenIgnored():
|
||||
self.env['runtime']['inputManager'].ungrabAllDevices()
|
||||
self.env['runtime']['outputManager'].interruptOutput()
|
||||
else:
|
||||
self.env['runtime']['inputManager'].grabAllDevices()
|
||||
if not self.getCurrScreenIgnored():
|
||||
self.update(eventData, 'onScreenUpdate')
|
||||
#if trigger == 'onUpdate' or self.isScreenChange() \
|
||||
# or len(self.env['screen']['newDelta']) > 6:
|
||||
# self.env['runtime']['screenDriver'].getCurrApplication()
|
||||
self.env['screen']['lastScreenUpdate'] = time.time()
|
||||
def getCurrScreenIgnored(self):
|
||||
return self.currScreenIgnored
|
||||
def getPrevScreenIgnored(self):
|
||||
return self.prevScreenIgnored
|
||||
def updateScreenIgnored(self):
|
||||
self.prevScreenIgnored = self.currScreenIgnored
|
||||
self.currScreenIgnored = self.isSuspendingScreen(self.env['screen']['newTTY'])
|
||||
def update(self, eventData, trigger='onUpdate'):
|
||||
|
||||
# set new "old" values
|
||||
self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes']
|
||||
self.env['screen']['oldContentText'] = self.env['screen']['newContentText']
|
||||
@ -60,6 +74,7 @@ class screenManager():
|
||||
self.env['screen']['oldAttribDelta'] = self.env['screen']['newAttribDelta']
|
||||
self.env['screen']['oldNegativeDelta'] = self.env['screen']['newNegativeDelta']
|
||||
self.env['screen']['newContentBytes'] = eventData['bytes']
|
||||
|
||||
# get metadata like cursor or screensize
|
||||
self.env['screen']['lines'] = int( eventData['lines'])
|
||||
self.env['screen']['columns'] = int( eventData['columns'])
|
||||
@ -135,7 +150,7 @@ class screenManager():
|
||||
if self.env['screen']['oldContentAttrib'] != self.env['screen']['newContentAttrib']:
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'):
|
||||
self.env['screen']['newAttribDelta'], self.env['screen']['newCursorAttrib'] = screen_utils.trackHighlights(self.env['screen']['oldContentAttrib'], self.env['screen']['newContentAttrib'], self.env['screen']['newContentText'], self.env['screen']['columns'])
|
||||
|
||||
|
||||
def formatAttributes(self, attribute, attributeFormatString = None):
|
||||
if not attributeFormatString:
|
||||
attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString')
|
||||
|
@ -40,6 +40,7 @@ class driver(inputDriver):
|
||||
self.iDevices = {}
|
||||
self.iDevicesFD = self._manager.list()
|
||||
self.uDevices = {}
|
||||
self.gDevices = {}
|
||||
self.iDeviceNo = 0
|
||||
self.watchDog = Value(c_bool, True)
|
||||
def initialize(self, environment):
|
||||
@ -116,8 +117,12 @@ class driver(inputDriver):
|
||||
def writeEventBuffer(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
for iDevice, uDevice, event in self.env['input']['eventBuffer']:
|
||||
self.writeUInput(uDevice, event)
|
||||
for iDevice, uDevice, event in self.env['input']['eventBuffer']:
|
||||
try:
|
||||
if self.gDevices[iDevice.fd]:
|
||||
self.writeUInput(uDevice, event)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
def clearEventBuffer(self):
|
||||
if not self._initialized:
|
||||
@ -240,7 +245,7 @@ class driver(inputDriver):
|
||||
if not self._initialized:
|
||||
return
|
||||
for fd in self.iDevices:
|
||||
self.grabDevice(fd)
|
||||
self.grabDevice(fd)
|
||||
def ungrabAllDevices(self):
|
||||
if not self._initialized:
|
||||
return
|
||||
@ -267,6 +272,7 @@ class driver(inputDriver):
|
||||
return
|
||||
try:
|
||||
self.iDevices[fd].grab()
|
||||
self.gDevices[fd] = True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('InputDriver evdev: grabing not possible: ' + str(e),debug.debugLevel.ERROR)
|
||||
def ungrabDevices(self,fd):
|
||||
@ -274,6 +280,7 @@ class driver(inputDriver):
|
||||
return
|
||||
try:
|
||||
self.iDevices[fd].ungrab()
|
||||
self.gDevices[fd] = False
|
||||
except:
|
||||
pass
|
||||
def removeDevice(self,fd):
|
||||
@ -298,7 +305,11 @@ class driver(inputDriver):
|
||||
del(self.uDevices[fd])
|
||||
except:
|
||||
pass
|
||||
self.updateMPiDevicesFD()
|
||||
try:
|
||||
del(self.gDevices[fd])
|
||||
except:
|
||||
pass
|
||||
self.MPiDevicesFD()
|
||||
|
||||
def hasIDevices(self):
|
||||
if not self._initialized:
|
||||
|
Loading…
Reference in New Issue
Block a user