diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js index ef0d805..dbe01a9 100644 --- a/src/chrome/content/overlay.js +++ b/src/chrome/content/overlay.js @@ -36,6 +36,7 @@ var firetrayChrome = { // each new window gets a new firetrayChrome ! window close, a new window will create a new handler (and hence, a new tray icon) */ onQuit: function(win) { + win.removeEventListener('close', firetrayChrome.onClose, true); firetray.Handler.unregisterWindow(win); firetray_log.info("windowsCount="+firetray.Handler.windowsCount+", visibleWindowsCount="+firetray.Handler.visibleWindowsCount); firetray_log.debug('Firetray UNLOADED !'); @@ -46,11 +47,12 @@ var firetrayChrome = { // each new window gets a new firetrayChrome ! hides_on_close is set (we are not actually closing the tabs!). There is no use trying to set warnOnClose=false temporarily in onClose, since onClose is called *after* the popup */ + // FIXME: https://bugzilla.mozilla.org/show_bug.cgi?id=827880 menubar + // prevents close button to fire 'close' onClose: function(event) { firetray_log.debug('Firetray CLOSE'); - let win = event.originalTarget; - if (!win instanceof ChromeWindow) - throw new TypeError('originalTarget not a ChromeWindow'); + if (event.originalTarget != window) + throw new TypeError('originalTarget not the current ChromeWindow'); let hides_on_close = firetray.Utils.prefService.getBoolPref('hides_on_close'); firetray_log.debug('hides_on_close: '+hides_on_close); diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm index 8e8993c..0c4a59a 100644 --- a/src/modules/FiretrayHandler.jsm +++ b/src/modules/FiretrayHandler.jsm @@ -129,7 +129,7 @@ firetray.Handler = { firetray.Chat.init(); } else { let platforms = FIRETRAY_CHAT_SUPPORTED_OS.join(", "); - log.error("Only "+platforms+" platform(s) supported at this time. Chat not loaded"); + log.warn("Only "+platforms+" platform(s) supported at this time. Chat not loaded"); } } @@ -370,6 +370,20 @@ firetray.Handler = { } }, + hideOnMinimizeMaybe: function(wid) { + let hidden = false; + let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize'); + if (hides_on_minimize) { + let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window'); + if (hides_single_window) + firetray.Handler.hideWindow(wid); + else + firetray.Handler.hideAllWindows(); + hidden = true; + } + return hidden; + }, + showHideIcon: function() { if (firetray.Utils.prefService.getBoolPref('show_icon_on_hide')) firetray.Handler.setIconVisibility( diff --git a/src/modules/ctypes/winnt/win32.jsm b/src/modules/ctypes/winnt/win32.jsm index 38cb97b..a369106 100644 --- a/src/modules/ctypes/winnt/win32.jsm +++ b/src/modules/ctypes/winnt/win32.jsm @@ -105,6 +105,8 @@ var win32 = new function() { this.WM_SHOWWINDOW = 0x0018; this.WM_WININICHANGE = 0x001A; this.WM_SETTINGCHANGE = this.WM_WININICHANGE; + this.WM_COMMAND = 0x0111; + this.WM_SYSCOMMAND = 0x0112; this.WM_HSCROLL = 0x0114; this.WM_VSCROLL = 0x0115; this.WM_MOUSEWHEEL = 0x020A; @@ -132,6 +134,9 @@ var win32 = new function() { this.WM_MOUSELAST = 0x020D; this.WM_MOUSELAST = 0x020A; + this.SC_MINIMIZE = 0xF020; + this.SC_CLOSE = 0xF060; + this.BITMAP = ctypes.StructType("BITMAP", [ { "bmType": this.LONG }, { "bmWidth": this.LONG }, diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm index 8ba273a..7c77713 100644 --- a/src/modules/linux/FiretrayWindow.jsm +++ b/src/modules/linux/FiretrayWindow.jsm @@ -555,17 +555,12 @@ firetray.Window.filterWindow = function(xev, gdkEv, data) { let winStates = firetray.Window.getXWindowStates(xid); let isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN; log.debug("winStates="+winStates+", isHidden="+isHidden); - // NOTE: Gecko 8.0 provides the 'sizemodechange' event + // NOTE: Gecko 8.0 provides the 'sizemodechange' event, which comes once + // the window is minimized. i.e. preventDefault() or returning false won't + // prevent the event. if (isHidden) { log.debug("GOT ICONIFIED"); - let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize'); - let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window'); - if (hides_on_minimize) { - if (hides_single_window) - firetray.Handler.hideWindow(xid); - else - firetray.Handler.hideAllWindows(); - } + firetray.Handler.hideOnMinimizeMaybe(xid); } break; diff --git a/src/modules/winnt/FiretrayWindow.jsm b/src/modules/winnt/FiretrayWindow.jsm index c7773af..afd9a4f 100644 --- a/src/modules/winnt/FiretrayWindow.jsm +++ b/src/modules/winnt/FiretrayWindow.jsm @@ -69,6 +69,16 @@ firetray.Window.wndProc = function(hWnd, uMsg, wParam, lParam) { // filterWindow } else if (uMsg === win32.WM_CLOSE) { log.debug("wndProc CALLED with WM_CLOSE"); + } else if (uMsg === win32.WM_SYSCOMMAND) { + // FIXME: not work with window.minimize() (menubar hidden) + log.debug("wndProc CALLED with WM_SYSCOMMAND wParam="+wParam); + if (wParam === win32.SC_MINIMIZE) { + log.debug("GOT ICONIFIED"); + if (firetray.Window.hideOnMinimizeMaybe(wid)) { + return 0; // processed => preventDefault + } + } + } else if (uMsg === win32.WM_DESTROY) { log.debug("wndProc CALLED with WM_DESTROY "+wid); @@ -80,7 +90,7 @@ firetray.Window.wndProc = function(hWnd, uMsg, wParam, lParam) { // filterWindow } let procPrev = firetray.Handler.wndProcsOrig.get(wid); - return user32.CallWindowProcW(procPrev, hWnd, uMsg, wParam, lParam); + return user32.CallWindowProcW(procPrev, hWnd, uMsg, wParam, lParam); // or DefWindowProcW }; firetray.Window.attachWndProc = function(wid, hwnd) {