Exemplo n.º 1
0
Arquivo: main.c Projeto: Abioy/ibus
static void
_xim_forward_key_event (X11IC   *x11ic,
                        guint    keyval,
                        guint    keycode,
                        guint    state)
{
    g_return_if_fail (x11ic != NULL);

    IMForwardEventStruct fe = {0};
    XEvent xkp = {0};

    xkp.xkey.type = (state & IBUS_RELEASE_MASK) ? KeyRelease : KeyPress;
    xkp.xkey.serial = 0L;
    xkp.xkey.send_event = False;
    xkp.xkey.same_screen = True;
    xkp.xkey.display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
    xkp.xkey.window =
        x11ic->focus_window ? x11ic->focus_window : x11ic->client_window;
    xkp.xkey.subwindow = None;
    xkp.xkey.root = DefaultRootWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));

    xkp.xkey.time = 0;
    xkp.xkey.state = state;
    xkp.xkey.keycode = (keycode == 0) ? 0 : keycode + 8;

    fe.major_code = XIM_FORWARD_EVENT;
    fe.icid = x11ic->icid;
    fe.connect_id = x11ic->connect_id;
    fe.sync_bit = 0;
    fe.serial_number = 0L;
    fe.event = xkp;

    IMForwardEvent (_xims, (XPointer) & fe);
}
Exemplo n.º 2
0
void MyIMForwardEvent (CARD16 connectId, CARD16 icId, int keycode)
{
    IMForwardEventStruct forwardEvent;
    XEvent          xEvent;

    memset (&forwardEvent, 0, sizeof (IMForwardEventStruct));
    forwardEvent.connect_id = connectId;
    forwardEvent.icid = icId;
    forwardEvent.major_code = XIM_FORWARD_EVENT;
    forwardEvent.sync_bit = 0;
    forwardEvent.serial_number = 0L;

    xEvent.xkey.type = KeyPress;
    xEvent.xkey.display = dpy;
    xEvent.xkey.serial = 0L;
    xEvent.xkey.send_event = False;
    xEvent.xkey.x = xEvent.xkey.y = xEvent.xkey.x_root = xEvent.xkey.y_root = 0;
    xEvent.xkey.same_screen = False;
    xEvent.xkey.subwindow = None;
    xEvent.xkey.window = None;
    xEvent.xkey.root = DefaultRootWindow (dpy);
    xEvent.xkey.state = 0;
    if (CurrentIC->focus_win)
        xEvent.xkey.window = CurrentIC->focus_win;
    else if (CurrentIC->client_win)
        xEvent.xkey.window = CurrentIC->client_win;

    xEvent.xkey.keycode = keycode;
    memcpy (&(forwardEvent.event), &xEvent, sizeof (forwardEvent.event));
    IMForwardEvent (ims, (XPointer) (&forwardEvent));
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: iwaim/ibus
static void
_xim_forward_gdk_event (GdkEventKey *event, X11IC *x11ic)
{
    g_return_if_fail (x11ic != NULL);

    IMForwardEventStruct fe = {0};
    XEvent xkp = {0};

    xkp.xkey.type = (event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease;
    xkp.xkey.serial = 0L;
    xkp.xkey.send_event = False;
    xkp.xkey.same_screen = True;
    xkp.xkey.display = GDK_DISPLAY();
    xkp.xkey.window =
        x11ic->focus_window ? x11ic->focus_window : x11ic->client_window;
    xkp.xkey.subwindow = None;
    xkp.xkey.root = DefaultRootWindow (GDK_DISPLAY());

    xkp.xkey.time = 0;
    xkp.xkey.state = event->state;
    xkp.xkey.keycode = event->hardware_keycode;

    fe.major_code = XIM_FORWARD_EVENT;
    fe.icid = x11ic->icid;
    fe.connect_id = x11ic->connect_id;
    fe.sync_bit = 0;
    fe.serial_number = 0L;
    fe.event = xkp;

    IMForwardEvent (_xims, (XPointer) & fe);
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: hychen/ibus
static int
xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
{
    X11IC *x11ic;
    XKeyEvent *xevent;
    GdkEventKey event;
    gboolean retval;

    LOG (1, "XIM_FORWARD_EVENT ic=%d connect_id=%d",
                call_data->icid, call_data->connect_id);

    x11ic = (X11IC *) g_hash_table_lookup (_x11_ic_table,
                                           GINT_TO_POINTER ((gint) call_data->icid));
    g_return_val_if_fail (x11ic != NULL, 0);

    xevent = (XKeyEvent*) &(call_data->event);

    translate_key_event (gdk_display_get_default (),
        (GdkEvent *)&event, (XEvent *)xevent);

    event.send_event = xevent->send_event;
    event.window = NULL;

    if (event.type == GDK_KEY_RELEASE) {
        event.state |= IBUS_RELEASE_MASK;
    }

    retval = ibus_input_context_process_key_event (x11ic->context,
                                                   event.keyval,
                                                   event.hardware_keycode - 8,
                                                   event.state);
    if (retval) {
        if (! x11ic->has_preedit_area) {
            _xim_set_cursor_location (x11ic);
        }
        return 1;
    }

    IMForwardEventStruct fe;
    memset (&fe, 0, sizeof (fe));

    fe.major_code = XIM_FORWARD_EVENT;
    fe.icid = x11ic->icid;
    fe.connect_id = x11ic->connect_id;
    fe.sync_bit = 0;
    fe.serial_number = 0L;
    fe.event = call_data->event;

    IMForwardEvent (_xims, (XPointer) &fe);

    return 1;
}
Exemplo n.º 5
0
void* XimConsumeQueue(void* arg, FcitxModuleFunctionArg args)
{
    FcitxXimFrontend* xim = arg;
    if (!xim->ims)
        return NULL;
    XimQueue* item;

    size_t len = utarray_len(xim->queue);

    for (item = (XimQueue*) utarray_front(xim->queue);
         item != NULL;
         item = (XimQueue*) utarray_next(xim->queue, item))
    {
        switch(item->type) {
        case XCT_FORWARD:
            {
                IMForwardEvent(xim->ims, item->ptr);
            }
            break;
        case XCT_CALLCALLBACK:
            {
                IMCallCallback(xim->ims, item->ptr);
                IMPreeditCBStruct* pcb = (IMPreeditCBStruct*) item->ptr;
                if (pcb->major_code == XIM_PREEDIT_DRAW) {
                    XFree(pcb->todo.draw.text->string.multi_byte);
                    free(pcb->todo.draw.text);
                }
            }
            break;
        case XCT_COMMIT:
            {
                IMCommitString(xim->ims, item->ptr);
                IMCommitStruct* cms = (IMCommitStruct*) item->ptr;
                XFree(cms->commit_string);
            }
            break;
        case XCT_PREEDIT_START:
            IMPreeditStart(xim->ims, item->ptr);
            break;
        case XCT_PREEDIT_END:
            IMPreeditEnd(xim->ims, item->ptr);
            break;
        }
        free(item->ptr);
    }

    utarray_clear(xim->queue);
    if (len)
        FcitxInstanceSetRecheckEvent(xim->owner);
    return NULL;
}
Exemplo n.º 6
0
static void
__do_forward_event(XIMHandle* handle, IMForwardEventStruct* proto)
{
    /* by pass the event */
    IMForwardEventStruct fe;
    memset(&fe, 0, sizeof (fe));
 
    fe.major_code = XIM_FORWARD_EVENT;
    fe.icid = proto->icid;
    fe.connect_id = proto->connect_id;
    fe.sync_bit = 0;
    fe.serial_number = 0L;
    fe.event = proto->event;
 
    IMForwardEvent(handle, (XPointer) &fe);
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: Abioy/ibus
static void
_process_key_event_done (GObject      *object,
                         GAsyncResult *res,
                         gpointer      user_data)
{
    IBusInputContext *context = (IBusInputContext *)object;
    IMForwardEventStruct *pfe = (IMForwardEventStruct*) user_data;

    GError *error = NULL;
    gboolean retval = ibus_input_context_process_key_event_async_finish (
            context,
            res,
            &error);

    if (error != NULL) {
        g_warning ("Process Key Event failed: %s.", error->message);
        g_error_free (error);
    }

    if (retval == FALSE) {
        IMForwardEvent (_xims, (XPointer) pfe);
    }
    g_slice_free (IMForwardEventStruct, pfe);
}
Exemplo n.º 8
0
static void bounce_back_key()
{
    IMForwardEventStruct forward_ev = *(current_forward_eve);
    IMForwardEvent(current_ims, (XPointer)&forward_ev);
}