Example #1
0
void Client::updateState(xcb_ewmh_connection_t* ewmhConn)
{
    xcb_connection_t* conn = ewmhConn->connection;
    xcb_get_geometry_cookie_t geomCookie;
    if (!mOwned)
        geomCookie = xcb_get_geometry_unchecked(conn, mWindow);
    const xcb_get_property_cookie_t normalHintsCookie = xcb_icccm_get_wm_normal_hints(conn, mWindow);
    const xcb_get_property_cookie_t leaderCookie = xcb_get_property(conn, 0, mWindow, Atoms::WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 1);
    const xcb_get_property_cookie_t transientCookie = xcb_icccm_get_wm_transient_for(conn, mWindow);
    const xcb_get_property_cookie_t hintsCookie = xcb_icccm_get_wm_hints(conn, mWindow);
    const xcb_get_property_cookie_t classCookie = xcb_icccm_get_wm_class(conn, mWindow);
    const xcb_get_property_cookie_t nameCookie = xcb_icccm_get_wm_name(conn, mWindow);
    const xcb_get_property_cookie_t protocolsCookie = xcb_icccm_get_wm_protocols(conn, mWindow, Atoms::WM_PROTOCOLS);
    const xcb_get_property_cookie_t strutCookie = xcb_ewmh_get_wm_strut(ewmhConn, mWindow);
    const xcb_get_property_cookie_t partialStrutCookie = xcb_ewmh_get_wm_strut_partial(ewmhConn, mWindow);
    const xcb_get_property_cookie_t stateCookie = xcb_ewmh_get_wm_state(ewmhConn, mWindow);
    const xcb_get_property_cookie_t typeCookie = xcb_ewmh_get_wm_window_type(ewmhConn, mWindow);
    const xcb_get_property_cookie_t pidCookie = xcb_ewmh_get_wm_pid(ewmhConn, mWindow);

    if (!mOwned)
        updateSize(conn, geomCookie);
    updateNormalHints(conn, normalHintsCookie);
    updateLeader(conn, leaderCookie);
    updateTransient(conn, transientCookie);
    updateHints(conn, hintsCookie);
    updateClass(conn, classCookie);
    updateName(conn, nameCookie);
    updateProtocols(conn, protocolsCookie);
    updateStrut(ewmhConn, strutCookie);
    updatePartialStrut(ewmhConn, partialStrutCookie);
    updateEwmhState(ewmhConn, stateCookie);
    updateWindowTypes(ewmhConn, typeCookie);
    updatePid(ewmhConn, pidCookie);
}
Example #2
0
void Client::propertyNotify(xcb_atom_t atom)
{
#warning Need to notify js that properties have changed
    warning() << "Got propertyNotify" << Atoms::name(atom) << mWindow;
    auto ewmhConnection = WindowManager::instance()->ewmhConnection();
    auto conn = ewmhConnection->connection;
    if (atom == XCB_ATOM_WM_NORMAL_HINTS) {
        const xcb_get_property_cookie_t normalHintsCookie = xcb_icccm_get_wm_normal_hints(conn, mWindow);
        updateNormalHints(conn, normalHintsCookie);
    } else if (atom == XCB_ATOM_WM_TRANSIENT_FOR) {
        const xcb_get_property_cookie_t transientCookie = xcb_icccm_get_wm_transient_for(conn, mWindow);
        updateTransient(conn, transientCookie);
    } else if (atom == Atoms::WM_CLIENT_LEADER) {
        const xcb_get_property_cookie_t leaderCookie = xcb_get_property(conn, 0, mWindow, Atoms::WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 1);
        updateLeader(conn, leaderCookie);
    } else if (atom == XCB_ATOM_WM_HINTS) {
        const xcb_get_property_cookie_t hintsCookie = xcb_icccm_get_wm_hints(conn, mWindow);
        updateHints(conn, hintsCookie);
    } else if (atom == XCB_ATOM_WM_CLASS) {
        const xcb_get_property_cookie_t classCookie = xcb_icccm_get_wm_class(conn, mWindow);
        updateClass(conn, classCookie);
    } else if (atom == XCB_ATOM_WM_NAME) {
        const xcb_get_property_cookie_t nameCookie = xcb_icccm_get_wm_name(conn, mWindow);
        updateName(conn, nameCookie);
    } else if (atom == Atoms::WM_PROTOCOLS) {
        const xcb_get_property_cookie_t protocolsCookie = xcb_icccm_get_wm_protocols(conn, mWindow, Atoms::WM_PROTOCOLS);
        updateProtocols(conn, protocolsCookie);
    } else if (atom == ewmhConnection->_NET_WM_STRUT) {
        const xcb_get_property_cookie_t strutCookie = xcb_ewmh_get_wm_strut(ewmhConnection, mWindow);
        updateStrut(ewmhConnection, strutCookie);
    } else if (atom == ewmhConnection->_NET_WM_STRUT_PARTIAL) {
        const xcb_get_property_cookie_t partialStrutCookie = xcb_ewmh_get_wm_strut_partial(ewmhConnection, mWindow);
        updatePartialStrut(ewmhConnection, partialStrutCookie);
    } else if (atom == ewmhConnection->_NET_WM_STATE) {
        const xcb_get_property_cookie_t stateCookie = xcb_ewmh_get_wm_state(ewmhConnection, mWindow);
        updateEwmhState(ewmhConnection, stateCookie);
    } else if (atom == ewmhConnection->_NET_WM_WINDOW_TYPE) {
        const xcb_get_property_cookie_t typeCookie = xcb_ewmh_get_wm_window_type(ewmhConnection, mWindow);
        updateWindowTypes(ewmhConnection, typeCookie);
    } else if (atom == ewmhConnection->_NET_WM_PID) {
        const xcb_get_property_cookie_t pidCookie = xcb_ewmh_get_wm_pid(ewmhConnection, mWindow);
        updatePid(ewmhConnection, pidCookie);
    } else {
        warning() << "Unhandled propertyNotify atom" << Atoms::name(atom);
    }
}
Example #3
0
void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *fullscreen, bool *takes_focus)
{
    xcb_ewmh_get_atoms_reply_t win_type;

    if (xcb_ewmh_get_wm_window_type_reply(ewmh, xcb_ewmh_get_wm_window_type(ewmh, win), &win_type, NULL) == 1) {
        for (unsigned int i = 0; i < win_type.atoms_len; i++) {
            xcb_atom_t a = win_type.atoms[i];
            if (a == ewmh->_NET_WM_WINDOW_TYPE_TOOLBAR
                    || a == ewmh->_NET_WM_WINDOW_TYPE_UTILITY) {
                *takes_focus = false;
            } else if (a == ewmh->_NET_WM_WINDOW_TYPE_DIALOG) {
                *floating = true;
            }
        }
        xcb_ewmh_get_atoms_reply_wipe(&win_type);
    }

    xcb_ewmh_get_atoms_reply_t win_state;

    if (xcb_ewmh_get_wm_state_reply(ewmh, xcb_ewmh_get_wm_state(ewmh, win), &win_state, NULL) == 1) {
        for (unsigned int i = 0; i < win_state.atoms_len; i++) {
            xcb_atom_t a = win_state.atoms[i];
            if (a == ewmh->_NET_WM_STATE_FULLSCREEN) {
                *fullscreen = true;
            }
        }
        xcb_ewmh_get_atoms_reply_wipe(&win_state);
    }

    xcb_window_t transient_for = XCB_NONE;
    xcb_icccm_get_wm_transient_for_reply(dpy, xcb_icccm_get_wm_transient_for(dpy, win), &transient_for, NULL);
    *transient = (transient_for == XCB_NONE ? false : true);
    if (*transient)
        *floating = true;

    rule_t *rule = rule_head;

    while (rule != NULL) {
        if (is_match(rule, win)) {
            if (rule->effect.floating)
                *floating = true;
        }
        rule = rule->next;
    }
}
Example #4
0
static void
setup_window_type(xcwm_window_t *window, xcwm_property_t *property)
{
    xcb_get_property_cookie_t cookie;
    xcb_window_t transient;
    xcb_ewmh_get_atoms_reply_t type;
    xcb_ewmh_connection_t ewmh_conn = window->context->atoms.ewmh_conn;
    int i;

    /* if nothing below matches, set the default to unknown */
    window->type = XCWM_WINDOW_TYPE_UNKNOWN;

    /* Get the window this one is transient for */
    cookie = xcb_icccm_get_wm_transient_for(window->context->conn,
                                            window->window_id);
    if (xcb_icccm_get_wm_transient_for_reply(window->context->conn, cookie,
                                             &transient, NULL)) {
        window->transient_for = _xcwm_get_window_node_by_window_id(transient);
        window->type = XCWM_WINDOW_TYPE_DIALOG;
        // not if override-redirect
    } else {
        window->transient_for = NULL;
        window->type = XCWM_WINDOW_TYPE_NORMAL;
    }

    /* Check and see if the client has set the _NET_WM_WINDOW_TYPE
     * atom. Since the "type" is a list of window types, ordered by
     * preference, we need to loop through to make sure we get a
     * match. */
    cookie = xcb_ewmh_get_wm_window_type(&ewmh_conn, window->window_id);
    if (xcb_ewmh_get_wm_window_type_reply(&ewmh_conn, cookie, &type, NULL)) {
        for (i = 0; i < type.atoms_len; i++) {
            if (type.atoms[i] ==  ewmh_conn._NET_WM_WINDOW_TYPE_DESKTOP) {
                window->type = XCWM_WINDOW_TYPE_DESKTOP;
                break;
            } else if (type.atoms[i] ==  ewmh_conn._NET_WM_WINDOW_TYPE_DOCK) {
                window->type = XCWM_WINDOW_TYPE_DOCK;
                break;
            } else if (type.atoms[i] ==  ewmh_conn._NET_WM_WINDOW_TYPE_TOOLBAR) {
                window->type = XCWM_WINDOW_TYPE_TOOLBAR;
                break;
            } else if (type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_MENU) {
                window->type = XCWM_WINDOW_TYPE_MENU;
                break;
            } else if (type.atoms[i]
                       == ewmh_conn._NET_WM_WINDOW_TYPE_UTILITY) {
                window->type = XCWM_WINDOW_TYPE_UTILITY;
                break;
            } else if ((type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_SPLASH) ||
                       (type.atoms[i] == window->context->atoms.net_wm_window_type_splashscreen)) {
                window->type = XCWM_WINDOW_TYPE_SPLASH;
                break;
            } else if (type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_DIALOG) {
                window->type = XCWM_WINDOW_TYPE_DIALOG;
                break;
            } else if (type.atoms[i]
                       == ewmh_conn._NET_WM_WINDOW_TYPE_DROPDOWN_MENU) {
                window->type = XCWM_WINDOW_TYPE_DROPDOWN_MENU;
                break;
            } else if (type.atoms[i]
                       == ewmh_conn._NET_WM_WINDOW_TYPE_POPUP_MENU) {
                window->type = XCWM_WINDOW_TYPE_POPUP_MENU;
                break;
            } else if (type.atoms[i]
                       == ewmh_conn._NET_WM_WINDOW_TYPE_TOOLTIP) {
                window->type = XCWM_WINDOW_TYPE_TOOLTIP;
                break;
            } else if (type.atoms[i]
                       == ewmh_conn._NET_WM_WINDOW_TYPE_NOTIFICATION) {
                window->type = XCWM_WINDOW_TYPE_NOTIFICATION;
                break;
            } else if (type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_COMBO) {
                window->type = XCWM_WINDOW_TYPE_COMBO;
                break;
            } else if (type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_DND) {
                window->type = XCWM_WINDOW_TYPE_DND;
                break;
            } else if (type.atoms[i] == ewmh_conn._NET_WM_WINDOW_TYPE_NORMAL) {
                window->type = XCWM_WINDOW_TYPE_NORMAL;
                break;
            }
        }
    }
}
Example #5
0
//! Query WM_TRANSIENT_FOR property
xcb_get_property_cookie_t Client::query_wm_transient_for()
{
    return xcb_icccm_get_wm_transient_for(g_xcb.connection, window());
}