};
/* function prototypes */
-xcb_char2b_t *char2b(const char *);
int conf_load(char *, int);
void constrain_window(struct ws_win *, struct swm_region *, int);
void do_sync(void);
xcb_atom_t get_atom_from_string(const char *);
xcb_screen_t *get_screen(int);
char *get_win_name(xcb_window_t);
-uint16_t getstate(xcb_window_t);
+uint32_t getstate(xcb_window_t);
void grabbuttons(struct ws_win *, int);
void map_window_raised(xcb_window_t);
void new_region(struct swm_screen *, int, int, int, int);
char *get_atom_name(xcb_atom_t);
#endif
-/* function definitions */
-xcb_char2b_t *
-char2b(const char *str)
-{
- xcb_char2b_t *s;
- size_t i, len;
-
- len = strlen(str);
- s = malloc(len * sizeof(xcb_char2b_t));
- if (!s)
- return (NULL);
-
- for (i = 0; i < len; i++) {
- s[i].byte1 = '\0';
- s[i].byte2 = str[i];
- }
-
- return (s);
-}
-
int
parse_rgb(const char *rgb, uint16_t *rr, uint16_t *gg, uint16_t *bb)
{
pc = xcb_get_property(conn, 0, screens[i].root, sup_check,
XCB_ATOM_WINDOW, 0, 1);
pr = xcb_get_property_reply(conn, pc, NULL);
- if (pr) {
+ if (pr && pr->format == sup_check) {
id = *((xcb_window_t *)xcb_get_property_value(pr));
xcb_destroy_window(conn, id);
dumpwins(struct swm_region *r, union arg *args)
{
struct ws_win *win;
- uint16_t state;
+ uint32_t state;
xcb_get_window_attributes_cookie_t c;
xcb_get_window_attributes_reply_t *wa;
a_state, 32, 2, data);
}
-uint16_t
+uint32_t
getstate(xcb_window_t w)
{
- uint16_t result = 0;
- uint16_t *pv;
+ uint32_t result = 0;
xcb_get_property_cookie_t c;
xcb_get_property_reply_t *r;
- c = xcb_get_property(conn, 0, w, a_state, XCB_ATOM_ATOM, 0L, 2L);
+ c = xcb_get_property(conn, 0, w, a_state, a_state, 0L, 2L);
r = xcb_get_property_reply(conn, c, NULL);
if (r) {
- pv = (uint16_t *)xcb_get_property_value(r);
- result = *pv;
+ if (r->type == a_state && r->format == 32 && r->length == 2)
+ result = *((uint32_t *)xcb_get_property_value(r));
free(r);
}
goto tryharder;
}
- ret = *((pid_t *)xcb_get_property_value(pr));
+ if (pr->type == apid && pr->format == 32)
+ ret = *((pid_t *)xcb_get_property_value(pr));
free(pr);
return (ret);
pr = xcb_get_property_reply(conn, pc, NULL);
if (!pr)
return (0);
- if (pr->type != XCB_ATOM_STRING) {
+ if (pr->type != apid) {
free(pr);
return (0);
}
xcb_get_property(conn, 0, id, a_swm_ws,
XCB_ATOM_STRING, 0, SWM_PROPLEN),
NULL);
- if (gpr) {
+ if (gpr && gpr->type) {
proplen = xcb_get_property_value_length(gpr);
if (proplen > 0) {
prop = malloc(proplen + 1);
DNPRINTF(SWM_D_PROP, "get_ws_idx: window: #%s: %s",
errstr, prop);
}
+ free(prop);
}
return ws_idx;
char *
get_atom_name(xcb_atom_t atom)
{
- char *name;
+ char *name = NULL;
size_t len;
xcb_get_atom_name_reply_t *r;
if (name) {
memcpy(name, xcb_get_atom_name_name(r), len);
name[len] = '\0';
-
- return name;
}
}
free(r);
}
- return NULL;
+ return (name);
}
#endif