/** Update the list of supported protocols for a client. * \param c The client. * \param reply The xcb property reply. */ void property_update_wm_protocols(client_t *c, xcb_get_property_reply_t *reply) { xcb_icccm_get_wm_protocols_reply_t protocols; xcb_get_property_reply_t *reply_copy; if(reply) { reply_copy = p_dup(reply, 1); if(!xcb_icccm_get_wm_protocols_from_reply(reply_copy, &protocols)) { p_delete(&reply_copy); return; } } else { /* If this fails for any reason, we still got the old value */ if(!xcb_icccm_get_wm_protocols_reply(globalconf.connection, xcb_icccm_get_wm_protocols_unchecked(globalconf.connection, c->window, WM_PROTOCOLS), &protocols, NULL)) return; } xcb_icccm_get_wm_protocols_reply_wipe(&c->protocols); memcpy(&c->protocols, &protocols, sizeof(protocols)); }
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; }
bool client_is_proto_del(Client *c) { int i; bool ret = false; xcb_icccm_get_wm_protocols_reply_t proto_reply; if(xcb_icccm_get_wm_protocols_reply(conn, xcb_icccm_get_wm_protocols_unchecked(conn, c->win, WMProtocols), &proto_reply, NULL)) { for(i = 0; !ret && i < proto_reply.atoms_len; i++) { if(proto_reply.atoms[i] == WMDelete) { ret = true; } } xcb_icccm_get_wm_protocols_reply_wipe(&proto_reply); } return ret; }
static int is_proto_delete(const struct client_t *c) { xcb_get_property_cookie_t cookie; xcb_icccm_get_wm_protocols_reply_t proto; unsigned int i; cookie = xcb_icccm_get_wm_protocols_unchecked(nil_.con, c->win, nil_.atom.wm_delete); if (xcb_icccm_get_wm_protocols_reply(nil_.con, cookie, &proto, 0)) { for (i = 0; i < proto.atoms_len; i++) { if (proto.atoms[i] == nil_.atom.wm_delete) { xcb_icccm_get_wm_protocols_reply_wipe(&proto); return 1; } } xcb_icccm_get_wm_protocols_reply_wipe(&proto); } return 0; }
// === SetAsPanel() === void LXCB::SetAsPanel(WId win){ if(DEBUG){ qDebug() << "XCB: SetAsPanel()"; } if(win==0){ return; } SetDisableWMActions(win); //also need to disable WM actions for this window //Disable Input focus (panel activation ruins task manager window detection routines) // - Disable Input flag in WM_HINTS xcb_icccm_wm_hints_t hints; //qDebug() << " - Disable WM_HINTS input flag"; xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(QX11Info::connection(), win); //qDebug() << " -- got cookie"; if(1 == xcb_icccm_get_wm_hints_reply(QX11Info::connection(), cookie, &hints, NULL) ){ //qDebug() << " -- Set no inputs flag"; xcb_icccm_wm_hints_set_input(&hints, false); //set no input focus xcb_icccm_set_wm_hints(QX11Info::connection(), win, &hints); //save hints back to window } // - Remove WM_TAKE_FOCUS from the WM_PROTOCOLS for the window // - - Generate the necessary atoms //qDebug() << " - Generate WM_PROTOCOLS and WM_TAKE_FOCUS atoms"; xcb_atom_t WM_PROTOCOLS, WM_TAKE_FOCUS; //the two atoms needed xcb_intern_atom_reply_t *preply = xcb_intern_atom_reply(QX11Info::connection(), \ xcb_intern_atom(QX11Info::connection(), 0, 12, "WM_PROTOCOLS"), NULL); xcb_intern_atom_reply_t *freply = xcb_intern_atom_reply(QX11Info::connection(), \ xcb_intern_atom(QX11Info::connection(), 0, 13, "WM_TAKE_FOCUS"), NULL); bool gotatoms = false; if(preply && freply){ WM_PROTOCOLS = preply->atom; WM_TAKE_FOCUS = freply->atom; free(preply); free(freply); gotatoms = true; //qDebug() << " -- success"; } // - - Now update the protocols for the window if(gotatoms){ //requires the atoms //qDebug() << " - Get WM_PROTOCOLS"; xcb_icccm_get_wm_protocols_reply_t proto; if( 1 == xcb_icccm_get_wm_protocols_reply(QX11Info::connection(), \ xcb_icccm_get_wm_protocols_unchecked(QX11Info::connection(), win, WM_PROTOCOLS), \ &proto, NULL) ){ //Found the current protocols, see if it has the focus atom set //remove the take focus atom and re-save them bool needremove = false; //Note: This first loop is required so that we can initialize the modified list with a valid size //qDebug() << " -- Check current protocols"; for(unsigned int i=0; i<proto.atoms_len; i++){ if(proto.atoms[i] == WM_TAKE_FOCUS){ needremove = true; break;} } if(needremove){ //qDebug() << " -- Remove WM_TAKE_FOCUS protocol"; xcb_atom_t *protolist = new xcb_atom_t[proto.atoms_len-1]; int num = 0; for(unsigned int i=0; i<proto.atoms_len; i++){ if(proto.atoms[i] != WM_TAKE_FOCUS){ protolist[num] = proto.atoms[i]; num++; } } //qDebug() << " -- Re-save modified protocols"; xcb_icccm_set_wm_protocols(QX11Info::connection(), win, WM_PROTOCOLS, num, protolist); } //qDebug() << " -- Clear protocols reply"; xcb_icccm_get_wm_protocols_reply_wipe(&proto); }//end of get protocols check } //end of gotatoms check //Make sure it has the "dock" window type // - get the current window types (Not necessary, only 1 type of window needed) // - set the adjusted window type(s) //qDebug() << " - Adjust window type"; xcb_atom_t list[1]; list[0] = EWMH._NET_WM_WINDOW_TYPE_DOCK; xcb_ewmh_set_wm_window_type(&EWMH, win, 1, list); //Make sure it is on all workspaces //qDebug() << " - Set window as sticky"; SetAsSticky(win); }
xcb_get_property_cookie_t property_get_wm_protocols(client_t *c) { return xcb_icccm_get_wm_protocols_unchecked(globalconf.connection, c->window, WM_PROTOCOLS); }
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; }