WindowPosition does not update miniwindow coordinates until after next repaint

Posted by Fiendish on Tue 04 Sep 2012 02:07 AM — 9 posts, 23,434 views.

USA Global Moderator #0
(discovered because of the new movewindow position saving changes)

WindowPosition does not update miniwindow coordinates right away. So any references to WindowInfo(win, 10) or WindowInfo(win, 11) are incorrect thereafter until something like a repaint happens.

This of course means that moving and then saving the new position does not work.
Amended on Tue 04 Sep 2012 02:16 AM by Fiendish
Australia Forum Administrator #1
The coordinates, some of them at least, depend on where the window is painted. For example, all of the "centering" operations, eg.

Quote:

The other positions (5, 7, 9, 11) are used for centering the window between the corners. MUSHclient tries to fit the miniwindow exactly in the middle between any corner windows. Also, if more than one window is designated as centered on that side (eg., the right side) it tries to fit them all in, evenly spaced.


The actual coordinates are discovered when the window is painted.
USA Global Moderator #2
This applies to absolute positioning as well? It seems a bit weird. I imagine miniwindows as being some virtual thing with a position that just gets drawn every once in a while.
Amended on Tue 04 Sep 2012 12:53 PM by Fiendish
Australia Forum Administrator #3
The updating of those "info" fields is done in one place, if that is what you mean. And since some of them are dynamic (it depends which windows are active at the time of the redraw, the output window size etc.) it has to be done at paint time.

Quote:

I imagine miniwindows as being some virtual thing ...


Not sure what you mean by that.
USA Global Moderator #4
Quote:
Not sure what you mean by that.

Ah, I mean...uhh...
Your house has a certain position even if you walk home with your eyes closed. :D
It is strange to me that the position should be determined by drawing, rather than the other way around.
Australia Forum Administrator #5
Think of Schrödinger's cat.

The miniwindow doesn't have a known position until you "look" at it, that is, draw it.

Otherwise every time you resized the output window, or created or destroyed a miniwindow, or enabled or disabled its "show" flag, you would have to run around recomputing all of the positions for every miniwindow, in order to satisfy your requirement that the WindowInfo works "all the time".

But even then you have only moved the problem. Say you do a WindowInfo, get the window's (intended) position, and then the main output window is resized before it is drawn, your information is still out of date.
USA Global Moderator #6
As long as you think it makes sense. Is this documented somewhere? I don't recall seeing this detail in WindowPosition help.
Amended on Wed 05 Sep 2012 12:46 AM by Fiendish
Australia Forum Administrator #7
The documentation for WindowInfo (the function you are querying) says:

Quote:

InfoType 10 to 13 are where the auto positioning last placed the window (the last time the main screen was refreshed).


USA Global Moderator #8
Aha, thanks.