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, monitor_t **m, desktop_t **d, 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_size_hints_t size_hints;
43 if (xcb_icccm_get_wm_normal_hints_reply(dpy, xcb_icccm_get_wm_normal_hints(dpy, win), &size_hints, NULL) == 1) {
44 if (size_hints.min_width == size_hints.max_width
45 && size_hints.min_height == size_hints.max_height
46 && size_hints.min_width > 0 && size_hints.min_height > 0)
50 xcb_ewmh_get_atoms_reply_t win_state;
52 if (xcb_ewmh_get_wm_state_reply(ewmh, xcb_ewmh_get_wm_state(ewmh, win), &win_state, NULL) == 1) {
53 for (unsigned int i = 0; i < win_state.atoms_len; i++) {
54 xcb_atom_t a = win_state.atoms[i];
55 if (a == ewmh->_NET_WM_STATE_FULLSCREEN) {
59 xcb_ewmh_get_atoms_reply_wipe(&win_state);
62 xcb_window_t transient_for = XCB_NONE;
63 xcb_icccm_get_wm_transient_for_reply(dpy, xcb_icccm_get_wm_transient_for(dpy, win), &transient_for, NULL);
64 *transient = (transient_for == XCB_NONE ? false : true);
68 rule_t *rule = rule_head;
70 while (rule != NULL) {
71 if (is_match(rule, win)) {
72 rule_effect_t efc = rule->effect;
75 if (efc.monitor != NULL && efc.desktop != NULL) {