]> Dogcows Code - chaz/openbox/blobdiff - cwmcc/client_props.c
add getting of some root properties
[chaz/openbox] / cwmcc / client_props.c
index 43641324dd4b0e32757b858d57f1ae7c099093e3..34ae4ecd9107d8d3f419fefe505bff590dcd81dd 100644 (file)
@@ -5,6 +5,9 @@
 #include "render/render.h"
 
 #include <X11/Xutil.h>
+#ifdef HAVE_STRING_H
+#  include <string.h>
+#endif
 
 void cwmcc_client_get_protocols(Window win, Atom **protocols)
 {
@@ -12,20 +15,36 @@ void cwmcc_client_get_protocols(Window win, Atom **protocols)
 
     if (!prop_get_array32(win, CWMCC_ATOM(client, wm_protocols),
                           CWMCC_ATOM(type, atom), protocols, &num)) {
+        g_warning("Failed to read WM_PROTOCOLS from 0x%lx", win);
         *protocols = NULL;
     }
 }
 
-int cwmcc_client_get_wm_state(Window win)
+void cwmcc_client_set_protocols(Window win, Atom *protocols)
 {
-    gulong s;
+    gulong n;
+    Atom *a;
 
+    for (a = protocols, n = 0; *a; ++a, ++n);
+    XChangeProperty(cwmcc_display, win, CWMCC_ATOM(client, wm_state),
+                    CWMCC_ATOM(type, atom), 32, PropModeReplace,
+                    (guchar*)protocols, n);
+}
+
+void cwmcc_client_get_wm_state(Window win, gulong *state)
+{
     if (!prop_get32(win, CWMCC_ATOM(client, wm_state),
-                    CWMCC_ATOM(client, wm_state), &s)) {
+                    CWMCC_ATOM(client, wm_state), state)) {
         g_warning("Failed to read WM_STATE from 0x%lx", win);
-        s = NormalState;
+        *state = NormalState;
     }
-    return s;
+}
+
+void cwmcc_client_set_wm_state(Window win, gulong state)
+{
+    XChangeProperty(cwmcc_display, win, CWMCC_ATOM(client, wm_state),
+                    CWMCC_ATOM(client, wm_state), 32, PropModeReplace,
+                    (guchar*)&state, 1);
 }
 
 void cwmcc_client_get_name(Window win, char **name)
@@ -37,6 +56,13 @@ void cwmcc_client_get_name(Window win, char **name)
         }
 }
 
+void cwmcc_client_set_name(Window win, char *name)
+{
+    XChangeProperty(cwmcc_display, win, CWMCC_ATOM(client, net_wm_name),
+                    CWMCC_ATOM(type, utf8), 32, PropModeReplace,
+                    (guchar*)name, strlen(name));
+}
+
 void cwmcc_client_get_icon_name(Window win, char **name)
 {
     if (!prop_get_string_utf8(win, CWMCC_ATOM(client, net_wm_icon_name), name))
@@ -47,6 +73,13 @@ void cwmcc_client_get_icon_name(Window win, char **name)
         }
 }
 
+void cwmcc_client_set_icon_name(Window win, char *name)
+{
+    XChangeProperty(cwmcc_display, win, CWMCC_ATOM(client, net_wm_icon_name),
+                    CWMCC_ATOM(type, utf8), 32, PropModeReplace,
+                    (guchar*)name, strlen(name));
+}
+
 void cwmcc_client_get_class(Window win, char **class, char **name)
 {
     char **s;
@@ -109,6 +142,13 @@ void cwmcc_client_get_desktop(Window win, gulong *desk)
     }
 }
 
+void cwmcc_client_set_desktop(Window win, gulong desk)
+{
+    XChangeProperty(cwmcc_display, win, CWMCC_ATOM(client, net_wm_desktop),
+                    CWMCC_ATOM(type, cardinal), 32, PropModeReplace,
+                    (guchar*)&desk, 1);
+}
+
 void cwmcc_client_get_type(Window win, gulong **types)
 {
     gulong num;
@@ -122,6 +162,17 @@ void cwmcc_client_get_type(Window win, gulong **types)
     }
 }
 
+void cwmcc_client_set_type(Window win, gulong *types)
+{
+    gulong n;
+    gulong *t;
+
+    for (t = types, n = 0; *t; ++t, ++n);
+    XChangeProperty(cwmcc_display, win, CWMCC_ATOM(client, wm_state),
+                    CWMCC_ATOM(type, atom), 32, PropModeReplace,
+                    (guchar*)types, n);
+}
+
 void cwmcc_client_get_state(Window win, gulong **states)
 {
     gulong num;
@@ -134,6 +185,17 @@ void cwmcc_client_get_state(Window win, gulong **states)
     }
 }
 
+void cwmcc_client_set_state(Window win, gulong *states)
+{
+    gulong n;
+    gulong *s;
+
+    for (s = states, n = 0; *s; ++s, ++n);
+    XChangeProperty(cwmcc_display, win, CWMCC_ATOM(client, wm_state),
+                    CWMCC_ATOM(type, atom), 32, PropModeReplace,
+                    (guchar*)states, n);
+}
+
 void cwmcc_client_get_strut(Window win, int *l, int *t, int *r, int *b)
 {
     gulong *data = NULL, num;
@@ -151,7 +213,7 @@ void cwmcc_client_get_strut(Window win, int *l, int *t, int *r, int *b)
         *t = data[2];
         *b = data[3];
     }
-    g_free(l);
+    g_free(data);
 }
 
 static void convert_pixmap_to_icon(Pixmap pix, Pixmap mask,
This page took 0.024741 seconds and 4 git commands to generate.