1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: main.c |
2 | * File: main.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: main.C,v 1.13 2003/12/17 09:00:35 pcg Exp $ |
4 | * $Id: main.C,v 1.16 2003/12/18 07:31:19 pcg Exp $ |
5 | * |
5 | * |
6 | * All portions of code are copyright by their respective author/s. |
6 | * All portions of code are copyright by their respective author/s. |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
8 | * - original version |
8 | * - original version |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
… | |
… | |
42 | |
42 | |
43 | #ifdef HAVE_TERMIOS_H |
43 | #ifdef HAVE_TERMIOS_H |
44 | # include <termios.h> |
44 | # include <termios.h> |
45 | #endif |
45 | #endif |
46 | |
46 | |
|
|
47 | #include <cstring> |
|
|
48 | |
|
|
49 | static char curlocale[128]; |
|
|
50 | |
|
|
51 | void |
|
|
52 | rxvt_set_locale (const char *locale) |
|
|
53 | { |
|
|
54 | if (locale && STRNCMP (locale, curlocale, 128)) |
|
|
55 | { |
|
|
56 | STRNCPY (curlocale, locale, 128); |
|
|
57 | setlocale (LC_CTYPE, curlocale); |
|
|
58 | } |
|
|
59 | } |
|
|
60 | |
47 | void * |
61 | void * |
48 | rxvt_term::operator new (size_t s) |
62 | rxvt_term::operator new (size_t s) |
49 | { |
63 | { |
50 | void *p = malloc (s); |
64 | void *p = malloc (s); |
51 | |
65 | |
… | |
… | |
76 | } |
90 | } |
77 | |
91 | |
78 | rxvt_term::~rxvt_term () |
92 | rxvt_term::~rxvt_term () |
79 | { |
93 | { |
80 | scr_release (); |
94 | scr_release (); |
|
|
95 | |
|
|
96 | free (locale); |
|
|
97 | free (codeset); |
81 | |
98 | |
82 | #ifndef NO_SETOWNER_TTYDEV |
99 | #ifndef NO_SETOWNER_TTYDEV |
83 | rxvt_privileged_ttydev (this, RESTORE); |
100 | rxvt_privileged_ttydev (this, RESTORE); |
84 | #endif |
101 | #endif |
85 | #ifdef UTMP_SUPPORT |
102 | #ifdef UTMP_SUPPORT |
… | |
… | |
175 | } |
192 | } |
176 | |
193 | |
177 | bool |
194 | bool |
178 | rxvt_term::init (int argc, const char *const *argv) |
195 | rxvt_term::init (int argc, const char *const *argv) |
179 | { |
196 | { |
180 | dR;//TODO (scrollbar, setidle) |
|
|
181 | |
|
|
182 | /* |
197 | /* |
183 | * Save and then give up any super-user privileges |
198 | * Save and then give up any super-user privileges |
184 | * If we need privileges in any area then we must specifically request it. |
199 | * If we need privileges in any area then we must specifically request it. |
185 | * We should only need to be root in these cases: |
200 | * We should only need to be root in these cases: |
186 | * 1. write utmp entries on some systems |
201 | * 1. write utmp entries on some systems |
187 | * 2. chown tty on some systems |
202 | * 2. chown tty on some systems |
188 | */ |
203 | */ |
189 | rxvt_privileges (this, SAVE); |
204 | rxvt_privileges (this, SAVE); |
190 | rxvt_privileges (this, IGNORE); |
205 | rxvt_privileges (this, IGNORE); |
191 | |
206 | |
192 | rxvt_init_secondary (this); |
207 | init_secondary (); |
193 | |
208 | |
194 | const char **cmd_argv = rxvt_init_resources (this, argc, argv); |
209 | const char **cmd_argv = init_resources (argc, argv); |
|
|
210 | |
|
|
211 | set_locale (""); |
195 | |
212 | |
196 | #if (MENUBAR_MAX) |
213 | #if (MENUBAR_MAX) |
197 | rxvt_menubar_read (this, rs[Rs_menu]); |
214 | rxvt_menubar_read (this, rs[Rs_menu]); |
198 | #endif |
215 | #endif |
199 | #ifdef HAVE_SCROLLBARS |
216 | #ifdef HAVE_SCROLLBARS |
200 | if (Options & Opt_scrollBar) |
217 | if (Options & Opt_scrollBar) |
201 | scrollbar_setIdle (); /* set existence for size calculations */ |
218 | scrollBar.setIdle (); /* set existence for size calculations */ |
202 | #endif |
219 | #endif |
203 | |
220 | |
204 | rxvt_Create_Windows (this, argc, argv); |
221 | rxvt_Create_Windows (this, argc, argv); |
205 | |
222 | |
206 | rxvt_init_xlocale (this); |
223 | init_xlocale (); |
207 | |
224 | |
208 | scr_reset (); /* initialize screen */ |
225 | scr_reset (); /* initialize screen */ |
209 | #ifdef RXVT_GRAPHICS |
226 | #ifdef RXVT_GRAPHICS |
210 | rxvt_Gr_reset (this); /* reset graphics */ |
227 | rxvt_Gr_reset (this); /* reset graphics */ |
211 | #endif |
228 | #endif |
… | |
… | |
232 | } |
249 | } |
233 | #endif |
250 | #endif |
234 | XMapWindow (Xdisplay, TermWin.vt); |
251 | XMapWindow (Xdisplay, TermWin.vt); |
235 | XMapWindow (Xdisplay, TermWin.parent[0]); |
252 | XMapWindow (Xdisplay, TermWin.parent[0]); |
236 | |
253 | |
237 | rxvt_init_env (this); |
254 | init_env (); |
238 | rxvt_init_command (this, cmd_argv); |
255 | init_command (cmd_argv); |
239 | |
256 | |
240 | x_ev.start (Xfd, EVENT_READ); |
257 | x_ev.start (Xfd, EVENT_READ); |
241 | pty_ev.start (cmd_fd, EVENT_READ); |
258 | pty_ev.start (cmd_fd, EVENT_READ); |
242 | |
259 | |
243 | check_ev.start (); |
260 | check_ev.start (); |
… | |
… | |
758 | XSetWindowBackground(R->Xdisplay, R->TermWin.vt, |
775 | XSetWindowBackground(R->Xdisplay, R->TermWin.vt, |
759 | R->PixColors[Color_bg]); |
776 | R->PixColors[Color_bg]); |
760 | |
777 | |
761 | /* handle Color_BD, scrollbar background, etc. */ |
778 | /* handle Color_BD, scrollbar background, etc. */ |
762 | |
779 | |
763 | rxvt_set_colorfgbg(aR); |
780 | rxvt_set_colorfgbg (aR); |
764 | rxvt_recolour_cursor(aR); |
781 | R->recolour_cursor (); |
765 | /* the only reasonable way to enforce a clean update */ |
782 | /* the only reasonable way to enforce a clean update */ |
766 | rxvt_scr_poweron(aR); |
783 | rxvt_scr_poweron (aR); |
767 | } |
784 | } |
768 | |
785 | |
769 | #else |
786 | #else |
770 | # define rxvt_set_window_color(aR_ idx,color) ((void)0) |
787 | # define rxvt_set_window_color(aR_ idx,color) ((void)0) |
771 | #endif /* XTERM_COLOR_CHANGE */ |
788 | #endif /* XTERM_COLOR_CHANGE */ |
772 | |
789 | |
773 | /* EXTPROTO */ |
|
|
774 | void |
790 | void |
775 | rxvt_recolour_cursor(pR) |
791 | rxvt_term::recolour_cursor () |
776 | { |
792 | { |
777 | rxvt_color xcol[2]; |
|
|
778 | |
|
|
779 | #if TODO |
793 | #if TODO |
|
|
794 | rxvt_color xcol[2]; |
|
|
795 | |
780 | xcol[0] = R->PixColors[Color_pointer]; |
796 | xcol[0] = PixColors[Color_pointer]; |
781 | xcol[1] = R->PixColors[Color_bg]; |
797 | xcol[1] = PixColors[Color_bg]; |
782 | XQueryColors(R->Xdisplay, XCMAP, xcol, 2); |
798 | XQueryColors (Xdisplay, XCMAP, xcol, 2); |
783 | XRecolorCursor(R->Xdisplay, R->TermWin_cursor, &(xcol[0]), &(xcol[1])); |
799 | XRecolorCursor (Xdisplay, TermWin_cursor, &(xcol[0]), &(xcol[1])); |
784 | #endif |
800 | #endif |
785 | } |
801 | } |
786 | |
802 | |
787 | /*----------------------------------------------------------------------*/ |
803 | /*----------------------------------------------------------------------*/ |
788 | /* |
804 | /* |
… | |
… | |
1052 | preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); |
1068 | preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); |
1053 | XSetICValues(R->Input_Context, XNPreeditAttributes, preedit_attr, NULL); |
1069 | XSetICValues(R->Input_Context, XNPreeditAttributes, preedit_attr, NULL); |
1054 | XFree(preedit_attr); |
1070 | XFree(preedit_attr); |
1055 | } |
1071 | } |
1056 | |
1072 | |
1057 | /* EXTPROTO */ |
|
|
1058 | void |
|
|
1059 | rxvt_setTermFontSet(pR_ int idx) |
|
|
1060 | { |
|
|
1061 | char *string; |
|
|
1062 | long length; |
|
|
1063 | int success = 0; |
|
|
1064 | |
|
|
1065 | if (idx < 0 || idx >= MAX_NFONTS) |
|
|
1066 | return; |
|
|
1067 | } |
|
|
1068 | |
|
|
1069 | /* INTPROTO */ |
1073 | /* INTPROTO */ |
1070 | void |
1074 | void |
1071 | rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect, |
1075 | rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect, |
1072 | XRectangle * needed_rect) |
1076 | XRectangle * needed_rect) |
1073 | { |
1077 | { |
… | |
… | |
1105 | R->Input_Context = NULL; |
1109 | R->Input_Context = NULL; |
1106 | /* To avoid Segmentation Fault in C locale: Solaris only? */ |
1110 | /* To avoid Segmentation Fault in C locale: Solaris only? */ |
1107 | if (STRCMP(R->locale, "C")) |
1111 | if (STRCMP(R->locale, "C")) |
1108 | XRegisterIMInstantiateCallback(R->Xdisplay, NULL, NULL, NULL, |
1112 | XRegisterIMInstantiateCallback(R->Xdisplay, NULL, NULL, NULL, |
1109 | rxvt_IMInstantiateCallback, NULL); |
1113 | rxvt_IMInstantiateCallback, NULL); |
|
|
1114 | } |
|
|
1115 | |
|
|
1116 | /* |
|
|
1117 | * Try to open a XIM with the current modifiers, then see if we can |
|
|
1118 | * open a suitable preedit type |
|
|
1119 | */ |
|
|
1120 | static Bool |
|
|
1121 | rxvt_IM_get_IC (pR) |
|
|
1122 | { |
|
|
1123 | int i, j, found; |
|
|
1124 | XIM xim; |
|
|
1125 | XPoint spot; |
|
|
1126 | XRectangle rect, status_rect, needed_rect; |
|
|
1127 | unsigned long fg, bg; |
|
|
1128 | const char *p; |
|
|
1129 | char **s; |
|
|
1130 | XIMStyles *xim_styles; |
|
|
1131 | XVaNestedList preedit_attr, status_attr; |
|
|
1132 | XIMCallback ximcallback; |
|
|
1133 | |
|
|
1134 | D_MAIN((stderr, "rxvt_IM_get_IC()")); |
|
|
1135 | xim = XOpenIM (R->Xdisplay, NULL, NULL, NULL); |
|
|
1136 | if (xim == NULL) |
|
|
1137 | return False; |
|
|
1138 | |
|
|
1139 | xim_styles = NULL; |
|
|
1140 | if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL) |
|
|
1141 | || !xim_styles || !xim_styles->count_styles) { |
|
|
1142 | XCloseIM(xim); |
|
|
1143 | return False; |
|
|
1144 | } |
|
|
1145 | |
|
|
1146 | p = R->rs[Rs_preeditType] ? R->rs[Rs_preeditType] |
|
|
1147 | : "OverTheSpot,OffTheSpot,Root"; |
|
|
1148 | s = rxvt_splitcommastring(p); |
|
|
1149 | for (i = found = 0; !found && s[i]; i++) { |
|
|
1150 | if (!STRCMP(s[i], "OverTheSpot")) |
|
|
1151 | R->input_style = (XIMPreeditPosition | XIMStatusNothing); |
|
|
1152 | else if (!STRCMP(s[i], "OffTheSpot")) |
|
|
1153 | R->input_style = (XIMPreeditArea | XIMStatusArea); |
|
|
1154 | else if (!STRCMP(s[i], "Root")) |
|
|
1155 | R->input_style = (XIMPreeditNothing | XIMStatusNothing); |
|
|
1156 | |
|
|
1157 | for (j = 0; j < xim_styles->count_styles; j++) |
|
|
1158 | if (R->input_style == xim_styles->supported_styles[j]) { |
|
|
1159 | found = 1; |
|
|
1160 | break; |
|
|
1161 | } |
|
|
1162 | } |
|
|
1163 | for (i = 0; s[i]; i++) |
|
|
1164 | free(s[i]); |
|
|
1165 | free(s); |
|
|
1166 | XFree(xim_styles); |
|
|
1167 | |
|
|
1168 | if (!found) { |
|
|
1169 | XCloseIM(xim); |
|
|
1170 | return False; |
|
|
1171 | } |
|
|
1172 | |
|
|
1173 | ximcallback.callback = rxvt_IMDestroyCallback; |
|
|
1174 | |
|
|
1175 | /* XXX: not sure why we need this (as well as IC one below) */ |
|
|
1176 | XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL); |
|
|
1177 | |
|
|
1178 | preedit_attr = status_attr = NULL; |
|
|
1179 | |
|
|
1180 | if (R->input_style & XIMPreeditPosition) { |
|
|
1181 | rxvt_setSize(aR_ & rect); |
|
|
1182 | rxvt_setPosition(aR_ & spot); |
|
|
1183 | rxvt_setColor(aR_ & fg, &bg); |
|
|
1184 | |
|
|
1185 | preedit_attr = XVaCreateNestedList(0, XNArea, &rect, |
|
|
1186 | XNSpotLocation, &spot, |
|
|
1187 | XNForeground, fg, XNBackground, bg, |
|
|
1188 | //XNFontSet, R->TermWin.fontset, |
|
|
1189 | NULL); |
|
|
1190 | } else if (R->input_style & XIMPreeditArea) { |
|
|
1191 | rxvt_setColor(aR_ & fg, &bg); |
|
|
1192 | |
|
|
1193 | /* |
|
|
1194 | * The necessary width of preedit area is unknown |
|
|
1195 | * until create input context. |
|
|
1196 | */ |
|
|
1197 | needed_rect.width = 0; |
|
|
1198 | |
|
|
1199 | rxvt_setPreeditArea(aR_ & rect, &status_rect, &needed_rect); |
|
|
1200 | |
|
|
1201 | preedit_attr = XVaCreateNestedList(0, XNArea, &rect, |
|
|
1202 | XNForeground, fg, XNBackground, bg, |
|
|
1203 | //XNFontSet, R->TermWin.fontset, |
|
|
1204 | NULL); |
|
|
1205 | status_attr = XVaCreateNestedList(0, XNArea, &status_rect, |
|
|
1206 | XNForeground, fg, XNBackground, bg, |
|
|
1207 | //XNFontSet, R->TermWin.fontset, |
|
|
1208 | NULL); |
|
|
1209 | } |
|
|
1210 | R->Input_Context = XCreateIC(xim, XNInputStyle, R->input_style, |
|
|
1211 | XNClientWindow, R->TermWin.parent[0], |
|
|
1212 | XNFocusWindow, R->TermWin.parent[0], |
|
|
1213 | XNDestroyCallback, &ximcallback, |
|
|
1214 | preedit_attr ? XNPreeditAttributes : NULL, |
|
|
1215 | preedit_attr, |
|
|
1216 | status_attr ? XNStatusAttributes : NULL, |
|
|
1217 | status_attr, NULL); |
|
|
1218 | if (preedit_attr) |
|
|
1219 | XFree(preedit_attr); |
|
|
1220 | if (status_attr) |
|
|
1221 | XFree(status_attr); |
|
|
1222 | if (R->Input_Context == NULL) { |
|
|
1223 | rxvt_print_error("failed to create input context"); |
|
|
1224 | XCloseIM(xim); |
|
|
1225 | return False; |
|
|
1226 | } |
|
|
1227 | if (R->input_style & XIMPreeditArea) |
|
|
1228 | rxvt_IMSetStatusPosition(aR); |
|
|
1229 | D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection")); |
|
|
1230 | return True; |
1110 | } |
1231 | } |
1111 | |
1232 | |
1112 | /* |
1233 | /* |
1113 | * X manual pages and include files don't match on some systems: |
1234 | * X manual pages and include files don't match on some systems: |
1114 | * some think this is an XIDProc and others an XIMProc so we can't |
1235 | * some think this is an XIDProc and others an XIMProc so we can't |
… | |
… | |
1130 | char buf[IMBUFSIZ]; |
1251 | char buf[IMBUFSIZ]; |
1131 | |
1252 | |
1132 | D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); |
1253 | D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); |
1133 | if (R->Input_Context) |
1254 | if (R->Input_Context) |
1134 | return; |
1255 | return; |
|
|
1256 | |
|
|
1257 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
|
|
1258 | if (R->rs[Rs_imLocale]) |
|
|
1259 | setlocale (LC_CTYPE, R->rs[Rs_imLocale]); |
|
|
1260 | #endif |
1135 | |
1261 | |
1136 | p = R->rs[Rs_inputMethod]; |
1262 | p = R->rs[Rs_inputMethod]; |
1137 | if (p && *p) |
1263 | if (p && *p) |
1138 | { |
1264 | { |
1139 | bool found = false; |
1265 | bool found = false; |
… | |
… | |
1156 | for (i = 0; s[i]; i++) |
1282 | for (i = 0; s[i]; i++) |
1157 | free(s[i]); |
1283 | free(s[i]); |
1158 | free(s); |
1284 | free(s); |
1159 | |
1285 | |
1160 | if (found) |
1286 | if (found) |
1161 | return; |
1287 | goto done; |
1162 | } |
1288 | } |
1163 | |
1289 | |
1164 | /* try with XMODIFIERS env. var. */ |
1290 | /* try with XMODIFIERS env. var. */ |
1165 | if ((p = XSetLocaleModifiers ("")) && *p |
1291 | if ((p = XSetLocaleModifiers ("")) && *p |
1166 | && rxvt_IM_get_IC (aR)) |
1292 | && rxvt_IM_get_IC (aR)) |
1167 | return; |
1293 | goto done; |
1168 | |
1294 | |
1169 | /* try with no modifiers base IF the user didn't specify an IM */ |
1295 | /* try with no modifiers base IF the user didn't specify an IM */ |
1170 | if ((p = XSetLocaleModifiers ("@im=none")) && *p |
1296 | if ((p = XSetLocaleModifiers ("@im=none")) && *p |
1171 | && rxvt_IM_get_IC (aR) == True) |
1297 | && rxvt_IM_get_IC (aR) == True) |
1172 | return; |
1298 | goto done; |
1173 | } |
|
|
1174 | |
1299 | |
1175 | /* |
1300 | done: |
1176 | * Try to open a XIM with the current modifiers, then see if we can |
1301 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1177 | * open a suitable preedit type |
1302 | if (R->rs[Rs_imLocale]) |
1178 | */ |
1303 | setlocale (LC_CTYPE, R->locale); |
1179 | /* INTPROTO */ |
1304 | #endif |
1180 | Bool |
|
|
1181 | rxvt_IM_get_IC(pR) |
|
|
1182 | { |
|
|
1183 | int i, j, found; |
|
|
1184 | XIM xim; |
|
|
1185 | XPoint spot; |
|
|
1186 | XRectangle rect, status_rect, needed_rect; |
|
|
1187 | unsigned long fg, bg; |
|
|
1188 | const char *p; |
|
|
1189 | char **s; |
|
|
1190 | XIMStyles *xim_styles; |
|
|
1191 | XVaNestedList preedit_attr, status_attr; |
|
|
1192 | XIMCallback ximcallback; |
|
|
1193 | |
|
|
1194 | D_MAIN((stderr, "rxvt_IM_get_IC()")); |
|
|
1195 | xim = XOpenIM(R->Xdisplay, NULL, NULL, NULL); |
|
|
1196 | if (xim == NULL) |
|
|
1197 | return False; |
|
|
1198 | |
|
|
1199 | xim_styles = NULL; |
|
|
1200 | if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) |
|
|
1201 | || !xim_styles || !xim_styles->count_styles) { |
|
|
1202 | XCloseIM(xim); |
|
|
1203 | return False; |
|
|
1204 | } |
|
|
1205 | |
|
|
1206 | p = R->rs[Rs_preeditType] ? R->rs[Rs_preeditType] |
|
|
1207 | : "OverTheSpot,OffTheSpot,Root"; |
|
|
1208 | s = rxvt_splitcommastring(p); |
|
|
1209 | for (i = found = 0; !found && s[i]; i++) { |
|
|
1210 | if (!STRCMP(s[i], "OverTheSpot")) |
|
|
1211 | R->input_style = (XIMPreeditPosition | XIMStatusNothing); |
|
|
1212 | else if (!STRCMP(s[i], "OffTheSpot")) |
|
|
1213 | R->input_style = (XIMPreeditArea | XIMStatusArea); |
|
|
1214 | else if (!STRCMP(s[i], "Root")) |
|
|
1215 | R->input_style = (XIMPreeditNothing | XIMStatusNothing); |
|
|
1216 | |
|
|
1217 | for (j = 0; j < xim_styles->count_styles; j++) |
|
|
1218 | if (R->input_style == xim_styles->supported_styles[j]) { |
|
|
1219 | found = 1; |
|
|
1220 | break; |
|
|
1221 | } |
|
|
1222 | } |
|
|
1223 | for (i = 0; s[i]; i++) |
|
|
1224 | free(s[i]); |
|
|
1225 | free(s); |
|
|
1226 | XFree(xim_styles); |
|
|
1227 | |
|
|
1228 | if (!found) { |
|
|
1229 | XCloseIM(xim); |
|
|
1230 | return False; |
|
|
1231 | } |
|
|
1232 | |
|
|
1233 | ximcallback.callback = rxvt_IMDestroyCallback; |
|
|
1234 | |
|
|
1235 | /* XXX: not sure why we need this (as well as IC one below) */ |
|
|
1236 | XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL); |
|
|
1237 | |
|
|
1238 | preedit_attr = status_attr = NULL; |
|
|
1239 | |
|
|
1240 | if (R->input_style & XIMPreeditPosition) { |
|
|
1241 | rxvt_setSize(aR_ & rect); |
|
|
1242 | rxvt_setPosition(aR_ & spot); |
|
|
1243 | rxvt_setColor(aR_ & fg, &bg); |
|
|
1244 | |
|
|
1245 | preedit_attr = XVaCreateNestedList(0, XNArea, &rect, |
|
|
1246 | XNSpotLocation, &spot, |
|
|
1247 | XNForeground, fg, XNBackground, bg, |
|
|
1248 | //XNFontSet, R->TermWin.fontset, |
|
|
1249 | NULL); |
|
|
1250 | } else if (R->input_style & XIMPreeditArea) { |
|
|
1251 | rxvt_setColor(aR_ & fg, &bg); |
|
|
1252 | |
|
|
1253 | /* |
|
|
1254 | * The necessary width of preedit area is unknown |
|
|
1255 | * until create input context. |
|
|
1256 | */ |
|
|
1257 | needed_rect.width = 0; |
|
|
1258 | |
|
|
1259 | rxvt_setPreeditArea(aR_ & rect, &status_rect, &needed_rect); |
|
|
1260 | |
|
|
1261 | preedit_attr = XVaCreateNestedList(0, XNArea, &rect, |
|
|
1262 | XNForeground, fg, XNBackground, bg, |
|
|
1263 | //XNFontSet, R->TermWin.fontset, |
|
|
1264 | NULL); |
|
|
1265 | status_attr = XVaCreateNestedList(0, XNArea, &status_rect, |
|
|
1266 | XNForeground, fg, XNBackground, bg, |
|
|
1267 | //XNFontSet, R->TermWin.fontset, |
|
|
1268 | NULL); |
|
|
1269 | } |
|
|
1270 | R->Input_Context = XCreateIC(xim, XNInputStyle, R->input_style, |
|
|
1271 | XNClientWindow, R->TermWin.parent[0], |
|
|
1272 | XNFocusWindow, R->TermWin.parent[0], |
|
|
1273 | XNDestroyCallback, &ximcallback, |
|
|
1274 | preedit_attr ? XNPreeditAttributes : NULL, |
|
|
1275 | preedit_attr, |
|
|
1276 | status_attr ? XNStatusAttributes : NULL, |
|
|
1277 | status_attr, NULL); |
|
|
1278 | if (preedit_attr) |
|
|
1279 | XFree(preedit_attr); |
|
|
1280 | if (status_attr) |
|
|
1281 | XFree(status_attr); |
|
|
1282 | if (R->Input_Context == NULL) { |
|
|
1283 | rxvt_print_error("failed to create input context"); |
|
|
1284 | XCloseIM(xim); |
|
|
1285 | return False; |
|
|
1286 | } |
|
|
1287 | if (R->input_style & XIMPreeditArea) |
|
|
1288 | rxvt_IMSetStatusPosition(aR); |
|
|
1289 | D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection")); |
|
|
1290 | return True; |
|
|
1291 | } |
1305 | } |
1292 | |
1306 | |
1293 | /* EXTPROTO */ |
1307 | /* EXTPROTO */ |
1294 | void |
1308 | void |
1295 | rxvt_IMSetStatusPosition(pR) |
1309 | rxvt_IMSetStatusPosition(pR) |