示例#1
0
    QByteArray getSettings()
    {
        QXcbConnectionGrabber connectionGrabber(screen->connection());

        int offset = 0;
        QByteArray settings;
        xcb_atom_t _xsettings_atom = screen->connection()->atom(QXcbAtom::_XSETTINGS_SETTINGS);
        while (1) {
            xcb_get_property_cookie_t get_prop_cookie =
                    xcb_get_property_unchecked(screen->xcb_connection(),
                                               false,
                                               x_settings_window,
                                               _xsettings_atom,
                                               _xsettings_atom,
                                               offset/4,
                                               8192);
            xcb_get_property_reply_t *reply = xcb_get_property_reply(screen->xcb_connection(), get_prop_cookie, NULL);
            bool more = false;
            if (!reply)
                return settings;

            settings += QByteArray((const char *)xcb_get_property_value(reply), xcb_get_property_value_length(reply));
            offset += xcb_get_property_value_length(reply);
            more = reply->bytes_after != 0;

            free(reply);

            if (!more)
                break;
        }

        return settings;
    }
示例#2
0
void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp)
{
    if (connection()->hasXRandr()) {
        xcb_randr_get_crtc_info_reply_t *crtc = xcb_randr_get_crtc_info_reply(xcb_connection(),
            xcb_randr_get_crtc_info_unchecked(xcb_connection(), m_crtc, timestamp), NULL);
        if (crtc) {
            m_geometry = QRect(crtc->x, crtc->y, crtc->width, crtc->height);
            m_availableGeometry = m_geometry;
            free(crtc);
        }
    }

    xcb_get_property_reply_t * workArea =
        xcb_get_property_reply(xcb_connection(),
            xcb_get_property_unchecked(xcb_connection(), false, screen()->root,
                             atom(QXcbAtom::_NET_WORKAREA),
                             XCB_ATOM_CARDINAL, 0, 1024), NULL);

    if (workArea && workArea->type == XCB_ATOM_CARDINAL && workArea->format == 32 && workArea->value_len >= 4) {
        // If workArea->value_len > 4, the remaining ones seem to be for virtual desktops.
        // But QScreen doesn't know about that concept.  In reality there could be a
        // "docked" panel (with _NET_WM_STRUT_PARTIAL atom set) on just one desktop.
        // But for now just assume the first 4 values give us the geometry of the
        // "work area", AKA "available geometry"
        uint32_t *geom = (uint32_t*)xcb_get_property_value(workArea);
        QRect virtualAvailableGeometry(geom[0], geom[1], geom[2], geom[3]);
        // Take the intersection of the desktop's available geometry with this screen's geometry
        // to get the part of the available geometry which belongs to this screen.
        m_availableGeometry = m_geometry & virtualAvailableGeometry;
    }
    free(workArea);
}
示例#3
0
文件: xcb.c 项目: eplanet/i3lock
xcb_window_t find_focused_window(xcb_connection_t *conn, const xcb_window_t root) {
    xcb_window_t result = XCB_NONE;

    _init_net_active_window(conn);

    xcb_get_property_reply_t *prop_reply = xcb_get_property_reply(
        conn,
        xcb_get_property_unchecked(
            conn, false, root, _NET_ACTIVE_WINDOW, XCB_GET_PROPERTY_TYPE_ANY, 0, 1 /* word */),
        NULL);
    if (prop_reply == NULL) {
        goto out;
    }
    if (xcb_get_property_value_length(prop_reply) == 0) {
        goto out_prop;
    }
    if (prop_reply->type != XCB_ATOM_WINDOW) {
        goto out_prop;
    }

    result = *((xcb_window_t *)xcb_get_property_value(prop_reply));

out_prop:
    free(prop_reply);
out:
    return result;
}
示例#4
0
void QXcbScreen::readXResources()
{
    int offset = 0;
    QByteArray resources;
    while(1) {
        xcb_get_property_reply_t *reply =
            xcb_get_property_reply(xcb_connection(),
                xcb_get_property_unchecked(xcb_connection(), false, screen()->root,
                                 XCB_ATOM_RESOURCE_MANAGER,
                                 XCB_ATOM_STRING, offset/4, 8192), NULL);
        bool more = false;
        if (reply && reply->format == 8 && reply->type == XCB_ATOM_STRING) {
            resources += QByteArray((const char *)xcb_get_property_value(reply), xcb_get_property_value_length(reply));
            offset += xcb_get_property_value_length(reply);
            more = reply->bytes_after != 0;
        }

        if (reply)
            free(reply);

        if (!more)
            break;
    }

    QList<QByteArray> split = resources.split('\n');
    for (int i = 0; i < split.size(); ++i) {
        const QByteArray &r = split.at(i);
        int value;
        if (xResource(r, "Xft.dpi:\t", &value))
            m_forcedDpi = value;
        else if (xResource(r, "Xft.hintstyle:\t", &value))
            m_hintStyle = QFontEngine::HintStyle(value);
    }
}
示例#5
0
void
property_update_net_wm_pid(client_t *c,
                           xcb_get_property_reply_t *reply)
{
    bool no_reply = !reply;

    if(no_reply)
    {
        xcb_get_property_cookie_t prop_c =
            xcb_get_property_unchecked(globalconf.connection, false, c->window, _NET_WM_PID, XCB_ATOM_CARDINAL, 0L, 1L);
        reply = xcb_get_property_reply(globalconf.connection, prop_c, NULL);
    }

    if(reply && reply->value_len)
    {
        uint32_t *rdata = xcb_get_property_value(reply);
        if(rdata)
        {
            luaA_object_push(globalconf.L, c);
            client_set_pid(globalconf.L, -1, *rdata);
            lua_pop(globalconf.L, 1);
        }
    }

    if(no_reply)
        p_delete(&reply);
}
示例#6
0
EAPI char *
ecore_x_window_prop_string_get(Ecore_X_Window win,
                               Ecore_X_Atom   type)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_property_reply_t *reply;
   char *str = NULL;
   int len = 0;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   cookie =
     xcb_get_property_unchecked(_ecore_xcb_conn, 0,
                                win ? win : ((xcb_screen_t *)_ecore_xcb_screen)->root,
                                type, XCB_GET_PROPERTY_TYPE_ANY, 0, 1000000L);
   reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return NULL;

   len = ((reply->value_len * reply->format) / 8);
   str = (char *)malloc((len + 1) * sizeof(char));
   memcpy(str, xcb_get_property_value(reply), len);
   str[len] = '\0';

   if (reply->type != ECORE_X_ATOM_UTF8_STRING)
     {
        Ecore_Xcb_Textproperty prop;
        int count = 0;
        char **list = NULL;
        Eina_Bool ret = EINA_FALSE;

        prop.value = strdup(str);
        prop.nitems = len;
        prop.encoding = reply->type;

#ifdef HAVE_ICONV
        ret = _ecore_xcb_utf8_textproperty_to_textlist(&prop, &list, &count);
#else
        ret = _ecore_xcb_mb_textproperty_to_textlist(&prop, &list, &count);
#endif
        if (ret)
          {
             if (count > 0)
               str = strdup(list[0]);
             else
               str = strdup((char *)prop.value);

             if (list) free(list);
          }
        else
          str = strdup((char *)prop.value);
     }

   free(reply);
   return str;
}
示例#7
0
/*!
  Returns WM_CLIENT_LEADER property for a given window.
 */
