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

Make sure UI loads when minimized. #13887

Merged
merged 3 commits into from
Jul 15, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions examples/api-tests/src/views.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

const { timeout } = require('@theia/core/lib/common/promise-util');

// @ts-check
describe('Views', function () {
this.timeout(7500);
Expand Down Expand Up @@ -52,24 +54,26 @@ describe('Views', function () {
if (view) {
assert.notEqual(shell.getAreaFor(view), contribution.defaultViewOptions.area);
assert.isFalse(view.isVisible);
assert.notEqual(view, shell.activeWidget);
assert.isTrue(view !== shell.activeWidget, `${contribution.viewLabel} !== shell.activeWidget`);
}

view = await contribution.toggleView();
assert.notEqual(view, undefined);
// we can't use "equals" here because Mocha chokes on the diff for certain widgets
assert.isTrue(view !== undefined, `${contribution.viewLabel} !== undefined`);
assert.equal(shell.getAreaFor(view), contribution.defaultViewOptions.area);
assert.isDefined(shell.getTabBarFor(view));
// @ts-ignore
assert.equal(shell.getAreaFor(shell.getTabBarFor(view)), contribution.defaultViewOptions.area);
assert.isTrue(view.isVisible);
assert.equal(view, shell.activeWidget);
assert.isTrue(view === shell.activeWidget, `${contribution.viewLabel} === shell.activeWidget`);

view = await contribution.toggleView();
await timeout(0); // seems that the "await" is not enought to guarantee that the panel is hidden
assert.notEqual(view, undefined);
assert.equal(shell.getAreaFor(view), contribution.defaultViewOptions.area);
assert.isDefined(shell.getTabBarFor(view));
assert.isFalse(view.isVisible);
assert.notEqual(view, shell.activeWidget);
assert.isTrue(view !== shell.activeWidget, `${contribution.viewLabel} !== shell.activeWidget`);
});
}

Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/browser/shell/split-panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ export class SplitPositionHandler {
move.resolve = resolve;
move.reject = reject;
if (this.splitMoves.length === 0) {
window.requestAnimationFrame(this.animationFrame.bind(this));
setTimeout(this.animationFrame.bind(this), 10);
}
this.splitMoves.push(move);
});
}

protected animationFrame(time: number): void {
protected animationFrame(): void {
const time = Date.now();
const move = this.splitMoves[this.currentMoveIndex];
let rejectedOrResolved = false;
if (move.ended || move.referenceWidget && move.referenceWidget.isHidden) {
Expand Down Expand Up @@ -133,7 +134,7 @@ export class SplitPositionHandler {
this.currentMoveIndex = 0;
}
if (this.splitMoves.length > 0) {
window.requestAnimationFrame(this.animationFrame.bind(this));
setTimeout(this.animationFrame.bind(this));
}
}

Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/electron-main/electron-main-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
// *****************************************************************************

import { inject, injectable, named } from 'inversify';
import { screen, app, BrowserWindow, WebContents, Event as ElectronEvent, BrowserWindowConstructorOptions, nativeImage,
nativeTheme, shell, dialog } from '../../electron-shared/electron';
import {
screen, app, BrowserWindow, WebContents, Event as ElectronEvent, BrowserWindowConstructorOptions, nativeImage,
nativeTheme, shell, dialog
} from '../../electron-shared/electron';
import * as path from 'path';
import { Argv } from 'yargs';
import { AddressInfo } from 'net';
Expand Down Expand Up @@ -350,6 +352,9 @@ export class ElectronMainApplication {
alwaysOnTop: true,
show: false,
transparent: true,
webPreferences: {
backgroundThrottling: false
}
});

if (this.isShowWindowEarly()) {
Expand Down Expand Up @@ -458,6 +463,7 @@ export class ElectronMainApplication {
// Setting the following option to `true` causes some features to break, somehow.
// Issue: https://github.com/eclipse-theia/theia/issues/8577
nodeIntegrationInWorker: false,
backgroundThrottling: false,
preload: path.resolve(this.globals.THEIA_APP_PROJECT_PATH, 'lib', 'frontend', 'preload.js').toString()
},
...this.config.electron?.windowOptions || {},
Expand Down
Loading