Bug 968647 - Part 2. Listen window position change for IME. r=roc
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 28 Feb 2014 16:45:08 +0900
changeset 171763 d3ce99c9b61ee2c18c5a44e80726ac3057918fcc
parent 171762 9724009ba067bdaa826242f0c61e95303581be91
child 171764 2275e85c9ad070c25bba736fa4ea3ed3afb2bf5e
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersroc
bugs968647
milestone30.0a1
Bug 968647 - Part 2. Listen window position change for IME. r=roc
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.mm
widget/gtk/nsWindow.cpp
widget/qt/nsWindow.cpp
widget/windows/nsWindow.cpp
widget/windows/winrt/MetroWidget.cpp
widget/xpwidgets/nsBaseWidget.cpp
widget/xpwidgets/nsBaseWidget.h
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1747,18 +1747,17 @@ bool nsChildView::PaintWindow(nsIntRegio
   mIsDispatchPaint = oldDispatchPaint;
   return returnValue;
 }
 
 #pragma mark -
 
 void nsChildView::ReportMoveEvent()
 {
-  if (mWidgetListener)
-    mWidgetListener->WindowMoved(this, mBounds.x, mBounds.y);
+   NotifyWindowMoved(mBounds.x, mBounds.y);
 }
 
 void nsChildView::ReportSizeEvent()
 {
   if (mWidgetListener)
     mWidgetListener->WindowResized(this, mBounds.width, mBounds.height);
 }
 
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1716,18 +1716,17 @@ nsCocoaWindow::ReportMoveEvent()
   if (mInReportMoveEvent) {
     return;
   }
   mInReportMoveEvent = true;
 
   UpdateBounds();
 
   // Dispatch the move event to Gecko
-  if (mWidgetListener)
-    mWidgetListener->WindowMoved(this, mBounds.x, mBounds.y);
+  NotifyWindowMoved(mBounds.x, mBounds.y);
 
   mInReportMoveEvent = false;
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 void
 nsCocoaWindow::DispatchSizeModeEvent()
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2363,18 +2363,17 @@ nsWindow::OnConfigureEvent(GtkWidget *aW
         // offsetForContextMenu on each iteration.
         return FALSE;
     }
 
     mBounds.MoveTo(screenBounds.TopLeft());
 
     // XXX mozilla will invalidate the entire window after this move
     // complete.  wtf?
-    if (mWidgetListener)
-      mWidgetListener->WindowMoved(this, mBounds.x, mBounds.y);
+    NotifyWindowMoved(mBounds.x, mBounds.y);
 
     return FALSE;
 }
 
 void
 nsWindow::OnContainerUnrealize()
 {
     // The GdkWindows are about to be destroyed (but not deleted), so remove
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -867,18 +867,18 @@ nsWindow::moveEvent(QMoveEvent* aEvent)
         return nsEventStatus_eIgnore;
 
     if ((mBounds.x == aEvent->pos().x() &&
          mBounds.y == aEvent->pos().y()))
     {
         return nsEventStatus_eIgnore;
     }
 
-    bool moved = mWidgetListener->WindowMoved(this, aEvent->pos().x(), aEvent->pos().y());
-    return moved ? nsEventStatus_eConsumeNoDefault : nsEventStatus_eIgnore;
+    NotifyWindowMoved(aEvent->pos().x(), aEvent->pos().y());
+    return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus
 nsWindow::resizeEvent(QResizeEvent* aEvent)
 {
     nsIntRect rect;
 
     // Generate XPFE resize event
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -5793,20 +5793,20 @@ void nsWindow::OnWindowPosChanged(WINDOW
                  ("*** mSizeMode: nsSizeMode_Normal\n"));
         break;
       case nsSizeMode_Minimized:
         PR_LOG(gWindowsLog, PR_LOG_ALWAYS, 
                ("*** mSizeMode: nsSizeMode_Minimized\n"));
         break;
       case nsSizeMode_Maximized:
           PR_LOG(gWindowsLog, PR_LOG_ALWAYS, 
-                 ("*** mSizeMode: nsSizeMode_Maximized\n");
+                 ("*** mSizeMode: nsSizeMode_Maximized\n"));
         break;
       default:
-          PR_LOG(gWindowsLog, PR_LOG_ALWAYS, ("*** mSizeMode: ??????\n");
+          PR_LOG(gWindowsLog, PR_LOG_ALWAYS, ("*** mSizeMode: ??????\n"));
         break;
     };
 #endif
 
     if (mWidgetListener)
       mWidgetListener->SizeModeChanged(mSizeMode);
 
     // If window was restored, window activation was bypassed during the 
@@ -5820,19 +5820,17 @@ void nsWindow::OnWindowPosChanged(WINDOW
       return;
   }
 
   // Handle window position changes
   if (!(wp->flags & SWP_NOMOVE)) {
     mBounds.x = wp->x;
     mBounds.y = wp->y;
 
-    if (mWidgetListener) {
-      mWidgetListener->WindowMoved(this, wp->x, wp->y);
-    }
+    NotifyWindowMoved(wp->x, wp->y);
   }
 
   // Handle window size changes
   if (!(wp->flags & SWP_NOSIZE)) {
     RECT r;
     int32_t newWidth, newHeight;
 
     ::GetWindowRect(mWnd, &r);
--- a/widget/windows/winrt/MetroWidget.cpp
+++ b/widget/windows/winrt/MetroWidget.cpp
@@ -1479,19 +1479,17 @@ MetroWidget::Activated(bool aActiveated)
       mWidgetListener->WindowActivated() :
       mWidgetListener->WindowDeactivated();
   }
 }
 
 NS_IMETHODIMP
 MetroWidget::Move(double aX, double aY)
 {
-  if (mWidgetListener) {
-    mWidgetListener->WindowMoved(this, aX, aY);
-  }
+  NotifyWindowMoved(aX, aY);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MetroWidget::Resize(double aWidth, double aHeight, bool aRepaint)
 {
   return Resize(0, 0, aWidth, aHeight, aRepaint);
 }
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -1467,16 +1467,28 @@ nsBaseWidget::NotifySizeMoveDone()
 
   nsIPresShell* presShell = mWidgetListener->GetPresShell();
   if (presShell) {
     presShell->WindowSizeMoveDone();
   }
 }
 
 void
+nsBaseWidget::NotifyWindowMoved(int32_t aX, int32_t aY)
+{
+  if (mWidgetListener) {
+    mWidgetListener->WindowMoved(this, aX, aY);
+  }
+
+  if (GetIMEUpdatePreference().WantPositionChanged()) {
+    NotifyIME(IMENotification(IMEMessage::NOTIFY_IME_OF_POSITION_CHANGE));
+  }
+}
+
+void
 nsBaseWidget::NotifySysColorChanged()
 {
   if (!mWidgetListener || mWidgetListener->GetXULWindow())
     return;
 
   nsIPresShell* presShell = mWidgetListener->GetPresShell();
   if (presShell) {
     presShell->SysColorChanged();
--- a/widget/xpwidgets/nsBaseWidget.h
+++ b/widget/xpwidgets/nsBaseWidget.h
@@ -205,16 +205,17 @@ public:
   NS_IMETHOD              AttachViewToTopLevel(bool aUseAttachedEvents, nsDeviceContext *aContext);
   virtual nsIWidgetListener* GetAttachedWidgetListener();
   virtual void               SetAttachedWidgetListener(nsIWidgetListener* aListener);
   NS_IMETHOD              RegisterTouchWindow();
   NS_IMETHOD              UnregisterTouchWindow();
 
   void NotifyWindowDestroyed();
   void NotifySizeMoveDone();
+  void NotifyWindowMoved(int32_t aX, int32_t aY);
 
   // Should be called by derived implementations to notify on system color and
   // theme changes.
   void NotifySysColorChanged();
   void NotifyThemeChanged();
   void NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
                             UIStateChangeType aShowFocusRings);