On Sat, Nov 12, 2011 at 5:40 AM, Manolo Gouy <manolo.g...@univ-lyon1.fr> wrote:
> I describe here the logic flow of window creation:
>
> // this puts in the crect rectangle the desired window position and size
>    NSRect crect;
>    crect.origin.x = w->x();
>    crect.origin.y = main_screen_height - (w->y() + w->h());
>    crect.size.width=w->w();
>    crect.size.height=w->h();

crect (x, y) = (2910, 718)

> // this creates a window asking for a position/size through crect
>    FLWindow *cw = [[FLWindow alloc] initWithFl_W:w
>                                      contentRect:crect
>                                        styleMask:winstyle];
>
> ...
> // this maps the new window to the screen
>      [cw makeKeyAndOrderFront:nil];
> // this gets the actual size of the mapped window
>    crect = [[cw contentView] frame];
> // and puts the actual size in w->w() and w->h()
>    w->w(int(crect.size.width));
>    w->h(int(crect.size.height));
> // this gets the actual window position
>    crect = [cw frame];

crect (x, y) = (1800, -114)

> // and puts the actual position in w->x() and w->y()
>    w->x(int(crect.origin.x));
>    w->y(int(main_screen_height - (crect.origin.y + w->h())));
> The last statement above reflects the fact that cocoa uses coordinates
> that go upward from the main screen bottom whereas FLTK uses
> coordinates that go downward from the main screen top.

Thanks, the comments help a lot.  So one thing that strikes me as
suspicious is that you are converting coordinates by subtracting
main_screen_height.  But if the window is on a different screen won't
that be incorrect?  It seems like any reference in fltk to a "main
screen" is likely to be misguided, since as far as I can tell main
screen just determines where the menu bar is, and that's not fltk's
responsibility.

> Did you try and add a poition() call in your make() function
> after the show() statement ? What happens ?

The positions are correct, but only while the other monitor is plugged
in.  When it's removed, they're all bunched up on the right, whereas
if I had listened to the window manager they would still be bunched
but at least fully on the screen.

If I add back my original workaround at the start of the thread, all
the positioning as "correct" (in the right place with the external
monitor, and placed according to the WM when it's not plugged in).

_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to