Attachment "tkFocus.c.patch" to
ticket [936195ffff]
added by
matzek
2004-04-16 16:34:14.
--- org/tk8.4.1/generic/tkFocus.c 2002-10-08 21:57:59.000000000 +0200
+++ gix/tk8.4.1/generic/tkFocus.c 2003-03-18 14:48:41.000000000 +0100
@@ -289,6 +289,17 @@
TkWindow *newFocusPtr;
int retValue, delta;
+ if (dispPtr->focusDebug
+ && (eventPtr->type == FocusIn || eventPtr->type == FocusOut)) {
+ printf("%02x %s(%x:%-30.30s, %s, mode=%x)\n",
+ (winPtr?(((long)winPtr->mainPtr)%256):0),
+ eventPtr->type == FocusIn ? "IN " : "OUT",
+ eventPtr->xfocus.window, (winPtr?winPtr->pathName:"NULL"),
+ (eventPtr->xfocus.send_event == GENERATED_EVENT_MAGIC ? "MAGIC" :
+ eventPtr->xfocus.send_event ? "GENER" : " "),
+ eventPtr->xfocus.mode);
+ }
+
/*
* If this was a generated event, just turn off the generated
* flag and pass the event through to Tk bindings.
@@ -571,10 +582,16 @@
* If force is set, we should make sure we grab the focus regardless
* of the current focus window since under Windows, we may need to
* take control away from another application.
+ * Some window managers (like Gnome or KDE3) send bogus FocusOut events
+ * to the embedded application. If then later in the embedding application
+ * the focus should be reset to the embedded window, we better do this
+ * even if we know that the container already has the focus.
*/
if (winPtr == displayFocusPtr->focusWinPtr && !force) {
- return;
+ if (!Tk_IsContainer(winPtr)) {
+ return;
+ }
}
/*
@@ -662,12 +679,18 @@
* when there is no window manager. GenerateFocusEvents will
* set up a serial number marker so we discard focus events
* that are triggered by the ChangeFocus.
+ * If we are still inside this proc only since we should reset
+ * the focus to a container window, we have to reset the current
+ * focus window, otherwise GenerateFocusEvents will do nothing.
*/
serial = TkpChangeFocus(TkpGetWrapperWindow(topLevelPtr), force);
if (serial != 0) {
displayFocusPtr->focusSerial = serial;
}
+ if (displayFocusPtr->focusWinPtr == winPtr && Tk_IsContainer(winPtr)) {
+ displayFocusPtr->focusWinPtr = NULL;
+ }
GenerateFocusEvents(displayFocusPtr->focusWinPtr, winPtr);
displayFocusPtr->focusWinPtr = winPtr;
winPtr->dispPtr->focusPtr = winPtr;