1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 07:14:13 +01:00

Remember last focused frame

This commit is contained in:
Kris Maglione
2008-11-21 06:35:27 +00:00
parent 2d7036b917
commit d4ef9cee7a
4 changed files with 37 additions and 38 deletions

View File

@@ -92,9 +92,9 @@ function Buffer() //{{{
if (win.scrollMaxX > 0 || win.scrollMaxY > 0) if (win.scrollMaxX > 0 || win.scrollMaxY > 0)
return win; return win;
for (let i = 0; i < win.frames.length; i++) for (let frame in util.Array.iterator(win.frames))
if (win.frames[i].scrollMaxX > 0 || win.frames[i].scrollMaxY > 0) if (frame.scrollMaxX > 0 || frame.scrollMaxY > 0)
return win.frames[i]; return frame;
return win; return win;
} }
@@ -1184,6 +1184,7 @@ function Buffer() //{{{
if (!window.content.document instanceof HTMLDocument) if (!window.content.document instanceof HTMLDocument)
return; return;
count = Math.max(count, 1);
var frames = []; var frames = [];
// find all frames - depth-first search // find all frames - depth-first search
@@ -1216,32 +1217,24 @@ function Buffer() //{{{
var next = current; var next = current;
if (forward) if (forward)
{ {
if (count > 1) next = current + count;
next = current + count;
else
next++;
if (next > frames.length - 1) if (next > frames.length - 1)
{ {
if (current == frames.length - 1) if (current == frames.length - 1)
liberator.beep(); // still allow the frame indicator to be activated liberator.beep();
next = frames.length - 1; // still allow the frame indicator to be activated
next = frames.length - 1;
} }
} }
else else
{ {
if (count > 1) next = current - count;
next = current - count;
else
next--;
if (next < 0) if (next < 0)
{ {
if (current == 0) if (current == 0)
liberator.beep(); // still allow the frame indicator to be activated liberator.beep();
next = 0; // still allow the frame indicator to be activated
next = 0;
} }
} }
@@ -1263,7 +1256,7 @@ function Buffer() //{{{
// TODO: print more useful information, just like the DOM inspector // TODO: print more useful information, just like the DOM inspector
showElementInfo: function (elem) showElementInfo: function (elem)
{ {
liberator.echo(<>Element:<br/></> + util.objectToString(elem), commandline.FORCE_MULTILINE); liberator.echo(<>Element:<br/>{util.objectToString(elem, true)}</>, commandline.FORCE_MULTILINE);
}, },
showPageInfo: function (verbose) showPageInfo: function (verbose)

View File

@@ -1064,6 +1064,9 @@ function Events() //{{{
var win = window.document.commandDispatcher.focusedWindow; var win = window.document.commandDispatcher.focusedWindow;
var elem = window.document.commandDispatcher.focusedElement; var elem = window.document.commandDispatcher.focusedElement;
if (win && win.top == content && liberator.has("tabs"))
tabs.localStore.focusedFrame = win;
if (elem && elem.readOnly) if (elem && elem.readOnly)
return; return;

View File

@@ -820,8 +820,8 @@ const liberator = (function () //{{{
// if clearFocusedElement, also blur a focused link // if clearFocusedElement, also blur a focused link
focusContent: function (clearFocusedElement) focusContent: function (clearFocusedElement)
{ {
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher); .getService(Components.interfaces.nsIWindowWatcher);
if (window == ww.activeWindow && document.commandDispatcher.focusedElement && clearFocusedElement) if (window == ww.activeWindow && document.commandDispatcher.focusedElement && clearFocusedElement)
document.commandDispatcher.focusedElement.blur(); document.commandDispatcher.focusedElement.blur();
@@ -830,16 +830,21 @@ const liberator = (function () //{{{
{ {
if (liberator.has("mail") && clearFocusedElement && !config.isComposeWindow) if (liberator.has("mail") && clearFocusedElement && !config.isComposeWindow)
{ {
var i = gDBView.selection.currentIndex; let i = gDBView.selection.currentIndex;
if (i == -1 && gDBView.rowCount >= 0) if (i == -1 && gDBView.rowCount >= 0)
i = 0; i = 0;
gDBView.selection.select(i); gDBView.selection.select(i);
} }
} }
catch (e) {} catch (e) {}
var elem = config.mainWidget || window.content; let elem = config.mainWidget || window.content;
if (this.has("tabs"))
{
let frame = tabs.localStore.focusedFrame;
if (frame && frame.top == window.content)
elem = frame;
}
if (elem && (elem != document.commandDispatcher.focusedElement)) if (elem && (elem != document.commandDispatcher.focusedElement))
elem.focus(); elem.focus();
}, },

View File

@@ -674,14 +674,20 @@ function Tabs() //{{{
get count() getBrowser().mTabs.length, get count() getBrowser().mTabs.length,
// used for :setlocal
get options() get options()
{ {
var tab = this.getTab(); let store = this.localStore;
if (!tab.liberatorOptions) if (!("options" in store))
tab.liberatorOptions = {}; store.options = {};
return store.options;
},
return tab.liberatorOptions; get localStore()
{
let tab = this.getTab();
if (!tab.liberatorStore)
tab.liberatorStore = {};
return tab.liberatorStore;
}, },
get tabStrip() get tabStrip()
@@ -696,15 +702,7 @@ function Tabs() //{{{
index: function (tab) index: function (tab)
{ {
if (tab) if (tab)
{ return Array.indexOf(getBrowser().mTabs, tab);
var length = getBrowser().mTabs.length;
for (let i = 0; i < length; i++)
{
if (getBrowser().mTabs[i] == tab)
return i;
}
return -1;
}
return getBrowser().mTabContainer.selectedIndex; return getBrowser().mTabContainer.selectedIndex;
}, },
@@ -737,7 +735,7 @@ function Tabs() //{{{
getTab: function (index) getTab: function (index)
{ {
if (index) if (index != undefined)
return getBrowser().mTabs[index]; return getBrowser().mTabs[index];
return getBrowser().mTabContainer.selectedItem; return getBrowser().mTabContainer.selectedItem;