diff --git a/src/extensions/default/NoDistractions/main.js b/src/extensions/default/NoDistractions/main.js index 1b0edf7d92..9b48b35163 100644 --- a/src/extensions/default/NoDistractions/main.js +++ b/src/extensions/default/NoDistractions/main.js @@ -19,6 +19,8 @@ * */ +/*global Phoenix*/ + define(function (require, exports, module) { @@ -51,17 +53,15 @@ define(function (require, exports, module) { panelsToggled = false, layoutUpdated = false; - function isInFullScreen() { - return !!document.fullscreenElement; - } - /** * @private * Updates the command checked status based on the preference for noDestraction mode */ function _updateCheckedState() { CommandManager.get(CMD_TOGGLE_PURE_CODE).setChecked(PreferencesManager.get(PREFS_PURE_CODE)); - CommandManager.get(CMD_TOGGLE_FULLSCREEN).setChecked(isInFullScreen()); + Phoenix.app.isFullscreen().then(isFullScreen =>{ + CommandManager.get(CMD_TOGGLE_FULLSCREEN).setChecked(isFullScreen); + }); } /** @@ -75,12 +75,10 @@ define(function (require, exports, module) { async function _toggleFullScreen() { Metrics.countEvent(Metrics.EVENT_TYPE.UI, 'fullscreen', 'toggle'); - if (!isInFullScreen()) { - await document.documentElement.requestFullscreen(); - } else if (document.exitFullscreen) { - await document.exitFullscreen(); - } - _updateCheckedState(); + Phoenix.app.isFullscreen().then(isFullScreen =>{ + Phoenix.app.setFullscreen(!isFullScreen) + .then(_updateCheckedState); + }); } /** diff --git a/src/phoenix/shell.js b/src/phoenix/shell.js index 51b0b0d6b1..aceb8d2c3a 100644 --- a/src/phoenix/shell.js +++ b/src/phoenix/shell.js @@ -63,6 +63,26 @@ Phoenix.app = { } window.__TAURI__.window.appWindow.close(); }, + isFullscreen: function () { + if(!Phoenix.browser.isTauri) { + // use browser full screen api in browsers. + return Promise.resolve(!!document.fullscreenElement); + } + return window.__TAURI__.window.appWindow.isFullscreen(); + }, + setFullscreen: function (enable) { + if(!Phoenix.browser.isTauri) { + // use browser full screen api in browsers. + if (enable) { + return document.documentElement.requestFullscreen(); + } else if (document.exitFullscreen) { + return document.exitFullscreen(); + } else { + return Promise.resolve(); + } + } + return window.__TAURI__.window.appWindow.setFullscreen(enable); + }, getDisplayLocation: function (fullVFSPath) { // reruns a user-friendly location that can be shown to the user to make some sense of the virtual file path. // The returned path may not be an actual path if it is not resolvable to a platform path, but a text indicating