Another tweak to fl_init_xim() as proposed by Denton Thomas.

Should not change the behaviour from the previous fix, it is
just a bit tidier!



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8279 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Ian MacArthur 2011-01-15 22:47:30 +00:00
parent d87cc866fc
commit bf52399372
1 changed files with 18 additions and 20 deletions

View File

@ -282,7 +282,7 @@ int fl_ready() {
static void convert_crlf(unsigned char *string, long& len) {
unsigned char *a, *b;
a = b = string;
while (*a) {
while (*a) {
if (*a == '\r' && a[1] == '\n') { a++; len--; }
else *b++ = *a++;
}
@ -568,8 +568,6 @@ void fl_init_xim()
if (!fl_xim_ic) {
Fl::warning("XCreateIC() failed\n");
XCloseIM(fl_xim_im);
if(xim_styles) XFree(xim_styles);
xim_styles = NULL; // make sure we remember we have free'd xim_styles
fl_xim_im = NULL;
}
// if xim_styles is still allocated, free it now
@ -614,13 +612,13 @@ void fl_open_display(Display* d) {
fl_XdndURIList = XInternAtom(d, "text/uri-list", 0);
fl_Xatextplainutf = XInternAtom(d, "text/plain;charset=UTF-8",0);
fl_Xatextplain = XInternAtom(d, "text/plain", 0);
fl_XaText = XInternAtom(d, "TEXT", 0);
fl_XaText = XInternAtom(d, "TEXT", 0);
fl_XaCompoundText = XInternAtom(d, "COMPOUND_TEXT", 0);
fl_XaUtf8String = XInternAtom(d, "UTF8_STRING", 0);
fl_XaTextUriList = XInternAtom(d, "text/uri-list", 0);
fl_NET_WM_NAME = XInternAtom(d, "_NET_WM_NAME", 0);
fl_NET_WM_ICON_NAME = XInternAtom(d, "_NET_WM_ICON_NAME", 0);
if (sizeof(Atom) < 4)
atom_bits = sizeof(Atom) * 8;
@ -955,10 +953,10 @@ int fl_handle(const XEvent& thisevent)
t == fl_Xatextplain ||
t == fl_XaUtf8String) {type = t; break;}
// rest are only used if no utf-8 available:
if (t == fl_XaText ||
t == fl_XaTextUriList ||
if (t == fl_XaText ||
t == fl_XaTextUriList ||
t == fl_XaCompoundText) type = t;
}
}
XFree(portion);
Atom property = xevent.xselection.property;
XConvertSelection(fl_display, property, type, property,
@ -966,17 +964,17 @@ int fl_handle(const XEvent& thisevent)
fl_event_time);
return true;
}
XTextProperty text_prop;
XTextProperty text_prop;
text_prop.value=portion;
text_prop.format=format;
text_prop.encoding=actual;
text_prop.nitems=count;
char **text_list;
text_list = (char**)&portion;
int bytesnew = strlen(*text_list)+1;
int bytesnew = strlen(*text_list)+1;
buffer = (unsigned char*)realloc(buffer, bytesread+bytesnew+remaining);
memcpy(buffer+bytesread, *text_list, bytesnew);
XFree(portion);
XFree(portion);
bytesread += bytesnew - 1;
if (!remaining) break;
}
@ -1264,21 +1262,21 @@ int fl_handle(const XEvent& thisevent)
// down, probably due to some back compatibility problem. Fortunately
// we can detect this because the repeating KeyPress event is in
// the queue, get it and execute it instead:
// Bool XkbSetDetectableAutorepeat ( display, detectable, supported_rtrn )
// Display * display ;
// Bool detectable ;
// Bool * supported_rtrn ;
// ...would be the easy way to corrct this isuue. Unfortunatly, this call is also
// ...would be the easy way to corrct this isuue. Unfortunatly, this call is also
// broken on many Unix distros including Ubuntu and Solaris (as of Dec 2009)
// Bogus KeyUp events are generated by repeated KeyDown events. One
// Bogus KeyUp events are generated by repeated KeyDown events. One
// neccessary condition is an identical key event pending right after
// the bogus KeyUp.
// The new code introduced Dec 2009 differs in that it only check the very
// next event in the queue, not the entire queue of events.
// This function wrongly detects a repeat key if a software keyboard
// sends a burst of events containing two consecutive equal keys. However,
// sends a burst of events containing two consecutive equal keys. However,
// in every non-gaming situation, this is no problem because both KeyPress
// events will cause the expected behavior.
XEvent peekevent;
@ -1292,7 +1290,7 @@ int fl_handle(const XEvent& thisevent)
goto KEYPRESS;
}
}
event = FL_KEYUP;
fl_key_vector[keycode/8] &= ~(1 << (keycode%8));
// keyup events just get the unshifted keysym:
@ -1346,10 +1344,10 @@ int fl_handle(const XEvent& thisevent)
Fl::e_original_keysym = (int)keysym;
}
Fl::e_keysym = int(keysym);
// replace XK_ISO_Left_Tab (Shift-TAB) with FL_Tab (modifier flags are set correctly by X11)
if (Fl::e_keysym == 0xfe20) Fl::e_keysym = FL_Tab;
set_event_xy();
Fl::e_is_click = 0;
break;}
@ -1452,7 +1450,7 @@ int fl_handle(const XEvent& thisevent)
case ReparentNotify: {
int xpos, ypos;
Window junk;
// on some systems, the ReparentNotify event is not handled as we would expect.
XErrorHandler oldHandler = XSetErrorHandler(catchXExceptions());
@ -1668,7 +1666,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
XSetTransientForHint(fl_display, xp->xid, fl_xid(wp));
if (!wp->visible()) showit = 0; // guess that wm will not show it
}
// Make sure that borderless windows do not show in the task bar
if (!win->border()) {
Atom net_wm_state = XInternAtom (fl_display, "_NET_WM_STATE", 0);