|
1 | 1 | # A part of NonVisual Desktop Access (NVDA) |
2 | | -# Copyright (C) 2009-2018 NV Access Limited, Aleksey Sadovoy, James Teh, Joseph Lee, Tuukka Ojala |
3 | | -# This file may be used under the terms of the GNU General Public License, version 2 or later. |
4 | | -# For more details see: https://www.gnu.org/licenses/gpl-2.0.htmlimport appModuleHandler |
| 2 | +# Copyright (C) 2009-2020 NV Access Limited, Aleksey Sadovoy, James Teh, Joseph Lee, Tuukka Ojala |
| 3 | +# This file is covered by the GNU General Public License. |
| 4 | +# See the file COPYING for more details. |
5 | 5 |
|
| 6 | +import appModuleHandler |
6 | 7 | import calendar |
7 | 8 | import collections |
8 | 9 | import time |
9 | | - |
10 | 10 | import api |
11 | | -import appModuleHandler |
| 11 | +from NVDAObjects.IAccessible import getNVDAObjectFromEvent |
12 | 12 | import ui |
| 13 | +import windowUtils |
| 14 | +import winUser |
13 | 15 |
|
14 | 16 | # A named tuple for holding the elapsed and total playing times from Foobar2000's status bar |
15 | 17 | statusBarTimes = collections.namedtuple('StatusBarTimes', ['elapsed', 'total']) |
@@ -41,11 +43,19 @@ def parseIntervalToTimestamp(interval): |
41 | 43 | return calendar.timegm(time.strptime(interval.strip(), format)) |
42 | 44 |
|
43 | 45 | class AppModule(appModuleHandler.AppModule): |
44 | | - statusBar=None |
45 | 46 |
|
46 | | - def event_gainFocus(self, obj, nextHandler): |
47 | | - if not self.statusBar: self.statusBar=api.getStatusBar() |
48 | | - nextHandler() |
| 47 | + def _get_statusBar(self): |
| 48 | + # #11082: retrieve status bar handle and resulting NVDA object from playlist window. |
| 49 | + # If only default status bar routine is used to assign status bar object, it can result in recursion limit error. |
| 50 | + try: |
| 51 | + statusBarHwnd = windowUtils.findDescendantWindow( |
| 52 | + api.getForegroundObject().windowHandle, |
| 53 | + className="ATL:msctls_statusbar32" |
| 54 | + ) |
| 55 | + except LookupError: |
| 56 | + # No status bar handle from places other than playlist window. |
| 57 | + return None |
| 58 | + return getNVDAObjectFromEvent(statusBarHwnd, winUser.OBJID_CLIENT, 0) |
49 | 59 |
|
50 | 60 | def getElapsedAndTotal(self): |
51 | 61 | empty = statusBarTimes(None, None) |
|
0 commit comments