fix: improve single-pixel resize handling on Windows (#44722)

* fix: improve single-pixel resize handling

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update spec/api-browser-window-spec.ts

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

* Update shell/browser/native_window_views.cc

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2024-11-19 10:53:04 -05:00 committed by GitHub
commit ca8e1e4af6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 6 deletions

View file

@ -1544,6 +1544,16 @@ describe('BrowserWindow module', () => {
await expect(once(w, 'resized')).to.eventually.be.fulfilled();
});
});
it('does not emits the resize event for move-only changes', async () => {
const [x, y] = w.getPosition();
w.once('resize', () => {
expect.fail('resize event should not be emitted');
});
w.setBounds({ x: x + 10, y: y + 10 });
});
});
describe('BrowserWindow.setSize(width, height)', () => {
@ -1557,6 +1567,17 @@ describe('BrowserWindow module', () => {
expectBoundsEqual(w.getSize(), size);
});
it('emits the resize event for single-pixel size changes', async () => {
const [width, height] = w.getSize();
const size = [width + 1, height - 1];
const resized = once(w, 'resize');
w.setSize(size[0], size[1]);
await resized;
expectBoundsEqual(w.getSize(), size);
});
ifit(process.platform === 'darwin')('on macOS', () => {
it('emits \'resized\' event after animating', async () => {
const size = [300, 400];