From kde-commits Sat Oct 28 17:54:51 2006 From: Maks Orlovich Date: Sat, 28 Oct 2006 17:54:51 +0000 To: kde-commits Subject: branches/KDE/3.5/kdelibs/khtml/rendering Message-Id: <1162058091.419755.24263.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=116205863126463 SVN commit 599826 by orlovich: Make sure to let the widgets know about focus changes before the pesky JS can change that, not after the fact when it's prolly no longer true. BUG: 63384 M +21 -0 render_replaced.cpp --- branches/KDE/3.5/kdelibs/khtml/rendering/render_replaced.cpp #599825:599826 @@ -616,6 +616,14 @@ return false; if ( !element() ) return true; + + static bool directToWidget = false; + if (directToWidget) { + //We're trying to get the event to the widget + //promptly. So get out of here.. + return false; + } + ref(); element()->ref(); @@ -624,12 +632,25 @@ //kdDebug() << "RenderWidget::eventFilter type=" << e->type() << endl; switch(e->type()) { case QEvent::FocusOut: + // First, forward it to the widget, so that Qt gets a precise + // state of the focus before pesky JS can try changing it.. + directToWidget = true; + QApplication::sendEvent(m_widget, e); + directToWidget = false; + filtered = true; //We already delivered it! + // Don't count popup as a valid reason for losing the focus // (example: opening the options of a select combobox shouldn't emit onblur) if ( QFocusEvent::reason() != QFocusEvent::Popup ) handleFocusOut(); break; case QEvent::FocusIn: + //As above, forward to the widget first... + directToWidget = true; + QApplication::sendEvent(m_widget, e); + directToWidget = false; + filtered = true; //We already delivered it! + //kdDebug(6000) << "RenderWidget::eventFilter captures FocusIn" << endl; element()->getDocument()->setFocusNode(element()); // if ( isEditable() ) {