mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-07 19:48:03 -05:00
* Fix window close and minimize button when not hides_on_* not set.
* Fix unregistering window.
This commit is contained in:
parent
a699c00761
commit
4e087b887f
@ -74,29 +74,30 @@ var firetrayChrome = { // each new window gets a new firetrayChrome !
|
|||||||
* we override the fake buttons' default actions.
|
* we override the fake buttons' default actions.
|
||||||
*/
|
*/
|
||||||
hijackTitlebarButtons: function() {
|
hijackTitlebarButtons: function() {
|
||||||
this.titlebarDispatch.forEach(function(button) {
|
Object.keys(this.titlebarDispatch).forEach(function(id) {
|
||||||
let fInfo = firetrayChrome.replaceCommand(button.id, button.new);
|
let button = this.titlebarDispatch[id];
|
||||||
|
let fInfo = firetrayChrome.replaceCommand(id, button.new);
|
||||||
if (fInfo) {
|
if (fInfo) {
|
||||||
button.old = fInfo[0];
|
button.old = fInfo[0];
|
||||||
firetray_log.debug('replaced command='+button.id+' type='+fInfo[1]+' func='+fInfo[0]);
|
firetray_log.debug('replaced command='+button.id+' type='+fInfo[1]+' func='+fInfo[0]);
|
||||||
button.type = fInfo[1];
|
button.type = fInfo[1];
|
||||||
}
|
}
|
||||||
});
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
titlebarDispatch: [
|
titlebarDispatch: {
|
||||||
{id: "titlebar-min", new: function(e){
|
"titlebar-min": { new: function(e){
|
||||||
firetray_log.debug(' titlebar-min clicked');
|
firetray_log.debug(' titlebar-min clicked');
|
||||||
if (!firetray.Handler.onMinimize(firetrayChrome.winId))
|
if (!firetray.Handler.onMinimize(firetrayChrome.winId))
|
||||||
firetrayChrome.applyDefaultCommand("titlebar-min");
|
firetrayChrome.applyDefaultCommand("titlebar-min");
|
||||||
}, old: null, type: null},
|
}, old: null, type: null },
|
||||||
{id: "titlebar-close", new: function(e){
|
"titlebar-close": { new: function(e){
|
||||||
firetray_log.debug(' titlebar-close clicked');
|
firetray_log.debug(' titlebar-close clicked');
|
||||||
if (!firetrayChrome.onClose(null)) {
|
if (!firetrayChrome.onClose(null)) {
|
||||||
firetrayChrome.applyDefaultCommand("titlebar-close");
|
firetrayChrome.applyDefaultCommand("titlebar-close");
|
||||||
}
|
}
|
||||||
}, old: null, type: null}
|
}, old: null, type: null }
|
||||||
],
|
},
|
||||||
|
|
||||||
replaceCommand: function(eltId, func) {
|
replaceCommand: function(eltId, func) {
|
||||||
let elt = document.getElementById(eltId);
|
let elt = document.getElementById(eltId);
|
||||||
|
@ -100,7 +100,7 @@ firetray.StatusIcon = {
|
|||||||
let img = this.loadImageFromFile(path);
|
let img = this.loadImageFromFile(path);
|
||||||
if (img && ICON_CHROME_FILES[imgName].use == 'menu')
|
if (img && ICON_CHROME_FILES[imgName].use == 'menu')
|
||||||
/* Ideally we should rebuild the menu each time it is shown as the menu
|
/* Ideally we should rebuild the menu each time it is shown as the menu
|
||||||
color may change. But, let's just consider it's not worth it for
|
color may change. But let's just consider it's not worth it for
|
||||||
now. */
|
now. */
|
||||||
img.himg = this.makeBitMapTransparent(img.himg);
|
img.himg = this.makeBitMapTransparent(img.himg);
|
||||||
if (img)
|
if (img)
|
||||||
|
@ -74,7 +74,8 @@ firetray.Window.wndProc = function(hWnd, uMsg, wParam, lParam) { // filterWindow
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We get the best effect by intercepting WM_WINDOWPOSCHANGING/SWP_SHOWWINDOW.
|
* For start_hidden, we get the best effect by intercepting
|
||||||
|
* WM_WINDOWPOSCHANGING/SWP_SHOWWINDOW.
|
||||||
* Here, we subclass only once either with a startup wndProc, if
|
* Here, we subclass only once either with a startup wndProc, if
|
||||||
* start_hidden, or just our default wndProc. None of the following works:
|
* start_hidden, or just our default wndProc. None of the following works:
|
||||||
* - a WH_CALLWNDPROC hook doesn't catch SWP_SHOWWINDOW
|
* - a WH_CALLWNDPROC hook doesn't catch SWP_SHOWWINDOW
|
||||||
@ -144,11 +145,12 @@ firetray.Window.attachWndProc = function(procInfo) {
|
|||||||
// procInfo = {wid, mapNew, mapBak}
|
// procInfo = {wid, mapNew, mapBak}
|
||||||
firetray.Window.detachWndProc = function(procInfo) {
|
firetray.Window.detachWndProc = function(procInfo) {
|
||||||
let wid = procInfo.wid;
|
let wid = procInfo.wid;
|
||||||
let procPrev = procInfo.mapBak.get(wid);
|
let procBak = procInfo.mapBak.get(wid);
|
||||||
|
let procNew = procInfo.mapNew.get(wid);
|
||||||
let hwnd = firetray.Win32.hexStrToHwnd(wid);
|
let hwnd = firetray.Win32.hexStrToHwnd(wid);
|
||||||
log.debug("hwnd="+hwnd);
|
log.debug("hwnd="+hwnd);
|
||||||
let proc = user32.SetWindowLongW(hwnd, user32.GWLP_WNDPROC, procPrev);
|
let procPrev = user32.SetWindowLongW(hwnd, user32.GWLP_WNDPROC, procBak);
|
||||||
firetray.js.assert(firetray.js.strEquals(proc, procInfo.mapNew.get(wid)),
|
firetray.js.assert(firetray.js.strEquals(procPrev, procNew),
|
||||||
"Wrong WndProc replaced.");
|
"Wrong WndProc replaced.");
|
||||||
procInfo.mapNew.remove(wid);
|
procInfo.mapNew.remove(wid);
|
||||||
procInfo.mapBak.remove(wid);
|
procInfo.mapBak.remove(wid);
|
||||||
@ -221,25 +223,22 @@ firetray.Handler.unregisterWindow = function(win) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mapNew;
|
||||||
try {
|
try {
|
||||||
firetray.Window.detachWndProc({
|
firetray.Handler.wndProcsStartup.get(wid); // throws
|
||||||
wid: wid,
|
mapNew = firetray.Handler.wndProcsStartup;
|
||||||
mapNew: firetray.Handler.wndProcsStartup,
|
log.debug("Window never shown (unregistered but procStartup still in place).");
|
||||||
mapBak: firetray.Handler.wndProcsOrig
|
|
||||||
});
|
|
||||||
log.debug("Window never shown.");
|
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
if (x.name === "RangeError") {
|
if (x.name === "RangeError") {
|
||||||
firetray.Window.detachWndProc({
|
mapNew = firetray.Handler.wndProcs;
|
||||||
wid: wid,
|
|
||||||
mapNew: firetray.Handler.wndProcs,
|
|
||||||
mapBak: firetray.Handler.wndProcsOrig
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
log.error(x);
|
log.error(x);
|
||||||
Cu.reportError(x);
|
Cu.reportError(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
firetray.Window.detachWndProc({
|
||||||
|
wid: wid, mapNew: mapNew, mapBak: firetray.Handler.wndProcsOrig
|
||||||
|
});
|
||||||
|
|
||||||
if (!delete firetray.Handler.windows[wid])
|
if (!delete firetray.Handler.windows[wid])
|
||||||
throw new DeleteError();
|
throw new DeleteError();
|
||||||
|
Loading…
Reference in New Issue
Block a user