-void XAtom::setPixmapValue(Window win, Atom atom, Pixmap value) const {
- setValue(win, atom, XA_PIXMAP, reinterpret_cast<unsigned char*>(&value),
- 32, 1, false);
-}
-
-
-/*
- * Set a string property value on a window.
- */
-void XAtom::setStringValue(Window win, Atom atom,
- const std::string &value) const {
- setValue(win, atom, XA_STRING,
- const_cast<unsigned char*>
- (reinterpret_cast<const unsigned char*>(value.c_str())),
- 8, value.size(), false);
-}
-
-
-/*
- * Add elements to a 32-bit CARDINAL property value on a window.
- */
-void XAtom::addCardValue(Window win, Atom atom, long value) const {
- setValue(win, atom, XA_CARDINAL, reinterpret_cast<unsigned char*>(&value),
- 32, 1, true);
-}
-
-
-/*
- * Add elements to an Atom property value on a window.
- */
-void XAtom::addAtomValue(Window win, Atom atom, Atom value) const {
- setValue(win, atom, XA_ATOM, reinterpret_cast<unsigned char*>(&value),
- 32, 1, true);
-}
-
-
-/*
- * Add elements to a Window property value on a window.
- */
-void XAtom::addWindowValue(Window win, Atom atom, Window value) const {
- setValue(win, atom, XA_WINDOW, reinterpret_cast<unsigned char*>(&value),
- 32, 1, true);
-}
-
+void XAtom::setValue(Window win, Atoms atom, StringType type,
+ const std::string &value) const {
+ assert(atom >= 0 && atom < NUM_ATOMS);
+ assert(type >= 0 && type < NUM_STRING_TYPE);
+ assert(win != None); assert(_atoms[atom] != None);
+
+ const char *c = value.c_str();
+ XTextProperty textprop;
+ if (Success != XmbTextListToTextProperty(_display, const_cast<char**>(&c), 1,
+ type == ansi ? XStringStyle :
+#ifdef X_HAVE_UTF8_STRING
+ XUTF8StringStyle,
+#else
+ XCompoundTextStyle,
+#endif
+ &textprop)) {
+ return;
+ }
+
+ XSetTextProperty(_display, win, &textprop, _atoms[atom]);