Skip to content

Commit e12eed3

Browse files
committed
Issue 93 include windows mode considerations.
1 parent fe978e0 commit e12eed3

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

background.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,17 @@ ngApp
244244
var ws = event.currentTarget.url.split('ws://')[1];
245245
var session = $scope.devToolsSessions.find(session => session.url.includes(ws));
246246
if (session === undefined) return;
247-
chrome.tabs.update(session.id, { active: true }, tab => {
248-
chrome.windows.update(tab.windowId, { focused: true }, window => {
249-
if ($scope.settings.debugVerbosity >= 4) console.log(`focusOnBreakpoint(): window: ${window.id} tab: ${tab.id}`);
247+
if (session.isWindow) {
248+
chrome.windows.update(session.id, { focused: true }, window => {
249+
if ($scope.settings.debugVerbosity >= 4) console.log(`focusOnBreakpoint(): window: ${window.id}`);
250250
});
251-
});
251+
} else {
252+
chrome.tabs.update(session.id, { active: true }, tab => {
253+
chrome.windows.update(tab.windowId, { focused: true }, window => {
254+
if ($scope.settings.debugVerbosity >= 4) console.log(`focusOnBreakpoint(): window: ${window.id} tab: ${tab.id}`);
255+
});
256+
});
257+
}
252258
break;
253259
}
254260
if ($scope.settings.debugVerbosity >= 1) console.log(event);
@@ -1605,18 +1611,21 @@ ngApp
16051611
});
16061612
if ($scope.settings.newWindow) {
16071613
$window._gaq.push(['_trackEvent', 'Program Event', 'createWindow', 'focused', + $scope.settings.windowFocused, true]);
1608-
chrome.windows.create({
1609-
url: url,
1610-
focused: $scope.settings.windowFocused,
1611-
type: ($scope.settings.panelWindowType) ? 'panel' : 'normal',
1612-
state: $scope.settings.windowStateMaximized ? chrome.windows.WindowState.MAXIMIZED : chrome.windows.WindowState.NORMAL
1613-
}, function(window) {
1614-
$scope.watchdog.increment();
1615-
/* Is window.id going to cause id conflicts with tab.id?! Should I be grabbing a tab.id here as well or instead of window.id? */
1616-
dtpSocketPromise
1617-
.then(dtpSocket => {
1618-
saveSession(url, infoUrl, websocketId, window.id, nodeInspectMetadataJSON, dtpSocket);
1619-
resolve(window);
1614+
chrome.windows.getCurrent(currentWindow => {
1615+
chrome.windows.create({
1616+
url: url,
1617+
focused: $scope.settings.windowFocused,
1618+
type: ($scope.settings.panelWindowType) ? 'panel' : 'normal',
1619+
state: $scope.settings.windowStateMaximized ? chrome.windows.WindowState.MAXIMIZED : $scope.settings.windowFocused ? chrome.windows.WindowState.NORMAL : chrome.windows.WindowState.MINIMIZED
1620+
}, function(window) {
1621+
chrome.windows.update(currentWindow.id, {focused: true});
1622+
$scope.watchdog.increment();
1623+
/* Is window.id going to cause id conflicts with tab.id?! Should I be grabbing a tab.id here as well or instead of window.id? */
1624+
dtpSocketPromise
1625+
.then(dtpSocket => {
1626+
saveSession(url, infoUrl, websocketId, window.id, nodeInspectMetadataJSON, dtpSocket);
1627+
resolve(window);
1628+
});
16201629
});
16211630
});
16221631
} else {

0 commit comments

Comments
 (0)