- T((T_CALLED("wbkgdset(%p,%s)"), win, _tracechtype(ch)));
-
- if (win) {
- chtype off = AttrOf(win->_bkgd);
- chtype on = AttrOf(ch);
-
- toggle_attr_off(win->_attrs,off);
- toggle_attr_on (win->_attrs,on);
-
- if (TextOf(ch)==0)
- ch |= BLANK;
- win->_bkgd = ch;
- }
- returnVoid;
+ T((T_CALLED("wbkgdset(%p,%s)"), win, _tracech_t(ch)));
+
+ if (win) {
+ attr_t off = AttrOf(win->_nc_bkgd);
+ attr_t on = AttrOf(CHDEREF(ch));
+
+ toggle_attr_off(win->_attrs, off);
+ toggle_attr_on(win->_attrs, on);
+
+ if (CharOf(CHDEREF(ch)) == L('\0'))
+ SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch)));
+ else
+ win->_nc_bkgd = CHDEREF(ch);
+#if USE_WIDEC_SUPPORT
+ /*
+ * If we're compiled for wide-character support, _bkgrnd is the
+ * preferred location for the background information since it stores
+ * more than _bkgd. Update _bkgd each time we modify _bkgrnd, so the
+ * macro getbkgd() will work.
+ */
+ {
+ cchar_t wch;
+ int tmp;
+
+ wgetbkgrnd(win, &wch);
+ tmp = wctob(CharOf(wch));
+
+ win->_bkgd = ((tmp == EOF) ? ' ' : (chtype) tmp) | AttrOf(wch);
+ }
+#endif
+ }
+ returnVoid;
+}
+
+NCURSES_EXPORT(void)
+wbkgdset(WINDOW *win, chtype ch)
+{
+ NCURSES_CH_T wch;
+ SetChar2(wch, ch);
+ wbkgrndset(win, CHREF(wch));