bool ewmh_wm_state_fullscreen(const xcb_window_t win) { const xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(cfg.ewmh, win); xcb_ewmh_get_atoms_reply_t data; if (!xcb_ewmh_get_wm_state_reply(cfg.ewmh, cookie, &data, (void *)0)) return false; bool state = false; for (unsigned short i = 0; i < data.atoms_len; i++) if ((state = data.atoms[i] == cfg.ewmh->_NET_WM_STATE_FULLSCREEN)) break; xcb_ewmh_get_atoms_reply_wipe(&data); return state; }
// === WindowIsMaximized() === bool LXCB::WindowIsMaximized(WId win){ if(DEBUG){ qDebug() << "XCB: WindowIsMaximized()"; } if(win==0){ return ""; } //See if the _NET_WM_STATE_MAXIMIZED_[VERT/HORZ] flags are set on the window xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(&EWMH, win); if(cookie.sequence == 0){ return false; } xcb_ewmh_get_atoms_reply_t states; if( 1 == xcb_ewmh_get_wm_state_reply(&EWMH, cookie, &states, NULL) ){ //Loop over the states for(unsigned int i=0; i<states.atoms_len; i++){ if(states.atoms[i] == EWMH._NET_WM_STATE_MAXIMIZED_HORZ \ || states.atoms[i] == EWMH._NET_WM_STATE_MAXIMIZED_VERT ){ return true; } } } return false; }
// === WindowState() === LXCB::WINDOWSTATE LXCB::WindowState(WId win){ if(DEBUG){ qDebug() << "XCB: WindowState()"; } if(win==0){ return IGNORE; } xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_state_unchecked(&EWMH, win); if(cookie.sequence == 0){ return IGNORE; } xcb_ewmh_get_atoms_reply_t states; WINDOWSTATE cstate = IGNORE; //First Check for special states (ATTENTION in particular); if( 1 == xcb_ewmh_get_wm_state_reply(&EWMH, cookie, &states, NULL) ){ for(unsigned int i=0; i<states.atoms_len; i++){ if(states.atoms[i] == EWMH._NET_WM_STATE_DEMANDS_ATTENTION){ cstate = ATTENTION; break; } //nothing more urgent - stop here else if(states.atoms[i] == EWMH._NET_WM_STATE_HIDDEN){ cstate = INVISIBLE; } } } //Now check to see if the window is the active one if(cstate == IGNORE){ xcb_get_property_cookie_t cookie = xcb_ewmh_get_active_window_unchecked(&EWMH, 0); xcb_window_t actwin; if(1 == xcb_ewmh_get_active_window_reply(&EWMH, cookie, &actwin, NULL) ){ if(actwin == win){ cstate = ACTIVE; } } } //Now check for ICCCM Urgency hint (not sure if this is still valid with EWMH instead) /*if(cstate == IGNORE){ xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_hints_unchecked(QX11Info::connection(), win); xcb_icccm_wm_hints_t hints; if( 1== xcb_icccm_get_wm_hints_reply(QX11Info::connection(), cookie, &hints, NULL) ){ if(xcb_icccm_wm_hints_get_urgency(hints) ){ cstate = ATTENTION; }; } }*/ //Now check for standard visible/invisible attribute (current mapping state) if(cstate == IGNORE){ xcb_get_window_attributes_cookie_t cookie = xcb_get_window_attributes(QX11Info::connection(), win); xcb_get_window_attributes_reply_t *attr = xcb_get_window_attributes_reply(QX11Info::connection(), cookie, NULL); if(attr!=0){ if(attr->map_state==XCB_MAP_STATE_VIEWABLE){ cstate = VISIBLE; } else{ cstate = INVISIBLE; } free(attr); } } return cstate; }