Problem: 1615653

Title: (TView::RestrictRegionToVisible) wrong cursor and help regions

Received: Dec 27 1996 11:46AM


There is a bug in UView.cp of MacApp 3.3 and following. The problem is that TView::RestrictRegionToVisible subtracts the clipping region of the current GrafPort from the region passed in. TView::RestrictRegionToVisible is used from TView::HandleCursor, TView::HandleHelp and TView::HandleDragCursor to restrict the calculated cursor regions to the visible portions of the view. Excluding the clipping region leads to a wrong calculation of cursor and help-regions if the view itself has been invalidated using TView::ForceRedraw or other invalidation methods, since the invalid region is accumulated into the clipping region.

You can easily reproduce the bug using the Calc example program. After resizing a column in Calc, the cursor changes to an arrow altough it should be the horizontal resize cursor. The problem is that Calc invalidates the view after resizing the columns and MacApp tries to calculate a cursor region before the update-event has been processed. Since the invalidated view gets accumulated into the clipping-region, TView::RestrictRegionToVisible changes the calculated cursor region to be empty which leads to MacApp's default-behavior of using the arrow-cursor. One solution is to simply stop TView::RestrictRegionToVisible from using the clipping region by disabling the SectRgn call:

void TView::RestrictRegionToVisible(RgnHandle aRegion)
{
#if qDebug
        this->AssumeFocused();
#endif
        CRect itsVisibleExtent;
        this->ViewToQDRect(this->GetVisibleExtent(), itsVisibleExtent);
        CTemporaryRegion visibleExtentRgn;
        RectRgn(visibleExtentRgn, itsVisibleExtent);
        SectRgn(aRegion, visibleExtentRgn, aRegion);
        // Intersect with visible region
        SectRgn(GetVisRegion(qd.thePort), aRegion, aRegion);
        // !!! BUG-FIX !!! Cursor-regions should not be limited
        // !!! BUG-FIX !!! by clip-region (invalidation)
        // SectRgn(GetClipRegion(qd.thePort), aRegion, aRegion);
} // TView::RestrictRegionToVisible
Another solution might be to defer the calculation of cursor-regions until pending update-events have been processed.
Fix:

Implemented the suggestion. Verified using Calc, resizing a column.