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