--- rxvt-unicode/src/main.C 2006/02/11 02:28:19 1.219 +++ rxvt-unicode/src/main.C 2007/08/17 22:02:14 1.245 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: main.C *----------------------------------------------------------------------* * @@ -58,10 +58,15 @@ bool rxvt_set_locale (const char *locale) NOTHROW { - if (!locale || !strncmp (locale, curlocale, 128)) + int size = strlen (locale) + 1; + + if (size > sizeof (curlocale)) + rxvt_fatal ("locale string too long, aborting.\n"); + + if (!locale || !memcmp (locale, curlocale, size)) return false; - strncpy (curlocale, locale, 128); + memcpy (curlocale, locale, size); setlocale (LC_CTYPE, curlocale); return true; } @@ -145,9 +150,12 @@ rxvt_term::rxvt_term () : -#if TRANSPARENT +#if ENABLE_TRANSPARENCY || ENABLE_PERL rootwin_ev (this, &rxvt_term::rootwin_cb), #endif +#if HAVE_BG_PIXMAP + update_background_ev(this, &rxvt_term::update_background_cb), +#endif #ifdef HAVE_SCROLLBARS scrollbar_ev (this, &rxvt_term::x_cb), #endif @@ -200,6 +208,7 @@ if (cmd_pid) kill (-cmd_pid, SIGHUP); + pty_ev.stop (); delete pty; pty = 0; } @@ -266,9 +275,9 @@ clear (); } - delete pix_colors_focused; + delete [] pix_colors_focused; #if OFF_FOCUS_FADING - delete pix_colors_unfocused; + delete [] pix_colors_unfocused; #endif displays.put (display); @@ -303,7 +312,7 @@ cmd_pid = 0; - if (!OPTION (Opt_hold)) + if (!option (Opt_hold)) destroy (); } @@ -327,7 +336,7 @@ #if HAVE_SCROLLBARS scrollbar_ev.stop (display); #endif -#if TRANSPARENT +#if ENABLE_TRANSPARENCY || ENABLE_PERL rootwin_ev.stop (display); #endif incr_ev.stop (); @@ -477,7 +486,7 @@ #endif #ifdef HAVE_SCROLLBARS - if (OPTION (Opt_scrollBar)) + if (option (Opt_scrollBar)) scrollBar.setIdle (); /* set existence for size calculations */ #endif @@ -494,16 +503,59 @@ #endif #ifdef HAVE_SCROLLBARS - if (OPTION (Opt_scrollBar)) + if (option (Opt_scrollBar)) resize_scrollbar (); /* create and map scrollbar */ #endif -#ifdef TRANSPARENT - if (OPTION (Opt_transparent)) - { - XSelectInput (dpy, display->root, PropertyChangeMask); - check_our_parents (); - rootwin_ev.start (display, display->root); - } +#ifdef HAVE_BG_PIXMAP + { + bgPixmap.set_target (this); + +#ifdef ENABLE_TRANSPARENCY + if (option (Opt_transparent)) + { + bgPixmap.set_transparent (); +#ifdef HAVE_AFTERIMAGE + if (rs [Rs_blurradius]) + bgPixmap.set_blur_radius (rs [Rs_blurradius]); +#endif + if (ISSET_PIXCOLOR (Color_tint)) + bgPixmap.set_tint (pix_colors_focused [Color_tint]); + if (rs [Rs_shade]) + bgPixmap.set_shade (rs [Rs_shade]); + + bgPixmap.set_root_pixmap (); + XSelectInput (dpy, display->root, PropertyChangeMask); + rootwin_ev.start (display, display->root); + } +#endif + +#ifdef XPM_BACKGROUND + if (rs[Rs_backgroundPixmap] != NULL) + { + const char *p = rs[Rs_backgroundPixmap]; + + if ((p = strchr (p, ';')) != NULL) + { + p++; + bgPixmap.set_geometry (p); + } + else + bgPixmap.set_defaultGeometry (); + + bgPixmap.set_file (rs[Rs_backgroundPixmap]); + } + /* do not want to render Pixmap yet if we are size/position dependant - + * wait for ConfigureNotify at least + * TODO: this does not work for some reason when transparency is disabled !!!! + */ + if (!bgPixmap.window_size_sensitive ()) + update_background (); +#endif + } +#endif + +#if ENABLE_PERL + rootwin_ev.start (display, display->root); #endif set_colorfgbg (); @@ -620,7 +672,7 @@ /*----------------------------------------------------------------------*/ /* - * window size/position calculcations for XSizeHint and other storage. + * window size/position calculations for XSizeHint and other storage. * if width/height are non-zero then override calculated width/height */ void @@ -702,7 +754,7 @@ sb_w = scrollbar_TotalWidth (); szHint.base_width += sb_w; - if (!OPTION (Opt_scrollBar_right)) + if (!option (Opt_scrollBar_right)) window_vt_x += sb_w; } @@ -733,7 +785,7 @@ szHint.height = szHint.base_height + height; } - if (scrollBar.state && OPTION (Opt_scrollBar_right)) + if (scrollBar.state && option (Opt_scrollBar_right)) window_sb_x = szHint.width - sb_w; if (recalc_x) @@ -805,7 +857,8 @@ prop = (*fs)[1]->properties (); prop.height += lineSpace; - fs->set_prop (prop); + + fs->set_prop (prop, false); fwidth = prop.width; fheight = prop.height; @@ -824,17 +877,20 @@ rxvt_fontprop prop2 = prop; if (res) - prop2.weight = prop2.slant = rxvt_fontprop::unset; + { + fs->populate (res); + fs->set_prop (prop2, false); + } else { - res = fontset[0]->fontdesc; + fs->populate (fontset[0]->fontdesc); if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic; + + fs->set_prop (prop2, true); } - fs->populate (res); - fs->set_prop (prop2); } #else fontset[style] = fontset[0]; @@ -937,18 +993,9 @@ /* XSetWindowAttributes attr; */ /* Cursor cursor; */ done: - -#if OFF_FOCUS_FADING - if (rs[Rs_fade]) - { - rgba c; - pix_colors [Color_fade].get (c); - pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); - } -#endif - /*TODO: handle Color_BD, scrollbar background, etc. */ + update_fade_color (idx); recolour_cursor (); scr_recolour (); } @@ -1103,10 +1150,13 @@ window_vt_x, window_vt_y, width, height); - scr_clear (); #ifdef XPM_BACKGROUND - resize_pixmap (); + /* TODO: replace with update_pixmap() that should unify transparency and bg image handling ! */ + if (bgPixmap.window_size_sensitive ()) + update_background (); #endif + + scr_clear (); } if (fix_screen || old_height == 0) @@ -1115,13 +1165,14 @@ // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version //scr_touch (false); -#ifdef XPM_BACKGROUND - if (pixmap) - scr_touch (false); +#ifdef HAVE_BG_PIXMAP +// TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? +// if (bgPixmap.pixmap) +// scr_touch (false); #endif #ifdef USE_XIM - IMSetStatusPosition (); + IMSetPosition (); #endif } @@ -1528,8 +1579,8 @@ status_attr, NULL); if (preedit_attr) XFree (preedit_attr); - if (status_attr) XFree (status_attr); - if (fs) XFreeFontSet (dpy, fs); + if (status_attr) XFree (status_attr); + if (fs) XFreeFontSet (dpy, fs); if (Input_Context == NULL) { @@ -1544,8 +1595,7 @@ vt_select_input (); #endif - if (input_style & XIMPreeditArea) - IMSetStatusPosition (); + IMSetPosition (); return true; } @@ -1613,34 +1663,47 @@ } void -rxvt_term::IMSetStatusPosition () +rxvt_term::IMSetPosition () { XRectangle preedit_rect, status_rect, *needed_rect; XVaNestedList preedit_attr, status_attr; if (!Input_Context || !focus - || !(input_style & XIMPreeditArea) + || !(input_style & (XIMPreeditArea | XIMPreeditPosition)) || !IMisRunning ()) return; - /* Getting the necessary width of preedit area */ - status_attr = XVaCreateNestedList (0, XNAreaNeeded, &needed_rect, NULL); - XGetICValues (Input_Context, XNStatusAttributes, status_attr, NULL); - XFree (status_attr); - - im_set_preedit_area (preedit_rect, status_rect, *needed_rect); - XFree (needed_rect); - - preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL); - status_attr = XVaCreateNestedList (0, XNArea, &status_rect, NULL); - - XSetICValues (Input_Context, - XNPreeditAttributes, preedit_attr, - XNStatusAttributes, status_attr, NULL); + if (input_style & XIMPreeditPosition) + { + im_set_size (preedit_rect); + preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL); + + XSetICValues (Input_Context, + XNPreeditAttributes, preedit_attr, NULL); + } + else + { + /* Getting the necessary width of preedit area */ + status_attr = XVaCreateNestedList (0, XNAreaNeeded, &needed_rect, NULL); + XGetICValues (Input_Context, XNStatusAttributes, status_attr, NULL); + XFree (status_attr); + + im_set_preedit_area (preedit_rect, status_rect, *needed_rect); + XFree (needed_rect); - XFree (preedit_attr); - XFree (status_attr); + preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL); + status_attr = XVaCreateNestedList (0, XNArea, &status_rect, NULL); + + XSetICValues (Input_Context, + XNPreeditAttributes, preedit_attr, + XNStatusAttributes, status_attr, + NULL); + + XFree (status_attr); + } + + XFree (preedit_attr); } #endif /* USE_XIM */