xcb_window_t Toplevel::staticWmClientLeader(xcb_window_t w)
{
    xcb_connection_t *c = connection();
    auto cookie = xcb_get_property_unchecked(c, false, w, atoms->wm_client_leader, XCB_ATOM_WINDOW, 0, 10000);
    ScopedCPointer<xcb_get_property_reply_t> prop(xcb_get_property_reply(c, cookie, nullptr));
    if (prop.isNull() || prop->value_len <= 0) {
        return w;
    }
    return static_cast<xcb_window_t*>(xcb_get_property_value(prop.data()))[0];
}
示例#8
0
/**
 * Sends the GetProperty request.
 * @param window Window whose properties are requested.
 * @param type   The atom.
 */
EAPI void
ecore_x_window_prop_string_get_prefetch(Ecore_X_Window window,
                                        Ecore_X_Atom   type)
{
   xcb_get_property_cookie_t cookie;

   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
                                       window ? window : ((xcb_screen_t *)_ecore_xcb_screen)->root,
                                       type, XCB_GET_PROPERTY_TYPE_ANY, 0L, 1000000L);
   _ecore_xcb_cookie_cache(cookie.sequence);
} /* ecore_x_window_prop_string_get_prefetch */
示例#9
0
/**
 * Sends the GetProperty request.
 * @param window   Window whose properties are requested.
 * @param property Property atom.
 * @param type     Type atom.
 */
EAPI void
ecore_x_window_prop_property_get_prefetch(Ecore_X_Window window,
                                          Ecore_X_Atom   property,
                                          Ecore_X_Atom   type)
{
   xcb_get_property_cookie_t cookie;

   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
                                       window ? window : ((xcb_screen_t *)_ecore_xcb_screen)->root,
                                       property, type, 0, LONG_MAX);
   _ecore_xcb_cookie_cache(cookie.sequence);
} /* ecore_x_window_prop_property_get_prefetch */
示例#10
0
/**
 * Sends the GetProperty request.
 * @param window Window whose properties are requested.
 * @param atom   The atom.
 */
EAPI void
ecore_x_window_prop_window_get_prefetch(Ecore_X_Window window,
                                        Ecore_X_Atom   atom)
{
   xcb_get_property_cookie_t cookie;

   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
                                       window,
                                       atom,
                                       ECORE_X_ATOM_WINDOW,
                                       0, 0x7fffffff);
   _ecore_xcb_cookie_cache(cookie.sequence);
} /* ecore_x_window_prop_window_get_prefetch */
示例#11
0
/**
 * Sends the GetProperty request.
 * @param window Window whose properties are requested.
 * @param atom   The atom.
 * @param type   The atom type.
 */
EAPI void
ecore_x_window_prop_xid_get_prefetch(Ecore_X_Window window,
                                     Ecore_X_Atom   atom,
                                     Ecore_X_Atom   type)
{
   xcb_get_property_cookie_t cookie;

   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
                                       window,
                                       atom,
                                       type,
                                       0, 0x7fffffff);
   _ecore_xcb_cookie_cache(cookie.sequence);
} /* ecore_x_window_prop_xid_get_prefetch */
示例#12
0
文件: window.c 项目: feler/ceres
/* window_get_state_prepare {{{
 */
