From a6bada4667e4dd6ff7b3ae9a083fb8f1205758f2 Mon Sep 17 00:00:00 2001 From: cTn Date: Tue, 24 Jun 2014 15:15:22 +0200 Subject: [PATCH] getting app.window.create ready for M36+ --- background.js | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/background.js b/background.js index cc73727ec2..dbf66d9b15 100644 --- a/background.js +++ b/background.js @@ -1,12 +1,8 @@ /* - resizable: false - Keep in mind this only disables the side/corner resizing via mouse, nothing more - maxWidth / maxHeight - is defined to prevent application reaching maximized state through window manager - - We are setting Bounds through setBounds method after window was created because on linux setting Bounds as - window.create property seemed to fail, probably because "previous" bounds was used instead according to docs. - - bounds - Size and position of the content in the window (excluding the titlebar). If an id is also specified and a window with a matching id has been shown before, the remembered bounds of the window will be used instead. + + Size calculation for innerBounds seems to be faulty, app was designed for 960x625, using arbitrary values to make innerBounds happy for now + arbitrary values do match the windows ui, how it will affect other OSs is currently unknown */ function start_app() { chrome.app.window.create('main.html', { @@ -29,6 +25,31 @@ function start_app() { } }); }); + + /* code belowis chrome 36+ ready, till this is enforced in manifest we have to use the old version + chrome.app.window.create('main.html', { + id: 'main-window', + frame: 'chrome', + innerBounds: { + minWidth: 974, + minHeight: 632 + } + }, function(createdWindow) { + createdWindow.onClosed.addListener(function() { + // connectionId is passed from the script side through the chrome.runtime.getBackgroundPage refference + // allowing us to automatically close the port when application shut down + + // save connectionId in separate variable before app_window is destroyed + var connectionId = app_window.serial.connectionId; + + if (connectionId > 0) { + chrome.serial.disconnect(connectionId, function(result) { + console.log('SERIAL: Connection closed - ' + result); + }); + } + }); + }); + */ } chrome.app.runtime.onLaunched.addListener(function() {