Merge branch 'master' of git.omp.am:/home/omp/git/conky
authorCesare Tirabassi <norsetto@ubuntu.com>
Tue, 14 Jul 2009 16:47:00 +0000 (18:47 +0200)
committerCesare Tirabassi <norsetto@ubuntu.com>
Tue, 14 Jul 2009 16:47:00 +0000 (18:47 +0200)
1  2 
src/x11.c

diff --combined src/x11.c
+++ b/src/x11.c
@@@ -194,7 -194,6 +194,6 @@@ void set_transparent_background(Window 
  
  void destroy_window(void)
  {
-       XDestroyWindow(display, window.window);
        XFreeGC(display, window.gc);
        memset(&window, 0, sizeof(struct conky_window));
  }
@@@ -560,7 -559,7 +559,7 @@@ void create_gc(void
  }
  
  //Get current desktop number
- static inline void get_x11_desktop_current(Display *display, Window root, Atom atom)
+ static inline void get_x11_desktop_current(Display *current_display, Window root, Atom atom)
  {
          Atom actual_type;
        int actual_format;
        unsigned char *prop = NULL;
        struct information *current_info = &info;
  
-       if ( (XGetWindowProperty( display, root, atom,
+       if ( (XGetWindowProperty( current_display, root, atom,
                                  0, 1L, False, XA_CARDINAL,
                                  &actual_type, &actual_format, &nitems,
                                  &bytes_after, &prop ) == Success ) &&
  }
  
  //Get total number of available desktops
- static inline void get_x11_desktop_number(Display *display, Window root, Atom atom)
+ static inline void get_x11_desktop_number(Display *current_display, Window root, Atom atom)
  {
          Atom actual_type;
        int actual_format;
        unsigned char *prop = NULL;
        struct information *current_info = &info;
  
-       if ( (XGetWindowProperty( display, root, atom,
+       if ( (XGetWindowProperty( current_display, root, atom,
                                  0, 1L, False, XA_CARDINAL,
                                  &actual_type, &actual_format, &nitems,
                                  &bytes_after, &prop ) == Success ) &&
  }
  
  //Get all desktop names
- static inline void get_x11_desktop_names(Display *display, Window root, Atom atom)
+ static inline void get_x11_desktop_names(Display *current_display, Window root, Atom atom)
  {
          Atom actual_type;
        int actual_format;
        unsigned char *prop = NULL;
        struct information *current_info = &info;
  
-       if ( (XGetWindowProperty( display, root, atom,
+       if ( (XGetWindowProperty( current_display, root, atom,
                                  0, (~0L), False, ATOM(UTF8_STRING),
                                  &actual_type, &actual_format, &nitems,
                                  &bytes_after, &prop ) == Success ) &&
@@@ -659,41 -658,31 +658,41 @@@ static inline void get_x11_desktop_curr
        }
  }
  
- void get_x11_desktop_info(Display *display, Atom atom)
+ 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;
  
-       root = RootWindow(display, current_info->x11.monitor.current);
+       root = RootWindow(current_display, current_info->x11.monitor.current);
  
        //Check if we initialise else retrieve changed property
        if (atom == 0) {
-         atom_current = XInternAtom(display, "_NET_CURRENT_DESKTOP", True);
-         atom_number  = XInternAtom(display, "_NET_NUMBER_OF_DESKTOPS", True);
-         atom_names   = XInternAtom(display, "_NET_DESKTOP_NAMES", True);
-         get_x11_desktop_current(display, root, atom_current);
-         get_x11_desktop_number(display, root, atom_number);
-         get_x11_desktop_names(display, root, atom_names);
+         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
 +        XWindowAttributes window_attributes;
 +        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(display, root, 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(display, root, atom_number);
+           get_x11_desktop_number(current_display, root, atom_number);
          } else if (atom == atom_names) {
-           get_x11_desktop_names(display, root, atom_names);
+           get_x11_desktop_names(current_display, root, atom_names);
            get_x11_desktop_current_name(current_info->x11.desktop.all_names);
          }
        }