The mozilla-firefox 1.0.2 was released. We found that this OverTheSpot patch needs some update to fit this release. The attached file is the updated patch. Please consider to apply this. Thanks.
diff -b -uNr mozilla.orig/widget/src/gtk2/nsCommonWidget.cpp mozilla/widget/src/gtk2/nsCommonWidget.cpp --- mozilla.orig/widget/src/gtk2/nsCommonWidget.cpp 2005-03-31 12:46:21.000000000 +0000 +++ mozilla/widget/src/gtk2/nsCommonWidget.cpp 2005-03-31 13:19:54.000000000 +0000 @@ -451,3 +451,34 @@ return PR_FALSE; } + +#include "nsWindow.h" + +extern nsWindow *gFocusWindow; + +PRBool nsCommonWidget::OnInput(nsInputEvent &aEvent) +{ + + PRBool ret = PR_FALSE; + PRBool releaseWidget = PR_FALSE; + nsCommonWidget *widget = NULL; + + +// printf("gFocusWindow win %x\n", gFocusWindow); + // rewrite the key event to the window with 'de focus + if (gFocusWindow) { + widget = gFocusWindow; + NS_ADDREF(widget); + aEvent.widget = gFocusWindow; + releaseWidget = PR_TRUE; + } + if (mEventCallback) { + nsEventStatus aStatus; + ret = DispatchEvent(&aEvent, aStatus); + } + + if (releaseWidget) + NS_RELEASE(widget); + + return ret; +} diff -b -uNr mozilla.orig/widget/src/gtk2/nsCommonWidget.h mozilla/widget/src/gtk2/nsCommonWidget.h --- mozilla.orig/widget/src/gtk2/nsCommonWidget.h 2005-03-31 12:46:21.000000000 +0000 +++ mozilla/widget/src/gtk2/nsCommonWidget.h 2005-03-31 13:19:55.000000000 +0000 @@ -112,6 +112,9 @@ NS_IMETHOD Enable (PRBool aState); NS_IMETHOD IsEnabled (PRBool *aState); + PRBool OnComposition(nsCompositionEvent &aEvent) { return OnInput(aEvent); }; + PRBool OnInput(nsInputEvent &aEvent); + // called when we are destroyed void OnDestroy(void); diff -b -uNr mozilla.orig/widget/src/gtk2/nsWindow.cpp mozilla/widget/src/gtk2/nsWindow.cpp --- mozilla.orig/widget/src/gtk2/nsWindow.cpp 2005-03-31 12:46:21.000000000 +0000 +++ mozilla/widget/src/gtk2/nsWindow.cpp 2005-03-31 13:19:55.000000000 +0000 @@ -190,7 +190,7 @@ static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID); // the current focus window -static nsWindow *gFocusWindow = NULL; +nsWindow *gFocusWindow = NULL; static PRBool gGlobalsInitialized = PR_FALSE; static PRBool gRaiseWindows = PR_TRUE; static nsWindow *gPluginFocusWindow = NULL; @@ -277,6 +277,8 @@ nsWindow::~nsWindow() { + KillICSpotTimer(); + LOG(("nsWindow::~nsWindow() [%p]\n", (void *)this)); if (mLastDragMotionWindow == this) { mLastDragMotionWindow = NULL; @@ -2135,6 +2137,11 @@ topLevelParent); mTransientParent = topLevelParent; // add ourselves to the parent window's window group + if (!topLevelParent) { + gtk_widget_realize(mShell); + GdkWindow* dialoglead = mShell->window; + gdk_window_set_group(dialoglead, dialoglead); + } if (parentArea) { nsWindow *parentnsWindow = get_window_for_gdk_window(parentArea->inner_window); @@ -3923,6 +3930,108 @@ } #ifdef USE_XIM +nsresult nsWindow::KillICSpotTimer () +{ + if(mICSpotTimer) + { +// printf("KillICSpotTimer %x\n", this); + mICSpotTimer->Cancel(); + mICSpotTimer = nsnull; + } + return NS_OK; +} + +nsresult nsWindow::PrimeICSpotTimer () +{ + KillICSpotTimer(); + nsresult err; + mICSpotTimer = do_CreateInstance("@mozilla.org/timer;1", &err); + if (NS_FAILED(err)) + return err; +// printf("PrimeICSpotTimer %x\n", this); + mICSpotTimer->InitWithFuncCallback(ICSpotCallback, this, 1000, + nsITimer::TYPE_ONE_SHOT); + return NS_OK; +} + +void nsWindow::ICSpotCallback(nsITimer * aTimer, void * aClosure) +{ + nsWindow *window= NS_REINTERPRET_CAST(nsWindow*, aClosure); + if( ! window) return; + nsresult res = NS_ERROR_FAILURE; + + GtkIMContext *im = window->IMEGetContext(); + + if (im) { + res = window->UpdateICSpot(); + } + if(NS_SUCCEEDED(res)) + { +// printf("ICSpotCallback\n"); + window->PrimeICSpotTimer(); + } +} + +nsresult nsWindow::UpdateICSpot() +{ + GtkIMContext *im; +#if 1 + if (!gFocusWindow || !(im=gFocusWindow->IMEGetContext())) + return NS_ERROR_FAILURE; +#endif + + // set spot location + nsCompositionEvent compEvent(NS_COMPOSITION_QUERY, this); + static gint oldx =0; + static gint oldy =0; + + compEvent.theReply.mCursorPosition.x=-1; + compEvent.theReply.mCursorPosition.y=-1; + this->OnComposition(compEvent); + // set SpotLocation + if((compEvent.theReply.mCursorPosition.x < 0) && + (compEvent.theReply.mCursorPosition.y < 0)) + return NS_ERROR_FAILURE; + +// im=gFocusWindow->IMEGetContext(); + + if((compEvent.theReply.mCursorPosition.x != oldx)|| + (compEvent.theReply.mCursorPosition.y != oldy)) + { + nsRect a,b,c; + + a.x=0; b.x=0; + gFocusWindow->WidgetToScreen(a, b); + + GtkWidget *owningWidget = + get_gtk_widget_for_gdk_window(gFocusWindow->mDrawingarea->inner_window); + nsWindow *owningWindow = get_window_for_gtk_widget(owningWidget); + owningWindow->WidgetToScreen(a, c); + + int dx = b.x - c.x, dy = b.y - c.y; + + nsPoint spot; + spot.x = dx + compEvent.theReply.mCursorPosition.x; + spot.y = dy + compEvent.theReply.mCursorPosition.y +#if 0 + + compEvent.theReply.mCursorPosition.height +#endif + ; + + GdkRectangle rect; + rect.x = spot.x; rect.y = spot.y; + rect.width = compEvent.theReply.mCursorPosition.width; + rect.height = 0; + +// printf("cursor %d %d %x\n", spot.x, spot.y, im); + gtk_im_context_set_cursor_location(im, &rect); + + oldx = compEvent.theReply.mCursorPosition.x; + oldy = compEvent.theReply.mCursorPosition.y; + } + return NS_OK; +} + void nsWindow::IMEDestroyContext(void) @@ -3953,11 +4062,17 @@ gtk_im_context_focus_in(im); gIMEFocusWindow = this; +#if 1 + UpdateICSpot(); + PrimeICSpotTimer(); +#endif } void nsWindow::IMELoseFocus(void) { + KillICSpotTimer(); + LOGIM(("IMELoseFocus %p\n", (void *)this)); GtkIMContext *im = IMEGetContext(); if (!im) @@ -4201,6 +4316,13 @@ } g_free(uniStr); + +#ifdef USE_XIM + if (window->IMEGetContext()) { + window->UpdateICSpot(); + window->PrimeICSpotTimer(); + } +#endif // USE_XIM } #define START_OFFSET(I) \ @@ -4328,6 +4450,9 @@ GtkIMContext * IM_get_input_context(MozDrawingarea *aArea) { + if (!aArea) + return NULL; + GtkWidget *owningWidget = get_gtk_widget_for_gdk_window(aArea->inner_window); diff -b -uNr mozilla.orig/widget/src/gtk2/nsWindow.h mozilla/widget/src/gtk2/nsWindow.h --- mozilla.orig/widget/src/gtk2/nsWindow.h 2005-03-31 12:46:21.000000000 +0000 +++ mozilla/widget/src/gtk2/nsWindow.h 2005-03-31 13:19:56.000000000 +0000 @@ -266,7 +266,11 @@ GtkIMContext *mIMContext; PRBool mComposingText; - + nsCOMPtr<nsITimer> mICSpotTimer; + static void ICSpotCallback(nsITimer* aTimer, void* aClosure); + nsresult KillICSpotTimer(); + nsresult PrimeICSpotTimer(); + nsresult UpdateICSpot(); #endif private: