vanilla icon indicating copy to clipboard operation
vanilla copied to clipboard

self.w.resize() pushes FloatingWindow on top (only on second screen)

Open roberto-arista opened this issue 7 years ago • 8 comments

Hi! Consider this demo:

from vanilla import *

MARGIN = 8
BOTTOM_MARGIN = MARGIN*2

class MyDemo(object):

    popOptions = ('one', 'two')

    def __init__(self):

        self.w = FloatingWindow((0, 0, 200, 300), 'MyDemo')

        self.jumpingY = 10
        self.w.myPop = PopUpButton((10, self.jumpingY, -10, 20),
                                   self.popOptions,
                                   callback=self.myPopCallback)
        self.jumpingY += MARGIN + 20
        self._initCtrlsModeOne()

        self.w.resize(200, self.jumpingY+BOTTOM_MARGIN)
        self.w.open()

    def _initCtrlsModeOne(self):
        self.w.buttonOneAA = SquareButton((10, self.jumpingY, -10, 30),
                                        'AA')
        self.jumpingY += MARGIN + 30

    def _delCtrlsModeOne(self):
        delattr(self.w, 'buttonOneAA')
        self.jumpingY -= MARGIN + 30

    def _delCtrlsModeTwo(self):
        delattr(self.w, 'buttonTwoBB')
        delattr(self.w, 'buttonTwoCC')
        self.jumpingY -= (MARGIN + 30)*2

    def _initCtrlsModeTwo(self):
        self.w.buttonTwoBB = SquareButton((10, self.jumpingY, -10, 30),
                                        'BB')
        self.jumpingY += MARGIN + 30
        self.w.buttonTwoCC = SquareButton((10, self.jumpingY, -10, 30),
                                        'CC')
        self.jumpingY += MARGIN + 30
        self.w.resize(200, self.jumpingY)

    def myPopCallback(self, sender):
        if self.popOptions[sender.get()] == 'one':
            self._delCtrlsModeTwo()
            self._initCtrlsModeOne()
        else:
            self._delCtrlsModeOne()
            self._initCtrlsModeTwo()
        self.w.resize(200, self.jumpingY+BOTTOM_MARGIN)

if __name__ == '__main__':
md = MyDemo()

It is an example for a possible scenario. I have a tool, this tool has a popUpButton() on top which defines the usage mode. Different modes (for example, “place anchors”, “build accents") need different controls below the popUpButton(). Different controls, different window size needed. Therefore I use self.w.resize() to adjust the window height. The issue is: if the tool is placed on my second screen, the method moves the tool on top of the screen.

jumpingwindow

I am on MacOS 10.13.3

Thanks!

roberto-arista avatar Feb 12 '18 15:02 roberto-arista

window.resize is round tripping posSize with window.getPosSize and window.setPosSize

there is something wrong when the screen is not the main screen

see https://github.com/typesupply/vanilla/blob/master/Lib/vanilla/vanillaWindows.py#L376-L377

typemytype avatar Feb 12 '18 15:02 typemytype

not reproducible on 10.10

typemytype avatar Feb 12 '18 15:02 typemytype

Actually, it is reproducible on 10.10, if your screen arrangement looks like this:

image

I bet is has to do with this chunk of code:

https://github.com/typesupply/vanilla/blob/750a336f2acc2d30bbc6f3c92bcdcb8c21e24573/Lib/vanilla/vanillaWindows.py#L343

In the arrangement shown, t (the top coord) can legitimately be negative, and vanilla does the wrong thing here (I think).

justvanrossum avatar Feb 13 '18 16:02 justvanrossum

This bug occurs also on normal windows and also if using setPosSize()

form-follows-function avatar Dec 27 '18 19:12 form-follows-function

could you elaborate your setup? osx version? setup of different screens?

typemytype avatar Dec 28 '18 19:12 typemytype

All he's saying is that it's not just the FloatingWindow, also a normal vanilla Window. I've shown earlier how to replicate on multiple screens.

justvanrossum avatar Dec 28 '18 19:12 justvanrossum

Just to make sure: macOS 10.12.6

My display settings aren't negative on the second screen. bildschirmfoto 2018-12-28 um 21 14 17

I was about to make an example gif and just encountered two important things to note:

  • If there are two windows the second window will fail to resize TypeError: resize() takes exactly 1 argument (2 given) (Maybe the vanillaBase and vanillaWindows-resize functions interfere?)
  • The resize bug will only occur if the application is launched from the second screen. I started the application on my main screen, then moving it to the secondary and the bug did not occur. So it is depending from which screen it was started.

@justvanrossum I got the feeling this bug lays deeper due to my screen setup and the launch-placement.

form-follows-function avatar Dec 28 '18 20:12 form-follows-function

Just ran into the same issue. I am on macOS 10.14.6.

I am changing the height of a Window on my second screen. Everything seems fine when the second screen is below my main screen (widows's y coordinate is positive)

Screenshot 2019-10-18 at 12 06 44

The windows gets unexpectedly stacked to the top of the screen when the second screen is above the main screen (widows's y coordinate is negative)

Screenshot 2019-10-18 at 12 09 11

Nothing critical though 😊

mathieureguer avatar Oct 18 '19 10:10 mathieureguer