The code in question is similar to this SO topic: Get X11 window caption height. The link points to answer with Xlib
code. The idea is to get window properties, _NET_FRAME_EXTENTS
namely. The code waits untill the window manager will set the decoration sizes. The code in the answer skips all events till the property returned.
Basically I do the same with XCB
. I want to know the decoration sizes of a window that I had just created. The pseudocode what I do with XCB
:
cookie = xcb_get_property(...)
reply = xcb_get_property_reply(..., cookie, ...)
if(NULL == reply){
/* fail */
}
if(reply->type != type){
/* fail */
}
prop_size = xcb_get_property_value_length(reply);
prop_val = xcb_get_property_value (reply);
if(0 == prop_size){
/* fail */
}
if(/* not failed */){
copy returned data here
print and return success.
}
if(/* failed */)
then wait for events and skip them
repeat the above untill success
The problem is that sometimes values being returned as zeros, and sometimes the values are correct. As you can see from above code, the success condition is only when the type match and there is some data that are read. The request is checked with cookie so, as I understand, the reply belongs to the request. I do map the window and flush events before I call the above code.
The question is, how to get WM decorations properly with XCB
?
question from:
https://stackoverflow.com/questions/65540910/x11-net-frame-extents-window-property-not-consistent-return-with-xcb 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…