src/gui/kernel/qwidget.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 5 d3bac044e0f0
--- a/src/gui/kernel/qwidget.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/kernel/qwidget.cpp	Fri Feb 19 23:40:16 2010 +0200
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -3088,7 +3088,8 @@
         QWidget *focusWidget = effectiveFocusWidget();
         QInputContext *qic = focusWidget->d_func()->inputContext();
         if (enable) {
-            qic->setFocusWidget(focusWidget);
+            if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
+                qic->setFocusWidget(focusWidget);
         } else {
             qic->reset();
             qic->setFocusWidget(0);
@@ -9774,13 +9775,12 @@
     }
 #endif
 
-    if (newParent) {
-        if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
+    if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
+        if (newParent)
             oldBs->removeDirtyWidget(this);
-            // Move the widget and all its static children from
-            // the old backing store to the new one.
-            oldBs->moveStaticWidgets(this);
-        }
+        // Move the widget and all its static children from
+        // the old backing store to the new one.
+        oldBs->moveStaticWidgets(this);
     }
 
     if ((QApplicationPrivate::app_compile_version < 0x040200
@@ -10358,17 +10358,22 @@
 #ifndef QT_NO_IM
         QWidget *focusWidget = d->effectiveFocusWidget();
         QInputContext *ic = 0;
-        if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) {
+        if (on && !internalWinId() && hasFocus()
+            && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
             ic = focusWidget->d_func()->inputContext();
-            ic->reset();
-            ic->setFocusWidget(0);
+            if (ic) {
+                ic->reset();
+                ic->setFocusWidget(0);
+            }
         }
         if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
             parentWidget()->d_func()->enforceNativeChildren();
         if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
             d->createWinId();
-        if (ic && isEnabled())
+        if (ic && isEnabled() && focusWidget->isEnabled()
+            && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
             ic->setFocusWidget(focusWidget);
+        }
 #endif //QT_NO_IM
         break;
     }
@@ -10405,7 +10410,8 @@
         if (!ic && (!on || hasFocus()))
             ic = focusWidget->d_func()->inputContext();
         if (ic) {
-            if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()) {
+            if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()
+                && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
                 ic->setFocusWidget(focusWidget);
             } else if (!on && ic->focusWidget() == focusWidget) {
                 ic->reset();
@@ -11872,16 +11878,20 @@
     mouse when a mouse button is pressed and keeps it until the last
     button is released.
 
-    Note that only visible widgets can grab mouse input. If
-    isVisible() returns false for a widget, that widget cannot call
-    grabMouse().
+    \note Only visible widgets can grab mouse input. If isVisible()
+    returns false for a widget, that widget cannot call grabMouse().
+
+    \note \bold{(Mac OS X developers)} For \e Cocoa, calling
+    grabMouse() on a widget only works when the mouse is inside the
+    frame of that widget.  For \e Carbon, it works outside the widget's
+    frame as well, like for Windows and X11.
 
     \sa releaseMouse() grabKeyboard() releaseKeyboard()
 */
 
 /*!
     \fn void QWidget::grabMouse(const QCursor &cursor)
-    \overload
+    \overload grabMouse()
 
     Grabs the mouse input and changes the cursor shape.
 
@@ -11891,6 +11901,8 @@
 
     \warning Grabbing the mouse might lock the terminal.
 
+    \note \bold{(Mac OS X developers)} See the note in QWidget::grabMouse().
+
     \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()
 */