Open naeloob opened 4 years ago
Another implementation to try to get the browser to the front. This time is changing its state : Minimized, Maximized, normal o fullscreen. In general it minimizes the window and then restore its original state.
activate(tab_id, focused) {
this._browser.tabs.update(tab_id, {'active': true});
if (focused) {
this._browser.tabs.get(tab_id,function (tab){
this._browser.windows.get(tab.windowId,function (win){
if (!win.focused) {
if (win.state=="normal"){
this._browser.windows.update(win.id, {state: "minimized"});
this._browser.windows.update(win.id, {state: "normal"});
}
if (win.state=="maximized"){
this._browser.windows.update(win.id, {state: "minimized"});
this._browser.windows.update(win.id, {state: "maximized"});
}
if (win.state=="minimized"){
this._browser.windows.update(win.id, {state: "maximized"});
}
if (win.state=="fullscreen"){
this._browser.windows.update(win.id, {state: "minimized"});
this._browser.windows.update(win.id, {state: "fullscreen"});
}
}
});
});
}
}
Edit : forget about this comment. Still Testing.
Firefox has another option on windows.update
From Firefox Docs : https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/update
drawAttention : boolean. If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window.
Don't know why but i have strange behaviour with these options :
So, until we full understand it, i think the best is add drawAttention on Firefox.
Changes on Class FirefoxTabs :
Changes on Class ChromeTabs :
Edit : It seems Chrome also has the drawAttention option, so both classes (FF and Chrome versions) could have the same method.
Edit2 : No, we cannot use the same method neither unify with this._browser... so : Chrome Version
FF Version