--- rxvt-unicode/src/main.C 2004/09/07 06:19:45 1.114 +++ rxvt-unicode/src/main.C 2005/01/17 00:59:23 1.128 @@ -34,7 +34,8 @@ #include "rxvt.h" /* NECESSARY */ #include "main.intpro" /* PROTOS for internal routines */ -#include +#include +#include #ifdef TTY_GID_SUPPORT # include @@ -44,7 +45,9 @@ # include #endif -#include +#ifdef KEYSYM_RESOURCE +# include "keyboard.h" +#endif vector rxvt_term::termlist; @@ -170,6 +173,13 @@ cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; termlist.push_back (this); + +#ifdef KEYSYM_RESOURCE + keyboard = new keyboard_manager; + + if (!keyboard) + rxvt_fatal ("out of memory, aborting.\n"); +#endif } rxvt_term::~rxvt_term () @@ -261,12 +271,15 @@ free (env_term); free (env_colorfgbg); free (locale); -#if 0 - free (codeset); -#endif + free (v_buffer); + free (incr_buf); delete envv; delete argv; + +#ifdef KEYSYM_RESOURCE + delete keyboard; +#endif } void @@ -334,6 +347,8 @@ { SET_R (this); + set_locale (""); + if (!init_vars ()) return false; @@ -341,7 +356,9 @@ const char **cmd_argv = init_resources (argc, argv); - set_locale (""); +#ifdef KEYSYM_RESOURCE + keyboard->register_done (); +#endif #if MENUBAR_MAX menubar_read (rs[Rs_menu]); @@ -385,6 +402,8 @@ init_command (cmd_argv); + free (cmd_argv); + pty_ev.start (pty.pty, EVENT_READ); check_ev.start (); @@ -785,6 +804,7 @@ TermWin.fontset[0] = fs; prop = (*fs)[1]->properties (); + prop.height += TermWin.lineSpace; fs->set_prop (prop); TermWin.fwidth = prop.width; @@ -833,44 +853,46 @@ return true; } +void rxvt_term::set_string_property (Atom prop, const char *str, int len) +{ + // TODO: SMART_WINDOW_TITLE + XChangeProperty (display->display, TermWin.parent[0], + prop, XA_STRING, 8, PropModeReplace, + (const unsigned char *)str, len >= 0 ? len : strlen (str)); +} + +void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) +{ + // TODO: SMART_WINDOW_TITLE + wchar_t *ws = rxvt_mbstowcs (str, len); + char *s = rxvt_wcstoutf8 (ws); + + XChangeProperty (display->display, TermWin.parent[0], + prop, xa[XA_UTF8_STRING], 8, PropModeReplace, + (const unsigned char *)s, strlen (s)); + + free (s); + free (ws); +} + /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ /* xterm sequences - title, iconName, color (exptl) */ void rxvt_term::set_title (const char *str) { -#ifdef SMART_WINDOW_TITLE - char *name; - - if (!XFetchName (display->display, TermWin.parent[0], &name)) - name = NULL; - - if (name == NULL || strcmp (name, str)) -#endif - XStoreName (display->display, TermWin.parent[0], str); - -#ifdef SMART_WINDOW_TITLE - if (name) - XFree (name); + set_string_property (XA_WM_NAME, str); +#if ENABLE_FRILLS + set_utf8_property (xa[XA_NET_WM_NAME], str); #endif } void rxvt_term::set_icon_name (const char *str) { -#ifdef SMART_WINDOW_TITLE - char *name; - - if (!XGetIconName (display->display, TermWin.parent[0], &name)) - name = NULL; - - if (name == NULL || strcmp (name, str)) -#endif - XSetIconName (display->display, TermWin.parent[0], str); - -#ifdef SMART_WINDOW_TITLE - if (name) - XFree (name); + set_string_property (XA_WM_ICON_NAME, str); +#if ENABLE_FRILLS + set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); #endif } @@ -999,10 +1021,6 @@ } /*----------------------------------------------------------------------*/ -/* - * Colour determination for low colour displays, routine from - * Hans de Goede - */ int rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) @@ -1301,32 +1319,44 @@ return false; } - p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root,None"; - s = rxvt_splitcommastring (p); + const char *pet[] = { rs[Rs_preeditType], "OverTheSpot,OffTheSpot,Root,None" }; - for (i = found = 0; !found && s[i]; i++) + for (int pi = 0; pi < 2; pi++) { - if (!strcmp (s[i], "OverTheSpot")) - input_style = (XIMPreeditPosition | XIMStatusNothing); - else if (!strcmp (s[i], "OffTheSpot")) - input_style = (XIMPreeditArea | XIMStatusArea); - else if (!strcmp (s[i], "Root")) - input_style = (XIMPreeditNothing | XIMStatusNothing); - else if (!strcmp (s[i], "None")) - input_style = (XIMPreeditNone | XIMStatusNone); - - for (j = 0; j < xim_styles->count_styles; j++) - if (input_style == xim_styles->supported_styles[j]) - { - found = 1; - break; - } + p = pet[pi]; + + if (!p) + continue; + + s = rxvt_splitcommastring (p); + + for (i = found = 0; !found && s[i]; i++) + { + if (!strcmp (s[i], "OverTheSpot")) + input_style = (XIMPreeditPosition | XIMStatusNothing); + else if (!strcmp (s[i], "OffTheSpot")) + input_style = (XIMPreeditArea | XIMStatusArea); + else if (!strcmp (s[i], "Root")) + input_style = (XIMPreeditNothing | XIMStatusNothing); + else if (!strcmp (s[i], "None")) + input_style = (XIMPreeditNone | XIMStatusNone); + + for (j = 0; j < xim_styles->count_styles; j++) + if (input_style == xim_styles->supported_styles[j]) + { + rxvt_freecommastring (s); + + found = 1; + goto foundpet; + } + + } + + rxvt_freecommastring (s); } - for (i = 0; s[i]; i++) - free (s[i]); +foundpet: - free (s); XFree (xim_styles); if (!found) @@ -1461,6 +1491,7 @@ bool found = false; s = rxvt_splitcommastring (p); + for (i = 0; s[i]; i++) { if (*s[i]) @@ -1474,9 +1505,8 @@ } } } - for (i = 0; s[i]; i++) - free (s[i]); - free (s); + + rxvt_freecommastring (s); if (found) goto done;