+void get_x11_desktop_info(Display *current_display, Atom atom)
+{
+ Window root;
+ static Atom atom_current, atom_number, atom_names;
+ struct information *current_info = &info;
+ XWindowAttributes window_attributes;
+
+ root = RootWindow(current_display, current_info->x11.monitor.current);
+
+ /* Check if we initialise else retrieve changed property */
+ if (atom == 0) {
+ atom_current = XInternAtom(current_display, "_NET_CURRENT_DESKTOP", True);
+ atom_number = XInternAtom(current_display, "_NET_NUMBER_OF_DESKTOPS", True);
+ atom_names = XInternAtom(current_display, "_NET_DESKTOP_NAMES", True);
+ get_x11_desktop_current(current_display, root, atom_current);
+ get_x11_desktop_number(current_display, root, atom_number);
+ get_x11_desktop_names(current_display, root, atom_names);
+ get_x11_desktop_current_name(current_info->x11.desktop.all_names);
+
+ /* Set the PropertyChangeMask on the root window, if not set */
+ XGetWindowAttributes(display, root, &window_attributes);
+ if (!(window_attributes.your_event_mask & PropertyChangeMask)) {
+ XSetWindowAttributes attributes;
+ attributes.event_mask = window_attributes.your_event_mask | PropertyChangeMask;
+ XChangeWindowAttributes(display, root, CWEventMask, &attributes);
+ XGetWindowAttributes(display, root, &window_attributes);
+ }
+ } else {
+ if (atom == atom_current) {
+ get_x11_desktop_current(current_display, root, atom_current);
+ get_x11_desktop_current_name(current_info->x11.desktop.all_names);
+ } else if (atom == atom_number) {
+ get_x11_desktop_number(current_display, root, atom_number);
+ } else if (atom == atom_names) {
+ get_x11_desktop_names(current_display, root, atom_names);
+ get_x11_desktop_current_name(current_info->x11.desktop.all_names);
+ }
+ }