1
0
mirror of https://github.com/moparisthebest/FireTray synced 2024-08-13 15:53:47 -04:00
This commit is contained in:
foudfou 2014-02-06 23:02:12 +01:00
parent 705b0ffb59
commit 42a8dac1ed
2 changed files with 27 additions and 26 deletions

View File

@ -356,8 +356,7 @@ firetray.Handler = {
showHideAllWindows: function() { showHideAllWindows: function() {
log.debug("showHideAllWindows"); log.debug("showHideAllWindows");
log.debug(" visibleWindowsCount="+firetray.Handler.visibleWindowsCount + log.debug(" visibleWindowsCount="+firetray.Handler.visibleWindowsCount+" / windowsCount="+firetray.Handler.windowsCount);
" / windowsCount="+firetray.Handler.windowsCount);
let visibilityRate = firetray.Handler.visibleWindowsCount / let visibilityRate = firetray.Handler.visibleWindowsCount /
firetray.Handler.windowsCount; firetray.Handler.windowsCount;
log.debug(" visibilityRate="+visibilityRate); log.debug(" visibilityRate="+visibilityRate);

View File

@ -71,7 +71,30 @@ firetray.Window.wndProc = function(hWnd, uMsg, wParam, lParam) { // filterWindow
return user32.CallWindowProcW(procPrev, hWnd, uMsg, wParam, lParam); return user32.CallWindowProcW(procPrev, hWnd, uMsg, wParam, lParam);
}; };
firetray.Window.restoreWndProc = function(wid) { firetray.Window.attachWndProc = function(wid) {
try {
let wndProc = user32.WNDPROC(firetray.Window.wndProc);
log.debug("proc="+wndProc);
this.wndProcs.insert(wid, wndProc);
let procPrev = user32.WNDPROC(
user32.SetWindowLongW(hwnd, user32.GWLP_WNDPROC,
ctypes.cast(wndProc, win32.LONG_PTR))
);
log.debug("procPrev="+procPrev+" winLastError="+ctypes.winLastError);
// we can't store WNDPROC callbacks (JS ctypes objects) with SetPropW(), as
// we need long-living refs.
this.wndProcsOrig.insert(wid, procPrev);
} catch (x) {
if (x.name === "RangeError") // instanceof not working :-(
win.alert(x+"\n\nYou seem to have more than "+FIRETRAY_WINDOW_COUNT_MAX
+" windows open. This breaks FireTray and most probably "
+firetray.Handler.appName+".");
else win.alert(x);
}
}
firetray.Window.detachWndProc = function(wid) {
let procPrev = firetray.Handler.wndProcsOrig.get(wid); let procPrev = firetray.Handler.wndProcsOrig.get(wid);
let hwnd = firetray.Win32.hexStrToHwnd(wid); let hwnd = firetray.Win32.hexStrToHwnd(wid);
log.debug("hwnd="+hwnd); log.debug("hwnd="+hwnd);
@ -123,28 +146,7 @@ firetray.Handler.registerWindow = function(win) {
log.debug("window "+wid+" registered"); log.debug("window "+wid+" registered");
// SetupWnd(hwnd); this.attachWndProc(wid);
try {
let wndProc = user32.WNDPROC(firetray.Window.wndProc);
log.debug("proc="+wndProc);
this.wndProcs.insert(wid, wndProc);
let procPrev = user32.WNDPROC(
user32.SetWindowLongW(hwnd, user32.GWLP_WNDPROC,
ctypes.cast(wndProc, win32.LONG_PTR))
);
log.debug("procPrev="+procPrev+" winLastError="+ctypes.winLastError);
// we can't store WNDPROC callbacks (JS ctypes objects) with SetPropW(), as
// we need long-living refs.
this.wndProcsOrig.insert(wid, procPrev);
} catch (x) {
if (x.name === "RangeError") // instanceof not working :-(
win.alert(x+"\n\nYou seem to have more than "+FIRETRAY_WINDOW_COUNT_MAX
+" windows open. This breaks FireTray and most probably "
+firetray.Handler.appName+".");
else win.alert(x);
}
firetray.Win32.acceptAllMessages(hwnd); firetray.Win32.acceptAllMessages(hwnd);
@ -161,7 +163,7 @@ firetray.Handler.unregisterWindow = function(win) {
return false; return false;
} }
firetray.Window.restoreWndProc(wid); this.detachWndProc(wid);
if (!delete firetray.Handler.windows[wid]) if (!delete firetray.Handler.windows[wid])
throw new DeleteError(); throw new DeleteError();