[orca] Add brief delay before announcing "no focus"
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Add brief delay before announcing "no focus"
- Date: Sat, 7 Jul 2018 14:26:59 +0000 (UTC)
commit 111583b5e560d219188fc33c5188a963a754ddc3
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Jul 7 10:25:03 2018 -0400
Add brief delay before announcing "no focus"
src/orca/event_manager.py | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index f26f4fa6f..78eece94a 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -353,6 +353,24 @@ class EventManager:
if debug.debugEventQueue:
self._enqueueCount -= 1
+ def _isNoFocus(self):
+ if orca_state.locusOfFocus or orca_state.activeWindow or orca_state.activeScript:
+ return False
+
+ msg = 'EVENT MANAGER: No focus'
+ debug.println(debug.LEVEL_SEVERE, msg, True)
+ return True
+
+ def _onNoFocus(self):
+ if not self._isNoFocus():
+ return False
+
+ fullMessage = messages.NO_FOCUS
+ defaultScript = _scriptManager.getDefaultScript()
+ defaultScript.presentMessage(fullMessage, '')
+ _scriptManager.setActiveScript(defaultScript, 'No focus')
+ return False
+
def _dequeue(self):
"""Handles all events destined for scripts. Called by the GTK
idle thread."""
@@ -389,25 +407,9 @@ class EventManager:
% event.type)
debug.objEvent = None
- # [[[TODO: HACK - it would seem logical to only do this if we
- # discover the queue is empty, but this inroduces a hang for
- # some reason if done inside an acquire/release block for a
- # lock. So...we do it here.]]]
- #
- try:
- noFocus = not (orca_state.activeScript or orca_state.locusOfFocus)
- except:
- noFocus = True
-
self._gidleLock.acquire()
if self._eventQueue.empty():
- if noFocus:
- if self._gilSleepTime:
- time.sleep(self._gilSleepTime)
- fullMessage = messages.NO_FOCUS
- defaultScript = _scriptManager.getDefaultScript()
- defaultScript.presentMessage(fullMessage, '')
- _scriptManager.setActiveScript(defaultScript, 'No focus')
+ GLib.timeout_add(2500, self._onNoFocus)
self._gidleId = 0
rerun = False # destroy and don't call again
self._gidleLock.release()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]