~ubuntu-branches/ubuntu/trusty/fcitx/trusty-proposed

« back to all changes in this revision

Viewing changes to src/frontend/xim/IC.c

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-02-10 17:03:56 UTC
  • mfrom: (1.3.18) (33.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130210170356-2yuv6xy3ed378kn0
Tags: 1:4.2.7-1
* New upstream release.
* New binary packages:
  - fcitx-libs-gclient: D-Bus client library for Glib
  - fcitx-libs-qt: D-Bus client library for Qt
  - fcitx-module-quickphrase-editor: Quick Phrase editor module

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
boolean  XimCheckIC(void* arg, FcitxInputContext* context, void* priv)
55
55
{
 
56
    FCITX_UNUSED(arg);
56
57
    CARD16* picid = (CARD16*) priv;
57
58
    FcitxXimIC* rec = (FcitxXimIC*) context->privateic;
58
59
    if (rec->id == *picid)
102
103
            rec->pre_attr.bg_pixmap = *(Pixmap *) pre_attr->value;
103
104
 
104
105
        else if (Is(XNFontSet, pre_attr)) {
105
 
            int             str_length = strlen((char *) pre_attr->value);
106
 
 
 
106
            int size = strlen((char*)pre_attr->value);
107
107
            if (rec->pre_attr.base_font != NULL) {
108
 
                if (Is(rec->pre_attr.base_font, pre_attr))
 
108
                if (Is(rec->pre_attr.base_font, pre_attr)) {
109
109
                    continue;
110
 
                XFree(rec->pre_attr.base_font);
 
110
                }
 
111
                rec->pre_attr.base_font = realloc(rec->pre_attr.base_font,
 
112
                                                  size);
 
113
            } else {
 
114
                rec->pre_attr.base_font = malloc(size);
111
115
            }
112
 
            rec->pre_attr.base_font = (char *) malloc(str_length + 1);
113
 
            strcpy(rec->pre_attr.base_font, (char *) pre_attr->value);
 
116
            memcpy(rec->pre_attr.base_font, pre_attr->value, size);
114
117
        } else if (Is(XNLineSpace, pre_attr))
115
118
            rec->pre_attr.line_space = *(CARD32 *) pre_attr->value;
116
119
        else if (Is(XNCursor, pre_attr))
137
140
            rec->sts_attr.bg_pixmap = *(Pixmap *) sts_attr->value;
138
141
 
139
142
        else if (Is(XNFontSet, sts_attr)) {
140
 
            int             str_length = strlen((char *) sts_attr->value);
141
 
 
 
143
            int size = strlen((char*)sts_attr->value) + 1;
142
144
            if (rec->sts_attr.base_font != NULL) {
143
145
                if (Is(rec->sts_attr.base_font, sts_attr))
144
146
                    continue;
145
 
                XFree(rec->sts_attr.base_font);
 
147
                rec->sts_attr.base_font = realloc(rec->sts_attr.base_font,
 
148
                                                  size);
 
149
            } else {
 
150
                rec->sts_attr.base_font = malloc(size);
146
151
            }
147
 
            rec->sts_attr.base_font = (char *) malloc(str_length + 1);
148
 
            strcpy(rec->sts_attr.base_font, (char *) sts_attr->value);
149
 
        } else if (Is(XNLineSpace, sts_attr))
 
152
            memcpy(rec->sts_attr.base_font, sts_attr->value, size);
 
153
        } else if (Is(XNLineSpace, sts_attr)) {
150
154
            rec->sts_attr.line_space = *(CARD32 *) sts_attr->value;
151
 
 
152
 
        else if (Is(XNCursor, sts_attr))
153
 
 
 
155
        } else if (Is(XNCursor, sts_attr)) {
154
156
            rec->sts_attr.cursor = *(Cursor *) sts_attr->value;
 
157
        }
155
158
    }
156
159
}
157
160
 
197
200
 **/
198
201
void XimDestroyIC(void* arg, FcitxInputContext* context)
199
202
{
 
203
    FCITX_UNUSED(arg);
200
204
    //free resource
201
205
    FcitxXimIC* privic = (FcitxXimIC*) context->privateic;
202
206
    if (privic->resource_name)
283
287
 
284
288
            pre_attr->value = (void *) malloc(total_len);
285
289
            p = (char *) pre_attr->value;
286
 
            memmove(p, &base_len, sizeof(CARD16));
 
290
            memcpy(p, &base_len, sizeof(CARD16));
287
291
            p += sizeof(CARD16);
288
292
            strncpy(p, rec->pre_attr.base_font, base_len);
289
293
            pre_attr->value_length = total_len;
324
328
 
325
329
            sts_attr->value = (void *) malloc(total_len);
326
330
            p = (char *) sts_attr->value;
327
 
            memmove(p, &base_len, sizeof(CARD16));
 
331
            memcpy(p, &base_len, sizeof(CARD16));
328
332
            p += sizeof(CARD16);
329
333
            strncpy(p, rec->sts_attr.base_font, base_len);
330
334
            sts_attr->value_length = total_len;
349
353
 
350
354
boolean XimCheckICFromSameApplication(void* arg, FcitxInputContext* icToCheck, FcitxInputContext* ic)
351
355
{
 
356
    FCITX_UNUSED(arg);
352
357
    FcitxXimIC* ximictoCheck = GetXimIC(icToCheck);
353
358
    FcitxXimIC* ximic = GetXimIC(ic);
354
359