[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why haven't I seen this before?



I've just run into a problem that made me do a real double take.

A co-programmer of mine just wrote some code to scroll a window,
and as I was reviewing the code, I found that he had put a fair
amount of effort into machinery to prevent scrolling after doing
and InvalRect.  He said this was necessary to prevent corrupted
scrolling.

Now I've been working on Macs for nearly 5 years now, and had a
hand in at least 10 products, and I had never heard of any such
thing being necessary.  So I told the guy he had mis-designed
something, and started to tell him what.  I lost.  He convinced
*me*.

Here is the sequence.  The target window has a dialog box over it
that obscures some of the contents of the window.  A click anywhere
dismisses the dialog.  Click twice very quickly over the page down
region of the target window's scroll bar.  The first click dismisses
the dialog and generates an activate and update events for the window.

If the target window gets the activate event before the mouse click
(likely) it is now ready to scroll.  Since any 'real' event has
higher priority than an update event, the target window may well get
the mouse click next.  That means that if you respond to a click
in the page region of the scroll bar by doing a ScrollRect, you will
scroll the area that used to be under the dialog box, and has been
painted the background color earlier.  When you are done scrolling,
presumeably, the update event finally gets to the window.  But now
the blank area that used to be under the dialog no longer is.  Thus
it is never redrawn.

Why have I never seen this before?  Actually I'm only curious about
that.  A lot more depends on my knowing why I'm seeing it now (my job!)

Blake Meike
blakem@world.std.com