From 59666767d2db44b819458824d5e4f9b11fe6a900 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Thu, 7 Sep 2017 23:45:10 +0530 Subject: [PATCH 1/2] Electron-118 - Implemented a method to disable always on top while using screen snippet (windows) --- js/screenSnippet/index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/js/screenSnippet/index.js b/js/screenSnippet/index.js index 5069ef84..1c6cbe78 100644 --- a/js/screenSnippet/index.js +++ b/js/screenSnippet/index.js @@ -10,10 +10,12 @@ const path = require('path'); const { isMac, isDevEnv } = require('../utils/misc.js'); const log = require('../log.js'); const logLevels = require('../enums/logLevels.js'); +const eventEmitter = require('.././eventEmitter'); // static ref to child process, only allow one screen snippet at time, so // hold ref to prev, so can kill before starting next snippet. let child; +let isAlwaysOnTop; /** * Captures a user selected portion of the monitor and returns jpeg image @@ -61,6 +63,17 @@ class ScreenSnippet { captureUtil = path.join(execPath, 'ScreenSnippet.exe'); } + // Method to verify and disable always on top property + // as an issue with the ScreenSnippet.exe not being on top + // of the electron wrapper + const windows = electron.BrowserWindow.getAllWindows(); + if (windows && windows.length > 0) { + isAlwaysOnTop = windows[ 0 ].isAlwaysOnTop(); + if (isAlwaysOnTop) { + eventEmitter.emit('isAlwaysOnTop', false); + } + } + captureUtilArgs = [outputFileName]; } @@ -74,9 +87,17 @@ class ScreenSnippet { child = childProcess.execFile(captureUtil, captureUtilArgs, (error) => { // will be called when child process exits. if (error && error.killed) { + // Method to reset always on top feature + if (isAlwaysOnTop) { + eventEmitter.emit('isAlwaysOnTop', true); + } // processs was killed, just resolve with no data. resolve(); } else { + // Method to reset always on top feature + if (isAlwaysOnTop) { + eventEmitter.emit('isAlwaysOnTop', true); + } readResult.call(this, outputFileName, resolve, reject, error); } }); From b3300bb9e35194863eb856a381d38d3b09c5c2a6 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Fri, 8 Sep 2017 12:48:03 +0530 Subject: [PATCH 2/2] Electron-118 - removed the duplicate code block --- js/screenSnippet/index.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/js/screenSnippet/index.js b/js/screenSnippet/index.js index 1c6cbe78..ed64d305 100644 --- a/js/screenSnippet/index.js +++ b/js/screenSnippet/index.js @@ -85,19 +85,15 @@ class ScreenSnippet { } child = childProcess.execFile(captureUtil, captureUtilArgs, (error) => { + // Method to reset always on top feature + if (isAlwaysOnTop) { + eventEmitter.emit('isAlwaysOnTop', true); + } // will be called when child process exits. if (error && error.killed) { - // Method to reset always on top feature - if (isAlwaysOnTop) { - eventEmitter.emit('isAlwaysOnTop', true); - } // processs was killed, just resolve with no data. resolve(); } else { - // Method to reset always on top feature - if (isAlwaysOnTop) { - eventEmitter.emit('isAlwaysOnTop', true); - } readResult.call(this, outputFileName, resolve, reject, error); } });