[comp.sys.mac.programmer] Screen bounds

rcb@rti.UUCP (Random) (09/21/88)

Ok. screenBits.bounds is only for the main screen on a multi screen
system. How do i define the bounds rectangle for a window drag that
will allow it to be dragged to the other screen?. I currently use
screenBits.bounds and inset it. I don't have two screens and therefore
have no way to test this.
-- 
					Randy Buckland (919)-541-7103
					Research Triangle Institute
					rcb@rti.rti.org [128.109.139.2]
					{decvax,ihnp4}!mcnc!rti!rcb

korn@eris.berkeley.edu (Peter "Arrgh" Korn) (09/21/88)

What I do in GLA 1.6a2 (a new release of GLA is on it's way folks), is
get the horizontal and vertical values of the upper left of the window
and stuff that into a rect "dummyRect" (currently the window is of
fixed size; that'll change soon).  Once that is done, I simple check
to see if that rect is inside the region "GrayRgn", which is defined
in all systems after 4.2 I believe (and certainly in 6.0).  This is
described in Inside Mac vol. V, and is a region containing the union of
all of the monitors connected to the system minus the menubar.

If no points of the rect are inside GrayRgn, I set default coords.  Code
is included below.


  SetRect (&dummyRect, (int) **windowPoshHandle, (int) **windowPosvHandle,
	(int) **windowPoshHandle + 40, (int) **windowPosvHandle + 50);

  if (!RectInRgn(&dummyRect, GrayRgn)) {
    **windowPoshHandle = (int) ((screenBits.Bounds.right - screenBits.Bounds.left)/2);
    **windowPosvHandle = (int) ((screenBits.Bounds.bottom - screenBits.Bounds.top)/2);


Note that I'm not setting the window to be in the dead center of the main
window (though close, because of the use of screenBits.Bounds which is only
defined for the window with the menubar on it), but that's just 'cause this
alpha version of GLA is an alpha version and I'm lazy...


Hope this helps,

Peter
--
Peter "Arrgh" Korn
korn@ucbvax.Berkeley.EDU
{decvax,hplabs,sdcsvax,ulysses,usenix}!ucbvax!korn

c9c-ac@dorothy.Berkeley.EDU (Mike) (09/22/88)

DragWindow will handle dagging to all the screens automatically if the 
DragRect specified is "close" to screenBits.bounds.

That is, it assumes you meant the whole desktop if you specify most of the main
screen.

Mike Ferris
c9c-ac@dorothy.Berkeley.Edu

ech@poseidon.UUCP (Edward C Horvath) (09/22/88)

From article <2461@rti.UUCP>, by rcb@rti.UUCP (Random):
! Ok. screenBits.bounds is only for the main screen on a multi screen
! system. How do i define the bounds rectangle for a window drag that
! will allow it to be dragged to the other screen?. I currently use
! screenBits.bounds and inset it. I don't have two screens and therefore
! have no way to test this.

DragWindow recognizes that your limit rect is "near" ScreenBits.bounds, and
actually relaxes it to encompass all screens.  While not strictly what you
might have WANTED, it is probably the "right thing" for Apple to have done
to permit scads of existing apps to run on multiple screens.

=Ned Horvath=