… | |
… | |
32 | |
32 | |
33 | #include "../config.h" /* NECESSARY */ |
33 | #include "../config.h" /* NECESSARY */ |
34 | #include "rxvt.h" /* NECESSARY */ |
34 | #include "rxvt.h" /* NECESSARY */ |
35 | #include "main.intpro" /* PROTOS for internal routines */ |
35 | #include "main.intpro" /* PROTOS for internal routines */ |
36 | |
36 | |
37 | #include <signal.h> |
37 | #include <csignal> |
38 | |
38 | |
39 | #ifdef TTY_GID_SUPPORT |
39 | #ifdef TTY_GID_SUPPORT |
40 | # include <grp.h> |
40 | # include <grp.h> |
41 | #endif |
41 | #endif |
42 | |
42 | |
… | |
… | |
259 | free (env_windowid); |
259 | free (env_windowid); |
260 | free (env_display); |
260 | free (env_display); |
261 | free (env_term); |
261 | free (env_term); |
262 | free (env_colorfgbg); |
262 | free (env_colorfgbg); |
263 | free (locale); |
263 | free (locale); |
264 | #if 0 |
264 | free (v_buffer); |
265 | free (codeset); |
265 | free (incr_buf); |
266 | #endif |
|
|
267 | |
266 | |
268 | delete envv; |
267 | delete envv; |
269 | delete argv; |
268 | delete argv; |
270 | } |
269 | } |
271 | |
270 | |
… | |
… | |
831 | } |
830 | } |
832 | |
831 | |
833 | return true; |
832 | return true; |
834 | } |
833 | } |
835 | |
834 | |
|
|
835 | void rxvt_term::set_string_property (Atom prop, const char *str, int len) |
|
|
836 | { |
|
|
837 | // TODO: SMART_WINDOW_TITLE |
|
|
838 | XChangeProperty (display->display, TermWin.parent[0], |
|
|
839 | prop, XA_STRING, 8, PropModeReplace, |
|
|
840 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
|
|
841 | } |
|
|
842 | |
|
|
843 | void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
|
|
844 | { |
|
|
845 | // TODO: SMART_WINDOW_TITLE |
|
|
846 | wchar_t *ws = rxvt_mbstowcs (str, len); |
|
|
847 | char *s = rxvt_wcstoutf8 (ws); |
|
|
848 | |
|
|
849 | XChangeProperty (display->display, TermWin.parent[0], |
|
|
850 | prop, xa[XA_UTF8_STRING], 8, PropModeReplace, |
|
|
851 | (const unsigned char *)s, strlen (s)); |
|
|
852 | |
|
|
853 | free (s); |
|
|
854 | free (ws); |
|
|
855 | } |
|
|
856 | |
836 | /*----------------------------------------------------------------------*/ |
857 | /*----------------------------------------------------------------------*/ |
837 | /*----------------------------------------------------------------------*/ |
858 | /*----------------------------------------------------------------------*/ |
838 | /* xterm sequences - title, iconName, color (exptl) */ |
859 | /* xterm sequences - title, iconName, color (exptl) */ |
839 | void |
860 | void |
840 | rxvt_term::set_title (const char *str) |
861 | rxvt_term::set_title (const char *str) |
841 | { |
862 | { |
842 | #ifdef SMART_WINDOW_TITLE |
863 | set_string_property (XA_WM_NAME, str); |
843 | char *name; |
864 | #if ENABLE_FRILLS |
844 | |
865 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
845 | if (!XFetchName (display->display, TermWin.parent[0], &name)) |
|
|
846 | name = NULL; |
|
|
847 | |
|
|
848 | if (name == NULL || strcmp (name, str)) |
|
|
849 | #endif |
|
|
850 | XStoreName (display->display, TermWin.parent[0], str); |
|
|
851 | |
|
|
852 | #ifdef SMART_WINDOW_TITLE |
|
|
853 | if (name) |
|
|
854 | XFree (name); |
|
|
855 | #endif |
866 | #endif |
856 | } |
867 | } |
857 | |
868 | |
858 | void |
869 | void |
859 | rxvt_term::set_icon_name (const char *str) |
870 | rxvt_term::set_icon_name (const char *str) |
860 | { |
871 | { |
861 | #ifdef SMART_WINDOW_TITLE |
872 | set_string_property (XA_WM_ICON_NAME, str); |
862 | char *name; |
873 | #if ENABLE_FRILLS |
863 | |
874 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
864 | if (!XGetIconName (display->display, TermWin.parent[0], &name)) |
|
|
865 | name = NULL; |
|
|
866 | |
|
|
867 | if (name == NULL || strcmp (name, str)) |
|
|
868 | #endif |
|
|
869 | XSetIconName (display->display, TermWin.parent[0], str); |
|
|
870 | |
|
|
871 | #ifdef SMART_WINDOW_TITLE |
|
|
872 | if (name) |
|
|
873 | XFree (name); |
|
|
874 | #endif |
875 | #endif |
875 | } |
876 | } |
876 | |
877 | |
877 | #ifdef XTERM_COLOR_CHANGE |
878 | #ifdef XTERM_COLOR_CHANGE |
878 | void |
879 | void |
… | |
… | |
997 | |
998 | |
998 | sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); |
999 | sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); |
999 | } |
1000 | } |
1000 | |
1001 | |
1001 | /*----------------------------------------------------------------------*/ |
1002 | /*----------------------------------------------------------------------*/ |
1002 | /* |
|
|
1003 | * Colour determination for low colour displays, routine from |
|
|
1004 | * Hans de Goede <hans@highrise.nl> |
|
|
1005 | */ |
|
|
1006 | |
1003 | |
1007 | int |
1004 | int |
1008 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
1005 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
1009 | { |
1006 | { |
1010 | if (!screen_in_out->set (display, colour)) |
1007 | if (!screen_in_out->set (display, colour)) |
… | |
… | |
1299 | { |
1296 | { |
1300 | im_destroy (); |
1297 | im_destroy (); |
1301 | return false; |
1298 | return false; |
1302 | } |
1299 | } |
1303 | |
1300 | |
1304 | p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root,None"; |
1301 | const char *pet[] = { rs[Rs_preeditType], "OverTheSpot,OffTheSpot,Root,None" }; |
|
|
1302 | |
|
|
1303 | for (int pi = 0; pi < 2; pi++) |
|
|
1304 | { |
|
|
1305 | p = pet[pi]; |
|
|
1306 | |
|
|
1307 | if (!p) |
|
|
1308 | continue; |
|
|
1309 | |
1305 | s = rxvt_splitcommastring (p); |
1310 | s = rxvt_splitcommastring (p); |
1306 | |
1311 | |
1307 | for (i = found = 0; !found && s[i]; i++) |
1312 | for (i = found = 0; !found && s[i]; i++) |
1308 | { |
1313 | { |
1309 | if (!strcmp (s[i], "OverTheSpot")) |
1314 | if (!strcmp (s[i], "OverTheSpot")) |
1310 | input_style = (XIMPreeditPosition | XIMStatusNothing); |
1315 | input_style = (XIMPreeditPosition | XIMStatusNothing); |
1311 | else if (!strcmp (s[i], "OffTheSpot")) |
1316 | else if (!strcmp (s[i], "OffTheSpot")) |
1312 | input_style = (XIMPreeditArea | XIMStatusArea); |
1317 | input_style = (XIMPreeditArea | XIMStatusArea); |
1313 | else if (!strcmp (s[i], "Root")) |
1318 | else if (!strcmp (s[i], "Root")) |
1314 | input_style = (XIMPreeditNothing | XIMStatusNothing); |
1319 | input_style = (XIMPreeditNothing | XIMStatusNothing); |
1315 | else if (!strcmp (s[i], "None")) |
1320 | else if (!strcmp (s[i], "None")) |
1316 | input_style = (XIMPreeditNone | XIMStatusNone); |
1321 | input_style = (XIMPreeditNone | XIMStatusNone); |
1317 | |
1322 | |
1318 | for (j = 0; j < xim_styles->count_styles; j++) |
1323 | for (j = 0; j < xim_styles->count_styles; j++) |
1319 | if (input_style == xim_styles->supported_styles[j]) |
1324 | if (input_style == xim_styles->supported_styles[j]) |
1320 | { |
1325 | { |
|
|
1326 | rxvt_freecommastring (s); |
|
|
1327 | |
1321 | found = 1; |
1328 | found = 1; |
1322 | break; |
1329 | goto foundpet; |
|
|
1330 | } |
|
|
1331 | |
1323 | } |
1332 | } |
1324 | } |
|
|
1325 | |
1333 | |
1326 | for (i = 0; s[i]; i++) |
1334 | rxvt_freecommastring (s); |
1327 | free (s[i]); |
1335 | } |
1328 | |
1336 | |
1329 | free (s); |
1337 | foundpet: |
|
|
1338 | |
1330 | XFree (xim_styles); |
1339 | XFree (xim_styles); |
1331 | |
1340 | |
1332 | if (!found) |
1341 | if (!found) |
1333 | { |
1342 | { |
1334 | im_destroy (); |
1343 | im_destroy (); |
… | |
… | |
1459 | if (p && *p) |
1468 | if (p && *p) |
1460 | { |
1469 | { |
1461 | bool found = false; |
1470 | bool found = false; |
1462 | |
1471 | |
1463 | s = rxvt_splitcommastring (p); |
1472 | s = rxvt_splitcommastring (p); |
|
|
1473 | |
1464 | for (i = 0; s[i]; i++) |
1474 | for (i = 0; s[i]; i++) |
1465 | { |
1475 | { |
1466 | if (*s[i]) |
1476 | if (*s[i]) |
1467 | { |
1477 | { |
1468 | strcpy (buf, "@im="); |
1478 | strcpy (buf, "@im="); |
… | |
… | |
1472 | found = true; |
1482 | found = true; |
1473 | break; |
1483 | break; |
1474 | } |
1484 | } |
1475 | } |
1485 | } |
1476 | } |
1486 | } |
1477 | for (i = 0; s[i]; i++) |
1487 | |
1478 | free (s[i]); |
1488 | rxvt_freecommastring (s); |
1479 | free (s); |
|
|
1480 | |
1489 | |
1481 | if (found) |
1490 | if (found) |
1482 | goto done; |
1491 | goto done; |
1483 | } |
1492 | } |
1484 | |
1493 | |