From 74f993028996f5e186a16045f61bf76e742158f1 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Fri, 9 Aug 2002 15:33:29 +0000 Subject: [PATCH] use a new window subclass that lies about it being the key window so the scrollbar of the autocomplete popup is always enabled. also fixes a memory leak where we'd leak the autocomplete popup in every window (bug 157637) --- camino/CHAutoCompleteTextField.mm | 17 ++++++++++++++--- camino/src/browser/AutoCompleteTextField.mm | 17 ++++++++++++++--- chimera/CHAutoCompleteTextField.mm | 17 ++++++++++++++--- chimera/src/browser/AutoCompleteTextField.mm | 17 ++++++++++++++--- 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/camino/CHAutoCompleteTextField.mm b/camino/CHAutoCompleteTextField.mm index 948395db1c9..bb68570d669 100644 --- a/camino/CHAutoCompleteTextField.mm +++ b/camino/CHAutoCompleteTextField.mm @@ -19,7 +19,7 @@ * * Contributor(s): * Joe Hewitt (Original Author) -* David Haas +* David Haas */ #import "CHAutoCompleteTextField.h" @@ -34,6 +34,17 @@ static const int kMaxRows = 6; static const int kFrameMargin = 1; static const int kEscapeKeyCode = 53; +@interface AutoCompleteWindow : NSWindow +- (BOOL)isKeyWindow; +@end + +@implementation AutoCompleteWindow +- (BOOL)isKeyWindow +{ + return YES; +} +@end + class AutoCompleteListener : public nsIAutoCompleteListener { public: @@ -95,8 +106,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self setSession:@"history"]; // construct and configure the popup window - mPopupWin = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) - styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO] retain]; + mPopupWin = [[AutoCompleteWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) + styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; [mPopupWin setReleasedWhenClosed:NO]; [mPopupWin setLevel:NSFloatingWindowLevel]; [mPopupWin setHasShadow:YES]; diff --git a/camino/src/browser/AutoCompleteTextField.mm b/camino/src/browser/AutoCompleteTextField.mm index 948395db1c9..bb68570d669 100644 --- a/camino/src/browser/AutoCompleteTextField.mm +++ b/camino/src/browser/AutoCompleteTextField.mm @@ -19,7 +19,7 @@ * * Contributor(s): * Joe Hewitt (Original Author) -* David Haas +* David Haas */ #import "CHAutoCompleteTextField.h" @@ -34,6 +34,17 @@ static const int kMaxRows = 6; static const int kFrameMargin = 1; static const int kEscapeKeyCode = 53; +@interface AutoCompleteWindow : NSWindow +- (BOOL)isKeyWindow; +@end + +@implementation AutoCompleteWindow +- (BOOL)isKeyWindow +{ + return YES; +} +@end + class AutoCompleteListener : public nsIAutoCompleteListener { public: @@ -95,8 +106,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self setSession:@"history"]; // construct and configure the popup window - mPopupWin = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) - styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO] retain]; + mPopupWin = [[AutoCompleteWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) + styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; [mPopupWin setReleasedWhenClosed:NO]; [mPopupWin setLevel:NSFloatingWindowLevel]; [mPopupWin setHasShadow:YES]; diff --git a/chimera/CHAutoCompleteTextField.mm b/chimera/CHAutoCompleteTextField.mm index 948395db1c9..bb68570d669 100644 --- a/chimera/CHAutoCompleteTextField.mm +++ b/chimera/CHAutoCompleteTextField.mm @@ -19,7 +19,7 @@ * * Contributor(s): * Joe Hewitt (Original Author) -* David Haas +* David Haas */ #import "CHAutoCompleteTextField.h" @@ -34,6 +34,17 @@ static const int kMaxRows = 6; static const int kFrameMargin = 1; static const int kEscapeKeyCode = 53; +@interface AutoCompleteWindow : NSWindow +- (BOOL)isKeyWindow; +@end + +@implementation AutoCompleteWindow +- (BOOL)isKeyWindow +{ + return YES; +} +@end + class AutoCompleteListener : public nsIAutoCompleteListener { public: @@ -95,8 +106,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self setSession:@"history"]; // construct and configure the popup window - mPopupWin = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) - styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO] retain]; + mPopupWin = [[AutoCompleteWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) + styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; [mPopupWin setReleasedWhenClosed:NO]; [mPopupWin setLevel:NSFloatingWindowLevel]; [mPopupWin setHasShadow:YES]; diff --git a/chimera/src/browser/AutoCompleteTextField.mm b/chimera/src/browser/AutoCompleteTextField.mm index 948395db1c9..bb68570d669 100644 --- a/chimera/src/browser/AutoCompleteTextField.mm +++ b/chimera/src/browser/AutoCompleteTextField.mm @@ -19,7 +19,7 @@ * * Contributor(s): * Joe Hewitt (Original Author) -* David Haas +* David Haas */ #import "CHAutoCompleteTextField.h" @@ -34,6 +34,17 @@ static const int kMaxRows = 6; static const int kFrameMargin = 1; static const int kEscapeKeyCode = 53; +@interface AutoCompleteWindow : NSWindow +- (BOOL)isKeyWindow; +@end + +@implementation AutoCompleteWindow +- (BOOL)isKeyWindow +{ + return YES; +} +@end + class AutoCompleteListener : public nsIAutoCompleteListener { public: @@ -95,8 +106,8 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener) [self setSession:@"history"]; // construct and configure the popup window - mPopupWin = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) - styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO] retain]; + mPopupWin = [[AutoCompleteWindow alloc] initWithContentRect:NSMakeRect(0,0,0,0) + styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; [mPopupWin setReleasedWhenClosed:NO]; [mPopupWin setLevel:NSFloatingWindowLevel]; [mPopupWin setHasShadow:YES];