syswindow_move() doesn't move?

Peter Castine's icon

This seems to be my week for obscure problems.

Following code snippet, simplified (and making some braindead
assumptions about Mac OS desktop geometry, but that's not the problem):

///////////////////
BitMap screenBits;
Rect screenRect,
windRect,
visWindRect;

GetQDGlobalsScreenBits(&screenBits);
screenRect = screenBits.bounds;

// myWind has already been initialized to a valid t_wind struct
windRect.left = myWind->w_x1;
windRect.right = myWind->w_x2;
windRect.top = myWind->w_y1;
windRect.bottom = myWind->w_y2;

SectRect(&screenRect, &windRect, &visWindRect);
// Really should iterate through the device list, but the
// above is good enough for testing...
if (EmptyRect(&visWindRect)) {
syswindow_move(wind_syswind(myWind), 20, 20, true);
}
///////////////////

The window is not moved after the call to syswindow_move().

For instance, inserting strategic post()s, as follows

///////////////////
post("screenRect (%ld, %ld) (%ld, %ld)",
(long) screenRect.left, (long) screenRect.top,
(long) screenRect.right, (long) screenRect.bottom);
post("windRect (%ld, %ld) (%ld, %ld)",
(long) windRect.left, (long) windRect.top,
(long) windRect.right, (long) windRect.bottom);

SectRect(&screenRect, &windRect, &visWindRect);

post("visible area (%ld, %ld) (%ld, %ld)",
(long) visWindRect.left, (long) visWindRect.top,
(long) visWindRect.right, (long) visWindRect.bottom);

if (EmptyRect(&visWindRect)) {
post("about to move window");

syswindow_move(wind_syswind(myWind), 20, 20, true);

post("...new top left: %ld %ld", myWind->w_x1, myWind->w_y1);
}
///////////////////

Can yield the following in the Max window:

screenRect (0, 0) (1440, 900)
windRect (-2032, 850) (-1593, 1170)
visible area (0, 0) (0, 0)
about to move window
...new top left: -2032 850

Expected result: last line should read "...new top left: 20 20". And
the window should be visible on the main screen.

This is on Mac OS 10.4.6, Max/MSP 4.5.6. IDE: CW 8.3.

If I'm not doing something blindingly obviously stupid, I can strip
the code down to a minimal object and make it available.

How does thispatcher do this?

Greetings, Peter