Windows resize

Hello!
I’ve got a question about the eternal problem of keeping aspect2d ratio while resizing window.:smiley:

I created a little code that work perfectly under linux, no worries.
But under windows, there is a bug. If i resize the window, nothing works ( it is still going through my code.) But if I move the window ( or lose focus, gain focus, etc… ) everything returns to normal.

As if there were a resizing function after my code that breaks everything.

Does that ring a bell anyone ?

class WindowHandler(DirectObject):
    def __init__(self):
        self.accept('window-event', self.first_activation)

    def first_activation(self,win):
        x = win.getXSize()
        y = win.getYSize()
        self.ratio2d = aspect2d.getScale()[0] , aspect2d.getScale()[1]
        self.first_size = x,y
        self.ratioX = x /float(base.cam.node().getLens().getHfov())
        self.ratioY = y /float(base.cam.node().getLens().getVfov())
        #=
        base.cam.node().getLens().setFilmSize(x,y)
        self.ignore('window-event')
        self.accept('window-event', self.resize_window)

    def resize_window(self,win):
        x = win.getXSize()
        y = win.getYSize()
        self.size = (x,y)
        self.resize_aspect2d()

    def resize_aspect2d(self):
        scaleX = self.ratio2d[0] * self.first_size[0] / float(self.size[0])
        scaleY = self.ratio2d[1] * self.first_size[1] / float(self.size[1])
        aspect2d.setScale(scaleX,0,scaleY)

I finally find a hack that make the window correctly resized, but it’s really ugly:

 base.win.setWindowEvent('event_temp')
        self.accept('event_temp',self.window_event_temp)
        self.ignore('window-event')
        self.accept('window-event', self.resize_window)

    def window_event_temp(self,win):
        messenger.send('window-event',[1,])

    def resize_window(self,win=None):
        x = base.win.getXSize()
        y = base.win.getYSize()
        self.resize_aspect2d()

The [1,] parameter is the key, if i pass win as argument, nothing change ( I 've still got the bad resize ) , but i supposed that the window handler try to do thing with the window passed in parameter, so i sent it a bad one, and i still do that i should, acceding the window with base.win.