mirror of
https://github.com/fltk/fltk.git
synced 2026-06-04 23:42:15 +08:00
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
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
CHANGES IN FLTK 1.3.0
|
CHANGES IN FLTK 1.3.0
|
||||||
|
|
||||||
|
- Fixed fl_set_spot() for Windows (STR #2101)
|
||||||
- Added sorting to Fl_Browser_ (STR #2113)
|
- Added sorting to Fl_Browser_ (STR #2113)
|
||||||
- Added utf8 support for OS X copy and paste
|
- Added utf8 support for OS X copy and paste
|
||||||
- Improved handling of composed keys in OS X 10.5 and up
|
- Improved handling of composed keys in OS X 10.5 and up
|
||||||
|
|||||||
+2
-1
@@ -34,6 +34,7 @@
|
|||||||
#define fl_draw_H
|
#define fl_draw_H
|
||||||
|
|
||||||
#include "Enumerations.H" // for the color names
|
#include "Enumerations.H" // for the color names
|
||||||
|
#include "Fl_Window.H" // for fl_set_spot()
|
||||||
|
|
||||||
// Image class...
|
// Image class...
|
||||||
class Fl_Image;
|
class Fl_Image;
|
||||||
@@ -277,7 +278,7 @@ FL_EXPORT const char* fl_expand_text(const char* from, char* buf, int maxbuf,
|
|||||||
|
|
||||||
// XIM:
|
// XIM:
|
||||||
FL_EXPORT void fl_set_status(int X, int Y, int W, int H);
|
FL_EXPORT void fl_set_status(int X, int Y, int W, int H);
|
||||||
FL_EXPORT void fl_set_spot(int font, int size, int x, int y, int w, int h);
|
FL_EXPORT void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win=0);
|
||||||
FL_EXPORT void fl_reset_spot(void);
|
FL_EXPORT void fl_reset_spot(void);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -353,7 +353,7 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
|
|||||||
fl_pop_clip();
|
fl_pop_clip();
|
||||||
if (Fl::focus() == this) {
|
if (Fl::focus() == this) {
|
||||||
fl_set_spot(textfont(), textsize(),
|
fl_set_spot(textfont(), textsize(),
|
||||||
(int)xpos+curx, Y+ypos-fl_descent(), W, H);
|
(int)xpos+curx, Y+ypos-fl_descent(), W, H, window());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case FL_FOCUS:
|
case FL_FOCUS:
|
||||||
fl_set_spot(textfont(), textsize(), x(), y(), w(), h());
|
fl_set_spot(textfont(), textsize(), x(), y(), w(), h(), window());
|
||||||
if (mark_ == position_) {
|
if (mark_ == position_) {
|
||||||
minimal_update(size()+1);
|
minimal_update(size()+1);
|
||||||
} else //if (Fl::selection_owner() != this)
|
} else //if (Fl::selection_owner() != this)
|
||||||
|
|||||||
+1
-1
@@ -127,7 +127,7 @@ 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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-18
@@ -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)
|
||||||
{
|
{
|
||||||
|
if (!win) return;
|
||||||
|
Fl_Window* tw = win;
|
||||||
|
while (tw->parent()) tw = tw->window(); // find top level window
|
||||||
|
|
||||||
get_imm_module();
|
get_imm_module();
|
||||||
HIMC himc = flImmGetContext(fl_msg.hwnd);
|
HIMC himc = flImmGetContext(fl_xid(tw));
|
||||||
|
|
||||||
if (himc) {
|
if (himc) {
|
||||||
Fl_Window* w = fl_find(fl_msg.hwnd);
|
COMPOSITIONFORM cfs;
|
||||||
|
|
||||||
// FIXME: the following is a temporary fix for STR #2101
|
|
||||||
if (!w) {
|
|
||||||
flImmReleaseContext(fl_msg.hwnd, himc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (w->parent()) w = w->window();
|
|
||||||
|
|
||||||
COMPOSITIONFORM cfs;
|
|
||||||
cfs.dwStyle = CFS_POINT;
|
cfs.dwStyle = CFS_POINT;
|
||||||
cfs.ptCurrentPos.x = x;
|
cfs.ptCurrentPos.x = X;
|
||||||
cfs.ptCurrentPos.y = y - w->labelsize();
|
cfs.ptCurrentPos.y = Y - tw->labelsize();
|
||||||
MapWindowPoints(fl_msg.hwnd, fl_xid(w), &cfs.ptCurrentPos, 1);
|
MapWindowPoints(fl_xid(win), fl_xid(tw), &cfs.ptCurrentPos, 1);
|
||||||
flImmSetCompositionWindow(himc, &cfs);
|
flImmSetCompositionWindow(himc, &cfs);
|
||||||
|
flImmReleaseContext(fl_xid(tw), himc);
|
||||||
flImmReleaseContext(fl_msg.hwnd, himc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -422,7 +422,7 @@ void fl_reset_spot(void)
|
|||||||
//if (fl_xim_ic) XUnsetICFocus(fl_xim_ic);
|
//if (fl_xim_ic) XUnsetICFocus(fl_xim_ic);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
int change = 0;
|
int change = 0;
|
||||||
XVaNestedList preedit_attr;
|
XVaNestedList preedit_attr;
|
||||||
@@ -435,11 +435,11 @@ void fl_set_spot(int font, int size, int x, int y, int w, int h)
|
|||||||
|
|
||||||
if (!fl_xim_ic || !fl_is_over_the_spot) return;
|
if (!fl_xim_ic || !fl_is_over_the_spot) return;
|
||||||
//XSetICFocus(fl_xim_ic);
|
//XSetICFocus(fl_xim_ic);
|
||||||
if (x != spot.x || y != spot.y) {
|
if (X != spot.x || Y != spot.y) {
|
||||||
spot.x = x;
|
spot.x = X;
|
||||||
spot.y = y;
|
spot.y = Y;
|
||||||
spot.height = h;
|
spot.height = H;
|
||||||
spot.width = w;
|
spot.width = W;
|
||||||
change = 1;
|
change = 1;
|
||||||
}
|
}
|
||||||
if (font != spotf || size != spots) {
|
if (font != spotf || size != spots) {
|
||||||
|
|||||||
Reference in New Issue
Block a user