From 1e62eea8ea02ca0b7f75ed3d2ad60d4d8ac712b3 Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Thu, 1 Mar 2018 20:07:27 +0100 Subject: [PATCH] fix fullscreen --- src/core/gui.coffee | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/core/gui.coffee b/src/core/gui.coffee index 6567a73..57c3172 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -1,6 +1,7 @@ self.OS.GUI = subwindows: new Object() dialog: undefined + fullscreen: false htmlToScheme: (html, app, parent) -> scheme = $.parseHTML html ($ parent).append scheme @@ -156,12 +157,18 @@ self.OS.GUI = app.appmenu = ($ "[data-id = 'appmenu']", "#syspanel")[0] app.init() - enterFullscreen: () -> + toggleFullscreen: () -> el = ($ "body")[0] - return el.requestFullscreen() if el.requestFullscreen - return el.mozRequestFullScreen() if el.mozRequestFullScreen - return el.webkitRequestFullscreen() if el.webkitRequestFullscreen - return el.msRequestFullscreen() if el.msRequestFullscreen + if _GUI.fullscreen + return document.exitFullscreen() if document.exitFullscreen + return document.mozCancelFullScreen() if document.mozCancelFullScreen + return document.webkitExitFullscreen() if document.webkitExitFullscreen + return document.exitFullscreen() if document.exitFullscreen + else + return el.requestFullscreen() if el.requestFullscreen + return el.mozRequestFullScreen() if el.mozRequestFullScreen + return el.webkitRequestFullscreen() if el.webkitRequestFullscreen + return el.msRequestFullscreen() if el.msRequestFullscreen undock: (app) -> ($ "#sysdock").get(0).removeapp app @@ -182,6 +189,8 @@ self.OS.GUI = event.preventDefault() initDM: -> + ($ "body").on 'webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange', ()-> + _GUI.fullscreen = not _GUI.fullscreen # check login first _API.resource "schemes/dm.html", (x) -> return null unless x @@ -317,7 +326,7 @@ self.OS.GUI = ] menu.child = menu.child.concat (v for k, v of _OS.setting.system.menu) menu.child.push - text: "Full screen", + text: "Toggle Full screen", dataid: "os-fullsize", iconclass: "fa fa-tv" menu.child.push @@ -326,7 +335,7 @@ self.OS.GUI = iconclass: "fa fa-user-times" menu.onmenuselect = (d) -> return _API.handler.logout() if d.item.data.dataid is "sys-logout" - return _GUI.enterFullscreen() if d.item.data.dataid is "os-fullsize" + return _GUI.toggleFullscreen() if d.item.data.dataid is "os-fullsize" _GUI.launch d.item.data.app unless d.item.data.dataid ($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", [menu]