From cedb5aa9fa2565b4f9364010c89274cf42c02fa5 Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Sun, 7 Nov 2004 15:29:10 +0000 Subject: [PATCH] This check-in fixes a long standing problem of not being able to use any keyboard controls on the embedded browser. Next step is to re-activate the keyboard listener features. M webclient/src_moz/EmbedProgress.cpp - call TopLevelFocusIn to make sure we get the input focus M webclient/src_moz/NativeBrowserControl.cpp M webclient/src_moz/NativeBrowserControl.h - copy TopLevelFocus{In,Out}() from EmbedPrivate. git-svn-id: svn://10.0.0.236/trunk@165083 18797224-902f-48f8-a5cc-f745e15eee43 --- .../java/webclient/src_moz/EmbedProgress.cpp | 2 + .../src_moz/NativeBrowserControl.cpp | 41 +++++++++++++++++++ .../webclient/src_moz/NativeBrowserControl.h | 2 + 3 files changed, 45 insertions(+) diff --git a/mozilla/java/webclient/src_moz/EmbedProgress.cpp b/mozilla/java/webclient/src_moz/EmbedProgress.cpp index 273b411c34d..8c661186662 100644 --- a/mozilla/java/webclient/src_moz/EmbedProgress.cpp +++ b/mozilla/java/webclient/src_moz/EmbedProgress.cpp @@ -135,6 +135,8 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress, // if we've got the start flag, emit the signal if ((aStateFlags & STATE_IS_NETWORK) && (aStateFlags & STATE_START)) { + + mOwner->TopLevelFocusIn(); PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, ("EmbedProgress::OnStateChange: START_DOCUMENT_LOAD\n")); diff --git a/mozilla/java/webclient/src_moz/NativeBrowserControl.cpp b/mozilla/java/webclient/src_moz/NativeBrowserControl.cpp index fbea970ecf6..86a3c1374bd 100644 --- a/mozilla/java/webclient/src_moz/NativeBrowserControl.cpp +++ b/mozilla/java/webclient/src_moz/NativeBrowserControl.cpp @@ -45,6 +45,9 @@ #include #include +// for the focus hacking we need to do +#include + NativeBrowserControl::NativeBrowserControl(void) { parentHWnd = nsnull; @@ -258,6 +261,44 @@ NativeBrowserControl::Destroy(void) parentHWnd = nsnull; } +// handle focus in and focus out events +void +NativeBrowserControl::TopLevelFocusIn(void) +{ + if (mIsDestroyed) + return; + + nsCOMPtr piWin; + GetPIDOMWindow(getter_AddRefs(piWin)); + + if (!piWin) + return; + + nsCOMPtr focusController; + piWin->GetRootFocusController(getter_AddRefs(focusController)); + if (focusController) + focusController->SetActive(PR_TRUE); +} + +void +NativeBrowserControl::TopLevelFocusOut(void) +{ + if (mIsDestroyed) + return; + + nsCOMPtr piWin; + GetPIDOMWindow(getter_AddRefs(piWin)); + + if (!piWin) + return; + + nsCOMPtr focusController; + piWin->GetRootFocusController(getter_AddRefs(focusController)); + if (focusController) + focusController->SetActive(PR_FALSE); +} + + NativeWrapperFactory *NativeBrowserControl::GetWrapperFactory() { return wrapperFactory; diff --git a/mozilla/java/webclient/src_moz/NativeBrowserControl.h b/mozilla/java/webclient/src_moz/NativeBrowserControl.h index 1dfb44df17d..bc8d1b19183 100644 --- a/mozilla/java/webclient/src_moz/NativeBrowserControl.h +++ b/mozilla/java/webclient/src_moz/NativeBrowserControl.h @@ -75,6 +75,8 @@ public: void Resize (PRUint32 x, PRUint32 y, PRUint32 aWidth, PRUint32 aHeight); void Destroy (void); + void TopLevelFocusIn (void); + void TopLevelFocusOut(void); NativeWrapperFactory * GetWrapperFactory();