mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-06 11:08:04 -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.
|
||||
*/
|
||||
hijackTitlebarButtons: function() {
|
||||
this.titlebarDispatch.forEach(function(button) {
|
||||
let fInfo = firetrayChrome.replaceCommand(button.id, button.new);
|
||||
Object.keys(this.titlebarDispatch).forEach(function(id) {
|
||||
let button = this.titlebarDispatch[id];
|
||||
let fInfo = firetrayChrome.replaceCommand(id, button.new);
|
||||
if (fInfo) {
|
||||
button.old = fInfo[0];
|
||||
firetray_log.debug('replaced command='+button.id+' type='+fInfo[1]+' func='+fInfo[0]);
|
||||
button.type = fInfo[1];
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
},
|
||||
|
||||
titlebarDispatch: [
|
||||
{id: "titlebar-min", new: function(e){
|
||||
titlebarDispatch: {
|
||||
"titlebar-min": { new: function(e){
|
||||
firetray_log.debug(' titlebar-min clicked');
|
||||
if (!firetray.Handler.onMinimize(firetrayChrome.winId))
|
||||
firetrayChrome.applyDefaultCommand("titlebar-min");
|
||||
}, old: null, type: null},
|
||||
{id: "titlebar-close", new: function(e){
|
||||
}, old: null, type: null },
|
||||
"titlebar-close": { new: function(e){
|
||||
firetray_log.debug(' titlebar-close clicked');
|
||||
if (!firetrayChrome.onClose(null)) {
|
||||
firetrayChrome.applyDefaultCommand("titlebar-close");
|
||||
}
|
||||
}, old: null, type: null}
|
||||
],
|
||||
}, old: null, type: null }
|
||||
},
|
||||
|
||||
replaceCommand: function(eltId, func) {
|
||||
let elt = document.getElementById(eltId);
|
||||
|
@ -100,7 +100,7 @@ firetray.StatusIcon = {
|
||||
let img = this.loadImageFromFile(path);
|
||||
if (img && ICON_CHROME_FILES[imgName].use == '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. */
|
||||
img.himg = this.makeBitMapTransparent(img.himg);
|
||||
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
|
||||
* start_hidden, or just our default wndProc. None of the following works:
|
||||
* - a WH_CALLWNDPROC hook doesn't catch SWP_SHOWWINDOW
|
||||
@ -144,11 +145,12 @@ firetray.Window.attachWndProc = function(procInfo) {
|
||||
// procInfo = {wid, mapNew, mapBak}
|
||||
firetray.Window.detachWndProc = function(procInfo) {
|
||||
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);
|
||||
log.debug("hwnd="+hwnd);
|
||||
let proc = user32.SetWindowLongW(hwnd, user32.GWLP_WNDPROC, procPrev);
|
||||
firetray.js.assert(firetray.js.strEquals(proc, procInfo.mapNew.get(wid)),
|
||||
let procPrev = user32.SetWindowLongW(hwnd, user32.GWLP_WNDPROC, procBak);
|
||||
firetray.js.assert(firetray.js.strEquals(procPrev, procNew),
|
||||
"Wrong WndProc replaced.");
|
||||
procInfo.mapNew.remove(wid);
|
||||
procInfo.mapBak.remove(wid);
|
||||
@ -221,25 +223,22 @@ firetray.Handler.unregisterWindow = function(win) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let mapNew;
|
||||
try {
|
||||
firetray.Window.detachWndProc({
|
||||
wid: wid,
|
||||
mapNew: firetray.Handler.wndProcsStartup,
|
||||
mapBak: firetray.Handler.wndProcsOrig
|
||||
});
|
||||
log.debug("Window never shown.");
|
||||
firetray.Handler.wndProcsStartup.get(wid); // throws
|
||||
mapNew = firetray.Handler.wndProcsStartup;
|
||||
log.debug("Window never shown (unregistered but procStartup still in place).");
|
||||
} catch (x) {
|
||||
if (x.name === "RangeError") {
|
||||
firetray.Window.detachWndProc({
|
||||
wid: wid,
|
||||
mapNew: firetray.Handler.wndProcs,
|
||||
mapBak: firetray.Handler.wndProcsOrig
|
||||
});
|
||||
mapNew = firetray.Handler.wndProcs;
|
||||
} else {
|
||||
log.error(x);
|
||||
Cu.reportError(x);
|
||||
}
|
||||
}
|
||||
firetray.Window.detachWndProc({
|
||||
wid: wid, mapNew: mapNew, mapBak: firetray.Handler.wndProcsOrig
|
||||
});
|
||||
|
||||
if (!delete firetray.Handler.windows[wid])
|
||||
throw new DeleteError();
|
||||
|
Loading…
Reference in New Issue
Block a user