patch-unclutter.c - pkgsrc-localpatches - leot's pkgsrc LOCALPATCHES
 (HTM) hg clone https://bitbucket.org/iamleot/pkgsrc-localpatches
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       patch-unclutter.c
       ---
            1 
            2 Use WM_CLASS instead of WM_NAME for -not argument.
            3 
            4 --- unclutter.c.orig    1994-04-11 17:40:47.000000000 +0200
            5 +++ unclutter.c 2015-02-23 11:09:35.000000000 +0100
            6 @@ -69,7 +69,7 @@
            7  char **names;  /* -> argv list of names to avoid */
            8  
            9  /*
           10 - * return true if window has a wm_name and the start of it matches
           11 + * return true if window has a wm_class and the start of it matches
           12   * one of the given names to avoid
           13   */
           14  nameinlist(display,window)
           15 @@ -77,15 +77,20 @@
           16  Window window;
           17  {
           18      char **cpp;
           19 -    char *name;
           20 +    char *class;
           21 +    XClassHint *ch;
           22  
           23 -    if(names==0)return 0;
           24 -    if(XFetchName (display, window, &name)){
           25 +    ch = XAllocClassHint();
           26 +
           27 +    if( names==0 || ch == NULL) return 0;
           28 +    if(XGetClassHint (display, window, ch)){
           29 +       XFree(ch->res_name);
           30 +       class = ch->res_class;
           31         for(cpp = names;*cpp!=0;cpp++){
           32 -           if(strncmp(*cpp,name,strlen(*cpp))==0)
           33 +           if(strncmp(*cpp,class,strlen(*cpp))==0)
           34                 break;
           35         }
           36 -       XFree(name);
           37 +       XFree(class);
           38         return(*cpp!=0);
           39      }
           40      return 0;