#include "cwmcc_internal.h"
+#include "atom.h"
#include <X11/Xutil.h>
#include <glib.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
/* this just isn't used...
static gboolean get(Window win, Atom prop, Atom type, int size,
&ret_items, &bytes_left, &xdata);
if (res == Success) {
if (ret_size == size && ret_items > 0) {
- *data = g_memdup(xdata, ret_items * (size / 8));
+ *data = g_malloc(ret_items * (size / 8) + sizeof(guchar*));
+ g_memmove(*data, xdata, ret_items * (size / 8));
+ data[ret_items * (size / 8)] = NULL;
*num = ret_items;
ret = TRUE;
}
return FALSE;
}
-gboolean prop_get_string_utf(Window win, Atom prop, Atom type, char **ret)
+gboolean prop_get_string_utf8(Window win, Atom prop, char **ret)
{
char *raw;
gulong num;
- if (get_all(win, prop, type, 8, (guchar**)&raw, &num)) {
+ if (get_all(win, prop, CWMCC_ATOM(type, utf8), 8, (guchar**)&raw, &num)) {
*ret = g_strdup(raw); /* grab the first string from the list */
g_free(raw);
return TRUE;
return FALSE;
}
-gboolean prop_get_strings_utf(Window win, Atom prop, Atom type, char ***ret)
+gboolean prop_get_strings_utf8(Window win, Atom prop, char ***ret)
{
char *raw, *p;
gulong num, i;
- if (get_all(win, prop, type, 8, (guchar**)&raw, &num)) {
+ if (get_all(win, prop, CWMCC_ATOM(type, utf8), 8, (guchar**)&raw, &num)) {
*ret = g_new(char*, num + 1);
(*ret)[num] = NULL; /* null terminated list */
return FALSE;
}
-gboolean prop_get_strings_locale(Window win, Atom prop, Atom type,char ***ret){
+gboolean prop_get_strings_locale(Window win, Atom prop, char ***ret)
+{
char *raw, *p;
gulong num, i;
- if (get_all(win, prop, type, 8, (guchar**)&raw, &num)) {
+ if (get_all(win, prop, CWMCC_ATOM(type, string), 8, (guchar**)&raw, &num)){
*ret = g_new(char*, num + 1);
(*ret)[num] = NULL; /* null terminated list */
return FALSE;
}
-void prop_set_strings_utf(Window win, Atom prop, Atom type, char **strs)
+void prop_set_strings_utf8(Window win, Atom prop, char **strs)
{
GString *str;
guint i;
str = g_string_append(str, strs[i]);
str = g_string_append_c(str, '\0');
}
- XChangeProperty(cwmcc_display, win, prop, type, 8,
+ XChangeProperty(cwmcc_display, win, prop, CWMCC_ATOM(type, utf8), 8,
PropModeReplace, (guchar*)str->str, str->len);
}