sync with OpenBSD -current
This commit is contained in:
parent
acb2a22980
commit
455fea1627
229 changed files with 25075 additions and 13981 deletions
|
@ -138,15 +138,19 @@ _XimPendingFilter(
|
|||
static Bool
|
||||
_XimProtoKeypressFilter(
|
||||
Xic ic,
|
||||
XKeyEvent *ev)
|
||||
XKeyEvent *ev,
|
||||
Window w)
|
||||
{
|
||||
Xim im = (Xim)ic->core.im;
|
||||
|
||||
if (IS_FABRICATED(im)) {
|
||||
if (_XimIsFabricatedSerial(im, ev)) {
|
||||
_XimPendingFilter(ic);
|
||||
UNMARK_FABRICATED(im);
|
||||
_XimUnfabricateSerial(im, ic, ev);
|
||||
return NOTFILTERD;
|
||||
}
|
||||
/* w=0 is used for _XimIsFabricatedSerial() only */
|
||||
if (!w)
|
||||
return NOTFILTERD;
|
||||
|
||||
if (IS_NEGLECT_EVENT(ic, KeyPressMask))
|
||||
return FILTERD;
|
||||
|
@ -193,21 +197,25 @@ _XimFilterKeypress(
|
|||
XEvent *ev,
|
||||
XPointer client_data)
|
||||
{
|
||||
return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev );
|
||||
return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev, w);
|
||||
}
|
||||
|
||||
static Bool
|
||||
_XimProtoKeyreleaseFilter(
|
||||
Xic ic,
|
||||
XKeyEvent *ev)
|
||||
XKeyEvent *ev,
|
||||
Window w)
|
||||
{
|
||||
Xim im = (Xim)ic->core.im;
|
||||
|
||||
if (IS_FABRICATED(im)) {
|
||||
if (_XimIsFabricatedSerial(im, ev)) {
|
||||
_XimPendingFilter(ic);
|
||||
UNMARK_FABRICATED(im);
|
||||
_XimUnfabricateSerial(im, ic, ev);
|
||||
return NOTFILTERD;
|
||||
}
|
||||
/* w=0 is used for _XimIsFabricatedSerial() only */
|
||||
if (!w)
|
||||
return NOTFILTERD;
|
||||
|
||||
if (IS_NEGLECT_EVENT(ic, KeyReleaseMask))
|
||||
return FILTERD;
|
||||
|
@ -254,7 +262,7 @@ _XimFilterKeyrelease(
|
|||
XEvent *ev,
|
||||
XPointer client_data)
|
||||
{
|
||||
return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev);
|
||||
return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev, w);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -263,6 +271,11 @@ _XimRegisterKeyPressFilter(
|
|||
{
|
||||
if (ic->core.focus_window) {
|
||||
if (!(ic->private.proto.registed_filter_event & KEYPRESS_MASK)) {
|
||||
_XRegisterFilterByType (ic->core.im->core.display,
|
||||
0,
|
||||
KeyPress, KeyPress,
|
||||
_XimFilterKeypress,
|
||||
(XPointer)ic);
|
||||
_XRegisterFilterByType (ic->core.im->core.display,
|
||||
ic->core.focus_window,
|
||||
KeyPress, KeyPress,
|
||||
|
@ -280,6 +293,11 @@ _XimRegisterKeyReleaseFilter(
|
|||
{
|
||||
if (ic->core.focus_window) {
|
||||
if (!(ic->private.proto.registed_filter_event & KEYRELEASE_MASK)) {
|
||||
_XRegisterFilterByType (ic->core.im->core.display,
|
||||
0,
|
||||
KeyRelease, KeyRelease,
|
||||
_XimFilterKeyrelease,
|
||||
(XPointer)ic);
|
||||
_XRegisterFilterByType (ic->core.im->core.display,
|
||||
ic->core.focus_window,
|
||||
KeyRelease, KeyRelease,
|
||||
|
@ -301,6 +319,10 @@ _XimUnregisterKeyPressFilter(
|
|||
ic->core.focus_window,
|
||||
_XimFilterKeypress,
|
||||
(XPointer)ic);
|
||||
_XUnregisterFilter (ic->core.im->core.display,
|
||||
0,
|
||||
_XimFilterKeypress,
|
||||
(XPointer)ic);
|
||||
ic->private.proto.registed_filter_event &= ~KEYPRESS_MASK;
|
||||
}
|
||||
}
|
||||
|
@ -317,6 +339,10 @@ _XimUnregisterKeyReleaseFilter(
|
|||
ic->core.focus_window,
|
||||
_XimFilterKeyrelease,
|
||||
(XPointer)ic);
|
||||
_XUnregisterFilter (ic->core.im->core.display,
|
||||
0,
|
||||
_XimFilterKeyrelease,
|
||||
(XPointer)ic);
|
||||
ic->private.proto.registed_filter_event &= ~KEYRELEASE_MASK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "Ximint.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
|
||||
int
|
||||
_XimCheckDataSize(
|
||||
|
@ -400,6 +402,7 @@ _XimPreConnect(
|
|||
Atom *atoms;
|
||||
Window im_window = 0;
|
||||
register int i;
|
||||
const char *env_enable_fabricated_order;
|
||||
|
||||
if((imserver = XInternAtom(display, XIM_SERVERS, True)) == (Atom)None)
|
||||
return False;
|
||||
|
@ -430,6 +433,16 @@ _XimPreConnect(
|
|||
return False;
|
||||
|
||||
im->private.proto.im_window = im_window;
|
||||
im->private.proto.fabricated_serial = 0;
|
||||
im->private.proto.fabricated_time = 0;
|
||||
im->private.proto.enable_fabricated_order = True;
|
||||
env_enable_fabricated_order = getenv("LIBX11_ENABLE_FABRICATED_ORDER");
|
||||
if (env_enable_fabricated_order && *env_enable_fabricated_order) {
|
||||
if (!strncasecmp(env_enable_fabricated_order, "0", 2) ||
|
||||
!strncasecmp(env_enable_fabricated_order, "false", 6)) {
|
||||
im->private.proto.enable_fabricated_order = False;
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
|
@ -1314,8 +1327,11 @@ _XimProtoSetIMValues(
|
|||
}
|
||||
_XimSetCurrentIMValues(im, &im_values);
|
||||
|
||||
if (!total)
|
||||
return (char *)NULL;
|
||||
if (!total) {
|
||||
if (buf != tmp_buf)
|
||||
Xfree(buf);
|
||||
return (char *)NULL;
|
||||
}
|
||||
|
||||
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
|
||||
buf_s[0] = im->private.proto.imid;
|
||||
|
|
|
@ -341,6 +341,93 @@ _XimForwardEvent(
|
|||
return _XimForwardEventCore(ic, ev, sync);
|
||||
}
|
||||
|
||||
Bool
|
||||
_XimFabricateSerial(
|
||||
Xim im,
|
||||
XKeyEvent *event)
|
||||
{
|
||||
/* GTK2 XIM module sets serial=0. */
|
||||
if (!event->serial || !im->private.proto.enable_fabricated_order) {
|
||||
MARK_FABRICATED(im);
|
||||
return True;
|
||||
}
|
||||
if (event->serial == im->private.proto.fabricated_serial) {
|
||||
fprintf(stderr, "%s,%d: The key event is already fabricated.\n", __FILE__, __LINE__);
|
||||
return False;
|
||||
}
|
||||
if (im->private.proto.fabricated_serial)
|
||||
fprintf(stderr, "%s,%d: Tried to fabricate a wrong key event.\n", __FILE__, __LINE__);
|
||||
|
||||
MARK_FABRICATED(im);
|
||||
im->private.proto.fabricated_serial = event->serial;
|
||||
im->private.proto.fabricated_time = event->time;
|
||||
return True;
|
||||
}
|
||||
|
||||
Bool
|
||||
_XimUnfabricateSerial(
|
||||
Xim im,
|
||||
Xic ic,
|
||||
XKeyEvent *event)
|
||||
{
|
||||
if (!im->private.proto.enable_fabricated_order) {
|
||||
UNMARK_FABRICATED(im);
|
||||
return True;
|
||||
}
|
||||
/* GTK2 XIM module sets serial=0. */
|
||||
if (!event->serial) {
|
||||
/* _XimCommitRecv() sets event->serial and call _XimFabricateSerial()
|
||||
* but GTK2 XIM always reset event->serial=0 with XFilterEvent().
|
||||
*/
|
||||
if (ic && ic->private.proto.commit_info)
|
||||
im->private.proto.fabricated_serial = 0;
|
||||
UNMARK_FABRICATED(im);
|
||||
return True;
|
||||
}
|
||||
if (!im->private.proto.fabricated_serial) {
|
||||
fprintf(stderr, "%s,%d: The key event is already unfabricated.\n", __FILE__, __LINE__);
|
||||
return False;
|
||||
}
|
||||
if (event->serial != im->private.proto.fabricated_serial)
|
||||
fprintf(stderr, "%s,%d: Tried to unfabricate a wrong key event.\n", __FILE__, __LINE__);
|
||||
|
||||
im->private.proto.fabricated_serial = 0;
|
||||
im->private.proto.fabricated_time = 0;
|
||||
UNMARK_FABRICATED(im);
|
||||
return True;
|
||||
}
|
||||
|
||||
Bool
|
||||
_XimIsFabricatedSerial(
|
||||
Xim im,
|
||||
XKeyEvent *event)
|
||||
{
|
||||
/* GTK2 XIM module sets serial=0. */
|
||||
if (!event->serial || !im->private.proto.enable_fabricated_order)
|
||||
return IS_FABRICATED(im) ? True : False;
|
||||
if (event->serial == im->private.proto.fabricated_serial)
|
||||
return True;
|
||||
if (!im->private.proto.fabricated_serial)
|
||||
return False;
|
||||
/* Rotate time */
|
||||
if (event->time < im->private.proto.fabricated_time) {
|
||||
if (event->time >= 1000)
|
||||
im->private.proto.fabricated_time = 0;
|
||||
} else if (event->time - im->private.proto.fabricated_time > 1000) {
|
||||
fprintf(stderr,
|
||||
"%s,%d: The application disposed a key event with %ld serial.\n",
|
||||
__FILE__, __LINE__,
|
||||
im->private.proto.fabricated_serial);
|
||||
im->private.proto.enable_fabricated_order = False;
|
||||
if (IS_FABRICATED(im)) {
|
||||
if (event->serial)
|
||||
im->private.proto.fabricated_serial = event->serial;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
static void
|
||||
_XimProcEvent(
|
||||
Display *d,
|
||||
|
@ -355,7 +442,7 @@ _XimProcEvent(
|
|||
ev->xany.serial |= serial << 16;
|
||||
ev->xany.send_event = False;
|
||||
ev->xany.display = d;
|
||||
MARK_FABRICATED(ic->core.im);
|
||||
_XimFabricateSerial((Xim)ic->core.im, &ev->xkey);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -548,7 +635,7 @@ _XimTriggerNotify(
|
|||
} else {
|
||||
buf_size = len;
|
||||
preply = Xmalloc(len);
|
||||
ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
|
||||
ret_code = _XimRead(im, &len, preply, buf_size,
|
||||
_XimTriggerNotifyCheck, (XPointer)ic);
|
||||
if(ret_code != XIM_TRUE) {
|
||||
Xfree(preply);
|
||||
|
@ -592,22 +679,47 @@ _XimRegCommitInfo(
|
|||
}
|
||||
|
||||
static void
|
||||
_XimUnregCommitInfo(
|
||||
Xic ic)
|
||||
_XimUnregRealCommitInfo(
|
||||
Xic ic,
|
||||
Bool reverse)
|
||||
{
|
||||
XimCommitInfo info;
|
||||
XimCommitInfo prev_info = NULL;
|
||||
|
||||
if (!(info = ic->private.proto.commit_info))
|
||||
info = ic->private.proto.commit_info;
|
||||
while (reverse && info) {
|
||||
if (!info->next)
|
||||
break;
|
||||
prev_info = info;
|
||||
info = info->next;
|
||||
}
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
|
||||
Xfree(info->string);
|
||||
Xfree(info->keysym);
|
||||
ic->private.proto.commit_info = info->next;
|
||||
if (prev_info)
|
||||
prev_info->next = info->next;
|
||||
else
|
||||
ic->private.proto.commit_info = info->next;
|
||||
Xfree(info);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
_XimUnregCommitInfo(
|
||||
Xic ic)
|
||||
{
|
||||
_XimUnregRealCommitInfo(ic, False);
|
||||
}
|
||||
|
||||
static void
|
||||
_XimUnregFirstCommitInfo(
|
||||
Xic ic)
|
||||
{
|
||||
_XimUnregRealCommitInfo(ic, True);
|
||||
}
|
||||
|
||||
void
|
||||
_XimFreeCommitInfo(
|
||||
Xic ic)
|
||||
|
@ -617,6 +729,19 @@ _XimFreeCommitInfo(
|
|||
return;
|
||||
}
|
||||
|
||||
static XimCommitInfo
|
||||
_XimFirstCommitInfo(
|
||||
Xic ic)
|
||||
{
|
||||
XimCommitInfo info = ic->private.proto.commit_info;
|
||||
while (info) {
|
||||
if (!info->next)
|
||||
break;
|
||||
info = info->next;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
static Bool
|
||||
_XimProcKeySym(
|
||||
Xic ic,
|
||||
|
@ -704,10 +829,6 @@ _XimCommitRecv(
|
|||
|
||||
(void)_XimRespSyncReply(ic, flag);
|
||||
|
||||
if (ic->private.proto.registed_filter_event
|
||||
& (KEYPRESS_MASK | KEYRELEASE_MASK))
|
||||
MARK_FABRICATED(im);
|
||||
|
||||
bzero(&ev, sizeof(ev)); /* uninitialized : found when running kterm under valgrind */
|
||||
|
||||
ev.type = KeyPress;
|
||||
|
@ -719,6 +840,10 @@ _XimCommitRecv(
|
|||
|
||||
ev.time = 0L;
|
||||
ev.serial = LastKnownRequestProcessed(im->core.display);
|
||||
|
||||
if (ic->private.proto.registed_filter_event
|
||||
& (KEYPRESS_MASK | KEYRELEASE_MASK))
|
||||
_XimFabricateSerial(im, &ev);
|
||||
/* FIXME :
|
||||
I wish there were COMMENTs (!) about the data passed around.
|
||||
*/
|
||||
|
@ -1011,7 +1136,7 @@ _XimProtoMbLookupString(
|
|||
state = &tmp_state;
|
||||
|
||||
if ((ev->type == KeyPress) && (ev->keycode == 0)) { /* Filter function */
|
||||
if (!(info = ic->private.proto.commit_info)) {
|
||||
if (!(info = _XimFirstCommitInfo(ic))) {
|
||||
*state = XLookupNone;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1027,7 +1152,7 @@ _XimProtoMbLookupString(
|
|||
else
|
||||
*state = XLookupKeySym;
|
||||
}
|
||||
_XimUnregCommitInfo(ic);
|
||||
_XimUnregFirstCommitInfo(ic);
|
||||
|
||||
} else if (ev->type == KeyPress) {
|
||||
ret = _XimLookupMBText(ic, ev, buffer, bytes, keysym, NULL);
|
||||
|
@ -1074,7 +1199,7 @@ _XimProtoWcLookupString(
|
|||
state = &tmp_state;
|
||||
|
||||
if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */
|
||||
if (!(info = ic->private.proto.commit_info)) {
|
||||
if (!(info = _XimFirstCommitInfo(ic))) {
|
||||
*state = XLookupNone;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1090,7 +1215,7 @@ _XimProtoWcLookupString(
|
|||
else
|
||||
*state = XLookupKeySym;
|
||||
}
|
||||
_XimUnregCommitInfo(ic);
|
||||
_XimUnregFirstCommitInfo(ic);
|
||||
|
||||
} else if (ev->type == KeyPress) {
|
||||
ret = _XimLookupWCText(ic, ev, buffer, bytes, keysym, NULL);
|
||||
|
@ -1137,7 +1262,7 @@ _XimProtoUtf8LookupString(
|
|||
state = &tmp_state;
|
||||
|
||||
if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */
|
||||
if (!(info = ic->private.proto.commit_info)) {
|
||||
if (!(info = _XimFirstCommitInfo(ic))) {
|
||||
*state = XLookupNone;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1153,7 +1278,7 @@ _XimProtoUtf8LookupString(
|
|||
else
|
||||
*state = XLookupKeySym;
|
||||
}
|
||||
_XimUnregCommitInfo(ic);
|
||||
_XimUnregFirstCommitInfo(ic);
|
||||
|
||||
} else if (ev->type == KeyPress) {
|
||||
ret = _XimLookupUTF8Text(ic, ev, buffer, bytes, keysym, NULL);
|
||||
|
|
|
@ -466,7 +466,7 @@ _XimExtension(
|
|||
} else {
|
||||
buf_size = len;
|
||||
preply = Xmalloc(buf_size);
|
||||
ret_code = _XimRead(im, &len, reply, buf_size,
|
||||
ret_code = _XimRead(im, &len, preply, buf_size,
|
||||
_XimQueryExtensionCheck, 0);
|
||||
if(ret_code != XIM_TRUE) {
|
||||
Xfree(preply);
|
||||
|
|
|
@ -1115,6 +1115,7 @@ _XimEncodeICATTRIBUTE(
|
|||
|
||||
*ret_len = 0;
|
||||
for (p = arg; p && p->name; p++) {
|
||||
len = 0;
|
||||
buf_s = (CARD16 *)buf;
|
||||
if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
|
||||
if (_XimSetInnerICAttributes(ic, top, p, mode))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue