2 #include <xcb/xcb_icccm.h>
3 #include <xcb/xcb_ewmh.h>
9 rule_t *next_match(rule_t *rule, xcb_window_t win)
15 while (r != NULL && found == NULL) {
23 bool is_match(rule_t *r, xcb_window_t win)
25 xcb_icccm_get_wm_class_reply_t reply;
26 if (xcb_icccm_get_wm_class_reply(dpy, xcb_icccm_get_wm_class(dpy, win), &reply, NULL) == 1
27 && (strcmp(reply.class_name, r->cause.name) == 0
28 || strcmp(reply.instance_name, r->cause.name) == 0)) {
29 xcb_icccm_get_wm_class_reply_wipe(&reply);
35 void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *fullscreen, bool *takes_focus)
37 xcb_ewmh_get_atoms_reply_t win_type;
39 if (xcb_ewmh_get_wm_window_type_reply(ewmh, xcb_ewmh_get_wm_window_type(ewmh, win), &win_type, NULL) == 1) {
40 for (unsigned int i = 0; i < win_type.atoms_len; i++) {
41 xcb_atom_t a = win_type.atoms[i];
42 if (a == ewmh->_NET_WM_WINDOW_TYPE_TOOLBAR
43 || a == ewmh->_NET_WM_WINDOW_TYPE_UTILITY) {
45 } else if (a == ewmh->_NET_WM_WINDOW_TYPE_DIALOG) {
51 xcb_ewmh_get_atoms_reply_t win_state;
53 if (xcb_ewmh_get_wm_state_reply(ewmh, xcb_ewmh_get_wm_state(ewmh, win), &win_state, NULL) == 1) {
54 for (unsigned int i = 0; i < win_state.atoms_len; i++) {
55 xcb_atom_t a = win_state.atoms[i];
56 if (a == ewmh->_NET_WM_STATE_FULLSCREEN) {
62 /* xcb_ewmh_get_atoms_reply_wipe(&win_type); */
64 xcb_window_t transient_for = XCB_NONE;
65 xcb_icccm_get_wm_transient_for_reply(dpy, xcb_icccm_get_wm_transient_for(dpy, win), &transient_for, NULL);
66 *transient = (transient_for == XCB_NONE ? false : true);
70 rule_t *rule = rule_head;
72 while (rule != NULL) {
73 if (is_match(rule, win)) {
74 if (rule->effect.floating) {