xcb_get_property_cookie_t
window_get_state_prepare(xcb_window_t window)
{
    /* xcb_get_property(xcb_connection_t *       c,
     *                  uint8_t         _delete,
     *                  xcb_window_t    window,
     *                  xcb_atom_t      property,
     *                  xcb_atom_t      type,
     *                  uint32_t        long_offset,
     *                  uint32_t        long_length)
     */
    return xcb_get_property_unchecked(rootconf.connection, false, window,
            WM_STATE, WM_STATE, 0L, 2L);
} /*  }}} */
示例#13
0
EAPI int
ecore_x_window_prop_card32_list_get(Ecore_X_Window win,
                                    Ecore_X_Atom   atom,
                                    unsigned int **list)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_property_reply_t *reply;
   int num = -1;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   if (list) *list = NULL;

   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom,
                                       XCB_ATOM_CARDINAL, 0, 0x7fffffff);
   reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return -1;

   if ((reply->type != XCB_ATOM_CARDINAL) || (reply->format != 32))
     num = -1;
   else if ((reply->value_len == 0) || (!xcb_get_property_value(reply)))
     num = 0;
   else
     {
        num = reply->value_len;
        if (list)
          {
             unsigned int *val;
             void *data;
             int i = 0;

             val = malloc(num * sizeof(unsigned int));
             if (!val)
               {
                  free(reply);
                  return num;
               }
             data = xcb_get_property_value(reply);
             for (i = 0; i < num; i++)
               val[i] = ((unsigned long *)data)[i];
             *list = val;
          }
     }

   free(reply);
   return num;
}
示例#14
0
QVector< uint32_t > Shadow::readX11ShadowProperty(xcb_window_t id)
{
    QVector<uint32_t> ret;
    xcb_connection_t *c = connection();
    const auto cookie = xcb_get_property_unchecked(c, false, id, atoms->kde_net_wm_shadow,
                                                   XCB_ATOM_CARDINAL, 0, 12);
    ScopedCPointer<xcb_get_property_reply_t> prop(xcb_get_property_reply(c, cookie, nullptr));
    if (!prop.isNull() && prop->type == XCB_ATOM_CARDINAL && prop->format == 32 ) {
        uint32_t* shadow = reinterpret_cast< uint32_t* >(xcb_get_property_value(prop.data()));
        ret.reserve(12);
        for (int i=0; i<12; ++i) {
            ret << shadow[i];
        }
    }
    return ret;
}
示例#15
0
EAPI int
ecore_x_window_prop_xid_list_get(Ecore_X_Window win,
                                 Ecore_X_Atom   atom,
                                 Ecore_X_Atom   type,
                                 Ecore_X_ID   **xids)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_property_reply_t *reply;
   int num = -1;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   if (xids) *xids = NULL;

   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom, type,
                                       0, 0x7fffffff);
   reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return -1;

   if ((reply->type != type) || (reply->format != 32))
     num = -1;
   else if ((reply->value_len == 0) || (!xcb_get_property_value(reply)))
     num = 0;
   else
     {
        Ecore_X_Atom *alst;
        void *val;

        num = xcb_get_property_value_length(reply);
        val = xcb_get_property_value(reply);
        alst = malloc(num * sizeof(Ecore_X_ID));
        if (alst)
          {
             int i = 0;

             for (i = 0; i < num; i++)
               alst[i] = ((unsigned long *)val)[i];
             *xids = alst;
          }
     }

   free(reply);
   return num;
}
示例#16
0
EAPI int
ecore_x_window_prop_xid_get(Ecore_X_Window win,
                            Ecore_X_Atom   atom,
                            Ecore_X_Atom   type,
                            Ecore_X_ID    *xids,
                            unsigned int   len)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_property_reply_t *reply;
   int num = 0;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   num = len;
   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom, type,
                                       0, 0x7fffffff);
   reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return -1;

   if ((reply->type != type) || (reply->format != 32))
     num = -1;
   else if (reply->value_len == 0)
     num = 0;
   else
     {
        unsigned int i = 0;
        unsigned char *v;

        if (reply->value_len < len)
          len = reply->value_len;

        v = xcb_get_property_value(reply);
        for (i = 0; i < len; i++)
          xids[i] = ((unsigned long *)v)[i];

        num = len;
     }

   if (reply) free(reply);
   return num;
}
示例#17
0
EAPI int
ecore_x_window_prop_card32_get(Ecore_X_Window win,
                               Ecore_X_Atom   atom,
                               unsigned int  *val,
                               unsigned int   len)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_property_reply_t *reply;
   int num = 0;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom,
                                       ECORE_X_ATOM_CARDINAL, 0, 0x7fffffff);
   reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return -1;

   if ((reply->type != ECORE_X_ATOM_CARDINAL) || (reply->format != 32))
     num = -1;
   else if (reply->value_len == 0)
     num = 0;
   else
     {
        if (reply->value_len < len)
          len = reply->value_len;

        if (val)
          {
             unsigned int i = 0;
             unsigned char *v;

             v = xcb_get_property_value(reply);
             for (i = 0; i < len; i++)
               val[i] = ((unsigned long *)v)[i];
             num = len;
          }
     }

   if (reply) free(reply);
   return num;
}
示例#18
0
文件: systray.c 项目: mcm3c/configs
/** Check if a window is a KDE tray.
 * \param w The window to check.
 * \return True if it is, false otherwise.
 */
