From bb26fc27592c2ad9a51cb0144bb5b0df3d1ab7f7 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 5 Nov 2015 11:41:51 +0100 Subject: [PATCH] Ajout mesures anti-disparition de Pitaya en mode desktop --- default-profile.json | 4 ++++ main.js | 9 +++++++++ src/store/actions/launcher.js | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/default-profile.json b/default-profile.json index e166422..efe814f 100644 --- a/default-profile.json +++ b/default-profile.json @@ -14,6 +14,10 @@ "icon": "chromium-browser", "exec": "/usr/bin/chromium-browser", "_key": "item_1444480285022_3" + }, + { + "label": "Pitaya Edit", + "exec": "PITAYA_MODE=edit PITAYA_AS_DESKTOP=0 npm start" } ], "_key": "item_1444480285022_2" diff --git a/main.js b/main.js index bd3ccec..600f8df 100644 --- a/main.js +++ b/main.js @@ -40,6 +40,15 @@ app.on('ready', function() { mainWindow = null; }); + mainWindow.on('blur', function() { + Util.Logger.info('Focus loosed.'); + }); + + mainWindow.on('focus', function() { + Util.Logger.info('Focus gained.'); + mainWindow.show(); + }); + }); process.on('exit', function(code) { diff --git a/src/store/actions/launcher.js b/src/store/actions/launcher.js index f6e9abb..9a5a93e 100644 --- a/src/store/actions/launcher.js +++ b/src/store/actions/launcher.js @@ -1,5 +1,6 @@ var Util = require('../../util'); var logger = Util.Logger; +var remote = require('remote'); var RUN_APP = exports.RUN_APP = 'RUN_APP'; var RUN_APP_SUCCESS = exports.RUN_APP_SUCCESS = 'RUN_APP_SUCCESS'; @@ -16,10 +17,16 @@ exports.runApp = function(execPath) { return Util.System.runApp(execPath, { clearFreeDesktopFlags: true }) .then(function() { dispatch({ type: RUN_APP_SUCCESS, execPath: execPath }); + // Hypothetical fix + var win = remote.getCurrentWindow(); + win.show(); return execPath; }) .catch(function(err) { dispatch({ type: RUN_APP_FAILED, error: err }); + // Hypothetical fix + var win = remote.getCurrentWindow(); + win.show(); return err; }) ;