1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-27 23:33:32 +01:00

Fix callInMainThread and wrap dactyl.beep. Fixes liberator issue #356.

This commit is contained in:
Kris Maglione
2010-08-28 18:58:37 -04:00
parent 9f0b293881
commit 0b13017b17

View File

@@ -41,7 +41,7 @@ const Storage = Module("storage", {
function Runnable(self, func, args) { function Runnable(self, func, args) {
return { return {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRunnable]), QueryInterface: XPCOMUtils.generateQI([Ci.nsIRunnable]),
run: function () { func.apply(self, args); } run: function () { func.apply(self, args || []); }
}; };
} }
@@ -183,17 +183,19 @@ const Dactyl = Module("dactyl", {
beep: function () { beep: function () {
// FIXME: popups clear the command line // FIXME: popups clear the command line
if (options["visualbell"]) { if (options["visualbell"]) {
// flash the visual bell dactyl.callInMainThread(function () {
let popup = document.getElementById("dactyl-visualbell"); // flash the visual bell
let win = config.visualbellWindow; let popup = document.getElementById("dactyl-visualbell");
let rect = win.getBoundingClientRect(); let win = config.visualbellWindow;
let width = rect.right - rect.left; let rect = win.getBoundingClientRect();
let height = rect.bottom - rect.top; let width = rect.right - rect.left;
let height = rect.bottom - rect.top;
// NOTE: this doesn't seem to work in FF3 with full box dimensions // NOTE: this doesn't seem to work in FF3 with full box dimensions
popup.openPopup(win, "overlap", 1, 1, false, false); popup.openPopup(win, "overlap", 1, 1, false, false);
popup.sizeTo(width - 2, height - 2); popup.sizeTo(width - 2, height - 2);
setTimeout(function () { popup.hidePopup(); }, 20); setTimeout(function () { popup.hidePopup(); }, 20);
});
} }
else { else {
let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound); let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound);
@@ -1026,7 +1028,7 @@ const Dactyl = Module("dactyl", {
callInMainThread: function (callback, self) { callInMainThread: function (callback, self) {
let mainThread = services.get("threadManager").mainThread; let mainThread = services.get("threadManager").mainThread;
if (!services.get("threadManager").isMainThread) if (!services.get("threadManager").isMainThread)
mainThread.dispatch({ run: callback.call(self) }, mainThread.DISPATCH_NORMAL); mainThread.dispatch(Runnable(self, callback), mainThread.DISPATCH_NORMAL);
else else
callback.call(self); callback.call(self);
}, },