summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2019-04-25 12:13:21 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2019-04-25 12:15:43 +0800
commitc073a062b6ad0dfccdd83282fd7ac5e0f8870a19 (patch)
tree2f6dc3d81b39f56393757c72898805d4a8afdaa1
parentabb43f3364f8f421ce76769a57f2f67b513d908d (diff)
downloadgtk+-c073a062b6ad0dfccdd83282fd7ac5e0f8870a19.tar.gz
gtkimcontextime.c: Fix preedit window placement on HiDPI
We must also take the scaling factor into account for placing the IME preedit window that is often used for Chinese and Japanese input on Windows.
-rw-r--r--modules/input/gtkimcontextime.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/modules/input/gtkimcontextime.c b/modules/input/gtkimcontextime.c
index 2b165e9fcd..5bc31c42db 100644
--- a/modules/input/gtkimcontextime.c
+++ b/modules/input/gtkimcontextime.c
@@ -845,6 +845,7 @@ gtk_im_context_ime_set_cursor_location (GtkIMContext *context,
COMPOSITIONFORM cf;
HWND hwnd;
HIMC himc;
+ guint scale;
g_return_if_fail (GTK_IS_IM_CONTEXT_IME (context));
@@ -860,10 +861,11 @@ gtk_im_context_ime_set_cursor_location (GtkIMContext *context,
if (!himc)
return;
+ scale = gdk_window_get_scale_factor (context_ime->client_window);
get_window_position (context_ime->client_window, &wx, &wy);
cf.dwStyle = CFS_POINT;
- cf.ptCurrentPos.x = wx + context_ime->cursor_location.x;
- cf.ptCurrentPos.y = wy + context_ime->cursor_location.y;
+ cf.ptCurrentPos.x = (wx + context_ime->cursor_location.x) * scale;
+ cf.ptCurrentPos.y = (wy + context_ime->cursor_location.y) * scale;
ImmSetCompositionWindow (himc, &cf);
ImmReleaseContext (hwnd, himc);
@@ -1050,6 +1052,7 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
{
gint wx = 0, wy = 0;
CANDIDATEFORM cf;
+ guint scale = gdk_window_get_scale_factor (context_ime->client_window);
get_window_position (context_ime->client_window, &wx, &wy);
/* FIXME! */
@@ -1062,17 +1065,17 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
gdk_win32_window_get_impl_hwnd (gdk_window_get_toplevel
(context_ime->client_window));
GetWindowRect (hwnd_top, &rc);
- pt.x = wx;
- pt.y = wy;
+ pt.x = wx * scale;
+ pt.y = wy * scale;
ClientToScreen (hwnd_top, &pt);
- wx = pt.x - rc.left;
- wy = pt.y - rc.top;
+ wx = (pt.x - rc.left) / scale;
+ wy = (pt.y - rc.top) / scale;
}
cf.dwIndex = 0;
cf.dwStyle = CFS_CANDIDATEPOS;
- cf.ptCurrentPos.x = wx + context_ime->cursor_location.x;
- cf.ptCurrentPos.y = wy + context_ime->cursor_location.y
- + context_ime->cursor_location.height;
+ cf.ptCurrentPos.x = (wx + context_ime->cursor_location.x) * scale;
+ cf.ptCurrentPos.y = (wy + context_ime->cursor_location.y
+ + context_ime->cursor_location.height) * scale;
ImmSetCandidateWindow (himc, &cf);
if ((msg->lParam & GCS_COMPSTR))