diff --git a/source/NVDAObjects/IAccessible/ia2TextMozilla.py b/source/NVDAObjects/IAccessible/ia2TextMozilla.py index 143ad1d4595..03930c51202 100644 --- a/source/NVDAObjects/IAccessible/ia2TextMozilla.py +++ b/source/NVDAObjects/IAccessible/ia2TextMozilla.py @@ -18,7 +18,7 @@ from NVDAObjects import NVDAObject, NVDAObjectTextInfo from . import IA2TextTextInfo, IAccessible from compoundDocuments import CompoundTextInfo -from locationHelper import RectLTWH +import locationHelper class FakeEmbeddingTextInfo(textInfos.offsets.OffsetsTextInfo): @@ -111,7 +111,7 @@ def __init__(self, obj, position): self._startObj = self._endObj = tempObj else: self._start, self._startObj, self._end, self._endObj = self._findUnitEndpoints(tempTi, position) - elif isinstance(position, textInfos.Point): + elif isinstance(position, locationHelper.Point): startObj = api.getDesktopObject().objectFromPoint(position.x, position.y) while startObj and startObj.role == controlTypes.ROLE_STATICTEXT: # Skip text leaf nodes. diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 9e24448b21b..9073e402ca7 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -30,7 +30,7 @@ from NVDAObjects import NVDAObjectTextInfo, InvalidNVDAObject from NVDAObjects.behaviors import ProgressBar, EditableTextWithoutAutoSelectDetection, Dialog, Notification, EditableTextWithSuggestions import braille -from locationHelper import RectLTWH +import locationHelper import ui class UIATextInfo(textInfos.TextInfo): @@ -308,10 +308,9 @@ def __init__(self,obj,position,_rangeObj=None): raise LookupError # sometimes rangeFromChild can return a NULL range if not self._rangeObj: raise LookupError - elif isinstance(position,textInfos.Point): + elif isinstance(position,locationHelper.Point): #rangeFromPoint used to cause a freeze in UIA client library! - p=POINT(position.x,position.y) - self._rangeObj=self.obj.UIATextPattern.RangeFromPoint(p) + self._rangeObj=self.obj.UIATextPattern.RangeFromPoint(position.toPOINT()) elif isinstance(position,UIAHandler.IUIAutomationTextRange): self._rangeObj=position.clone() else: @@ -658,7 +657,7 @@ def _getBoundingRectsFromUIARange(self,range): if not rectArray: return rects rectIndexes = xrange(0, len(rectArray), 4) - rectGen = (RectLTWH.fromFloatCollection(*rectArray[i:i+4]) for i in rectIndexes) + rectGen = (locationHelper.RectLTWH.fromFloatCollection(*rectArray[i:i+4]) for i in rectIndexes) rects.extend(rectGen) return rects @@ -1353,7 +1352,7 @@ def _get_location(self): if r is None: return # r is a tuple of floats representing left, top, width and height. - return RectLTWH.fromFloatCollection(*r) + return locationHelper.RectLTWH.fromFloatCollection(*r) def _get_value(self): val=self._getUIACacheablePropertyValue(UIAHandler.UIA_RangeValueValuePropertyId,True) diff --git a/source/NVDAObjects/__init__.py b/source/NVDAObjects/__init__.py index e8f65f3951f..74422175da8 100644 --- a/source/NVDAObjects/__init__.py +++ b/source/NVDAObjects/__init__.py @@ -28,6 +28,7 @@ import braille import globalPluginHandler import brailleInput +import locationHelper class NVDAObjectTextInfo(textInfos.offsets.OffsetsTextInfo): """A default TextInfo which is used to enable text review of information about widgets that don't support text content. @@ -989,7 +990,7 @@ def event_mouseMove(self,x,y): speechWasCanceled=False self._mouseEntered=True try: - info=self.makeTextInfo(textInfos.Point(x,y)) + info=self.makeTextInfo(locationHelper.Point(x,y)) except NotImplementedError: info=NVDAObjectTextInfo(self,textInfos.POSITION_FIRST) except LookupError: diff --git a/source/NVDAObjects/window/edit.py b/source/NVDAObjects/window/edit.py index ce623664917..b007dda8cfc 100644 --- a/source/NVDAObjects/window/edit.py +++ b/source/NVDAObjects/window/edit.py @@ -32,6 +32,7 @@ from ..behaviors import EditableTextWithAutoSelectDetection import braille import watchdog +import locationHelper selOffsetsAtLastCaretEvent=None @@ -170,10 +171,10 @@ def _getPointFromOffset(self,offset): winKernel.readProcessMemory(processHandle,internalP,ctypes.byref(p),ctypes.sizeof(p),None) finally: winKernel.virtualFreeEx(processHandle,internalP,0,winKernel.MEM_RELEASE) - point=textInfos.Point(p.x,p.y) + point=locationHelper.Point(p.x,p.y) else: res=watchdog.cancellableSendMessage(self.obj.windowHandle,winUser.EM_POSFROMCHAR,offset,None) - point=textInfos.Point(winUser.GET_X_LPARAM(res),winUser.GET_Y_LPARAM(res)) + point=locationHelper.Point(winUser.GET_X_LPARAM(res),winUser.GET_Y_LPARAM(res)) # A returned coordinate can be a negative value if # the specified character is not displayed in the edit control's client area. # If the specified index is greater than the index of the last character in the control, @@ -181,8 +182,7 @@ def _getPointFromOffset(self,offset): if point.x <0 or point.y <0: raise LookupError("Point with client coordinates x=%d, y=%d not within client area of object" % (point.x, point.y)) - point.x, point.y = winUser.ClientToScreen(self.obj.windowHandle, point.x, point.y) - return point + return point.toScreen(self.obj.windowHandle) def _getOffsetFromPoint(self,x,y): @@ -447,8 +447,7 @@ def _getParagraphOffsets(self,offset): class ITextDocumentTextInfo(textInfos.TextInfo): def _get_pointAtStart(self): - p=textInfos.Point(0,0) - (p.x,p.y)=self._rangeObj.GetPoint(comInterfaces.tom.tomStart) + p=locationHelper.Point(*self._rangeObj.GetPoint(comInterfaces.tom.tomStart)) if p.x and p.y: return p else: @@ -570,7 +569,7 @@ def _getEmbeddedObjectLabel(self,embedRangeObj): r.collapse(1) left,top=r.GetPoint(comInterfaces.tom.tomStart) import displayModel - label=displayModel.DisplayModelTextInfo(self.obj, textInfos.Rect(left, top, right, bottom)).text + label=displayModel.DisplayModelTextInfo(self.obj, locationHelper.RectLTRB(left, top, right, bottom)).text if label and not label.isspace(): return label # Windows Live Mail exposes the label via the embedded object's data (IDataObject) @@ -625,8 +624,8 @@ def __init__(self,obj,position,_rangeObj=None): if _rangeObj: self._rangeObj=_rangeObj.Duplicate return - if isinstance(position,textInfos.Point): - self._rangeObj=self.obj.ITextDocumentObject.rangeFromPoint(position.x,position.y) + if isinstance(position,locationHelper.Point): + self._rangeObj=self.obj.ITextDocumentObject.rangeFromPoint(*position) elif position==textInfos.POSITION_ALL: self._rangeObj=self.obj.ITextDocumentObject.range(0,0) self._rangeObj.expand(comInterfaces.tom.tomStory) diff --git a/source/NVDAObjects/window/scintilla.py b/source/NVDAObjects/window/scintilla.py index 130ac9ba1d7..8527d03f1e0 100755 --- a/source/NVDAObjects/window/scintilla.py +++ b/source/NVDAObjects/window/scintilla.py @@ -13,6 +13,7 @@ import locale import watchdog import eventHandler +import locationHelper # Window messages SCI_POSITIONFROMPOINT=2022 @@ -72,11 +73,10 @@ def _getOffsetFromPoint(self,x,y): return watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_POSITIONFROMPOINT,x,y) def _getPointFromOffset(self,offset): - x, y = winUser.ClientToScreen(self.obj.windowHandle, + point=locationHelper.Point( watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_POINTXFROMPOSITION,None,offset), watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_POINTYFROMPOSITION,None,offset) - ) - point=textInfos.Point(x, y) + ).toScreen(self.obj.windowHandle) if point.x is not None and point.y is not None: return point else: diff --git a/source/NVDAObjects/window/winword.py b/source/NVDAObjects/window/winword.py index 87464e77556..1293125ea24 100755 --- a/source/NVDAObjects/window/winword.py +++ b/source/NVDAObjects/window/winword.py @@ -40,7 +40,7 @@ from . import Window from ..behaviors import EditableTextWithoutAutoSelectDetection from . import _msOfficeChart -from textInfos import Point +import locationHelper #Word constants @@ -661,7 +661,7 @@ def __init__(self,obj,position,_rangeObj=None): if _rangeObj: self._rangeObj=_rangeObj.Duplicate return - if isinstance(position,textInfos.Point): + if isinstance(position, locationHelper.Point): try: self._rangeObj=self.obj.WinwordDocumentObject.activeWindow.RangeFromPoint(position.x,position.y) except COMError: @@ -1018,7 +1018,7 @@ def _get_pointAtStart(self): raise LookupError if not any((left.value, top.value, width.value, height.value)): raise LookupError - return Point(left.value, top.value) + return locationHelper.Point(left.value, top.value) def updateCaret(self): self.obj.WinwordWindowObject.ScrollIntoView(self._rangeObj) diff --git a/source/appModules/explorer.py b/source/appModules/explorer.py index 603a870d6ab..f46b153df27 100644 --- a/source/appModules/explorer.py +++ b/source/appModules/explorer.py @@ -66,18 +66,6 @@ def _get_shouldAllowIAccessibleFocusEvent(self): return True return False - -class ClassicStartMenu(Window): - # Override the name, as Windows names this the "Application" menu contrary to all documentation. - # Translators: The title of Start menu/screen in your language (only the word start). - name = _("Start") - - def event_gainFocus(self): - # In Windows XP, the Start button will get focus first, so silence this. - speech.cancelSpeech() - super(ClassicStartMenu, self).event_gainFocus() - - class NotificationArea(IAccessible): """The Windows notification area, a.k.a. system tray. """ @@ -199,14 +187,7 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList): return # Optimization: return early to avoid comparing class names and roles that will never match. if windowClass == "ToolbarWindow32": - if role == controlTypes.ROLE_POPUPMENU: - parent = obj.parent - if parent and parent.windowClassName == "SysPager" and obj.windowStyle & 0x80: - clsList.insert(0, ClassicStartMenu) - else: - # Check whether this is the notification area, a.k.a. system tray. - if isinstance(obj.parent, ClassicStartMenu): - return # This can't be a notification area + if role != controlTypes.ROLE_POPUPMENU: try: # The toolbar's immediate parent is its window object, so we need to go one further. toolbarParent = obj.parent.parent @@ -280,7 +261,7 @@ def event_NVDAObject_init(self, obj): return if windowClass == "DV2ControlHost" and role == controlTypes.ROLE_PANE: - # Windows Vista/7 start menu. + # Windows 7 start menu. obj.presentationType=obj.presType_content obj.isPresentableFocusAncestor = True # In Windows 7, the description of this pane is extremely verbose help text, so nuke it. diff --git a/source/appModules/klangoplayer.py b/source/appModules/klangoplayer.py deleted file mode 100644 index eaa94a1dabe..00000000000 --- a/source/appModules/klangoplayer.py +++ /dev/null @@ -1,7 +0,0 @@ -#appModules/klangoplayer.py - -import appModuleHandler - -class AppModule(appModuleHandler.AppModule): - - sleepMode=True diff --git a/source/appModules/outlook.py b/source/appModules/outlook.py index c9777c5c133..9dc00b39ec0 100644 --- a/source/appModules/outlook.py +++ b/source/appModules/outlook.py @@ -201,9 +201,12 @@ def chooseNVDAObjectOverlayClasses(self, obj, clsList): return if (windowClassName=="SUPERGRID" and controlID==4704) or (windowClassName=="rctrl_renwnd32" and controlID==109): outlookVersion=self.outlookVersion - if outlookVersion and outlookVersion<=9: - clsList.insert(0, MessageList_pre2003) - elif obj.event_objectID==winUser.OBJID_CLIENT and obj.event_childID==0: + if ( + outlookVersion + and outlookVersion > 9 + and obj.event_objectID==winUser.OBJID_CLIENT + and obj.event_childID==0 + ): clsList.insert(0,SuperGridClient2010) if (windowClassName == "AfxWndW" and controlID==109) or (windowClassName in ("WeekViewWnd","DayViewWnd")): clsList.insert(0,CalendarView) @@ -246,67 +249,6 @@ def event_gainFocus(self): obj.parent=self.parent eventHandler.executeEvent("gainFocus",obj) -class MessageList_pre2003(IAccessible): - - def _get_name(self): - if hasattr(self,'curMessageItem'): - return self.curMessageItem.msg.parent.name - - def _get_role(self): - return controlTypes.ROLE_LIST - - def _get_firstChild(self): - return getattr(self,"curMessageItem",None) - - def _get_children(self): - child=getattr(self,"curMessageItem",None) - if child: - return [child] - else: - return [] - - def event_gainFocus(self): - try: - msg=self.nativeOm.ActiveExplorer().selection[0] - except: - msg=None - pass - if msg: - self.curMessageItem=MessageItem(self,msg) - super(MessageList_pre2003,self).event_gainFocus() - if msg: - eventHandler.executeEvent("gainFocus",self.curMessageItem) - - def script_moveByMessage(self,gesture): - if hasattr(self,'curMessageItem'): - oldEntryID=self.curMessageItem.msg.entryID - else: - oldEntryID=None - gesture.send() - try: - msg=self.nativeOm.ActiveExplorer().selection[0] - except: - msg=None - pass - if msg: - messageItem=MessageItem(self,msg) - newEntryID=messageItem.msg.entryID - if newEntryID!=oldEntryID: - self.curMessageItem=messageItem - eventHandler.executeEvent("gainFocus",messageItem) - - __moveByMessageGestures = ( - "kb:downArrow", - "kb:upArrow", - "kb:home", - "kb:end", - "kb:delete", - ) - - def initOverlayClass(self): - for gesture in self.__moveByMessageGestures: - self.bindGesture(gesture, "moveByMessage") - class MessageItem(Window): def __init__(self,windowHandle=None,parent=None,msg=None): diff --git a/source/appModules/skype.py b/source/appModules/skype.py index 8131324f1b7..1c42e161b38 100644 --- a/source/appModules/skype.py +++ b/source/appModules/skype.py @@ -1,265 +1,11 @@ # -*- coding: UTF-8 -*- #appModules/skype.py #A part of NonVisual Desktop Access (NVDA) -#Copyright (C) 2007-2019 Peter Vágner, NV Access Limited, Babbage B.V. +#Copyright (C) 2019 Peter Vágner, NV Access Limited, Babbage B.V. #This file is covered by the GNU General Public License. #See the file COPYING for more details. -import re -from comtypes import COMError -import wx import appModuleHandler -import controlTypes -import winUser -import NVDAObjects.IAccessible -import oleacc -import ui -import windowUtils -import displayModel -import queueHandler -import config -import NVDAObjects.behaviors -import api -from logHandler import log - -# Translators: The name of the NVDA command category for Skype specific commands. -SCRCAT_SKYPE = _("Skype") - -TYPING_INDICATOR_MATCH = { - ("TTypingIndicatorPanel", controlTypes.ROLE_STATICTEXT), - ("TWidgetControl", controlTypes.ROLE_LISTITEM), # Skype <= 7.2 -} - -class Conversation(NVDAObjects.IAccessible.IAccessible): - scriptCategory = SCRCAT_SKYPE - - def initOverlayClass(self): - for n in xrange(0, 10): - self.bindGesture("kb:NVDA+control+%d" % n, "reviewRecentMessage") - - def _isEqual(self, other): - # Sometimes, we get this object as an unproxied IAccessible, - # which means the location is different, so IAccessible._isEqual return False. - # This can cause us to get a gainFocus and a focusEntered on two different instances. - # We don't care about the location here. - return self.windowHandle == other.windowHandle - - def _gainedFocus(self): - # The user has entered this Skype conversation. - if self.appModule.conversation: - # Another conversation was previously focused. Clean it up. - self.appModule.conversation.lostFocus() - - self.appModule.conversation = self - try: - self.outputList = NVDAObjects.IAccessible.getNVDAObjectFromEvent( - windowUtils.findDescendantWindow(self.windowHandle, className="TChatContentControl"), - winUser.OBJID_CLIENT, 0).lastChild - except LookupError: - log.debugWarning("Couldn't find output list") - self.outputList = None - else: - self.outputList.startMonitoring() - for wClass, role in TYPING_INDICATOR_MATCH: - try: - self.typingIndicator = NVDAObjects.IAccessible.getNVDAObjectFromEvent( - windowUtils.findDescendantWindow(self.windowHandle, className=wClass), - winUser.OBJID_CLIENT, 1) - except LookupError: - continue - self.typingIndicator.startMonitoring() - break - else: - log.debugWarning("Couldn't find typing indicator") - self.typingIndicator = None - - def event_focusEntered(self): - self._gainedFocus() - super(Conversation, self).event_focusEntered() - - def event_gainFocus(self): - # A conversation might have its own top level window, - # but foreground changes often trigger gainFocus instead of focusEntered. - self._gainedFocus() - super(Conversation, self).event_gainFocus() - - def lostFocus(self): - self.appModule.conversation = None - if self.outputList: - self.outputList.stopMonitoring() - self.outputList = None - if self.typingIndicator: - self.typingIndicator.stopMonitoring() - self.typingIndicator = None - - def script_reviewRecentMessage(self, gesture): - try: - index = int(gesture.mainKeyName[-1]) - except (AttributeError, ValueError): - return - if index == 0: - index = 10 - self.outputList.reviewRecentMessage(index) - # Describes the NVDA command to review messages in Skype. - script_reviewRecentMessage.__doc__ = _("Reports and moves the review cursor to a recent message") - script_reviewRecentMessage.canPropagate = True - -class ChatOutputList(NVDAObjects.IAccessible.IAccessible): - - def startMonitoring(self): - self.oldMessageCount = None - self.update(initial=True) - displayModel.requestTextChangeNotifications(self, True) - - def stopMonitoring(self): - displayModel.requestTextChangeNotifications(self, False) - - RE_MESSAGE = re.compile(r"^From (?P.*), (?P.*), sent on (?P