示例#1
0
/*         should we rewrite its code ? */
EAPI Eina_Bool
ecore_x_window_prop_protocol_isset(Ecore_X_Window      window,
                                   Ecore_X_WM_Protocol protocol)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_wm_protocols_reply_t protocols;
   Ecore_X_Atom proto;
   uint32_t i;
   uint8_t ret = 0;

   /* check for invalid values */
   if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
      return ret;

   proto = _ecore_xcb_atoms_wm_protocols[protocol];

   cookie = xcb_get_wm_protocols(_ecore_xcb_conn, window, ECORE_X_ATOM_WM_PROTOCOLS);

   if (!xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protocols, NULL))
      return ret;

   for (i = 0; i < protocols.atoms_len; i++)
      if (protocols.atoms[i] == proto)
        {
           ret = 1;
           break;
        }

   xcb_get_wm_protocols_reply_wipe(&protocols);

   return ret;
} /* ecore_x_window_prop_protocol_isset */
示例#2
0
EAPI Eina_Bool
ecore_x_window_prop_protocol_isset(Ecore_X_Window      win,
                                   Ecore_X_WM_Protocol protocol)
{
   Eina_Bool ret = EINA_FALSE;
   Ecore_X_Atom proto;
#ifdef OLD_XCB_VERSION
   xcb_get_wm_protocols_reply_t protos;
#else
   xcb_icccm_get_wm_protocols_reply_t protos;
#endif
   xcb_get_property_cookie_t cookie;
   uint8_t reply;
   uint32_t count = 0, i = 0;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return EINA_FALSE;

   proto = _ecore_xcb_atoms_wm_protocol[protocol];
#ifdef OLD_XCB_VERSION
   cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win,
                                           ECORE_X_ATOM_WM_PROTOCOLS);
   reply = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL);
#else
   cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win,
                                                 ECORE_X_ATOM_WM_PROTOCOLS);
   reply = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie,
                                            &protos, NULL);
#endif
   if (!reply) return EINA_FALSE;

   count = protos.atoms_len;
   for (i = 0; i < count; i++)
     {
        if (protos.atoms[i] == proto)
          {
             ret = EINA_TRUE;
             break;
          }
     }

#ifdef OLD_XCB_VERSION
   xcb_get_wm_protocols_reply_wipe(&protos);
#else
   xcb_icccm_get_wm_protocols_reply_wipe(&protos);
#endif
   return ret;
}
示例#3
0
文件: window.c 项目: feler/ceres
/* window_check_protocol - check if a given window has a given protocol {{{
 * @window a window
 * @proto a protocol
 */
bool
window_check_protocol(xcb_window_t window, xcb_atom_t protocol)
{
    uint16_t i;
    xcb_get_wm_protocols_reply_t protocols;
    
    if(xcb_get_wm_protocols_reply(rootconf.connection,
                xcb_get_wm_protocols_unchecked(rootconf.connection,
                    window, WM_PROTOCOLS),
                &protocols, NULL))
    {
        for(i = 0; i < protocols.atoms_len; i++)
            if(protocols.atoms[i] == protocol)
                return true;
        xcb_get_wm_protocols_reply_wipe(&protocols);
    }
    return false;
} /*  }}} */
示例#4
0
EAPI Ecore_X_WM_Protocol *
ecore_x_window_prop_protocol_list_get(Ecore_X_Window window,
                                      int           *num_ret)
{
   xcb_get_property_cookie_t cookie;
   xcb_get_wm_protocols_reply_t protocols;
   Ecore_X_WM_Protocol *prot_ret = NULL;
   uint32_t protos_count;
   uint32_t i;

   cookie = xcb_get_wm_protocols(_ecore_xcb_conn, window, ECORE_X_ATOM_WM_PROTOCOLS);

   if (!xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protocols, NULL))
      return NULL;

   if ((protocols.atoms_len <= 0))
      return NULL;

   prot_ret = calloc(1, protocols.atoms_len * sizeof(Ecore_X_WM_Protocol));
   if (!prot_ret)
     {
        xcb_get_wm_protocols_reply_wipe(&protocols);
        return NULL;
     }

   for (i = 0; i < protocols.atoms_len; i++)
     {
        Ecore_X_WM_Protocol j;

        prot_ret[i] = -1;
        for (j = 0; j < ECORE_X_WM_PROTOCOL_NUM; j++)
          {
             if (_ecore_xcb_atoms_wm_protocols[j] == protocols.atoms[i])
                prot_ret[i] = j;
          }
     }
   xcb_get_wm_protocols_reply_wipe(&protocols);
   *num_ret = protos_count;

   return prot_ret;
} /* ecore_x_window_prop_protocol_list_get */
示例#5
0
EAPI Ecore_X_WM_Protocol *
ecore_x_window_prop_protocol_list_get(Ecore_X_Window win,
                                      int           *num_ret)
{
#ifdef OLD_XCB_VERSION
   xcb_get_wm_protocols_reply_t protos;
#else
   xcb_icccm_get_wm_protocols_reply_t protos;
#endif
   xcb_get_property_cookie_t cookie;
   uint8_t reply;
   uint32_t count = 0, i = 0;
   Ecore_X_WM_Protocol *prot_ret = NULL;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   if (!num_ret) return NULL;

   *num_ret = 0;

#ifdef OLD_XCB_VERSION
   cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win,
                                           ECORE_X_ATOM_WM_PROTOCOLS);
   reply = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL);
#else
   cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win,
                                                 ECORE_X_ATOM_WM_PROTOCOLS);
   reply = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie,
                                            &protos, NULL);
#endif
   if (!reply) return NULL;

   count = protos.atoms_len;
   if (count <= 0)
     {
#ifdef OLD_XCB_VERSION
        xcb_get_wm_protocols_reply_wipe(&protos);
#else
        xcb_icccm_get_wm_protocols_reply_wipe(&protos);
#endif
        return NULL;
     }

   prot_ret = calloc(1, count * sizeof(Ecore_X_WM_Protocol));
   if (!prot_ret)
     {
#ifdef OLD_XCB_VERSION
        xcb_get_wm_protocols_reply_wipe(&protos);
#else
        xcb_icccm_get_wm_protocols_reply_wipe(&protos);
#endif
        return NULL;
     }

   for (i = 0; i < count; i++)
     {
        Ecore_X_WM_Protocol j;

        prot_ret[i] = -1;
        for (j = 0; j < ECORE_X_WM_PROTOCOL_NUM; j++)
          {
             if (_ecore_xcb_atoms_wm_protocol[j] == protos.atoms[i])
               prot_ret[i] = j;
          }
     }

   if (num_ret) *num_ret = count;

#ifdef OLD_XCB_VERSION
   xcb_get_wm_protocols_reply_wipe(&protos);
#else
   xcb_icccm_get_wm_protocols_reply_wipe(&protos);
#endif
   return prot_ret;
}