提交 3399d30c 编写于 作者: P Peng Lyu

Fullscreen change event.

上级 63bcdd83
......@@ -857,6 +857,7 @@ export const EventType = {
ERROR: 'error',
RESIZE: 'resize',
SCROLL: 'scroll',
FULLSCREEN_CHANGE: 'fullscreenchange',
// Form
SELECT: 'select',
CHANGE: 'change',
......
......@@ -36,6 +36,7 @@ import { SignService } from 'vs/platform/sign/browser/signService';
import { hash } from 'vs/base/common/hash';
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
import { ProductService } from 'vs/platform/product/browser/productService';
import { setFullscreen } from 'vs/base/browser/browser';
class CodeRendererMain extends Disposable {
......@@ -63,6 +64,13 @@ class CodeRendererMain extends Disposable {
// Layout
this._register(addDisposableListener(window, EventType.RESIZE, () => this.workbench.layout()));
this._register(addDisposableListener(document, EventType.FULLSCREEN_CHANGE, () => {
if (document.fullscreenElement || (<any>document).webkitFullscreenElement) {
setFullscreen(true);
} else {
setFullscreen(false);
}
}));
// Resource Loading
this._register(new WebResources(<IFileService>services.serviceCollection.get(IFileService)));
......
......@@ -788,17 +788,13 @@ export class SimpleWindowService implements IWindowService {
if ((<any>document).fullscreen !== undefined) {
if (!(<any>document).fullscreen) {
return (<any>target).requestFullscreen().then(() => {
browser.setFullscreen(true);
}).catch(() => {
return (<any>target).requestFullscreen().catch(() => {
// if it fails, chromium throws an exception with error undefined.
// re https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen
console.warn('Toggle Full Screen failed');
});
} else {
return document.exitFullscreen().then(() => {
browser.setFullscreen(false);
}).catch(() => {
return document.exitFullscreen().catch(() => {
console.warn('Exit Full Screen failed');
});
}
......@@ -809,7 +805,7 @@ export class SimpleWindowService implements IWindowService {
try {
if (!(<any>document).webkitIsFullScreen) {
(<any>target).webkitRequestFullscreen(); // it's async, but doesn't return a real promise.
browser.setFullscreen(true);
browser.setFullscreen(true); // we have to set this proactively because Safari doesn't emit fullscreenchange event.
} else {
(<any>document).webkitExitFullscreen(); // it's async, but doesn't return a real promise.
browser.setFullscreen(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册