~ubuntu-branches/ubuntu/karmic/ibus/karmic-updates

« back to all changes in this revision

Viewing changes to bus/inputcontext.c

  • Committer: Bazaar Package Importer
  • Author(s): LI Daobing
  • Date: 2009-07-23 20:22:09 UTC
  • mfrom: (1.1.4 upstream) (6.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090723202209-bmgqa80g1umg8l2p
Tags: 1.2.0.20090723-1
new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "engineproxy.h"
26
26
#include "factoryproxy.h"
27
27
 
28
 
#define BUS_INPUT_CONTEXT_GET_PRIVATE(o)  \
29
 
   (G_TYPE_INSTANCE_GET_PRIVATE ((o), BUS_TYPE_INPUT_CONTEXT, BusInputContextPrivate))
30
 
 
31
28
enum {
32
29
    PROCESS_KEY_EVENT,
33
30
    SET_CURSOR_LOCATION,
61
58
    PROP_0,
62
59
};
63
60
 
64
 
 
65
 
/* IBusInputContextPriv */
66
 
struct _BusInputContextPrivate {
67
 
    BusConnection *connection;
68
 
    BusEngineProxy *engine;
69
 
    gchar *client;
70
 
 
71
 
    gboolean has_focus;
72
 
    gboolean enabled;
73
 
 
74
 
    /* capabilities */
75
 
    guint capabilities;
76
 
 
77
 
    /* cursor location */
78
 
    gint x;
79
 
    gint y;
80
 
    gint w;
81
 
    gint h;
82
 
 
83
 
    /* prev key event */
84
 
    guint prev_keyval;
85
 
    guint prev_modifiers;
86
 
 
87
 
    /* preedit text */
88
 
    IBusText *preedit_text;
89
 
    guint     preedit_cursor_pos;
90
 
    gboolean  preedit_visible;
91
 
 
92
 
    /* auxiliary text */
93
 
    IBusText *auxiliary_text;
94
 
    gboolean  auxiliary_visible;
95
 
 
96
 
    /* lookup table */
97
 
    IBusLookupTable *lookup_table;
98
 
    gboolean lookup_table_visible;
99
 
 
100
 
    /* filter release */
101
 
    gboolean filter_release;
102
 
 
103
 
};
104
 
 
105
61
typedef struct _BusInputContextPrivate BusInputContextPrivate;
106
62
 
107
63
static guint    context_signals[LAST_SIGNAL] = { 0 };
116
72
static gboolean bus_input_context_filter_keyboard_shortcuts
117
73
                                                (BusInputContext        *context,
118
74
                                                 guint                   keyval,
 
75
                                                 guint                   keycode,
119
76
                                                 guint                   modifiers);
120
77
static gboolean bus_input_context_send_signal   (BusInputContext        *context,
121
78
                                                 const gchar            *signal_name,
217
174
 
218
175
    BusInputContext *context;
219
176
    gchar *path;
220
 
    BusInputContextPrivate *priv;
221
177
 
222
178
    path = g_strdup_printf (IBUS_PATH_INPUT_CONTEXT, ++id);
223
179
 
226
182
                                                NULL);
227
183
    g_free (path);
228
184
 
229
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
230
 
 
231
185
#if 0
232
186
    ibus_service_add_to_connection (IBUS_SERVICE (context),
233
187
                                 IBUS_CONNECTION (connection));
234
188
#endif
235
189
 
236
190
    g_object_ref (connection);
237
 
    priv->connection = connection;
238
 
    priv->client = g_strdup (client);
 
191
    context->connection = connection;
 
192
    context->client = g_strdup (client);
239
193
 
240
 
    g_signal_connect (priv->connection,
 
194
    g_signal_connect (context->connection,
241
195
                      "destroy",
242
196
                      (GCallback) _connection_destroy_cb,
243
197
                      context);
252
206
 
253
207
    parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass);
254
208
 
255
 
    g_type_class_add_private (klass, sizeof (BusInputContextPrivate));
256
 
 
257
209
    ibus_object_class->destroy = (IBusObjectDestroyFunc) bus_input_context_destroy;
258
210
 
259
211
    IBUS_SERVICE_CLASS (klass)->ibus_message = (ServiceIBusMessageFunc) bus_input_context_ibus_message;
525
477
static void
526
478
bus_input_context_init (BusInputContext *context)
527
479
{
528
 
    BusInputContextPrivate *priv;
529
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
530
 
 
531
 
    priv->connection = NULL;
532
 
    priv->client = NULL;
533
 
    priv->engine = NULL;
534
 
    priv->has_focus = FALSE;
535
 
    priv->enabled = FALSE;
536
 
 
537
 
    priv->prev_keyval = IBUS_VoidSymbol;
538
 
    priv->prev_modifiers = 0;
539
 
 
540
 
    priv->capabilities = 0;
541
 
 
542
 
    priv->x = 0;
543
 
    priv->y = 0;
544
 
    priv->w = 0;
545
 
    priv->h = 0;
546
 
 
547
 
    g_object_ref (text_empty);
548
 
    priv->preedit_text = text_empty;
549
 
    priv->preedit_cursor_pos = 0;
550
 
    priv->preedit_visible = FALSE;
551
 
 
552
 
    g_object_ref (text_empty);
553
 
    priv->auxiliary_text = text_empty;
554
 
    priv->auxiliary_visible = FALSE;
 
480
    context->connection = NULL;
 
481
    context->client = NULL;
 
482
    context->engine = NULL;
 
483
    context->has_focus = FALSE;
 
484
    context->enabled = FALSE;
 
485
 
 
486
    context->prev_keyval = IBUS_VoidSymbol;
 
487
    context->prev_modifiers = 0;
 
488
 
 
489
    context->capabilities = 0;
 
490
 
 
491
    context->x = 0;
 
492
    context->y = 0;
 
493
    context->w = 0;
 
494
    context->h = 0;
 
495
 
 
496
    g_object_ref (text_empty);
 
497
    context->preedit_text = text_empty;
 
498
    context->preedit_cursor_pos = 0;
 
499
    context->preedit_visible = FALSE;
 
500
 
 
501
    g_object_ref (text_empty);
 
502
    context->auxiliary_text = text_empty;
 
503
    context->auxiliary_visible = FALSE;
555
504
 
556
505
    g_object_ref (lookup_table_empty);
557
 
    priv->lookup_table = lookup_table_empty;
558
 
    priv->lookup_table_visible = FALSE;
 
506
    context->lookup_table = lookup_table_empty;
 
507
    context->lookup_table_visible = FALSE;
559
508
 
560
509
    g_object_ref (props_empty);
561
510
}
563
512
static void
564
513
bus_input_context_destroy (BusInputContext *context)
565
514
{
566
 
    BusInputContextPrivate *priv;
567
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
568
 
 
569
 
    if (priv->has_focus) {
 
515
    if (context->has_focus) {
570
516
        bus_input_context_focus_out (context);
571
 
        priv->has_focus = FALSE;
 
517
        context->has_focus = FALSE;
572
518
    }
573
519
 
574
 
    if (priv->engine) {
 
520
    if (context->engine) {
575
521
        bus_input_context_unset_engine (context);
576
522
    }
577
523
 
578
 
    if (priv->preedit_text) {
579
 
        g_object_unref (priv->preedit_text);
580
 
        priv->preedit_text = NULL;
581
 
    }
582
 
 
583
 
    if (priv->auxiliary_text) {
584
 
        g_object_unref (priv->auxiliary_text);
585
 
        priv->auxiliary_text = NULL;
586
 
    }
587
 
 
588
 
    if (priv->lookup_table) {
589
 
        g_object_unref (priv->lookup_table);
590
 
        priv->lookup_table = NULL;
591
 
    }
592
 
 
593
 
    if (priv->connection) {
594
 
        g_signal_handlers_disconnect_by_func (priv->connection,
 
524
    if (context->preedit_text) {
 
525
        g_object_unref (context->preedit_text);
 
526
        context->preedit_text = NULL;
 
527
    }
 
528
 
 
529
    if (context->auxiliary_text) {
 
530
        g_object_unref (context->auxiliary_text);
 
531
        context->auxiliary_text = NULL;
 
532
    }
 
533
 
 
534
    if (context->lookup_table) {
 
535
        g_object_unref (context->lookup_table);
 
536
        context->lookup_table = NULL;
 
537
    }
 
538
 
 
539
    if (context->connection) {
 
540
        g_signal_handlers_disconnect_by_func (context->connection,
595
541
                                         (GCallback) _connection_destroy_cb,
596
542
                                         context);
597
 
        g_object_unref (priv->connection);
598
 
        priv->connection = NULL;
 
543
        g_object_unref (context->connection);
 
544
        context->connection = NULL;
599
545
    }
600
546
 
601
 
    if (priv->client) {
602
 
        g_free (priv->client);
603
 
        priv->client = NULL;
 
547
    if (context->client) {
 
548
        g_free (context->client);
 
549
        context->client = NULL;
604
550
    }
605
551
 
606
552
    IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (context));
620
566
        "      <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
621
567
        "    </method>\n"
622
568
        "  </interface>\n"
623
 
        "  <interface name=\"org.freedesktop.IBus\">\n"
624
 
        "    <method name=\"RequestName\">\n"
625
 
        "      <arg direction=\"in\" type=\"s\"/>\n"
626
 
        "      <arg direction=\"in\" type=\"u\"/>\n"
627
 
        "      <arg direction=\"out\" type=\"u\"/>\n"
628
 
        "    </method>\n"
629
 
        "    <signal name=\"NameOwnerChanged\">\n"
630
 
        "      <arg type=\"s\"/>\n"
631
 
        "      <arg type=\"s\"/>\n"
632
 
        "      <arg type=\"s\"/>\n"
633
 
        "    </signal>\n"
 
569
        "  <interface name=\"org.freedesktop.IBus.InputContext\">\n"
 
570
 
 
571
        /* methods */
 
572
        "    <method name=\"ProcessKeyEvent\">\n"
 
573
        "      <arg name=\"keyval\" direction=\"in\" type=\"u\"/>\n"
 
574
        "      <arg name=\"keycode\" direction=\"in\" type=\"u\"/>\n"
 
575
        "      <arg name=\"state\" direction=\"in\" type=\"u\"/>\n"
 
576
        "      <arg name=\"handled\" direction=\"out\" type=\"b\"/>\n"
 
577
        "    </method>\n"
 
578
        "    <method name=\"SetCursorLocation\">\n"
 
579
        "      <arg name=\"x\" direction=\"in\" type=\"i\"/>\n"
 
580
        "      <arg name=\"y\" direction=\"in\" type=\"i\"/>\n"
 
581
        "      <arg name=\"w\" direction=\"in\" type=\"i\"/>\n"
 
582
        "      <arg name=\"h\" direction=\"in\" type=\"i\"/>\n"
 
583
        "    </method>\n"
 
584
        "    <method name=\"FocusIn\"/>\n"
 
585
        "    <method name=\"FocusOut\"/>\n"
 
586
        "    <method name=\"Reset\"/>\n"
 
587
        "    <method name=\"Enable\"/>\n"
 
588
        "    <method name=\"Disable\"/>\n"
 
589
        "    <method name=\"IsEnabled\">\n"
 
590
        "      <arg name=\"enable\" direction=\"out\" type=\"b\"/>\n"
 
591
        "    </method>\n"
 
592
        "    <method name=\"SetCapabilities\">\n"
 
593
        "      <arg name=\"caps\" direction=\"in\" type=\"u\"/>\n"
 
594
        "    </method>\n"
 
595
        "    <method name=\"SetEngine\">\n"
 
596
        "      <arg name=\"name\" direction=\"in\" type=\"s\"/>\n"
 
597
        "    </method>\n"
 
598
        "    <method name=\"GetEngine\">\n"
 
599
        "      <arg name=\"desc\" direction=\"out\" type=\"v\"/>\n"
 
600
        "    </method>\n"
 
601
        "    <method name=\"Destroy\"/>\n"
 
602
 
 
603
        /* signals */
 
604
        "    <signal name=\"CommitText\">\n"
 
605
        "      <arg name=\"text\" type=\"v\"/>\n"
 
606
        "    </signal>\n"
 
607
        "    <signal name=\"Enabled\"/>\n"
 
608
        "    <signal name=\"Disabled\"/>\n"
 
609
        "    <signal name=\"ForwardKeyEvent\">\n"
 
610
        "      <arg name=\"keyval\" type=\"u\"/>\n"
 
611
        "      <arg name=\"keycode\" type=\"u\"/>\n"
 
612
        "      <arg name=\"state\" type=\"u\"/>\n"
 
613
        "    </signal>\n"
 
614
 
 
615
        "    <signal name=\"UpdatePreeditText\">\n"
 
616
        "      <arg name=\"text\" type=\"v\"/>\n"
 
617
        "      <arg name=\"cursor_pos\" type=\"u\"/>\n"
 
618
        "      <arg name=\"visible\" type=\"b\"/>\n"
 
619
        "    </signal>\n"
 
620
        "    <signal name=\"ShowPreeditText\"/>\n"
 
621
        "    <signal name=\"HidePreeditText\"/>\n"
 
622
 
 
623
        "    <signal name=\"UpdateAuxiliaryText\">\n"
 
624
        "      <arg name=\"text\" type=\"v\"/>\n"
 
625
        "      <arg name=\"visible\" type=\"b\"/>\n"
 
626
        "    </signal>\n"
 
627
        "    <signal name=\"ShowAuxiliaryText\"/>\n"
 
628
        "    <signal name=\"HideAuxiliaryText\"/>\n"
 
629
 
 
630
        "    <signal name=\"UpdateLookupTable\">\n"
 
631
        "      <arg name=\"table\" type=\"v\"/>\n"
 
632
        "      <arg name=\"visible\" type=\"b\"/>\n"
 
633
        "    </signal>\n"
 
634
        "    <signal name=\"ShowLookupTable\"/>\n"
 
635
        "    <signal name=\"HideLookupTable\"/>\n"
 
636
        "    <signal name=\"PageUpLookupTable\"/>\n"
 
637
        "    <signal name=\"PageDownLookupTable\"/>\n"
 
638
        "    <signal name=\"CursorUpLookupTable\"/>\n"
 
639
        "    <signal name=\"CursorDownLookupTable\"/>\n"
 
640
 
 
641
        "    <signal name=\"RegisterProperties\">\n"
 
642
        "      <arg name=\"props\" type=\"v\"/>\n"
 
643
        "    </signal>\n"
 
644
        "    <signal name=\"UpdateProperty\">\n"
 
645
        "      <arg name=\"prop\" type=\"v\"/>\n"
 
646
        "    </signal>\n"
 
647
 
634
648
        "  </interface>\n"
635
649
        "</node>\n";
636
650
 
659
673
    retval = (gboolean) GPOINTER_TO_INT (data);
660
674
    call_data = (CallData *) user_data;
661
675
 
662
 
    BusInputContextPrivate *priv;
663
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (call_data->context);
664
 
 
665
 
 
666
676
    reply = ibus_message_new_method_return (call_data->message);
667
677
    ibus_message_append_args (reply,
668
678
                              G_TYPE_BOOLEAN, &retval,
669
679
                              G_TYPE_INVALID);
670
 
    ibus_connection_send ((IBusConnection *)priv->connection, reply);
 
680
 
 
681
    ibus_connection_send ((IBusConnection *)call_data->context->connection, reply);
671
682
 
672
683
    g_object_unref (call_data->context);
673
684
    ibus_message_unref (call_data->message);
676
687
}
677
688
 
678
689
static IBusMessage *
679
 
_ic_process_key_event (BusInputContext *context,
680
 
                       IBusMessage     *message,
681
 
                       BusConnection   *connection)
 
690
_ic_process_key_event  (BusInputContext *context,
 
691
                        IBusMessage     *message,
 
692
                        BusConnection   *connection)
682
693
{
683
694
    g_assert (BUS_IS_INPUT_CONTEXT (context));
684
695
    g_assert (message != NULL);
685
696
    g_assert (BUS_IS_CONNECTION (connection));
686
697
 
687
698
    IBusMessage *reply = NULL;
688
 
    guint keyval, modifiers;
 
699
    guint keyval, keycode, modifiers;
689
700
    gboolean retval;
690
701
    IBusError *error;
691
702
 
692
 
    BusInputContextPrivate *priv;
693
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
694
 
 
695
703
    retval = ibus_message_get_args (message,
696
704
                &error,
697
705
                G_TYPE_UINT, &keyval,
 
706
                G_TYPE_UINT, &keycode,
698
707
                G_TYPE_UINT, &modifiers,
699
708
                G_TYPE_INVALID);
700
709
 
706
715
        return reply;
707
716
    }
708
717
 
709
 
    retval = bus_input_context_filter_keyboard_shortcuts (context, keyval, modifiers);
 
718
    retval = bus_input_context_filter_keyboard_shortcuts (context, keyval, keycode, modifiers);
710
719
 
711
720
    if (retval) {
712
 
        priv->filter_release = TRUE;
713
721
        reply = ibus_message_new_method_return (message);
714
722
        ibus_message_append_args (reply,
715
723
                                  G_TYPE_BOOLEAN, &retval,
716
724
                                  G_TYPE_INVALID);
717
725
    }
718
 
    else if (priv->enabled && priv->engine) {
 
726
    else if (context->enabled && context->engine) {
719
727
        CallData *call_data;
720
728
 
721
729
        call_data = g_slice_new (CallData);
726
734
        call_data->context = context;
727
735
        call_data->message = message;
728
736
 
729
 
        bus_engine_proxy_process_key_event (priv->engine,
 
737
        bus_engine_proxy_process_key_event (context->engine,
730
738
                                            keyval,
 
739
                                            keycode,
731
740
                                            modifiers,
732
741
                                            (GFunc) _ic_process_key_event_reply_cb,
733
742
                                            call_data);
755
764
    gboolean retval;
756
765
    IBusError *error;
757
766
 
758
 
    BusInputContextPrivate *priv;
759
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
760
 
 
761
767
    retval = ibus_message_get_args (message, &error,
762
768
                G_TYPE_INT, &x,
763
769
                G_TYPE_INT, &y,
773
779
        return reply;
774
780
    }
775
781
 
776
 
    priv->x = x;
777
 
    priv->y = y;
778
 
    priv->h = h;
779
 
    priv->w = w;
 
782
    context->x = x;
 
783
    context->y = y;
 
784
    context->h = h;
 
785
    context->w = w;
780
786
 
781
 
    if (priv->engine) {
782
 
        bus_engine_proxy_set_cursor_location (priv->engine, x, y, w, h);
 
787
    if (context->engine) {
 
788
        bus_engine_proxy_set_cursor_location (context->engine, x, y, w, h);
783
789
    }
784
790
 
785
 
    if (priv->capabilities & IBUS_CAP_FOCUS) {
 
791
    if (context->capabilities & IBUS_CAP_FOCUS) {
786
792
        g_signal_emit (context,
787
793
                       context_signals[SET_CURSOR_LOCATION],
788
794
                       0,
843
849
 
844
850
    IBusMessage *reply;
845
851
 
846
 
    BusInputContextPrivate *priv;
847
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
848
 
 
849
 
 
850
 
    if (priv->engine) {
851
 
        bus_engine_proxy_reset (priv->engine);
 
852
    if (context->engine) {
 
853
        bus_engine_proxy_reset (context->engine);
852
854
    }
853
855
 
854
856
    reply = ibus_message_new_method_return (message);
869
871
    gboolean retval;
870
872
    IBusError *error;
871
873
 
872
 
    BusInputContextPrivate *priv;
873
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
874
 
 
875
 
 
876
874
    retval = ibus_message_get_args (message,
877
875
                &error,
878
876
                G_TYPE_UINT, &caps,
886
884
        return reply;
887
885
    }
888
886
 
889
 
    if (priv->capabilities != caps) {
890
 
        priv->capabilities = caps;
 
887
    if (context->capabilities != caps) {
 
888
        context->capabilities = caps;
891
889
 
892
 
        if (priv->engine) {
893
 
            bus_engine_proxy_set_capabilities (priv->engine, caps);
 
890
        if (context->engine) {
 
891
            bus_engine_proxy_set_capabilities (context->engine, caps);
894
892
        }
895
893
    }
896
894
 
943
941
 
944
942
    IBusMessage *reply;
945
943
 
946
 
    BusInputContextPrivate *priv;
947
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
948
 
 
949
944
    reply = ibus_message_new_method_return (message);
950
945
    ibus_message_append_args (reply,
951
 
            G_TYPE_BOOLEAN, &priv->enabled,
 
946
            G_TYPE_BOOLEAN, &context->enabled,
952
947
            G_TYPE_INVALID);
953
948
 
954
949
    return reply;
968
963
    IBusError *error;
969
964
    gchar *engine_name;
970
965
 
971
 
    BusInputContextPrivate *priv;
972
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
973
 
 
974
966
    retval = ibus_message_get_args (message,
975
967
                                    &error,
976
968
                                    G_TYPE_STRING, &engine_name,
985
977
 
986
978
    g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, engine_name);
987
979
 
988
 
    if (priv->engine == NULL) {
 
980
    if (context->engine == NULL) {
989
981
        reply = ibus_message_new_error_printf (message,
990
982
                                               "org.freedesktop.IBus.NoEngine",
991
983
                                               "can not find engine with name %s",
1011
1003
    IBusMessage *reply;
1012
1004
    IBusEngineDesc *desc;
1013
1005
 
1014
 
    BusInputContextPrivate *priv;
1015
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1016
 
 
1017
 
    if (priv->engine) {
1018
 
        desc = bus_engine_proxy_get_desc (priv->engine);
 
1006
    if (context->engine) {
 
1007
        desc = bus_engine_proxy_get_desc (context->engine);
1019
1008
        if (desc != NULL) {
1020
1009
            reply = ibus_message_new_method_return (message);
1021
1010
            ibus_message_append_args (reply,
1126
1115
{
1127
1116
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1128
1117
 
1129
 
    BusInputContextPrivate *priv;
1130
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1131
 
 
1132
 
    return priv->has_focus;
 
1118
    return context->has_focus;
1133
1119
}
1134
1120
 
1135
1121
void
1137
1123
{
1138
1124
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1139
1125
 
1140
 
    BusInputContextPrivate *priv;
1141
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1142
 
 
1143
 
    if (priv->has_focus)
 
1126
    if (context->has_focus)
1144
1127
        return;
1145
1128
 
1146
 
    priv->has_focus = TRUE;
 
1129
    context->has_focus = TRUE;
1147
1130
 
1148
 
    if (priv->engine && priv->enabled) {
1149
 
        bus_engine_proxy_focus_in (priv->engine);
 
1131
    if (context->engine && context->enabled) {
 
1132
        bus_engine_proxy_focus_in (context->engine);
1150
1133
    }
1151
1134
 
1152
 
    if (priv->capabilities & IBUS_CAP_FOCUS) {
 
1135
    if (context->capabilities & IBUS_CAP_FOCUS) {
1153
1136
        g_signal_emit (context, context_signals[FOCUS_IN], 0);
1154
 
 
1155
 
        if (priv->preedit_visible && (priv->capabilities & IBUS_CAP_PREEDIT_TEXT) == 0) {
1156
 
            g_signal_emit (context,
1157
 
                           context_signals[UPDATE_PREEDIT_TEXT],
1158
 
                           0,
1159
 
                           priv->preedit_text,
1160
 
                           priv->preedit_cursor_pos,
1161
 
                           priv->preedit_visible);
1162
 
        }
1163
 
        if (priv->auxiliary_visible && (priv->capabilities & IBUS_CAP_AUXILIARY_TEXT) == 0) {
1164
 
            g_signal_emit (context,
1165
 
                           context_signals[UPDATE_AUXILIARY_TEXT],
1166
 
                           0,
1167
 
                           priv->auxiliary_text,
1168
 
                           priv->auxiliary_visible);
1169
 
        }
1170
 
        if (priv->auxiliary_visible && (priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == 0) {
1171
 
            g_signal_emit (context,
1172
 
                           context_signals[UPDATE_LOOKUP_TABLE],
1173
 
                           0,
1174
 
                           priv->lookup_table,
1175
 
                           priv->lookup_table_visible);
 
1137
        if (context->engine && context->enabled) {
 
1138
            if (context->preedit_visible && (context->capabilities & IBUS_CAP_PREEDIT_TEXT) == 0) {
 
1139
                g_signal_emit (context,
 
1140
                               context_signals[UPDATE_PREEDIT_TEXT],
 
1141
                               0,
 
1142
                               context->preedit_text,
 
1143
                               context->preedit_cursor_pos,
 
1144
                               context->preedit_visible);
 
1145
            }
 
1146
            if (context->auxiliary_visible && (context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == 0) {
 
1147
                g_signal_emit (context,
 
1148
                               context_signals[UPDATE_AUXILIARY_TEXT],
 
1149
                               0,
 
1150
                               context->auxiliary_text,
 
1151
                               context->auxiliary_visible);
 
1152
            }
 
1153
            if (context->lookup_table_visible && (context->capabilities & IBUS_CAP_LOOKUP_TABLE) == 0) {
 
1154
                g_signal_emit (context,
 
1155
                               context_signals[UPDATE_LOOKUP_TABLE],
 
1156
                               0,
 
1157
                               context->lookup_table,
 
1158
                               context->lookup_table_visible);
 
1159
            }
1176
1160
        }
1177
1161
    }
1178
1162
}
1182
1166
{
1183
1167
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1184
1168
 
1185
 
    BusInputContextPrivate *priv;
1186
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1187
 
 
1188
 
    if (!priv->has_focus)
 
1169
    if (!context->has_focus)
1189
1170
        return;
1190
1171
 
1191
 
    priv->has_focus = FALSE;
 
1172
    context->has_focus = FALSE;
1192
1173
 
1193
 
    if (priv->engine && priv->enabled) {
1194
 
        bus_engine_proxy_focus_out (priv->engine);
 
1174
    if (context->engine && context->enabled) {
 
1175
        bus_engine_proxy_focus_out (context->engine);
1195
1176
    }
1196
1177
 
1197
 
    if (priv->capabilities & IBUS_CAP_FOCUS) {
1198
 
        if (priv->preedit_visible && (priv->capabilities & IBUS_CAP_PREEDIT_TEXT) == 0) {
 
1178
    if (context->capabilities & IBUS_CAP_FOCUS) {
 
1179
        if (context->preedit_visible && (context->capabilities & IBUS_CAP_PREEDIT_TEXT) == 0) {
1199
1180
            g_signal_emit (context, context_signals[HIDE_PREEDIT_TEXT], 0);
1200
1181
        }
1201
 
        if (priv->auxiliary_visible && (priv->capabilities & IBUS_CAP_AUXILIARY_TEXT) == 0) {
 
1182
        if (context->auxiliary_visible && (context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == 0) {
1202
1183
            g_signal_emit (context, context_signals[HIDE_AUXILIARY_TEXT], 0);
1203
1184
        }
1204
 
        if (priv->auxiliary_visible && (priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == 0) {
 
1185
        if (context->auxiliary_visible && (context->capabilities & IBUS_CAP_LOOKUP_TABLE) == 0) {
1205
1186
            g_signal_emit (context, context_signals[HIDE_LOOKUP_TABLE], 0);
1206
1187
        }
1207
1188
        g_signal_emit (context, context_signals[FOCUS_OUT], 0);
1214
1195
    {                                                       \
1215
1196
        g_assert (BUS_IS_INPUT_CONTEXT (context));          \
1216
1197
                                                            \
1217
 
        BusInputContextPrivate *priv;                       \
1218
 
        priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);     \
1219
1198
                                                            \
1220
 
        if (priv->engine) {                                 \
1221
 
            bus_engine_proxy_##name (priv->engine);         \
 
1199
        if (context->engine) {                              \
 
1200
            bus_engine_proxy_##name (context->engine);      \
1222
1201
        }                                                   \
1223
1202
    }
1224
1203
 
1237
1216
{
1238
1217
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1239
1218
 
1240
 
    BusInputContextPrivate *priv;
1241
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1242
 
 
1243
 
    if (priv->engine) {
1244
 
        bus_engine_proxy_candidate_clicked (priv->engine,
 
1219
    if (context->engine) {
 
1220
        bus_engine_proxy_candidate_clicked (context->engine,
1245
1221
                                            index,
1246
1222
                                            button,
1247
1223
                                            state);
1255
1231
{
1256
1232
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1257
1233
 
1258
 
    BusInputContextPrivate *priv;
1259
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1260
 
 
1261
 
    if (priv->engine) {
1262
 
        bus_engine_proxy_property_activate (priv->engine, prop_name, prop_state);
 
1234
    if (context->engine) {
 
1235
        bus_engine_proxy_property_activate (context->engine, prop_name, prop_state);
1263
1236
    }
1264
1237
}
1265
1238
 
1271
1244
{
1272
1245
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1273
1246
 
1274
 
    BusInputContextPrivate *priv;
1275
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1276
 
 
1277
 
    if (priv->preedit_text) {
1278
 
        g_object_unref (priv->preedit_text);
 
1247
    if (context->preedit_text) {
 
1248
        g_object_unref (context->preedit_text);
1279
1249
    }
1280
1250
 
1281
 
    priv->preedit_text = (IBusText *) g_object_ref (text ? text : text_empty);
1282
 
    priv->preedit_cursor_pos = cursor_pos;
1283
 
    priv->preedit_visible = visible;
 
1251
    context->preedit_text = (IBusText *) g_object_ref (text ? text : text_empty);
 
1252
    context->preedit_cursor_pos = cursor_pos;
 
1253
    context->preedit_visible = visible;
1284
1254
 
1285
 
    if (priv->capabilities & IBUS_CAP_PREEDIT_TEXT) {
 
1255
    if (context->capabilities & IBUS_CAP_PREEDIT_TEXT) {
1286
1256
        bus_input_context_send_signal (context,
1287
1257
                                       "UpdatePreeditText",
1288
 
                                       IBUS_TYPE_TEXT, &(priv->preedit_text),
1289
 
                                       G_TYPE_UINT, &(priv->preedit_cursor_pos),
1290
 
                                       G_TYPE_BOOLEAN, &(priv->preedit_visible),
 
1258
                                       IBUS_TYPE_TEXT, &(context->preedit_text),
 
1259
                                       G_TYPE_UINT, &(context->preedit_cursor_pos),
 
1260
                                       G_TYPE_BOOLEAN, &(context->preedit_visible),
1291
1261
                                       G_TYPE_INVALID);
1292
1262
    }
1293
1263
    else {
1294
1264
        g_signal_emit (context,
1295
1265
                       context_signals[UPDATE_PREEDIT_TEXT],
1296
1266
                       0,
1297
 
                       priv->preedit_text,
1298
 
                       priv->preedit_cursor_pos,
1299
 
                       priv->preedit_visible);
 
1267
                       context->preedit_text,
 
1268
                       context->preedit_cursor_pos,
 
1269
                       context->preedit_visible);
1300
1270
    }
1301
1271
}
1302
1272
 
1305
1275
{
1306
1276
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1307
1277
 
1308
 
    BusInputContextPrivate *priv;
1309
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1310
 
 
1311
 
    if (priv->preedit_visible) {
 
1278
    if (context->preedit_visible) {
1312
1279
        return;
1313
1280
    }
1314
1281
 
1315
 
    priv->preedit_visible = TRUE;
 
1282
    context->preedit_visible = TRUE;
1316
1283
 
1317
 
    if ((priv->capabilities & IBUS_CAP_PREEDIT_TEXT) == IBUS_CAP_PREEDIT_TEXT) {
 
1284
    if ((context->capabilities & IBUS_CAP_PREEDIT_TEXT) == IBUS_CAP_PREEDIT_TEXT) {
1318
1285
        bus_input_context_send_signal (context,
1319
1286
                                       "ShowPreeditText",
1320
1287
                                       G_TYPE_INVALID);
1331
1298
{
1332
1299
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1333
1300
 
1334
 
    BusInputContextPrivate *priv;
1335
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1336
 
 
1337
 
    if (!priv->preedit_visible) {
 
1301
    if (!context->preedit_visible) {
1338
1302
        return;
1339
1303
    }
1340
1304
 
1341
 
    priv->preedit_visible = FALSE;
 
1305
    context->preedit_visible = FALSE;
1342
1306
 
1343
 
    if ((priv->capabilities & IBUS_CAP_PREEDIT_TEXT) == IBUS_CAP_PREEDIT_TEXT) {
 
1307
    if ((context->capabilities & IBUS_CAP_PREEDIT_TEXT) == IBUS_CAP_PREEDIT_TEXT) {
1344
1308
        bus_input_context_send_signal (context,
1345
1309
                                       "HidePreeditText",
1346
1310
                                       G_TYPE_INVALID);
1359
1323
{
1360
1324
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1361
1325
 
1362
 
    BusInputContextPrivate *priv;
1363
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1364
 
 
1365
 
    if (priv->auxiliary_text) {
1366
 
        g_object_unref (priv->auxiliary_text);
 
1326
    if (context->auxiliary_text) {
 
1327
        g_object_unref (context->auxiliary_text);
1367
1328
    }
1368
1329
 
1369
 
    priv->auxiliary_text = (IBusText *) g_object_ref (text ? text : text_empty);
1370
 
    priv->auxiliary_visible = visible;
 
1330
    context->auxiliary_text = (IBusText *) g_object_ref (text ? text : text_empty);
 
1331
    context->auxiliary_visible = visible;
1371
1332
 
1372
 
    if (priv->capabilities & IBUS_CAP_AUXILIARY_TEXT) {
 
1333
    if (context->capabilities & IBUS_CAP_AUXILIARY_TEXT) {
1373
1334
        bus_input_context_send_signal (context,
1374
1335
                                       "UpdateAuxiliaryText",
1375
 
                                       IBUS_TYPE_TEXT, &(priv->auxiliary_text),
1376
 
                                       G_TYPE_BOOLEAN, &(priv->auxiliary_visible),
 
1336
                                       IBUS_TYPE_TEXT, &(context->auxiliary_text),
 
1337
                                       G_TYPE_BOOLEAN, &(context->auxiliary_visible),
1377
1338
                                       G_TYPE_INVALID);
1378
1339
    }
1379
1340
    else {
1380
1341
        g_signal_emit (context,
1381
1342
                       context_signals[UPDATE_AUXILIARY_TEXT],
1382
1343
                       0,
1383
 
                       priv->auxiliary_text,
1384
 
                       priv->auxiliary_visible);
 
1344
                       context->auxiliary_text,
 
1345
                       context->auxiliary_visible);
1385
1346
    }
1386
1347
}
1387
1348
 
1390
1351
{
1391
1352
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1392
1353
 
1393
 
    BusInputContextPrivate *priv;
1394
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1395
 
 
1396
 
    if (priv->auxiliary_visible) {
 
1354
    if (context->auxiliary_visible) {
1397
1355
        return;
1398
1356
    }
1399
1357
 
1400
 
    priv->auxiliary_visible = TRUE;
 
1358
    context->auxiliary_visible = TRUE;
1401
1359
 
1402
 
    if ((priv->capabilities & IBUS_CAP_AUXILIARY_TEXT) == IBUS_CAP_AUXILIARY_TEXT) {
 
1360
    if ((context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == IBUS_CAP_AUXILIARY_TEXT) {
1403
1361
        bus_input_context_send_signal (context,
1404
1362
                                       "ShowAuxiliaryText",
1405
1363
                                       G_TYPE_INVALID);
1416
1374
{
1417
1375
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1418
1376
 
1419
 
    BusInputContextPrivate *priv;
1420
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1421
 
 
1422
 
    if (!priv->auxiliary_visible) {
 
1377
    if (!context->auxiliary_visible) {
1423
1378
        return;
1424
1379
    }
1425
1380
 
1426
 
    priv->auxiliary_visible = FALSE;
 
1381
    context->auxiliary_visible = FALSE;
1427
1382
 
1428
 
    if ((priv->capabilities & IBUS_CAP_AUXILIARY_TEXT) == IBUS_CAP_AUXILIARY_TEXT) {
 
1383
    if ((context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == IBUS_CAP_AUXILIARY_TEXT) {
1429
1384
        bus_input_context_send_signal (context,
1430
1385
                                       "HideAuxiliaryText",
1431
1386
                                       G_TYPE_INVALID);
1444
1399
{
1445
1400
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1446
1401
 
1447
 
    BusInputContextPrivate *priv;
1448
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1449
 
 
1450
 
    if (priv->lookup_table) {
1451
 
        g_object_unref (priv->lookup_table);
 
1402
    if (context->lookup_table) {
 
1403
        g_object_unref (context->lookup_table);
1452
1404
    }
1453
1405
 
1454
 
    priv->lookup_table = (IBusLookupTable *) g_object_ref (table ? table : lookup_table_empty);
1455
 
    priv->lookup_table_visible = visible;
 
1406
    context->lookup_table = (IBusLookupTable *) g_object_ref (table ? table : lookup_table_empty);
 
1407
    context->lookup_table_visible = visible;
1456
1408
 
1457
 
    if (priv->capabilities & IBUS_CAP_LOOKUP_TABLE) {
 
1409
    if (context->capabilities & IBUS_CAP_LOOKUP_TABLE) {
1458
1410
        bus_input_context_send_signal (context,
1459
1411
                                       "UpdateLookupTable",
1460
 
                                       IBUS_TYPE_LOOKUP_TABLE, &(priv->lookup_table),
1461
 
                                       G_TYPE_BOOLEAN, &(priv->lookup_table_visible),
 
1412
                                       IBUS_TYPE_LOOKUP_TABLE, &(context->lookup_table),
 
1413
                                       G_TYPE_BOOLEAN, &(context->lookup_table_visible),
1462
1414
                                       G_TYPE_INVALID);
1463
1415
    }
1464
1416
    else {
1465
1417
        g_signal_emit (context,
1466
1418
                       context_signals[UPDATE_LOOKUP_TABLE],
1467
1419
                       0,
1468
 
                       priv->lookup_table,
1469
 
                       priv->lookup_table_visible);
 
1420
                       context->lookup_table,
 
1421
                       context->lookup_table_visible);
1470
1422
    }
1471
1423
}
1472
1424
 
1475
1427
{
1476
1428
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1477
1429
 
1478
 
    BusInputContextPrivate *priv;
1479
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1480
 
 
1481
 
    if (priv->lookup_table_visible) {
 
1430
    if (context->lookup_table_visible) {
1482
1431
        return;
1483
1432
    }
1484
1433
 
1485
 
    priv->lookup_table_visible = TRUE;
 
1434
    context->lookup_table_visible = TRUE;
1486
1435
 
1487
 
    if ((priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
 
1436
    if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
1488
1437
        bus_input_context_send_signal (context,
1489
1438
                                       "ShowLookupTable",
1490
1439
                                       G_TYPE_INVALID);
1501
1450
{
1502
1451
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1503
1452
 
1504
 
    BusInputContextPrivate *priv;
1505
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1506
 
 
1507
 
    if (!priv->lookup_table_visible) {
 
1453
    if (!context->lookup_table_visible) {
1508
1454
        return;
1509
1455
    }
1510
1456
 
1511
 
    priv->lookup_table_visible = FALSE;
 
1457
    context->lookup_table_visible = FALSE;
1512
1458
 
1513
 
    if ((priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
 
1459
    if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
1514
1460
        bus_input_context_send_signal (context,
1515
1461
                                       "HideLookupTable",
1516
1462
                                       G_TYPE_INVALID);
1527
1473
{
1528
1474
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1529
1475
 
1530
 
    BusInputContextPrivate *priv;
1531
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1532
 
 
1533
 
    if (!ibus_lookup_table_page_up (priv->lookup_table)) {
 
1476
    if (!ibus_lookup_table_page_up (context->lookup_table)) {
1534
1477
        return;
1535
1478
    }
1536
1479
 
1537
 
    if ((priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
 
1480
    if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
1538
1481
        bus_input_context_send_signal (context,
1539
1482
                                       "PageUpLookupTable",
1540
1483
                                       G_TYPE_INVALID);
1551
1494
{
1552
1495
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1553
1496
 
1554
 
    BusInputContextPrivate *priv;
1555
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1556
 
 
1557
 
    if (!ibus_lookup_table_page_down (priv->lookup_table)) {
 
1497
    if (!ibus_lookup_table_page_down (context->lookup_table)) {
1558
1498
        return;
1559
1499
    }
1560
1500
 
1561
 
    if ((priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
 
1501
    if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
1562
1502
        bus_input_context_send_signal (context,
1563
1503
                                       "PageDownLookupTable",
1564
1504
                                       G_TYPE_INVALID);
1575
1515
{
1576
1516
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1577
1517
 
1578
 
    BusInputContextPrivate *priv;
1579
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1580
 
 
1581
 
    if (!ibus_lookup_table_cursor_up (priv->lookup_table)) {
 
1518
    if (!ibus_lookup_table_cursor_up (context->lookup_table)) {
1582
1519
        return;
1583
1520
    }
1584
1521
 
1585
 
    if ((priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
 
1522
    if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
1586
1523
        bus_input_context_send_signal (context,
1587
1524
                                       "CursorUpLookupTable",
1588
1525
                                       G_TYPE_INVALID);
1599
1536
{
1600
1537
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1601
1538
 
1602
 
    BusInputContextPrivate *priv;
1603
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1604
 
 
1605
 
    if (!ibus_lookup_table_cursor_down (priv->lookup_table)) {
 
1539
    if (!ibus_lookup_table_cursor_down (context->lookup_table)) {
1606
1540
        return;
1607
1541
    }
1608
1542
 
1609
 
    if ((priv->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
 
1543
    if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
1610
1544
        bus_input_context_send_signal (context,
1611
1545
                                       "CursorDownLookupTable",
1612
1546
                                       G_TYPE_INVALID);
1625
1559
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1626
1560
    g_assert (IBUS_IS_PROP_LIST (props));
1627
1561
 
1628
 
    BusInputContextPrivate *priv;
1629
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1630
 
 
1631
 
    if (priv->capabilities & IBUS_CAP_PROPERTY) {
 
1562
    if (context->capabilities & IBUS_CAP_PROPERTY) {
1632
1563
        bus_input_context_send_signal (context,
1633
1564
                                       "RegisterProperties",
1634
1565
                                       IBUS_TYPE_PROP_LIST, &props,
1649
1580
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1650
1581
    g_assert (IBUS_IS_PROPERTY (prop));
1651
1582
 
1652
 
    BusInputContextPrivate *priv;
1653
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1654
 
 
1655
 
    if (priv->capabilities & IBUS_CAP_PROPERTY) {
 
1583
    if (context->capabilities & IBUS_CAP_PROPERTY) {
1656
1584
        bus_input_context_send_signal (context,
1657
1585
                                       "UpdateProperty",
1658
1586
                                       IBUS_TYPE_PROPERTY, &prop,
1673
1601
    g_assert (BUS_IS_ENGINE_PROXY (engine));
1674
1602
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1675
1603
 
1676
 
    BusInputContextPrivate *priv;
1677
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1678
 
 
1679
 
    g_assert (priv->engine == engine);
 
1604
    g_assert (context->engine == engine);
1680
1605
 
1681
1606
    bus_input_context_unset_engine (context);
1682
1607
    bus_input_context_disable (context);
1691
1616
    g_assert (text != NULL);
1692
1617
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1693
1618
 
1694
 
    BusInputContextPrivate *priv;
1695
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1696
 
 
1697
 
    g_assert (priv->engine == engine);
 
1619
    g_assert (context->engine == engine);
1698
1620
 
1699
1621
    bus_input_context_send_signal (context,
1700
1622
                                   "CommitText",
1706
1628
static void
1707
1629
_engine_forward_key_event_cb (BusEngineProxy    *engine,
1708
1630
                              guint              keyval,
 
1631
                              guint              keycode,
1709
1632
                              guint              state,
1710
1633
                              BusInputContext   *context)
1711
1634
{
1712
1635
    g_assert (BUS_IS_ENGINE_PROXY (engine));
1713
1636
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1714
1637
 
1715
 
    BusInputContextPrivate *priv;
1716
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1717
 
 
1718
 
    g_assert (priv->engine == engine);
 
1638
    g_assert (context->engine == engine);
1719
1639
 
1720
1640
    bus_input_context_send_signal (context,
1721
1641
                                   "ForwardKeyEvent",
1722
1642
                                   G_TYPE_UINT,  &keyval,
 
1643
                                   G_TYPE_UINT,  &keycode,
1723
1644
                                   G_TYPE_UINT,  &state,
1724
1645
                                   G_TYPE_INVALID);
1725
1646
 
1736
1657
    g_assert (IBUS_IS_TEXT (text));
1737
1658
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1738
1659
 
1739
 
    BusInputContextPrivate *priv;
1740
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1741
 
 
1742
 
    g_assert (priv->engine == engine);
 
1660
    g_assert (context->engine == engine);
1743
1661
 
1744
1662
    bus_input_context_update_preedit_text (context, text, cursor_pos, visible);
1745
1663
}
1754
1672
    g_assert (IBUS_IS_TEXT (text));
1755
1673
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1756
1674
 
1757
 
    BusInputContextPrivate *priv;
1758
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1759
 
 
1760
 
    g_assert (priv->engine == engine);
 
1675
    g_assert (context->engine == engine);
1761
1676
 
1762
1677
    bus_input_context_update_auxiliary_text (context, text, visible);
1763
1678
}
1772
1687
    g_assert (IBUS_IS_LOOKUP_TABLE (table));
1773
1688
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1774
1689
 
1775
 
    BusInputContextPrivate *priv;
1776
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1777
 
 
1778
 
    g_assert (priv->engine == engine);
 
1690
    g_assert (context->engine == engine);
1779
1691
 
1780
1692
    bus_input_context_update_lookup_table (context, table, visible);
1781
1693
}
1789
1701
    g_assert (IBUS_IS_PROP_LIST (props));
1790
1702
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1791
1703
 
1792
 
    BusInputContextPrivate *priv;
1793
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1794
 
 
1795
 
    g_assert (priv->engine == engine);
 
1704
    g_assert (context->engine == engine);
1796
1705
 
1797
1706
    bus_input_context_register_properties (context, props);
1798
1707
}
1806
1715
    g_assert (IBUS_IS_PROPERTY (prop));
1807
1716
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1808
1717
 
1809
 
    BusInputContextPrivate *priv;
1810
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1811
 
 
1812
 
    g_assert (priv->engine == engine);
 
1718
    g_assert (context->engine == engine);
1813
1719
 
1814
1720
    bus_input_context_update_property (context, prop);
1815
1721
}
1822
1728
        g_assert (BUS_IS_ENGINE_PROXY (engine));                \
1823
1729
        g_assert (BUS_IS_INPUT_CONTEXT (context));              \
1824
1730
                                                                \
1825
 
        BusInputContextPrivate *priv;                           \
1826
 
        priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);         \
1827
 
                                                                \
1828
 
        g_assert (priv->engine == engine);                      \
 
1731
        g_assert (context->engine == engine);                   \
1829
1732
                                                                \
1830
1733
        bus_input_context_##name (context);                     \
1831
1734
}
1847
1750
{
1848
1751
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1849
1752
 
1850
 
    BusInputContextPrivate *priv;
1851
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1852
 
 
1853
 
    if (priv->engine == NULL) {
 
1753
    if (context->engine == NULL) {
1854
1754
            g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, NULL);
1855
1755
    }
1856
1756
 
1857
 
    if (priv->engine == NULL)
 
1757
    if (context->engine == NULL)
1858
1758
        return;
1859
1759
 
1860
 
    priv->enabled = TRUE;
 
1760
    context->enabled = TRUE;
1861
1761
 
1862
 
    bus_engine_proxy_enable (priv->engine);
 
1762
    bus_engine_proxy_enable (context->engine);
1863
1763
    bus_input_context_send_signal (context,
1864
1764
                                   "Enabled",
1865
1765
                                   G_TYPE_INVALID);
1866
1766
    g_signal_emit (context,
1867
1767
                   context_signals[ENABLED],
1868
1768
                   0);
1869
 
    if (priv->has_focus) {
1870
 
        bus_engine_proxy_focus_in (priv->engine);
 
1769
    if (context->has_focus) {
 
1770
        bus_engine_proxy_focus_in (context->engine);
1871
1771
    }
1872
1772
}
1873
1773
 
1876
1776
{
1877
1777
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1878
1778
 
1879
 
    BusInputContextPrivate *priv;
1880
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1881
 
 
1882
 
    if (priv->engine) {
1883
 
        if (priv->has_focus) {
1884
 
            bus_engine_proxy_focus_out (priv->engine);
 
1779
    if (context->engine) {
 
1780
        if (context->has_focus) {
 
1781
            bus_engine_proxy_focus_out (context->engine);
1885
1782
        }
1886
 
        bus_engine_proxy_disable (priv->engine);
 
1783
        bus_engine_proxy_disable (context->engine);
1887
1784
    }
1888
1785
 
1889
1786
    bus_input_context_send_signal (context,
1893
1790
                   context_signals[DISABLED],
1894
1791
                   0);
1895
1792
 
1896
 
    priv->enabled = FALSE;
 
1793
    context->enabled = FALSE;
1897
1794
}
1898
1795
 
1899
1796
gboolean
1901
1798
{
1902
1799
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1903
1800
 
1904
 
    BusInputContextPrivate *priv;
1905
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1906
 
 
1907
 
    return priv->enabled;
 
1801
    return context->enabled;
1908
1802
}
1909
1803
 
1910
1804
const static struct {
1937
1831
{
1938
1832
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1939
1833
 
1940
 
    BusInputContextPrivate *priv;
1941
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1942
 
 
1943
1834
    bus_input_context_register_properties (context, props_empty);
1944
1835
    bus_input_context_update_preedit_text (context, text_empty, 0, FALSE);
1945
1836
    bus_input_context_update_auxiliary_text (context, text_empty, FALSE);
1946
1837
    bus_input_context_update_lookup_table (context, lookup_table_empty, FALSE);
1947
1838
 
1948
 
    if (priv->engine) {
 
1839
    if (context->engine) {
1949
1840
        gint i;
1950
1841
        for (i = 0; signals[i].name != NULL; i++) {
1951
 
            g_signal_handlers_disconnect_by_func (priv->engine, signals[i].callback, context);
 
1842
            g_signal_handlers_disconnect_by_func (context->engine, signals[i].callback, context);
1952
1843
        }
1953
1844
        /* we destroy the engine */
1954
 
        ibus_object_destroy ((IBusObject *) priv->engine);
1955
 
        g_object_unref (priv->engine);
1956
 
        priv->engine = NULL;
 
1845
        ibus_object_destroy ((IBusObject *) context->engine);
 
1846
        g_object_unref (context->engine);
 
1847
        context->engine = NULL;
1957
1848
    }
1958
1849
 
1959
1850
}
1964
1855
{
1965
1856
    g_assert (BUS_IS_INPUT_CONTEXT (context));
1966
1857
 
1967
 
    BusInputContextPrivate *priv;
1968
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
1969
 
 
1970
 
    if (priv->engine != NULL) {
 
1858
    if (context->engine != NULL) {
1971
1859
        bus_input_context_unset_engine (context);
1972
1860
    }
1973
1861
 
1976
1864
    }
1977
1865
    else {
1978
1866
        gint i;
1979
 
        priv->engine = engine;
1980
 
        g_object_ref (priv->engine);
 
1867
        context->engine = engine;
 
1868
        g_object_ref (context->engine);
1981
1869
 
1982
1870
        for (i = 0; signals[i].name != NULL; i++) {
1983
 
            g_signal_connect (priv->engine,
 
1871
            g_signal_connect (context->engine,
1984
1872
                              signals[i].name,
1985
1873
                              signals[i].callback,
1986
1874
                              context);
1987
1875
        }
1988
 
        bus_engine_proxy_set_cursor_location (priv->engine, priv->x, priv->y, priv->w, priv->h);
1989
 
        if (priv->enabled) {
1990
 
            bus_engine_proxy_enable (priv->engine);
1991
 
            if (priv->has_focus) {
1992
 
                bus_engine_proxy_focus_in (priv->engine);
 
1876
        bus_engine_proxy_set_cursor_location (context->engine, context->x, context->y, context->w, context->h);
 
1877
        if (context->enabled) {
 
1878
            bus_engine_proxy_enable (context->engine);
 
1879
            if (context->has_focus) {
 
1880
                bus_engine_proxy_focus_in (context->engine);
1993
1881
            }
1994
1882
        }
1995
1883
    }
2003
1891
{
2004
1892
    g_assert (BUS_IS_INPUT_CONTEXT (context));
2005
1893
 
2006
 
    BusInputContextPrivate *priv;
2007
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
2008
 
 
2009
 
    return priv->engine;
 
1894
    return context->engine;
2010
1895
}
2011
1896
 
2012
1897
static gboolean
2013
1898
bus_input_context_filter_keyboard_shortcuts (BusInputContext    *context,
2014
1899
                                             guint               keyval,
 
1900
                                             guint               keycode,
2015
1901
                                             guint               modifiers)
2016
1902
{
2017
1903
    g_assert (BUS_IS_INPUT_CONTEXT (context));
2018
1904
 
2019
 
    BusInputContextPrivate *priv;
2020
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
2021
 
 
2022
1905
    gboolean retval = FALSE;
2023
1906
 
2024
1907
    static GQuark trigger;
2027
1910
 
2028
1911
    GQuark event;
2029
1912
 
 
1913
    if (keycode != 0 && !BUS_DEFAULT_IBUS->use_sys_layout) {
 
1914
        IBusKeymap *keymap = BUS_DEFAULT_KEYMAP;
 
1915
        if (keymap != NULL) {
 
1916
            guint tmp = ibus_keymap_lookup_keysym (keymap,
 
1917
                                                 keycode,
 
1918
                                                 modifiers);
 
1919
            if (tmp != IBUS_VoidSymbol)
 
1920
                keyval = tmp;
 
1921
        }
 
1922
    }
 
1923
 
2030
1924
    if (trigger == 0) {
2031
1925
        trigger = g_quark_from_static_string ("trigger");
2032
1926
        next_factory = g_quark_from_static_string ("next-engine");
2033
1927
        prev_factory = g_quark_from_static_string ("prev-engine");
2034
1928
    }
2035
1929
 
2036
 
    if (priv->filter_release){
 
1930
    if (context->filter_release){
2037
1931
        if(modifiers & IBUS_RELEASE_MASK) {
2038
1932
            /* filter release key event */
2039
1933
            return TRUE;
2040
1934
        }
2041
1935
        else {
2042
1936
            /* stop filter release key event */
2043
 
            priv->filter_release = FALSE;
 
1937
            context->filter_release = FALSE;
2044
1938
        }
2045
1939
    }
2046
1940
 
2047
1941
    event = ibus_hotkey_profile_filter_key_event (BUS_DEFAULT_HOTKEY_PROFILE,
2048
1942
                                                  keyval,
2049
1943
                                                  modifiers,
2050
 
                                                  priv->prev_keyval,
2051
 
                                                  priv->prev_modifiers,
 
1944
                                                  context->prev_keyval,
 
1945
                                                  context->prev_modifiers,
2052
1946
                                                  0);
2053
 
    priv->prev_keyval = keyval;
2054
 
    priv->prev_modifiers = modifiers;
 
1947
    context->prev_keyval = keyval;
 
1948
    context->prev_modifiers = modifiers;
2055
1949
 
2056
1950
    if (event == trigger) {
2057
 
        gboolean enabled = priv->enabled;
 
1951
        gboolean enabled = context->enabled;
2058
1952
 
2059
 
        if (priv->enabled) {
 
1953
        if (context->enabled) {
2060
1954
            bus_input_context_disable (context);
2061
1955
        }
2062
1956
        else {
2063
1957
            bus_input_context_enable (context);
2064
1958
        }
2065
1959
 
2066
 
        retval = (enabled != priv->enabled);
 
1960
        retval = (enabled != context->enabled);
2067
1961
    }
2068
1962
    else if (event == next_factory) {
2069
 
        if (priv->engine == NULL || priv->enabled == FALSE) {
 
1963
        if (context->engine == NULL || context->enabled == FALSE) {
2070
1964
            retval =  FALSE;
2071
1965
        }
2072
1966
        else {
2075
1969
        }
2076
1970
    }
2077
1971
    else if (event == prev_factory) {
2078
 
        if (priv->engine == NULL || priv->enabled == FALSE) {
 
1972
        if (context->engine == NULL || context->enabled == FALSE) {
2079
1973
            retval = FALSE;
2080
1974
        }
2081
1975
        else {
2086
1980
 
2087
1981
    if (retval == TRUE) {
2088
1982
        /* begine filter release key event */
2089
 
        priv->filter_release = TRUE;
 
1983
        context->filter_release = TRUE;
2090
1984
    }
2091
1985
 
2092
1986
    return retval;
2101
1995
{
2102
1996
    g_assert (BUS_IS_INPUT_CONTEXT (context));
2103
1997
    g_assert (signal_name != NULL);
 
1998
    g_assert (context->connection != NULL);
2104
1999
 
2105
2000
    va_list args;
2106
2001
    gboolean retval;
2107
2002
    IBusMessage *message;
2108
 
    BusInputContextPrivate *priv;
2109
 
 
2110
 
    priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
2111
 
 
2112
 
    g_assert (priv->connection != NULL);
2113
2003
 
2114
2004
    message = ibus_message_new_signal (ibus_service_get_path ((IBusService *)context),
2115
2005
                                       IBUS_INTERFACE_INPUT_CONTEXT,
2121
2011
    ibus_message_append_args_valist (message, first_arg_type, args);
2122
2012
    va_end (args);
2123
2013
 
2124
 
    retval = ibus_connection_send ((IBusConnection *)priv->connection, message);
 
2014
    retval = ibus_connection_send ((IBusConnection *)context->connection, message);
2125
2015
    ibus_message_unref (message);
2126
2016
 
2127
2017
    return retval;