in reply to Tk multiple monitor problem

As far as portability Tk sucks at geometry, but its not alone in getting this wrong

Replies are listed 'Best First'.
Re^2: Tk multiple monitor problem
by JohnRS (Scribe) on Mar 10, 2012 at 11:39 UTC

    Yes, from what I gather, the problem with Show is that the check to make sure that it places popups in viewable area fails because the test doesn't realize that there is a left monitor. This is somewhat odd considering that you can use the geometry command to put the main window there.

    Indeed, I have come up with a work around. It's tacky, but it works. Rather than fight Show's limitation, I use it as is, letting it place the popup incorrectly. Then I use a geometry command to move the popup to where it should be. Since your code stops running after the Show, I came up with the following way to accomplish this. Immediately prior to the Show I added the following.

    $mw->after(2, \&Popup_Position_Fix, $popup, $popover);

    The Popup_Position_Fix routine does some calculating then executes a geometry command on the popup. As I said, tacky, but it works. :)

      As long as it works, tacky is beautiful :) but grepping through the source, -popover should have worked, go figure

      Tk/DialogBox.pm

      Tk/Wm.pm

        I did look at DialogBox.pm and a few others. This is why I feld that probably the Show routine was at fault. I did not know where to find Popup till your message, however. In Wm.pm I now see it. Indeed, this part of it would appear to cause the problem.

        # adjust to not cross screen borders if ($X < 0) { $X = 0 }

        Unfortunately, when I change this line my code runs the same. So I'm mystified.

        Also in Wm.pm I noted the Post routine. It contains this.

        $w->geometry("+$X+$Y"); # $w->MoveToplevelWindow($X,$Y);

        I'm guessing that the commented out MoveToplevelWindow call was replaced by the one to geometry (which works OK on multiple monitors).

        Thanks for the leads, however. :)