I have problems reading some XWindow ICCCM Properties.
The problem actually is when i try to read _NET_WM_STATUS property. The function i'm using is:
int get_property_value(Display* display, Window window,char *propname, long max_length,
unsigned long *nitems_return, unsigned char **prop_return){
int result;
Atom property;
Atom actual_type_return;
int actual_format_return;
unsigned long bytes_after_return;
unsigned char* prop_to_return;
unsigned long n_items;
printf("-----GET_PROPERTY_VALUE-------\n");
printf("\tPropname: %s\n", propname);
property = XInternAtom(display, propname, True);
if(property==None){
printf("\tWrong Atom\n");
return;
}
result = XGetWindowProperty(display, window, property, 0, /* long_offset */
(~0L), /* long_length */
False, /* delete */
AnyPropertyType, /* req_type */
&actual_type_return,
&actual_format_return,
&n_items, &bytes_after_return, &prop_to_return);
if (result != Success){
printf("\tXGetWindowProperty failed\n");
return (-1);
} else {
printf("\tActual Type: %s\n", XGetAtomName(display,property));
printf("\tProperty format: %d\n", actual_format_return);
//printf("Actual property return: %s\n", XGetAtomName(display,actual_type_return));
printf("\tByte after return: %ld\n", bytes_after_return);
printf("\tnitems return: %d\n", n_items);
printf("\tprop return: %s\n", prop_to_return);
}
printf("-----END OF GET_PROPERTY_VALUE-------\n");
return (0);
}
The get_property_value function is called after a ClientMessage is received, and this is the piece of code that handle the Event:
case ClientMessage:
printf("ClientMessage\n");
printf("Message: %s\n", XGetAtomName(display,local_event.xclient.message_type));
unsigned long nitems_return;
unsigned char *prop_return;
get_property_value(display, local_event.xclient.window, XGetAtomName(display,local_event.xclient.message_type), 256, &nitems_return, (unsigned char **)&prop_return);
break;
But when i read properties sometimes i get a property with no values, is that possible? The problem mainly is when i'm trying read AtomProperties sent from firefox (i'm trying to read the _NET_WM_STATE value) in ClientMessage Event.
As you can see from the output the property name is correctly read, but then it seems that it doesn't contains any item.
ClientMessage
Message: _NET_WM_STATE
-----GET_PROPERTY_VALUE-------
Propname: _NET_WM_STATE
Actual Type: _NET_WM_STATE
Property format: 0
Byte after return: 0
nitems return: 0
prop return: (null)
-----END OF GET_PROPERTY_VALUE-------