5 new commits in focusHighlight: https://bitbucket.org/nvdaaddonteam/focushighlight/commits/c908862ac349/ Changeset: c908862ac349 Branch: None User: nishimotz Date: 2014-05-04 09:05:18 Summary: refactored Affected #: 1 file diff --git a/addon/globalPlugins/focusHighlight.py b/addon/globalPlugins/focusHighlight.py index 2d14a7b..ee68cf6 100644 --- a/addon/globalPlugins/focusHighlight.py +++ b/addon/globalPlugins/focusHighlight.py @@ -13,6 +13,7 @@ import win32con import sys from ctypes import WINFUNCTYPE, Structure, windll from ctypes import c_long, c_int, c_uint, c_char_p, c_char, byref, pointer +from ctypes import WinError from ctypes.wintypes import COLORREF import api @@ -227,7 +228,7 @@ def createMarkWindow(wndclass, name, hwndHide, rect, alpha): return hwnd -def HighlightWin(): +def createHighlightWin(): wndclass = WNDCLASS() wndclass.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW wndclass.lpfnWndProc = WNDPROC(WndProc) @@ -318,19 +319,11 @@ def WndProc(hwnd, message, wParam, lParam): return 0 return windll.user32.DefWindowProcA(c_int(hwnd), c_int(message), c_int(wParam), c_int(lParam)) - -class Highlighter(object): - def run(self): - t = threading.Thread(target=self._bg) - t.daemon = True - t.start() - def _bg(self): - HighlightWin() +t = threading.Thread(target=createHighlightWin) +t.daemon = True +t.start() class GlobalPlugin(globalPluginHandler.GlobalPlugin): - global highlighter - highlighter = Highlighter() - highlighter.run() def event_gainFocus(self, obj, nextHandler): updateFocusLocation(obj) https://bitbucket.org/nvdaaddonteam/focushighlight/commits/75a9fd5dcd72/ Changeset: 75a9fd5dcd72 Branch: None User: nishimotz Date: 2014-05-04 09:30:10 Summary: refactored Affected #: 1 file diff --git a/addon/globalPlugins/focusHighlight.py b/addon/globalPlugins/focusHighlight.py index ee68cf6..1550726 100644 --- a/addon/globalPlugins/focusHighlight.py +++ b/addon/globalPlugins/focusHighlight.py @@ -112,9 +112,13 @@ NAVIGATOR_PADDING = 4 NAVIGATOR_ALPHA = 192 navigatorHwndList = [0, 0, 0, 0] +ID_TIMER = 100 +UPDATE_PERIOD = 300 + def rectEquals(r1, r2): return (r1.top == r2.top and r1.bottom == r2.bottom and r1.left == r2.left and r1.right == r2.right) + def location2rect(location): rect = RECT() if location and len(location) >= 4: @@ -166,9 +170,11 @@ def limitRectInDesktop(newRect): newRect.bottom = max(0, min(t+h, newRect.bottom)) return newRect + def locationAvailable(obj): return (obj and hasattr(obj, 'location') and obj.location and len(obj.location) >= 4) + def updateFocusLocation(sender=None): global focusRect if locationAvailable(sender): @@ -228,10 +234,54 @@ def createMarkWindow(wndclass, name, hwndHide, rect, alpha): return hwnd +def doPaint(hwnd): + if rectEquals(focusRect, navigatorRect) or hwnd in focusHwndList: + color, brush, bkColor = focusMarkColor, focusMarkBrush, focusBkColor + elif hwnd in navigatorHwndList: + color, brush, bkColor = navigatorMarkColor, navigatorMarkBrush, navBkColor + else: + return + ps = PAINTSTRUCT() + rect = RECT() + hdc = windll.user32.BeginPaint(c_int(hwnd), byref(ps)) + windll.gdi32.SetDCBrushColor(c_int(hdc), color) + windll.gdi32.SetBkColor(c_int(hdc), bkColor) + windll.user32.GetClientRect(c_int(hwnd), byref(rect)) + windll.user32.FillRect(hdc, byref(rect), brush) + windll.user32.EndPaint(c_int(hwnd), byref(ps)) + + +def invalidateRects(): + for hwnd in focusHwndList + navigatorHwndList: + if hwnd: + windll.user32.InvalidateRect(c_int(hwnd), None, True) + + +def wndProc(hwnd, message, wParam, lParam): + if message == win32con.WM_PAINT: + doPaint(hwnd) + return 0 + elif message == win32con.WM_DESTROY: + windll.user32.PostQuitMessage(0) + return 0 + elif message == win32con.WM_SHOWWINDOW: + timer = windll.user32.SetTimer(c_int(hwnd), ID_TIMER, UPDATE_PERIOD, None) + return 0 + elif message == win32con.WM_TIMER: + updateFocusLocation() + try: + updateNavigatorLocation() + except: + pass + invalidateRects() + return 0 + return windll.user32.DefWindowProcA(c_int(hwnd), c_int(message), c_int(wParam), c_int(lParam)) + + def createHighlightWin(): wndclass = WNDCLASS() wndclass.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW - wndclass.lpfnWndProc = WNDPROC(WndProc) + wndclass.lpfnWndProc = WNDPROC(wndProc) wndclass.cbClsExtra = wndclass.cbWndExtra = 0 wndclass.hInstance = windll.kernel32.GetModuleHandleA(c_int(win32con.NULL)) wndclass.hIcon = c_int(win32con.NULL) @@ -273,51 +323,6 @@ def createHighlightWin(): windll.user32.UnregisterClassA(byref(wndclass), wndclass.hInstance) return msg.wParam -ID_TIMER = 100 -UPDATE_PERIOD = 300 - -def doPaint(hwnd): - if rectEquals(focusRect, navigatorRect) or hwnd in focusHwndList: - color, brush, bkColor = focusMarkColor, focusMarkBrush, focusBkColor - elif hwnd in navigatorHwndList: - color, brush, bkColor = navigatorMarkColor, navigatorMarkBrush, navBkColor - else: - return - ps = PAINTSTRUCT() - rect = RECT() - hdc = windll.user32.BeginPaint(c_int(hwnd), byref(ps)) - windll.gdi32.SetDCBrushColor(c_int(hdc), color) - windll.gdi32.SetBkColor(c_int(hdc), bkColor) - windll.user32.GetClientRect(c_int(hwnd), byref(rect)) - windll.user32.FillRect(hdc, byref(rect), brush) - windll.user32.EndPaint(c_int(hwnd), byref(ps)) - - -def invalidateRects(): - for hwnd in focusHwndList + navigatorHwndList: - if hwnd: - windll.user32.InvalidateRect(c_int(hwnd), None, True) - - -def WndProc(hwnd, message, wParam, lParam): - if message == win32con.WM_PAINT: - doPaint(hwnd) - return 0 - elif message == win32con.WM_DESTROY: - windll.user32.PostQuitMessage(0) - return 0 - elif message == win32con.WM_SHOWWINDOW: - timer = windll.user32.SetTimer(c_int(hwnd), ID_TIMER, UPDATE_PERIOD, None) - return 0 - elif message == win32con.WM_TIMER: - updateFocusLocation() - try: - updateNavigatorLocation() - except: - pass - invalidateRects() - return 0 - return windll.user32.DefWindowProcA(c_int(hwnd), c_int(message), c_int(wParam), c_int(lParam)) t = threading.Thread(target=createHighlightWin) t.daemon = True https://bitbucket.org/nvdaaddonteam/focushighlight/commits/b986d74b484c/ Changeset: b986d74b484c Branch: None User: nishimotz Date: 2014-05-04 10:09:13 Summary: fixed issue with 'Reload plugins' Affected #: 2 files diff --git a/addon/globalPlugins/focusHighlight.py b/addon/globalPlugins/focusHighlight.py index 1550726..2838e78 100644 --- a/addon/globalPlugins/focusHighlight.py +++ b/addon/globalPlugins/focusHighlight.py @@ -115,6 +115,10 @@ navigatorHwndList = [0, 0, 0, 0] ID_TIMER = 100 UPDATE_PERIOD = 300 +wndclass = None +hwndHide = None +terminating = False + def rectEquals(r1, r2): return (r1.top == r2.top and r1.bottom == r2.bottom and r1.left == r2.left and r1.right == r2.right) @@ -279,6 +283,8 @@ def wndProc(hwnd, message, wParam, lParam): def createHighlightWin(): + global wndclass + global hwndHide wndclass = WNDCLASS() wndclass.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW wndclass.lpfnWndProc = WNDPROC(wndProc) @@ -314,19 +320,31 @@ def createHighlightWin(): NULL = c_int(win32con.NULL) while windll.user32.GetMessageA(pMsg, NULL, 0, 0) != 0: - windll.user32.TranslateMessage(pMsg) - windll.user32.DispatchMessageA(pMsg) + try: + windll.user32.TranslateMessage(pMsg) + windll.user32.DispatchMessageA(pMsg) + except Exception as e: + log.debug(str(e)) + if terminating: + break + return msg.wParam + +def destroyHighlightWin(): + global wndclass + global hwndHide for i in xrange(4): windll.user32.DestroyWindow(focusHwndList[i]) windll.user32.DestroyWindow(hwndHide) windll.user32.UnregisterClassA(byref(wndclass), wndclass.hInstance) - return msg.wParam + wndclass = None + hwndHide = None -t = threading.Thread(target=createHighlightWin) -t.daemon = True -t.start() +myThread = threading.Thread(target=createHighlightWin) +myThread.daemon = True +myThread.start() +log.debug("focusHighlight started") class GlobalPlugin(globalPluginHandler.GlobalPlugin): @@ -334,3 +352,11 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): updateFocusLocation(obj) updateNavigatorLocation() nextHandler() + + def terminate(self): + global terminating + global myThread + terminating = True + destroyHighlightWin() + myThread.join(5.0) + log.debug("focusHighlight terminated") diff --git a/readme.md b/readme.md index 3263eac..0936332 100644 --- a/readme.md +++ b/readme.md @@ -17,6 +17,7 @@ To disable object tracking, uninstall the addon. ## Changes for 1.1 ## * Changed navigator object rectangle to jagged line. +* Fixed issue with 'Reload plugins'. ## Changes for 1.0 ## https://bitbucket.org/nvdaaddonteam/focushighlight/commits/dfd0d12e854a/ Changeset: dfd0d12e854a Branch: None User: nishimotz Date: 2014-05-04 10:24:19 Summary: fixed issue with terminating NVDA Affected #: 1 file diff --git a/addon/globalPlugins/focusHighlight.py b/addon/globalPlugins/focusHighlight.py index 2838e78..bd9d0be 100644 --- a/addon/globalPlugins/focusHighlight.py +++ b/addon/globalPlugins/focusHighlight.py @@ -355,8 +355,6 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): def terminate(self): global terminating - global myThread terminating = True destroyHighlightWin() - myThread.join(5.0) log.debug("focusHighlight terminated") https://bitbucket.org/nvdaaddonteam/focushighlight/commits/84bbf4166fd0/ Changeset: 84bbf4166fd0 Branch: master User: nishimotz Date: 2014-05-04 14:11:39 Summary: fixed issue with UnregisterClassA on Windows 8.1 Affected #: 1 file diff --git a/addon/globalPlugins/focusHighlight.py b/addon/globalPlugins/focusHighlight.py index bd9d0be..69e0377 100644 --- a/addon/globalPlugins/focusHighlight.py +++ b/addon/globalPlugins/focusHighlight.py @@ -13,9 +13,10 @@ import win32con import sys from ctypes import WINFUNCTYPE, Structure, windll from ctypes import c_long, c_int, c_uint, c_char_p, c_char, byref, pointer -from ctypes import WinError +from ctypes import WinError, GetLastError, FormatError from ctypes.wintypes import COLORREF import api +import time WNDPROC = WINFUNCTYPE(c_long, c_int, c_uint, c_int, c_int) @@ -73,6 +74,7 @@ WS_EX_TRANSPARENT = 0x00000020 WS_EX_APPWINDOW = 0x00040000 LWA_COLORKEY = 0x00000001 LWA_ALPHA = 0x00000002 +ERROR_CLASS_HAS_WINDOWS = 1412 def RGB(r,g,b): return r | (g<<8) | (b<<16) @@ -336,7 +338,16 @@ def destroyHighlightWin(): for i in xrange(4): windll.user32.DestroyWindow(focusHwndList[i]) windll.user32.DestroyWindow(hwndHide) - windll.user32.UnregisterClassA(byref(wndclass), wndclass.hInstance) + while True: + ret = windll.user32.UnregisterClassA(wndclass.lpszClassName, wndclass.hInstance) + if ret == 0: + if GetLastError() == ERROR_CLASS_HAS_WINDOWS: + time.sleep(0.5) + else: + log.error(FormatError()) + break + else: + break wndclass = None hwndHide = None Repository URL: https://bitbucket.org/nvdaaddonteam/focushighlight/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.