diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2008-12-27 19:22:30 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2008-12-27 19:22:30 +0000 |
| commit | d34cc411e07122f8ace8ba25242a0a0a2e22b0c1 (patch) | |
| tree | d3b4df5846201f415a8e59cf2c516e9456696d5b /src/Fl_win32.cxx | |
| parent | a3589a181717329808ec595edce8e68629b7ade2 (diff) | |
STR 2101: fl_set_spot() could crash on Windows under certain conditions.
The Windows version needs a window to anchor the display window for complex
text editing (IME), e.g. Japanese text. This update adds an additional
Fl_Window argument to fl_set_spot(), but this is only used for Windows.
The implemented version is tested with Japanese text input, including input
in subwindows (test/subwindow.cxx).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6605 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_win32.cxx')
| -rw-r--r-- | src/Fl_win32.cxx | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 1aa82c175..06ada4884 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -250,29 +250,23 @@ void fl_reset_spot() { } -void fl_set_spot(int font, int size, int x, int y, int w, int h) +void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win) { - get_imm_module(); - HIMC himc = flImmGetContext(fl_msg.hwnd); - if (himc) { - Fl_Window* w = fl_find(fl_msg.hwnd); - - // FIXME: the following is a temporary fix for STR #2101 - if (!w) { - flImmReleaseContext(fl_msg.hwnd, himc); - return; - } + if (!win) return; + Fl_Window* tw = win; + while (tw->parent()) tw = tw->window(); // find top level window - while (w->parent()) w = w->window(); + get_imm_module(); + HIMC himc = flImmGetContext(fl_xid(tw)); - COMPOSITIONFORM cfs; + if (himc) { + COMPOSITIONFORM cfs; cfs.dwStyle = CFS_POINT; - cfs.ptCurrentPos.x = x; - cfs.ptCurrentPos.y = y - w->labelsize(); - MapWindowPoints(fl_msg.hwnd, fl_xid(w), &cfs.ptCurrentPos, 1); + cfs.ptCurrentPos.x = X; + cfs.ptCurrentPos.y = Y - tw->labelsize(); + MapWindowPoints(fl_xid(win), fl_xid(tw), &cfs.ptCurrentPos, 1); flImmSetCompositionWindow(himc, &cfs); - - flImmReleaseContext(fl_msg.hwnd, himc); + flImmReleaseContext(fl_xid(tw), himc); } } |
