From f231f72cbe692351fb23af0322885bf0cac4487e Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 3 Oct 2016 00:01:52 +0200 Subject: [PATCH] improve application detection and speed up --- src/fenrir-package/core/screenManager.py | 8 ++++---- src/fenrir-package/fenrir.py | 2 +- src/fenrir-package/inputDriver/evdev.py | 19 +++++++++++-------- src/fenrir-package/screenDriver/linux.py | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py index b86ee326..a7b0d278 100644 --- a/src/fenrir-package/core/screenManager.py +++ b/src/fenrir-package/core/screenManager.py @@ -21,12 +21,12 @@ class screenManager(): def shutdown(self): self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') - def update(self, trigger = 'onUpdate'): + def update(self, trigger='onUpdate'): self.env['runtime']['screenDriver'].getCurrScreen() - if not self.isSuspendingScreen(): - if trigger == 'onUpdate' or self.isScreenChange(): - self.env['runtime']['screenDriver'].getCurrApplication() + if not self.isSuspendingScreen(): self.env['runtime']['screenDriver'].update(trigger) + if trigger == 'onUpdate' or self.isScreenChange() or len(self.env['screenData']['newDelta']) > 6: + self.env['runtime']['screenDriver'].getCurrApplication() self.env['screenData']['lastScreenUpdate'] = time.time() def isSuspendingScreen(self): diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index a232d2b8..daf3bfb6 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -49,7 +49,7 @@ class fenrir(): if self.environment['input']['keyForeward'] > 0: self.environment['input']['keyForeward'] -=1 self.environment['runtime']['screenManager'].update('onInput') - self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') + self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') else: self.environment['runtime']['screenManager'].update('onUpdate') if self.environment['runtime']['applicationManager'].isApplicationChange(): diff --git a/src/fenrir-package/inputDriver/evdev.py b/src/fenrir-package/inputDriver/evdev.py index 55746dd7..317ed3f0 100644 --- a/src/fenrir-package/inputDriver/evdev.py +++ b/src/fenrir-package/inputDriver/evdev.py @@ -33,14 +33,17 @@ class driver(): r, w, x = select(self.iDevices, [], [], self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')) if r != []: for fd in r: - event = self.iDevices[fd].read_one() - self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) - if event.code != 0: - currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) - if not currMapEvent: - return currMapEvent - if currMapEvent['EventState'] in [0,1,2]: - return currMapEvent + while(True): + event = self.iDevices[fd].read_one() + if not event: + return None + self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) + if event.code != 0: + currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) + if not currMapEvent: + return currMapEvent + if currMapEvent['EventState'] in [0,1,2]: + return currMapEvent return None def writeEventBuffer(self): diff --git a/src/fenrir-package/screenDriver/linux.py b/src/fenrir-package/screenDriver/linux.py index fcb35af7..c0048dfb 100644 --- a/src/fenrir-package/screenDriver/linux.py +++ b/src/fenrir-package/screenDriver/linux.py @@ -71,7 +71,7 @@ class driver(): return xlist - def update(self, trigger='updateScreen'): + def update(self, trigger='onUpdate'): newContentBytes = b'' try: # read screen