Bug 1181000 - Use logical pixel to set IME candidate window. r=karlt

This commit is contained in:
Makoto Kato 2015-07-27 14:37:02 +09:00
parent c45fdce8ed
commit 00aa5f2e97
2 changed files with 8 additions and 10 deletions

View File

@ -1585,19 +1585,16 @@ IMContextWrapper::SetCursorPosition(GtkIMContext* aContext)
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);
}

View File

@ -166,6 +166,8 @@ public:
// 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);
@ -499,7 +501,6 @@ private:
gint DevicePixelsToGdkCoordRoundUp(int pixels);
gint DevicePixelsToGdkCoordRoundDown(int pixels);
GdkPoint DevicePixelsToGdkPointRoundDown(nsIntPoint point);
GdkRectangle DevicePixelsToGdkRectRoundOut(nsIntRect rect);
GdkRectangle DevicePixelsToGdkSizeRoundUp(nsIntSize pixelSize);
// From GDK