bool
systray_iskdedockapp(xcb_window_t w)
{
    xcb_get_property_cookie_t kde_check_q;
    xcb_get_property_reply_t *kde_check;
    bool ret;

    /* Check if that is a KDE tray because it does not respect fdo standards,
     * thanks KDE. */
    kde_check_q = xcb_get_property_unchecked(globalconf.connection, false, w,
                                             _KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR,
                                             XCB_ATOM_WINDOW, 0, 1);

    kde_check = xcb_get_property_reply(globalconf.connection, kde_check_q, NULL);

    /* it's a KDE systray ?*/
    ret = (kde_check && kde_check->value_len);

    p_delete(&kde_check);

    return ret;
}
示例#19
0
/** Update leader hint of a client.
 * \param c The client.
 * \param reply (Optional) An existing reply.
 */
void
property_update_wm_client_leader(client_t *c, xcb_get_property_reply_t *reply)
{
    xcb_get_property_cookie_t client_leader_q;
    void *data;
    bool no_reply = !reply;

    if(no_reply)
    {
        client_leader_q = xcb_get_property_unchecked(globalconf.connection, false, c->window,
                                                     WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 1, 32);

        reply = xcb_get_property_reply(globalconf.connection, client_leader_q, NULL);
    }

    if(reply && reply->value_len && (data = xcb_get_property_value(reply)))
        c->leader_window = *(xcb_window_t *) data;

    /* Only free when we created a reply ourselves. */
    if(no_reply)
        p_delete(&reply);
}
示例#20
0
static Eina_Bool
_e_alert_root_tainted_get(void)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_property_reply_t *reply;
   uint32_t *v;
   int atom_cardinal, atom_tainted;
   int r = 0;

   atom_cardinal = _e_alert_atom_get("CARDINAL");
   atom_tainted = _e_alert_atom_get("_E_TAINTED");

   cookie = xcb_get_property_unchecked(conn, 0, screen->root, atom_tainted,
                                       atom_cardinal, 0, 0x7fffffff);
   reply = xcb_get_property_reply(conn, cookie, NULL);
   if (!reply) return EINA_TRUE;

   v = xcb_get_property_value(reply);
   if (v) r = v[0];

   free(reply);
   return !!r;
}
示例#21
0
static xcb_window_t
_e_alert_comp_win_get(void)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_property_reply_t *reply;
   uint32_t *v;
   int atom_cardinal, atom_composite_win;
   xcb_window_t r = 0;

   atom_cardinal = _e_alert_atom_get("CARDINAL");
   atom_composite_win = _e_alert_atom_get("_E_COMP_WINDOW");

   cookie = xcb_get_property_unchecked(conn, 0, screen->root, atom_composite_win,
                                       atom_cardinal, 0, 0x7fffffff);
   reply = xcb_get_property_reply(conn, cookie, NULL);
   if (!reply) return 0;

   v = xcb_get_property_value(reply);
   if (v) r = v[0];

   free(reply);
   return r;
}
bool QXcbNativeInterface::systrayVisualHasAlphaChannel() {
    const QXcbScreen *screen = static_cast<QXcbScreen *>(QGuiApplication::primaryScreen()->handle());

    if (m_systrayVisualId == XCB_NONE) {
        xcb_connection_t *xcb_conn = screen->xcb_connection();
        xcb_atom_t tray_atom = screen->atom(QXcbAtom::_NET_SYSTEM_TRAY_VISUAL);

        xcb_window_t systray_window = locateSystemTray(xcb_conn, screen);
        if (systray_window == XCB_WINDOW_NONE)
            return false;

        // Get the xcb property for the _NET_SYSTEM_TRAY_VISUAL atom
        xcb_get_property_cookie_t systray_atom_cookie;
        xcb_get_property_reply_t *systray_atom_reply;

        systray_atom_cookie = xcb_get_property_unchecked(xcb_conn, false, systray_window,
                                                        tray_atom, XCB_ATOM_VISUALID, 0, 1);
        systray_atom_reply = xcb_get_property_reply(xcb_conn, systray_atom_cookie, 0);

        if (!systray_atom_reply)
            return false;

        if (systray_atom_reply->value_len > 0 && xcb_get_property_value_length(systray_atom_reply) > 0) {
            xcb_visualid_t * vids = (uint32_t *)xcb_get_property_value(systray_atom_reply);
            m_systrayVisualId = vids[0];
        }

        free(systray_atom_reply);
    }

    if (m_systrayVisualId != XCB_NONE) {
        quint8 depth = screen->depthOfVisual(m_systrayVisualId);
        return depth == 32;
    } else {
        return false;
    }
}
示例#23
0
文件: window.c 项目: Akulen/awesome
int
window_get_xproperty(lua_State *L, xcb_window_t window, int prop_idx)
{
    xproperty_t *prop = luaA_find_xproperty(L, prop_idx);
    xcb_atom_t type;
    void *data;
    xcb_get_property_reply_t *reply;
    uint32_t length;

    type = prop->type == PROP_STRING ? UTF8_STRING : XCB_ATOM_CARDINAL;
    length = prop->type == PROP_STRING ? UINT32_MAX : 1;
    reply = xcb_get_property_reply(globalconf.connection,
            xcb_get_property_unchecked(globalconf.connection, false, window,
                prop->atom, type, 0, length), NULL);
    if(!reply)
        return 0;

    data = xcb_get_property_value(reply);

    if(prop->type == PROP_STRING)
        lua_pushlstring(L, data, reply->value_len);
    else
    {
        if(reply->value_len <= 0)
        {
            p_delete(&reply);
            return 0;
        }
        if(prop->type == PROP_NUMBER)
            lua_pushinteger(L, *(uint32_t *) data);
        else
            lua_pushboolean(L, *(uint32_t *) data);
    }

    p_delete(&reply);
    return 1;
}
示例#24
0
void QXcbScreen::readXResources()
{
    int offset = 0;
    QByteArray resources;
    while(1) {
        xcb_get_property_reply_t *reply =
            xcb_get_property_reply(xcb_connection(),
                xcb_get_property_unchecked(xcb_connection(), false, screen()->root,
                                 XCB_ATOM_RESOURCE_MANAGER,
                                 XCB_ATOM_STRING, offset/4, 8192), NULL);
        bool more = false;
        if (reply && reply->format == 8 && reply->type == XCB_ATOM_STRING) {
            resources += QByteArray((const char *)xcb_get_property_value(reply), xcb_get_property_value_length(reply));
            offset += xcb_get_property_value_length(reply);
            more = reply->bytes_after != 0;
        }

        if (reply)
            free(reply);

        if (!more)
            break;
    }

    QList<QByteArray> split = resources.split('\n');
    for (int i = 0; i < split.size(); ++i) {
        const QByteArray &r = split.at(i);
        if (r.startsWith("Xft.dpi:\t")) {
            bool ok;
            int dpi = r.mid(sizeof("Xft.dpi:")).toInt(&ok);
            if (ok)
                m_forcedDpi = dpi;
            break;
        }
    }
}
示例#25
0
/** Send request to get a window state (WM_STATE).
 * \param w A client window.
 * \return The cookie associated with the request.
 */
