Changeset 2517
- Timestamp:
- 11/20/08 04:41:51 (7 weeks ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
. (modified) (5 props)
-
source/api.py (modified) (2 diffs)
-
source/braille.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property bzr:revision-info
-
old new 1 timestamp: 2008-11-20 00:32:02.549000025+10001 timestamp: 2008-11-20 14:40:18.513999939 +1000 2 2 committer: James Teh <jamie@jantrid.net> 3 3 properties:
-
- Property bzr:revision-id:v3-list-QlpoOTFBWSZTWbrL2vUAAB1VgAAQABCAQDrrnqAgAFCgaaGRkxBoTIJ6mmaNRwhndFAoNhZjh_YY4a01fOg1ulgNNC2UrzPdXXEnDpX8XckU4UJC6y9r1A..
-
old new 286 286 2314 jamie@jantrid.net-20081119113620-dz3izx839k8dy7z0 287 287 2315 jamie@jantrid.net-20081119143202-ybvjifczhpjl9ldo 288 2316 jamie@jantrid.net-20081120044018-ubawgup09fsqgp0i
-
- Property bzr:file-ids
-
old new 1 source/brailleDisplayDrivers/handyTech.py handytech.py-20080908070031-15dxcuiuxfazjt1r-3 1 source/api.py 46@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2Fapi.py 2 source/braille.py braille.py-20080908070240-tjwqjsv7drp1kt8c-1
-
- Property bzr:text-parents
-
old new 1 source/api.py jamie@jantrid.net-20081111000130-ogbjmubm7hbp2w8b 2 source/braille.py mick@kulgan.net-20081117132147-0s0gw63lue1v5xar
-
- Property bzr:revision-info
-
trunk/source/api.py
r2493 r2517 132 132 virtualBufferObject.event_virtualBuffer_firstGainFocus() 133 133 oldVirtualBuffer=globalVars.focusObject.virtualBuffer if globalVars.focusObject else None 134 # Set global focus variables before calling event_virtualBuffer_gainFocus. 135 globalVars.focusDifferenceLevel=focusDifferenceLevel 136 globalVars.focusObject=obj 137 globalVars.focusAncestors=ancestors 134 138 if obj.virtualBuffer is not oldVirtualBuffer: 135 139 if hasattr(oldVirtualBuffer,"event_virtualBuffer_loseFocus"): … … 137 141 if hasattr(obj.virtualBuffer,"event_virtualBuffer_gainFocus"): 138 142 obj.virtualBuffer.event_virtualBuffer_gainFocus() 139 globalVars.focusDifferenceLevel=focusDifferenceLevel140 globalVars.focusObject=obj141 globalVars.focusAncestors=ancestors142 143 if log.isEnabledFor(log.DEBUG): 143 144 log.debug("%s %s %s %s"%(obj.name or "",controlTypes.speechRoleLabels[obj.role],obj.value or "",obj.description or "")) -
trunk/source/braille.py
r2505 r2517 540 540 raise 541 541 542 def get ContextRegions(obj):542 def getFocusContextRegions(obj, oldFocusRegions=None): 543 543 # Late import to avoid circular import. 544 544 from virtualBuffers import VirtualBuffer 545 if isinstance(obj,VirtualBuffer): 546 obj=obj.rootNVDAObject 547 ancestors=[] 548 ancestor=obj.parent 549 while ancestor: 550 ancestors.append(ancestor) 551 ancestor=ancestor.parent 552 ancestors.reverse() 553 for parent in ancestors[1:]: 545 ancestors = api.getFocusAncestors() 546 547 ancestorsEnd = len(ancestors) 548 if isinstance(obj, VirtualBuffer): 549 obj = obj.rootNVDAObject 550 # We only want the ancestors of the buffer's root NVDAObject. 551 if obj != api.getFocusObject(): 552 # Search backwards through the focus ancestors to find the index of obj. 553 for index, ancestor in itertools.izip(xrange(len(ancestors) - 1, 0, -1), reversed(ancestors)): 554 if obj == ancestor: 555 ancestorsEnd = index 556 break 557 558 if oldFocusRegions: 559 # We have the regions from the previous focus, so use the focus difference level to avoid rebuilding regions which are the same. 560 # The focus difference level is generally where the new ancestors begin. 561 # However, we must ensure that it is not beyond the last ancestor we wish to consider. 562 # Also, we don't ever want to fetch ancestor 0 (the desktop). 563 newAncestorsStart = max(min(api.getFocusDifferenceLevel(), ancestorsEnd), 1) 564 # Search backwards through the old regions to find the last common region. 565 for index, region in itertools.izip(xrange(len(oldFocusRegions) - 1, -1, -1), reversed(oldFocusRegions)): 566 ancestorIndex = getattr(region, "_focusAncestorIndex", None) 567 if ancestorIndex is None: 568 continue 569 if ancestorIndex < newAncestorsStart: 570 # This is the last common region. 571 # An ancestor may have been skipped and not have a region, which means that we need to grab new ancestors from this point. 572 newAncestorsStart = ancestorIndex + 1 573 commonRegionsEnd = index + 1 574 break 575 else: 576 # No common regions were found. 577 commonRegionsEnd = 0 578 newAncestorsStart = 1 579 # Yield the common regions. 580 for region in oldFocusRegions[0:commonRegionsEnd]: 581 yield region 582 else: 583 # Fetch all ancestors. 584 newAncestorsStart = 1 585 586 for index, parent in enumerate(ancestors[newAncestorsStart:ancestorsEnd], newAncestorsStart): 554 587 role=parent.role 555 588 if role in (controlTypes.ROLE_UNKNOWN,controlTypes.ROLE_WINDOW,controlTypes.ROLE_SECTION,controlTypes.ROLE_TREEVIEWITEM,controlTypes.ROLE_LISTITEM,controlTypes.ROLE_PARAGRAPH,controlTypes.ROLE_PROGRESSBAR,controlTypes.ROLE_EDITABLETEXT,controlTypes.ROLE_MENUITEM): … … 562 595 if controlTypes.STATE_INVISIBLE in states or controlTypes.STATE_UNAVAILABLE in states: 563 596 continue 564 yield NVDAObjectRegion(parent, appendText=" ") 597 region = NVDAObjectRegion(parent, appendText=" ") 598 region._focusAncestorIndex = index 599 region.update() 600 yield region 565 601 566 602 def getFocusRegions(obj, review=False): … … 576 612 if isinstance(obj, VirtualBuffer): 577 613 obj = obj.rootNVDAObject 578 yield (ReviewNVDAObjectRegion if review else NVDAObjectRegion)(obj, appendText=" " if region2 else "") 614 region = (ReviewNVDAObjectRegion if review else NVDAObjectRegion)(obj, appendText=" " if region2 else "") 615 region.update() 616 yield region 579 617 if region2: 618 region2.update() 580 619 yield region2 581 620 … … 709 748 if self.tether != self.TETHER_FOCUS: 710 749 return 711 self._doNew Regions(itertools.chain(getContextRegions(obj), getFocusRegions(obj)))712 713 def _doNew Regions(self, regions):750 self._doNewObject(itertools.chain(getFocusContextRegions(obj, oldFocusRegions=self.mainBuffer.regions), getFocusRegions(obj))) 751 752 def _doNewObject(self, regions): 714 753 self.mainBuffer.clear() 715 754 for region in regions: 716 755 self.mainBuffer.regions.append(region) 717 region.update()718 756 self.mainBuffer.update() 719 757 # Last region should receive focus. … … 775 813 else: 776 814 # We're reviewing a different object. 777 self._doNew Regions(getFocusRegions(reviewPos.obj, review=True))815 self._doNewObject(getFocusRegions(reviewPos.obj, review=True)) 778 816 779 817 def initialize():

NVDA is supported by