[comp.sys.amiga.tech] CloseScreen internals

john13@garfield.MUN.EDU (John Russell) (11/13/88)

I'm curious as to whether the inner workings of CloseScreen could be
changed for the better without breaking anything. I think they could.

Why not make the screen structure's presence dependent on a semaphore?

OpenScreen: initializes semaphore value to 0
OpenWindow: increments semaphore value of that screen unless WBenchWindow
	flag set (so Open/CloseWorkbench work)
CloseWindow: decrements semaphore value; when all windows are closed
	semaphore reads 0
CloseScreen: decrements semaphore value; normally this is called after
	all windows are closed so value goes to -1

All functions that decremented the count would check, and if the count was
-1 would actually close the screen and remove it from the system.

The benefits? This would allow windows to open on any screen (maybe unbeknownst 
to the screen owner) and, if the owner attempted a CloseScreen it would succeed
but not actually take the screen away until the remaining window(s)
finally closed.

Detriments? I can't think of any; this is similar to the way it's supposed to
work now, except that it's the responsibility of the screen owner to close
all his windows before closing the screen. The system should provide just
that extra bit of security checking, thus opening up major opportunities for
shared screens between applications.

John
-- 
"Families of Murder Victims bring Human Face to Court Proceedings"
		-- Gets my vote as most poorly-worded headline of the year

jimm@amiga.UUCP (Jim Mackraz) (11/15/88)

In article <4996@garfield.MUN.EDU> john13@garfield.MUN.EDU (John Russell) writes:
)I'm curious as to whether the inner workings of CloseScreen could be
)changed for the better without breaking anything. I think they could.
)
)Why not make the screen structure's presence dependent on a semaphore?

In V1.4, CloseScreen (and OpenWindow, CloseWindow, OpenScreen, and some new ones) will
support "Public Screens" which do All You Want and More.

Although there is a count of "visitor windows," the mechanism isn't exactly
a semaphore, although critical sections of the processing are protected by
an internal Intuition semaphore.

One of the tricky parts for a visitor window is determining if a screen exists, then 
adjusting for the screen's mode, font, depth and so on.  Sound familiar?  That's
what GetScreenData() was all about.  Well, that approach turned out kind of lame,
and a more general function LockPublicScreen() gets you a pointer to the
actual open screen, and a guarantee that that screen won't be closed until
you unlock it and close any windows you opened while it was locked.

I agree with John: this will be pretty useful.  It provides, as a side effect,
the ability to open workbench applications on various screens.  You can
have an editor, for example, which "jumps" from screen to screen, taking you
with it ;^)

)John

	jimm
-- 
	Jim Mackraz, I and I Computing	  
	amiga!jimm	BIX:jmackraz
Opinions are my own.  Comments regarding the Amiga operating system, and
all others, are not to be taken as Commodore official policy.