+void create_gc(void)
+{
+ XGCValues values;
+
+ values.graphics_exposures = 0;
+ values.function = GXcopy;
+ window.gc = XCreateGC(display, window.drawable,
+ GCFunction | GCGraphicsExposures, &values);
+ window.gc_back = XCreateGC(display, window.drawable,
+ GCFunction | GCGraphicsExposures, &values);
+}
+
+//Get current desktop number
+static inline void get_x11_desktop_current(Display *current_display, Window root, Atom atom)
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop = NULL;
+ struct information *current_info = &info;
+
+ if (atom == None) return;
+
+ if ( (XGetWindowProperty( current_display, root, atom,
+ 0, 1L, False, XA_CARDINAL,
+ &actual_type, &actual_format, &nitems,
+ &bytes_after, &prop ) == Success ) &&
+ (actual_type == XA_CARDINAL) &&
+ (nitems == 1L) && (actual_format == 32) ) {
+ current_info->x11.desktop.current = prop[0]+1;
+ }
+ if(prop) {
+ XFree(prop);
+ }
+}
+
+//Get total number of available desktops
+static inline void get_x11_desktop_number(Display *current_display, Window root, Atom atom)
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop = NULL;
+ struct information *current_info = &info;
+
+ if (atom == None) return;
+
+ if ( (XGetWindowProperty( current_display, root, atom,
+ 0, 1L, False, XA_CARDINAL,
+ &actual_type, &actual_format, &nitems,
+ &bytes_after, &prop ) == Success ) &&
+ (actual_type == XA_CARDINAL) &&
+ (nitems == 1L) && (actual_format == 32) ) {
+ current_info->x11.desktop.number = prop[0];
+ }
+ if(prop) {
+ XFree(prop);
+ }
+}
+
+//Get all desktop names
+static inline void get_x11_desktop_names(Display *current_display, Window root, Atom atom)
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop = NULL;
+ struct information *current_info = &info;
+
+ if (atom == None) return;
+
+ if ( (XGetWindowProperty( current_display, root, atom,
+ 0, (~0L), False, ATOM(UTF8_STRING),
+ &actual_type, &actual_format, &nitems,
+ &bytes_after, &prop ) == Success ) &&
+ (actual_type == ATOM(UTF8_STRING)) &&
+ (nitems > 0L) && (actual_format == 8) ) {
+
+ if(current_info->x11.desktop.all_names) {
+ free(current_info->x11.desktop.all_names);
+ current_info->x11.desktop.all_names = NULL;
+ }
+ current_info->x11.desktop.all_names = malloc(nitems*sizeof(char));
+ memcpy(current_info->x11.desktop.all_names, prop, nitems);
+ current_info->x11.desktop.nitems = nitems;
+ }
+ if(prop) {
+ XFree(prop);
+ }
+}
+
+//Get current desktop name
+static inline void get_x11_desktop_current_name(char *names)