• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Technical Notes & WindowShade

Crutch

Well-known member
Seeking some basic Googling or just smart-person help here:

1. What's a good source for the latest and greatest final version of the classic Mac OS technical notes? I have a binder full of these in hard copy and can find various sources for older versions of the Notes online, but am seeking the definitive late-90s final cut.

2. Has anyone seen any documentation on how the WindowShade feature works/is implemented in 7.5 and above? It is interfering with my Exposé extension in a weird way which seems hard to work around, and I've never seen it documented anywhere. My specific problem is that calling _ShowHide seems to always un-collapse a windowshaded window. I would like to be able to hide, move, then redisplay such a window without uncollapsing it. (If that fails there are uglier things I can do instead, but would love to solve this the right way.)

Looking at you @cheesestraws as the person maybe likeliest to know :)
 
Last edited:

cheesestraws

Well-known member
Thankyou for your confidence, but I fear I'm going to disappoint you on both counts—my tech note collection is sparse, and is missing several, including 197, which would probably be of a great deal of use in my Chooser endeavours...

wrt WindowShade, I don't have any especial knowledge and would have to go back to the code. I did just have a quick scroll through the disassembly of the INIT resource from the old standalone WindowShade cdev, and it doesn't look too obtuse, though...
 

Crutch

Well-known member
I figured out a way to check if WindowShade has been triggered, which was good enough for me to build a workaround (I just check for EmptyRgn(WindowPeek(w)->contRgn), pretty obvious really). So all set with that, though I'd still love to know exactly how it works and in particular where it keeps a record of what the window's size "should" be.
 

Crutch

Well-known member
Instantly after posting that (the fix is already posted in the Exposé thread) I found this with some googling: https://developer.apple.com/library/archive/qa/tb/tb13.html#//apple_ref/doc/uid/DTS10002199

I am posting the text here in case that Apple link ever dies. It’s exactly as I suspected. Maybe useful to somebody else one day!

Technical Q&A TB13
WindowShade Problems​

Q WindowShade is causing a problem for our application, which saves the window position and size when it saves a document to disk. If our application's windows are "rolled up" using WindowShade, it's windows appear to have zero height, and they are saved that way. Is there any way to determine if a window is "rolled up"? If so, can we determine what its true size is and what the global coordinates of the top left corner of the content region are, so that we can restore and reposition the window when the document is reloaded from disk.

A When WindowShade rolls up a window, it hides the content region of the window. You can tell when a window is shaded, because its contRgn is set to an empty region, and its strucRgn is modified to equal the new "shaded" window outline. WindowShade doesn't do anything with the grafPort, so if you need to store the window's dimensions before closing it, you can obtain them from the window's portRect. When you open your window again, you can look at your window's data structure, obtain the saved portRect info, and size the window appropriately.
To determine if a window is rolled up you would use a test such as the one below:
if (EmptyRgn(((WindowPeek) myWindow)->contRgn))
//our window is rolled up

With regard to the window's position, WindowShade empties the content region of the window it rolls up by setting the bottom coordinate of the contRgn's region bounding box equal to the top coordinate of the contRgn's region bounding box, but the contRgn's top, left, and right coordinates are not changed. These are global coordinates, so you can obtain them and then store the contRgn top and left coordinates as follows:
Point contentPosn;
contentPosn.v = (**((WindowPeek)myShellWindow)->contRgn).rgnBBox.top;
contentPosn.h = (**((WindowPeek)myShellWindow)->contRgn).rgnBBox.left;

You should track the strucRgn's top and left coordinates to position your windows later, as shown below:
Point strucPosn;

strucPosn.v = (**((WindowPeek)myShellWindow)->strucRgn).rgnBBox.top;
strucPosn.h = (**((WindowPeek)myShellWindow)->strucRgn).rgnBBox.left;

[May 01 1995]​

 
Top