[comp.sys.mac.programmer] How's the screen cleaned after _SysError?

ephraim@Think.COM (Ephraim Vishniac) (02/27/90)

How is the screen restored after a call to _SysError?

Before you say, "There is no 'after' _SysError," please note that the
disk-swap alert is displayed by _SysError.  A little creeping around
with Macsbug informs me that there's a low-mem global called DSWndUpdate,
but I haven't puzzled out how it's used or what it does.

The reason I'm asking about this is that I'd like to be able to display an
alert at just about any time (much like the disk-swap alert, and for
similar reasons) and then clean up nicely.  Right now, I'm waiting for the
next call to _GetOSEvent and using _PaintBehind to get the alert rect
redrawn.  This works, but it's not as smooth as whatever the disk-swap code
does.
Ephraim Vishniac    ephraim@think.com   ThinkingCorp@applelink.apple.com
 Thinking Machines Corporation / 245 First Street / Cambridge, MA 02142
        One of the flaws in the anarchic bopper society was
        the ease with which such crazed rumors could spread.

amanda@mermaid.intercon.com (Amanda Walker) (02/27/90)

In article <34252@news.Think.COM>, ephraim@Think.COM (Ephraim Vishniac) writes:
> Right now, I'm waiting for the
> next call to _GetOSEvent and using _PaintBehind to get the alert rect
> redrawn.  This works, but it's not as smooth as whatever the disk-swap code
> does.

If you know how big your alert is going to be, you could reserve a
bitmap/pixmap and just save the stuff behind the alert before you put it
up, and restore it on your way out...  I believe there was once some code
floating around sumex that did this, called "quickalert" or some such.

--
Amanda Walker
InterCon Systems Corporation

"Many of the truths we cling to depend greatly upon our own point of view."
	--Obi-Wan Kenobi in "Return of the Jedi"

lsr@Apple.COM (Larry Rosenstein) (03/01/90)

In article <34252@news.Think.COM> ephraim@Think.COM (Ephraim Vishniac) 
writes:
> How is the screen restored after a call to _SysError?

There's a low memory global called DSAlertRect.  In GetMouse, if the high 
bit of DSWndUpdate is 1, then the system refreshes the rectangle stored in 
DSAlertRect.

Since this doesn't seem to be documented, use at your own risk.

Larry Rosenstein, Apple Computer, Inc.
Object Specialist

Internet: lsr@Apple.com   UUCP: {nsc, sun}!apple!lsr
AppleLink: Rosenstein1

ephraim@think.com (Ephraim Vishniac) (03/01/90)

In article <6959@internal.Apple.COM> lsr@Apple.COM (Larry Rosenstein) writes:
>In article <34252@news.Think.COM> ephraim@Think.COM (Ephraim Vishniac) 
>writes:
>> How is the screen restored after a call to _SysError?

>There's a low memory global called DSAlertRect.  In GetMouse, if the high 
>bit of DSWndUpdate is 1, then the system refreshes the rectangle stored in 
>DSAlertRect.

GetMouse doesn't do this on my Mac II (6.02, Multifinder off).  I
disassembled it and found that the only subroutine call was to a
journaling routine which exits immedidately if journaling is off. 

Also, DSWndUpdate seems to be $FF most of the time (i.e., the high bit
is always set). 

>Since this doesn't seem to be documented, use at your own risk.

Not documented?  Not so!  Please refer to "Low Memory in Alphabetical
Order" dated 12 Apr 85.  (You did keep every scrap of paper from the
Macintosh Software Supplements, right?) DSWndUpdate is at least as
well documented as the famous MrMacHook.  Notice the line that reads:

DSWndUpdate .EQU $15D ;01 GNE not to paintBehind DS AlertRect? [byte]

This suggests that it's GetNextEvent, not GetMouse, and painting will
occur when the bit is cleared, not set.  I haven't actually tried this
out yet - it took me a while to find the right documentation.

--
Ephraim Vishniac    ephraim@think.com   ThinkingCorp@applelink.apple.com
 Thinking Machines Corporation / 245 First Street / Cambridge, MA 02142
        One of the flaws in the anarchic bopper society was
        the ease with which such crazed rumors could spread.

wdh@well.sf.ca.us (Bill Hofmann) (03/02/90)

In article <34252@news.Think.COM> ephraim@Think.COM (Ephraim Vishniac) writes:
>How is the screen restored after a call to _SysError?
>
>The reason I'm asking about this is that I'd like to be able to display an
>alert at just about any time (much like the disk-swap alert, and for
>similar reasons) and then clean up nicely.  Right now, I'm waiting for the
>next call to _GetOSEvent and using _PaintBehind to get the alert rect
>redrawn.  This works, but it's not as smooth as whatever the disk-swap code
>does.
The Debugger is much handier for obscure trivia like this.  Its listing for
DSWndUpdate is "GetNextEvent not to paintBehind DS AlertRect", and looking
at the code for EventAvail and GetNextEvent, it does something like this:
	BSET	#7,DsWndUpdate
	BNE.S	out
	...GetPort(curPort) SetPort(WMgrPort)
	SUBQ	#4,a7
	_FrontWindow
	SUBQ	#4,a7
	_NewRgn
	MOVEA.L	(a7),a3
	PEA	DsAlertRect	; $3f8
	PUSH.L	a3
	_PaintBehind
	PUSH.L	a3
	_DisposRgn
	...SetPort(curPort)
So to force a cleanup, just BCLR #7,DsWndUpdate, being sure DsAlertRect
is properly set up.

But how about using the Notification Manager?  That'll let you put up an
alert in front of everything, in a much less hackish way.

-Bill Hofmann

PS: How're things?