3 #include <xcb/xcb_icccm.h>
4 #include <xcb/xcb_ewmh.h>
10 bool is_match(rule_t *r, xcb_window_t win)
12 xcb_icccm_get_wm_class_reply_t reply;
13 if (xcb_icccm_get_wm_class_reply(dpy, xcb_icccm_get_wm_class(dpy, win), &reply, NULL) == 1
14 && (strcmp(reply.class_name, r->cause.name) == 0
15 || strcmp(reply.instance_name, r->cause.name) == 0)) {
16 xcb_icccm_get_wm_class_reply_wipe(&reply);
22 void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *fullscreen, bool *takes_focus, bool *manage)
24 xcb_ewmh_get_atoms_reply_t win_type;
26 if (xcb_ewmh_get_wm_window_type_reply(ewmh, xcb_ewmh_get_wm_window_type(ewmh, win), &win_type, NULL) == 1) {
27 for (unsigned int i = 0; i < win_type.atoms_len; i++) {
28 xcb_atom_t a = win_type.atoms[i];
29 if (a == ewmh->_NET_WM_WINDOW_TYPE_TOOLBAR
30 || a == ewmh->_NET_WM_WINDOW_TYPE_UTILITY) {
32 } else if (a == ewmh->_NET_WM_WINDOW_TYPE_DIALOG) {
34 } else if (a == ewmh->_NET_WM_WINDOW_TYPE_DOCK || a == ewmh->_NET_WM_WINDOW_TYPE_NOTIFICATION) {
38 xcb_ewmh_get_atoms_reply_wipe(&win_type);
41 xcb_ewmh_get_atoms_reply_t win_state;
43 if (xcb_ewmh_get_wm_state_reply(ewmh, xcb_ewmh_get_wm_state(ewmh, win), &win_state, NULL) == 1) {
44 for (unsigned int i = 0; i < win_state.atoms_len; i++) {
45 xcb_atom_t a = win_state.atoms[i];
46 if (a == ewmh->_NET_WM_STATE_FULLSCREEN) {
50 xcb_ewmh_get_atoms_reply_wipe(&win_state);
53 xcb_window_t transient_for = XCB_NONE;
54 xcb_icccm_get_wm_transient_for_reply(dpy, xcb_icccm_get_wm_transient_for(dpy, win), &transient_for, NULL);
55 *transient = (transient_for == XCB_NONE ? false : true);
59 rule_t *rule = rule_head;
61 while (rule != NULL) {
62 if (is_match(rule, win)) {
63 if (rule->effect.floating)