~ubuntu-branches/ubuntu/wily/scim/wily-proposed

« back to all changes in this revision

Viewing changes to extras/immodules/client-clutter/scim-bridge-client-clutter.c

  • Committer: Package Import Robot
  • Author(s): Rolf Leggewie, Rolf Leggewie, Tz-Huan Huang
  • Date: 2012-06-30 11:21:42 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120630112142-a4cwzsr16dty8dk7
Tags: 1.4.14-1
[ Rolf Leggewie ]
* new upstream release 1.4.14
  - drop 32_scim-1.4.8-fix-dlopen.patch which has landed upstream
* bump compat level to 9
* debian/control: add Toni Mueller as co-maintainer
  Welcome aboard!

[ Tz-Huan Huang ]
* start shipping a couple of newly introduced im-module packages
* debian/rules:
  - simplify dh_auto_install override where upstream changes allow this
  - drop -fpermissive from CXXFLAGS, fixed upstream
* debian/README.*: update the documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * SCIM Bridge
 
3
 *
 
4
 * Copyright (c) 2006 Ryo Dairiki <ryo-dairiki@users.sourceforge.net>
 
5
 * Copyright (C) 2009, Intel Corporation.
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation and
 
10
 * appearing in the file LICENSE.LGPL included in the package of this file.
 
11
 * You can also redistribute it and/or modify it under the terms of
 
12
 * the GNU General Public License as published by the Free Software Foundation and
 
13
 * appearing in the file LICENSE.GPL included in the package of this file.
 
14
 *
 
15
 * This library is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
18
 */
 
19
 
 
20
#include <unistd.h>
 
21
 
 
22
#include <sys/select.h>
 
23
#include <sys/types.h>
 
24
 
 
25
#include <glib.h>
 
26
 
 
27
#include <clutter/clutter.h>
 
28
 
 
29
#include "scim-bridge-client.h"
 
30
#include "scim-bridge-client-clutter.h"
 
31
#include "scim-bridge-client-imcontext-clutter.h"
 
32
#include "scim-bridge-client-protected.h"
 
33
#include "scim-bridge-imcontext.h"
 
34
#include "scim-bridge-output.h"
 
35
 
 
36
/* Private Variables */
 
37
static GIOChannel *messenger_iochannel = NULL;
 
38
static guint messenger_event_source = -1;
 
39
 
 
40
static boolean initialized = FALSE;
 
41
 
 
42
 
 
43
/* Private Functions */
 
44
static gboolean handle_message (GIOChannel *source, GIOCondition condition, gpointer data)
 
45
{
 
46
    const int socket_fd = scim_bridge_client_get_messenger_fd ();
 
47
 
 
48
    fd_set read_set;
 
49
    FD_ZERO (&read_set);
 
50
    FD_SET (socket_fd, &read_set);
 
51
 
 
52
    struct timeval timeout;
 
53
    timeout.tv_sec = 0;
 
54
    timeout.tv_usec = 0;
 
55
    if (select (socket_fd + 1, &read_set, NULL, NULL, &timeout) > 0) {
 
56
        if (scim_bridge_client_read_and_dispatch ()) {
 
57
            scim_bridge_perrorln ("An IOException occurred at handle_message ()");
 
58
            return FALSE;
 
59
        }
 
60
    }
 
61
 
 
62
    return TRUE;
 
63
}
 
64
 
 
65
 
 
66
/* Public Functions */
 
67
void scim_bridge_client_clutter_initialize ()
 
68
{
 
69
    scim_bridge_pdebugln (5, "scim_bridge_client_clutter_initialize ()");
 
70
 
 
71
    if (initialized) {
 
72
        return;
 
73
    } else {
 
74
        initialized = TRUE;
 
75
    }
 
76
 
 
77
    if (scim_bridge_client_initialize ()) {
 
78
        scim_bridge_perrorln ("Failed to initialize scim-bridge...");
 
79
    } else {
 
80
        scim_bridge_client_open_messenger ();
 
81
    }
 
82
 
 
83
    scim_bridge_client_imcontext_static_initialize ();
 
84
}
 
85
 
 
86
 
 
87
void scim_bridge_client_clutter_finalize ()
 
88
{
 
89
    scim_bridge_pdebugln (5, "scim_bridge_client_clutter_finalize ()");
 
90
 
 
91
    if (!initialized) {
 
92
        return;
 
93
    } else {
 
94
        initialized = FALSE;
 
95
    }
 
96
 
 
97
    scim_bridge_client_finalize ();
 
98
    scim_bridge_client_imcontext_static_finalize ();
 
99
}
 
100
 
 
101
 
 
102
void scim_bridge_client_messenger_opened ()
 
103
{
 
104
    if (messenger_iochannel == NULL) {
 
105
        messenger_iochannel = g_io_channel_unix_new (scim_bridge_client_get_messenger_fd ());
 
106
        messenger_event_source = g_io_add_watch (messenger_iochannel, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, &handle_message, NULL);
 
107
    }
 
108
 
 
109
    scim_bridge_client_imcontext_connection_opened ();
 
110
}
 
111
 
 
112
 
 
113
void scim_bridge_client_messenger_closed ()
 
114
{
 
115
    if (messenger_iochannel != NULL) {
 
116
        g_io_channel_unref (messenger_iochannel);
 
117
        messenger_iochannel = NULL;
 
118
        g_source_remove (messenger_event_source);
 
119
        messenger_event_source = -1;
 
120
    }
 
121
 
 
122
    scim_bridge_client_imcontext_connection_closed ();
 
123
}
 
124