Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
roberto-arista opened this issue Feb 12, 2018 · 8 comments
Labels

Comments

@roberto-arista
Copy link
Contributor

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!

@typemytype
Copy link
Member

typemytype commented Feb 12, 2018

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
Copy link
Member

not reproducible on 10.10

@justvanrossum
Copy link
Collaborator

justvanrossum commented Feb 13, 2018

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).

@form-follows-function
Copy link
Contributor

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

@typemytype
Copy link
Member

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

@justvanrossum
Copy link
Collaborator

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.

@form-follows-function
Copy link
Contributor

form-follows-function commented Dec 28, 2018

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.

@mathieureguer
Copy link
Contributor

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 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants