feat: support fullScreen BrowserWindow property (#23145)
This commit is contained in:
parent
928e23a263
commit
f3dc3997b1
3 changed files with 75 additions and 15 deletions
|
@ -807,6 +807,10 @@ hide it immediately.
|
||||||
|
|
||||||
A `Boolean` property that determines whether the window is in simple (pre-Lion) fullscreen mode.
|
A `Boolean` property that determines whether the window is in simple (pre-Lion) fullscreen mode.
|
||||||
|
|
||||||
|
#### `win.fullScreen`
|
||||||
|
|
||||||
|
A `Boolean` property that determines whether the window is in fullscreen mode.
|
||||||
|
|
||||||
#### `win.visibleOnAllWorkspaces`
|
#### `win.visibleOnAllWorkspaces`
|
||||||
|
|
||||||
A `Boolean` property that determines whether the window is visible on all workspaces.
|
A `Boolean` property that determines whether the window is visible on all workspaces.
|
||||||
|
|
|
@ -29,6 +29,11 @@ Object.defineProperty(TopLevelWindow.prototype, 'visibleOnAllWorkspaces', {
|
||||||
set: function (visible) { this.setVisibleOnAllWorkspaces(visible); }
|
set: function (visible) { this.setVisibleOnAllWorkspaces(visible); }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(TopLevelWindow.prototype, 'fullScreen', {
|
||||||
|
get: function () { return this.isFullScreen(); },
|
||||||
|
set: function (full) { this.setFullScreen(full); }
|
||||||
|
});
|
||||||
|
|
||||||
Object.defineProperty(TopLevelWindow.prototype, 'simpleFullScreen', {
|
Object.defineProperty(TopLevelWindow.prototype, 'simpleFullScreen', {
|
||||||
get: function () { return this.isSimpleFullScreen(); },
|
get: function () { return this.isSimpleFullScreen(); },
|
||||||
set: function (simple) { this.setSimpleFullScreen(simple); }
|
set: function (simple) { this.setSimpleFullScreen(simple); }
|
||||||
|
|
|
@ -1010,27 +1010,78 @@ describe('BrowserWindow module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(process.platform === 'win32')(`Fullscreen state`, () => {
|
ifdescribe(process.platform === 'win32')(`Fullscreen state`, () => {
|
||||||
it(`checks normal bounds when fullscreen'ed`, (done) => {
|
it('with properties', () => {
|
||||||
const bounds = w.getBounds();
|
it('can be set with the fullscreen constructor option', () => {
|
||||||
w.once('enter-full-screen', () => {
|
w = new BrowserWindow({ fullscreen: true });
|
||||||
expectBoundsEqual(w.getNormalBounds(), bounds);
|
expect(w.fullScreen).to.be.true();
|
||||||
done();
|
});
|
||||||
|
|
||||||
|
it('can be changed', () => {
|
||||||
|
w.fullScreen = false;
|
||||||
|
expect(w.fullScreen).to.be.false();
|
||||||
|
w.fullScreen = true;
|
||||||
|
expect(w.fullScreen).to.be.true();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`checks normal bounds when fullscreen'ed`, (done) => {
|
||||||
|
const bounds = w.getBounds();
|
||||||
|
w.once('enter-full-screen', () => {
|
||||||
|
expectBoundsEqual(w.getNormalBounds(), bounds);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
w.show();
|
||||||
|
w.fullScreen = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`checks normal bounds when unfullscreen'ed`, (done) => {
|
||||||
|
const bounds = w.getBounds();
|
||||||
|
w.once('enter-full-screen', () => {
|
||||||
|
w.fullScreen = false;
|
||||||
|
});
|
||||||
|
w.once('leave-full-screen', () => {
|
||||||
|
expectBoundsEqual(w.getNormalBounds(), bounds);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
w.show();
|
||||||
|
w.fullScreen = true;
|
||||||
});
|
});
|
||||||
w.show();
|
|
||||||
w.setFullScreen(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`checks normal bounds when unfullscreen'ed`, (done) => {
|
it('with functions', () => {
|
||||||
const bounds = w.getBounds();
|
it('can be set with the fullscreen constructor option', () => {
|
||||||
w.once('enter-full-screen', () => {
|
w = new BrowserWindow({ fullscreen: true });
|
||||||
|
expect(w.isFullScreen()).to.be.true();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can be changed', () => {
|
||||||
w.setFullScreen(false);
|
w.setFullScreen(false);
|
||||||
|
expect(w.isFullScreen()).to.be.false();
|
||||||
|
w.setFullScreen(true);
|
||||||
|
expect(w.isFullScreen()).to.be.true();
|
||||||
});
|
});
|
||||||
w.once('leave-full-screen', () => {
|
|
||||||
expectBoundsEqual(w.getNormalBounds(), bounds);
|
it(`checks normal bounds when fullscreen'ed`, (done) => {
|
||||||
done();
|
const bounds = w.getBounds();
|
||||||
|
w.once('enter-full-screen', () => {
|
||||||
|
expectBoundsEqual(w.getNormalBounds(), bounds);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
w.show();
|
||||||
|
w.setFullScreen(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`checks normal bounds when unfullscreen'ed`, (done) => {
|
||||||
|
const bounds = w.getBounds();
|
||||||
|
w.once('enter-full-screen', () => {
|
||||||
|
w.setFullScreen(false);
|
||||||
|
});
|
||||||
|
w.once('leave-full-screen', () => {
|
||||||
|
expectBoundsEqual(w.getNormalBounds(), bounds);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
w.show();
|
||||||
|
w.setFullScreen(true);
|
||||||
});
|
});
|
||||||
w.show();
|
|
||||||
w.setFullScreen(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue