Bug 1181000 - Use logical pixel to set IME candidate window. r=karlt
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 27 Jul 2015 14:37:02 +0900
changeset 276063 1eb0af29f4c6bafe669e17ca1d85fb80b9004514
parent 276062 e192ba2bd04506341a150c5a164a96d5bd492c8a
child 276064 f388b16123561fa8305e432a66132c4ac397c625
push idunknown
push userunknown
push dateunknown
reviewerskarlt
bugs1181000
milestone42.0a1
Bug 1181000 - Use logical pixel to set IME candidate window. r=karlt
widget/gtk/IMContextWrapper.cpp
widget/gtk/nsWindow.h
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -1580,29 +1580,26 @@ IMContextWrapper::SetCursorPosition(GtkI
              this, useCaret ? "NS_QUERY_CARET_RECT" : "NS_QUERY_TEXT_RECT"));
         return;
     }
 
     nsWindow* rootWindow =
         static_cast<nsWindow*>(mLastFocusedWindow->GetTopLevelWidget());
 
     // Get the position of the rootWindow in screen.
-    gint rootX, rootY;
-    gdk_window_get_origin(rootWindow->GetGdkWindow(), &rootX, &rootY);
+    LayoutDeviceIntPoint root = rootWindow->WidgetToScreenOffset();
 
     // Get the position of IM context owner window in screen.
-    gint ownerX, ownerY;
-    gdk_window_get_origin(mOwnerWindow->GetGdkWindow(), &ownerX, &ownerY);
+    LayoutDeviceIntPoint owner = mOwnerWindow->WidgetToScreenOffset();
 
     // Compute the caret position in the IM owner window.
-    GdkRectangle area;
-    area.x = charRect.mReply.mRect.x + rootX - ownerX;
-    area.y = charRect.mReply.mRect.y + rootY - ownerY;
-    area.width  = 0;
-    area.height = charRect.mReply.mRect.height;
+    LayoutDeviceIntRect rect = charRect.mReply.mRect + root - owner;
+    rect.width = 0;
+    GdkRectangle area = rootWindow->DevicePixelsToGdkRectRoundOut(
+                            LayoutDeviceIntRect::ToUntyped(rect));
 
     gtk_im_context_set_cursor_location(aContext, &area);
 }
 
 nsresult
 IMContextWrapper::GetCurrentParagraph(nsAString& aText,
                                       uint32_t& aCursorPos)
 {
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -161,16 +161,18 @@ public:
      * event.  This is intended for pointer grab requests (including drags).
      */
     static guint32     GetLastUserInputTime();
 
     // utility method, -1 if no change should be made, otherwise returns a
     // value that can be passed to gdk_window_set_decorations
     gint               ConvertBorderStyles(nsBorderStyle aStyle);
 
+    GdkRectangle DevicePixelsToGdkRectRoundOut(nsIntRect rect);
+
     // event callbacks
 #if (MOZ_WIDGET_GTK == 2)
     gboolean           OnExposeEvent(GdkEventExpose *aEvent);
 #else
     gboolean           OnExposeEvent(cairo_t *cr);
 #endif
     gboolean           OnConfigureEvent(GtkWidget *aWidget,
                                         GdkEventConfigure *aEvent);
@@ -494,17 +496,16 @@ private:
 
     // HiDPI scale conversion
     gint GdkScaleFactor();
 
     // To GDK
     gint DevicePixelsToGdkCoordRoundUp(int pixels);
     gint DevicePixelsToGdkCoordRoundDown(int pixels);
     GdkPoint DevicePixelsToGdkPointRoundDown(nsIntPoint point);
-    GdkRectangle DevicePixelsToGdkRectRoundOut(nsIntRect rect);
     GdkRectangle DevicePixelsToGdkSizeRoundUp(nsIntSize pixelSize);
 
     // From GDK
     int GdkCoordToDevicePixels(gint coord);
     mozilla::LayoutDeviceIntPoint GdkPointToDevicePixels(GdkPoint point);
     nsIntRect GdkRectToDevicePixels(GdkRectangle rect);
 };