xcb_get_property_cookie_t
xwindow_get_state_unchecked(xcb_window_t w)
{
    return xcb_get_property_unchecked(globalconf.connection, false, w, WM_STATE,
                                      WM_STATE, 0L, 2L);
}
示例#26
0
/** Send a request for a window's opacity.
 * \param win The window
 * \return A cookie for xwindow_get_opacity_from_reply().
 */
xcb_get_property_cookie_t
xwindow_get_opacity_unchecked(xcb_window_t win)
{
    return xcb_get_property_unchecked(globalconf.connection, false, win,
                                      _NET_WM_WINDOW_OPACITY, XCB_ATOM_CARDINAL, 0L, 1L);
}
示例#27
0
/** Render a list of widgets.
 * \param wibox The wibox.
 * \todo Remove GC.
 */
void
widget_render(wibox_t *wibox)
{
    lua_State *L = globalconf.L;
    draw_context_t *ctx = &wibox->ctx;
    area_t rectangle = { 0, 0, 0, 0 };
    color_t col;

    rectangle.width = ctx->width;
    rectangle.height = ctx->height;

    if (!widget_geometries(wibox))
        return;

    if(ctx->bg.alpha != 0xffff)
    {
        int x = wibox->geometry.x + wibox->border_width,
            y = wibox->geometry.y + wibox->border_width;
        xcb_get_property_reply_t *prop_r;
        char *data;
        xcb_pixmap_t rootpix;
        xcb_get_property_cookie_t prop_c;
        xcb_screen_t *s = xutil_screen_get(globalconf.connection, ctx->phys_screen);
        prop_c = xcb_get_property_unchecked(globalconf.connection, false, s->root, _XROOTPMAP_ID,
                                            PIXMAP, 0, 1);
        if((prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL)))
        {
            if(prop_r->value_len
               && (data = xcb_get_property_value(prop_r))
               && (rootpix = *(xcb_pixmap_t *) data))
               switch(wibox->orientation)
               {
                 case North:
                   draw_rotate(ctx,
                               rootpix, ctx->pixmap,
                               s->width_in_pixels, s->height_in_pixels,
                               ctx->width, ctx->height,
                               M_PI_2,
                               y + ctx->width,
                               - x);
                   break;
                 case South:
                   draw_rotate(ctx,
                               rootpix, ctx->pixmap,
                               s->width_in_pixels, s->height_in_pixels,
                               ctx->width, ctx->height,
                               - M_PI_2,
                               - y,
                               x + ctx->height);
                   break;
                 case East:
                   xcb_copy_area(globalconf.connection, rootpix,
                                 wibox->pixmap, wibox->gc,
                                 x, y,
                                 0, 0,
                                 ctx->width, ctx->height);
                   break;
               }
            p_delete(&prop_r);
        }
    }

    widget_node_array_t *widgets = &wibox->widgets;

    widget_node_array_wipe(widgets);
    widget_node_array_init(widgets);
    /* push wibox */
    luaA_object_push(globalconf.L, wibox);
    /* push widgets table */
    luaA_object_push_item(globalconf.L, -1, wibox->widgets_table);
    /* remove wibox */
    lua_remove(globalconf.L, -2);
    luaA_table2widgets(L, widgets);

    /* get computed geometries */
    for(unsigned int i = 0; i < lua_objlen(L, -1); i++)
    {
        lua_pushnumber(L, i + 1);
        lua_gettable(L, -2);

        widgets->tab[i].geometry.x = luaA_getopt_number(L, -1, "x", wibox->geometry.x);
        widgets->tab[i].geometry.y = luaA_getopt_number(L, -1, "y", wibox->geometry.y);
        widgets->tab[i].geometry.width = luaA_getopt_number(L, -1, "width", 1);
        widgets->tab[i].geometry.height = luaA_getopt_number(L, -1, "height", 1);

        lua_pop(L, 1);
    }
    lua_pop(L, 1);

    /* draw background image, only if the background color is not opaque */
    if(wibox->bg_image && ctx->bg.alpha != 0xffff)
        draw_image(ctx, 0, 0, 1.0, wibox->bg_image);

    /* draw background color */
    xcolor_to_color(&ctx->bg, &col);
    draw_rectangle(ctx, rectangle, 1.0, true, &col);

    /* draw everything! */
    for(int i = 0; i < widgets->len; i++)
        if(widgets->tab[i].widget->isvisible)
            widgets->tab[i].widget->draw(widgets->tab[i].widget,
                                         ctx, widgets->tab[i].geometry, wibox);

    switch(wibox->orientation)
    {
        case South:
          draw_rotate(ctx, ctx->pixmap, wibox->pixmap,
                      ctx->width, ctx->height,
                      ctx->height, ctx->width,
                      M_PI_2, ctx->height, 0);
          break;
        case North:
          draw_rotate(ctx, ctx->pixmap, wibox->pixmap,
                      ctx->width, ctx->height,
                      ctx->height, ctx->width,
                      - M_PI_2, 0, ctx->width);
          break;
        case East:
          break;
    }
}
示例#28
0
xcb_get_property_cookie_t
property_get_net_wm_pid(client_t *c)
{
    return xcb_get_property_unchecked(globalconf.connection, false, c->window, _NET_WM_PID, XCB_ATOM_CARDINAL, 0L, 1L);
}
示例#29
0
xcb_get_property_cookie_t
property_get_wm_client_leader(client_t *c)
{
    return xcb_get_property_unchecked(globalconf.connection, false, c->window,
                                      WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32);
}
示例#30
0
static gchar *i3ipc_connection_get_socket_path(i3ipcConnection *self, GError **err) {
  GError *tmp_error = NULL;
  xcb_intern_atom_reply_t *atom_reply;
  gchar *socket_path;
  char *atomname = "I3_SOCKET_PATH";
  size_t content_max_words = 256;
  xcb_screen_t *screen;
  xcb_intern_atom_cookie_t atom_cookie;
  xcb_window_t root;
  xcb_get_property_cookie_t prop_cookie;
  xcb_get_property_reply_t *prop_reply;

  g_return_val_if_fail(err == NULL || *err == NULL, NULL);

  if (self->priv->socket_path != NULL)
    return self->priv->socket_path;

  xcb_connection_t *conn = xcb_connect(NULL, NULL);

  screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;

  root = screen->root;

  atom_cookie = xcb_intern_atom(conn, 0, strlen(atomname), atomname);
  atom_reply = xcb_intern_atom_reply(conn, atom_cookie, NULL);

  if (atom_reply == NULL) {
    /* TODO i3ipc custom errors */
    g_free(atom_reply);
    tmp_error = g_error_new(G_IO_ERROR, G_IO_ERROR_FAILED, "socket path atom reply is null");
    g_propagate_error(err, tmp_error);
    return NULL;
  }

  prop_cookie = xcb_get_property_unchecked(conn,
      FALSE,                      /* _delete */
      root,                       /* window */
      atom_reply->atom,           /* property */
      XCB_GET_PROPERTY_TYPE_ANY,  /* type */
      0,                          /* long_offset */
      content_max_words           /* long_length */
      );

  prop_reply = xcb_get_property_reply(conn, prop_cookie, NULL);

  if (prop_reply == NULL) {
    /* TODO i3ipc custom errors */
    g_free(atom_reply);
    g_free(prop_reply);
    tmp_error = g_error_new(G_IO_ERROR, G_IO_ERROR_FAILED, "socket path property reply is null");
    g_propagate_error(err, tmp_error);
    return NULL;
  }

  int len = xcb_get_property_value_length(prop_reply);
  socket_path = malloc(len + 1);

  strncpy(socket_path, (char *)xcb_get_property_value(prop_reply), len);
  socket_path[len] = '\0';

  g_free(atom_reply);
  g_free(prop_reply);
  xcb_disconnect(conn);

  return socket_path;
}