1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */
2 
3 #include "../ui_xic.h"
4 
5 #include <string.h>
6 #include <pobl/bl_debug.h>
7 #include <pobl/bl_mem.h> /* malloc */
8 
9 /* --- global functions --- */
10 
ui_xic_activate(ui_window_t * win,char * xim_name,char * xim_locale)11 int ui_xic_activate(ui_window_t *win, char *xim_name, char *xim_locale) {
12   if (win->xic) {
13     /* already activated */
14 
15     return 0;
16   }
17 
18   if ((win->xic = malloc(sizeof(ui_xic_t))) == NULL) {
19     return 0;
20   }
21 
22   if ((win->xic->parser = vt_char_encoding_parser_new(VT_UTF8)) == NULL) {
23     free(win->xic);
24     win->xic = NULL;
25 
26     return 0;
27   }
28 
29   ui_xic_font_set_changed(win);
30 
31   return 1;
32 }
33 
ui_xic_deactivate(ui_window_t * win)34 int ui_xic_deactivate(ui_window_t *win) {
35   if (win->xic == NULL) {
36     /* already deactivated */
37 
38     return 0;
39   }
40 
41   (*win->xic->parser->destroy)(win->xic->parser);
42   free(win->xic);
43   win->xic = NULL;
44 
45   return 1;
46 }
47 
ui_xic_get_xim_name(ui_window_t * win)48 char *ui_xic_get_xim_name(ui_window_t *win) { return ""; }
49 
ui_xic_get_default_xim_name(void)50 char *ui_xic_get_default_xim_name(void) { return ""; }
51 
ui_xic_fg_color_changed(ui_window_t * win)52 int ui_xic_fg_color_changed(ui_window_t *win) { return 0; }
53 
ui_xic_bg_color_changed(ui_window_t * win)54 int ui_xic_bg_color_changed(ui_window_t *win) { return 0; }
55 
ui_xic_font_set_changed(ui_window_t * win)56 int ui_xic_font_set_changed(ui_window_t *win) { return 0; }
57 
ui_xic_resized(ui_window_t * win)58 int ui_xic_resized(ui_window_t *win) { return 0; }
59 
ui_xic_set_spot(ui_window_t * win)60 int ui_xic_set_spot(ui_window_t *win) { return 0; }
61 
ui_xic_get_str(ui_window_t * win,u_char * seq,size_t seq_len,ef_parser_t ** parser,KeySym * keysym,XKeyEvent * event)62 size_t ui_xic_get_str(ui_window_t *win, u_char *seq, size_t seq_len, ef_parser_t **parser,
63                       KeySym *keysym, XKeyEvent *event) {
64   *keysym = event->keysym;
65 
66   if (event->utf8 == NULL) {
67     *parser = NULL;
68 
69     return 0;
70   } else {
71     size_t len = strlen(event->utf8);
72 
73     if (len == 0 && (event->state & ControlMask)) {
74       *seq = '\0';
75       len = 1;
76       *parser = NULL;
77     } else if (len <= seq_len) {
78       memcpy(seq, event->utf8, seq_len);
79       *parser = win->xic->parser;
80     }
81 
82     return len;
83   }
84 }
85 
ui_xic_get_utf8_str(ui_window_t * win,u_char * seq,size_t seq_len,ef_parser_t ** parser,KeySym * keysym,XKeyEvent * event)86 size_t ui_xic_get_utf8_str(ui_window_t *win, u_char *seq, size_t seq_len, ef_parser_t **parser,
87                            KeySym *keysym, XKeyEvent *event) {
88   return 0;
89 }
90 
ui_xic_filter_event(ui_window_t * win,XEvent * event)91 int ui_xic_filter_event(ui_window_t *win, /* Should be root window. */
92                         XEvent *event) {
93   return 0;
94 }
95 
ui_xic_set_focus(ui_window_t * win)96 int ui_xic_set_focus(ui_window_t *win) { return 1; }
97 
ui_xic_unset_focus(ui_window_t * win)98 int ui_xic_unset_focus(ui_window_t *win) { return 1; }
99 
ui_xic_is_active(ui_window_t * win)100 int ui_xic_is_active(ui_window_t *win) { return 0; }
101 
ui_xic_switch_mode(ui_window_t * win)102 int ui_xic_switch_mode(ui_window_t *win) { return 0; }
103 
104 #if 0
105 
106 /*
107  * ui_xim.c <-> ui_xic.c communication functions
108  * Not necessary in fb.
109  */
110 
111 int ui_xim_activated(ui_window_t *win) { return 1; }
112 
113 int ui_xim_destroyed(ui_window_t *win) { return 1; }
114 
115 #endif
116