kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.36k stars 128 forks source link

Window.setFrame causes flickering if done quickly after screen changes #296

Open metakirby5 opened 2 years ago

metakirby5 commented 2 years ago

After upgrading to 3.0.0, I noticed that doing Window.setFrame quickly after the screen changes, e.g. via Space.moveWindows or Window.setScreen causes the window to flicker in its old screen before assuming its final position. I'm not sure how fast "quickly" exactly is, but around 0.15 seconds after the screen changes is when the flickering no longer occurs on my machine (tested by deferring the setFrame call with Timer.after).

I looked in the source code and found that setFrame does the following:

- (BOOL) setFrame:(CGRect)frame {

    [self setSize:frame.size];
    [self setTopLeft:frame.origin];
    [self setSize:frame.size];

    return CGRectEqualToRect([self frame], frame);
}

I tried simulating setFrame with a different set of calls to achieve the same effect, and it seems to solve the issue:

function setFrame(window, frame) {
  window.setTopLeft(frame);
  window.setSize(frame);
  window.setTopLeft(frame);
}
kasper commented 2 years ago

@metakirby5 Thanks for the report, I will look into this!