From 3bce8a7dc30b57d0bd36e7269a07604b0efa1c1c Mon Sep 17 00:00:00 2001 From: "mark%moxienet.com" Date: Mon, 9 Jan 2006 22:20:34 +0000 Subject: [PATCH] 294476 Impossible to give keyboard focus to minimized windows raised by opening a URL from another app. Activate windows being restored. Also fixes: popup windows not rolled up when windows are minimized with command-M; minimized windows sometimes retain focus even though they're hiding in the dock. r=josh sr=smfr --- widget/src/mac/nsMacWindow.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/widget/src/mac/nsMacWindow.cpp b/widget/src/mac/nsMacWindow.cpp index f881d59bece8..383dff4c2a39 100644 --- a/widget/src/mac/nsMacWindow.cpp +++ b/widget/src/mac/nsMacWindow.cpp @@ -573,7 +573,9 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent, // to enable live resizing { kEventClassWindow, kEventWindowBoundsChanged }, // to roll up popups when we're minimized - { kEventClassWindow, kEventWindowCollapse }, + { kEventClassWindow, kEventWindowCollapsing }, + // to activate when restoring + { kEventClassWindow, kEventWindowExpanded }, // to keep invisible windows off the screen { kEventClassWindow, kEventWindowConstrain }, // to handle update events @@ -700,14 +702,30 @@ nsMacWindow::WindowEventHandler ( EventHandlerCallRef inHandlerChain, EventRef i break; // roll up popups when we're minimized - case kEventWindowCollapse: + case kEventWindowCollapsing: { if ( gRollupListener && gRollupWidget ) gRollupListener->Rollup(); + nsMacWindow *self = NS_REINTERPRET_CAST(nsMacWindow *, userData); + if (self) { + gEventDispatchHandler.DispatchGuiEvent(self, NS_DEACTIVATE); + } retVal = ::CallNextEventHandler(inHandlerChain, inEvent); } break; - + + // Activate when restoring from the minimized state. This ensures that + // the restored window will be able to take focus. + case kEventWindowExpanded: + { + nsMacWindow *self = NS_REINTERPRET_CAST(nsMacWindow *, userData); + if (self) { + gEventDispatchHandler.DispatchGuiEvent(self, NS_ACTIVATE); + } + retVal = ::CallNextEventHandler(inHandlerChain, inEvent); + } + break; + default: // do nothing... break;