示例#1
0
文件: Client.cpp 项目: jhanssen/nwm
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);
}
示例#2
0
文件: client.cpp 项目: edmondas/ncwm
void Client::handlePropertyNotify(XPropertyEvent *event) {

    if (event->state == PropertyDelete) {
        return; // ignore delete properties
    }

    // WM atoms
    if (event->atom == Atoms::WM_PROTOCOLS) {
        protocols_ = XCORE->protocols(clientWindow_);
        return;
    }
    else if (event->atom == Atoms::MWM_HINTS) {
        if (XCORE->hasDecoration(clientWindow_) && !frameWindow()) {
            hasDecoration_ = true;
        }
        return;
    }

    // default atoms
    static string tmp;
    ostringstream oss;
    switch (event->atom) {
    case XA_WM_ICON_NAME:
        tmp = XCORE->atomValue(clientWindow_, XA_WM_ICON_NAME);
        if (tmp.length() > 0) {
            // update only if the icon name is != 0
            iconName_ = tmp + id_;
        }
        monitor()->clientBar()->illuminate();
        monitor()->statusBar()->illuminate();
        break;
    case XA_WM_NAME:
        tmp = XCORE->atomValue(clientWindow_, XA_WM_NAME);
        if (tmp.length() > 0) {
            // update only if the title is != 0
            setName(tmp + id_);
        }
        illuminate();
        monitor()->statusBar()->illuminate();
        break;
    case XA_WM_TRANSIENT_FOR:
        updateTransient();
        break;
    case XA_WM_NORMAL_HINTS:
        updateSize();
        oss << "git size: x=" << x() << ", y=" << y() << ", w=" <<
            width() << ", h=" << height();
        LOGDEBUG(oss.str());
        break;
    }
}
示例#3
0
文件: Client.cpp 项目: jhanssen/nwm
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);
    }
}
示例#4
0
文件: client.cpp 项目: edmondas/ncwm
void Client::initICCCM() {

    state_ = XCORE->state(clientWindow_);
    iconName_ = XCORE->atomValue(clientWindow_, XA_WM_ICON_NAME);
    setName(XCORE->atomValue(clientWindow_, XA_WM_NAME) + id_);
    if (iconName_ == "") {
        iconName_ = name();
    }
    else {
        iconName_ += id_;
    }
    updateSize();
    protocols_ = XCORE->protocols(clientWindow_);
    if (XCORE->hasDecoration(clientWindow_) && !frameWindow()) {
        hasDecoration_ = true;
    }

    updateTransient();
}
示例#5
0
文件: client.cpp 项目: edmondas/ncwm
Client::Client(Monitor *monitor, Window window, XWindowAttributes *attr)
    : Thing(monitor, new Rectangle(), Thing::CLIENT)
{
    clientWindow_ = window;
    frame_ = 0;
    state_ = WithdrawnState;
    iconName_ = "";
    isCentered_ = false;
    protocols_ = 0;
    hasFrame_ = false;
    requestsFocus_ = false;
    isDestroyed_ = false;
    hooked_ = "";
    workspace_ = 0;

    ostringstream oss;
    oss << "<" << monitor->nextClientId() << ">";
    id_ = oss.str();

    eventMask_ = PropertyChangeMask;
    XCORE->selectEvents(clientWindow_, eventMask_);

    setX(attr->x);
    setY(attr->y);
    setWidth(attr->width);
    setHeight(attr->height);
    borderWidth_ = attr->border_width;

    oss.str("");
    oss << "constructing new client with dimensions: " <<
        x() << "," << y() << "," << width() << "," << height();
    LOGDEBUG(oss.str());

    className_ = XCORE->className(clientWindow_);
    instanceName_ = XCORE->instanceName(clientWindow_);

    string value;

    updateTransient();
    if (transient_) {
         value = Util::get(KERNEL->sessionSettings(),
                     "client." + className_ + "::" + instanceName_ + ".transient-mode");

        if ("" == value) {
            value = Util::get(KERNEL->commonSettings(),
                              "default.transient-mode");

            if ("" == value) {
                value = "float";
            }
        }
    }
    else {
        value = Util::get(KERNEL->sessionSettings(),
                         "client." + className_ + "::" + instanceName_ + ".mode");
    }

    if (value == "float") {
        mode_ = FLOAT;
    }
    else if (value == "sticky") {
        mode_ = STICKY;
    }
    else if (value == "max") {
        mode_ = MAX;
    }
#ifdef SLOT_SUPPORT
    else if (value == "slot") {
        mode_ = SLOT;
    }
#endif // SLOT_SUPPORT
    // fallback, unknown yet
    else if (Util::get(KERNEL->commonSettings(), "default.client-mode")
            == "float")
    {
        mode_ = FLOAT;
    }
    else {
        mode_ = MAX;
    }

    hooked_ = Util::get(KERNEL->sessionSettings(),
            "client." + className_ + "::" + instanceName_ + ".hooked");
}