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

feat: support fullScreen BrowserWindow property #23330

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api/browser-window.md
Expand Up @@ -807,6 +807,10 @@ hide it immediately.

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`

A `Boolean` property that determines whether the window is visible on all workspaces.
Expand Down
5 changes: 5 additions & 0 deletions lib/browser/api/top-level-window.js
Expand Up @@ -29,6 +29,11 @@ Object.defineProperty(TopLevelWindow.prototype, 'visibleOnAllWorkspaces', {
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', {
get: function () { return this.isSimpleFullScreen(); },
set: function (simple) { this.setSimpleFullScreen(simple); }
Expand Down
81 changes: 66 additions & 15 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -993,27 +993,78 @@ describe('BrowserWindow module', () => {
});

ifdescribe(process.platform === 'win32')(`Fullscreen state`, () => {
it(`checks normal bounds when fullscreen'ed`, (done) => {
const bounds = w.getBounds();
w.once('enter-full-screen', () => {
expectBoundsEqual(w.getNormalBounds(), bounds);
done();
it('with properties', () => {
it('can be set with the fullscreen constructor option', () => {
w = new BrowserWindow({ fullscreen: true });
expect(w.fullScreen).to.be.true();
});

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) => {
const bounds = w.getBounds();
w.once('enter-full-screen', () => {
it('with functions', () => {
it('can be set with the fullscreen constructor option', () => {
w = new BrowserWindow({ fullscreen: true });
expect(w.isFullScreen()).to.be.true();
});

it('can be changed', () => {
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);
done();

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.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);
});
});
});
Expand Down