Re: FVWM: Titles in fvwmpager 2.1.10...???

From: Andreas Dischinger <disching_at_fmi.uni-passau.de>
Date: Wed, 10 Feb 1999 07:57:22 +0100 (MET)

Hi Philip,

the pager only displays the icon names of the windows in its
balloons. This is a known bug in 2.1.x. Domonik toldd me, it will be
fixed in 2.2 series. If you want to fix it, apply this patch. It
although updates the manpage of the pager. Look for
FvwmPagerBalloonStringFormat and FvwmPagerWindowLabelFormat.

Andreas

--8<----------------------------------------------
diff -cr fvwm-2.1.10.orig/modules/FvwmPager/FvwmPager.1 fvwm-2.1.10/modules/FvwmPager/FvwmPager.1
*** fvwm-2.1.10.orig/modules/FvwmPager/FvwmPager.1 Sat Dec 12 02:33:14 1998
--- fvwm-2.1.10/modules/FvwmPager/FvwmPager.1 Fri Jan 22 11:07:01 1999
***************
*** 170,175 ****
--- 170,181 ----
  Change the normal/highlight colors of the windows. \fIfore\fP and
  \fIhiFore\fP specify the colors as used for the font inside the windows.
  \fIback\fP and \fIhiBack\fP are used to fill the windows with.
+
+ .IP "*FvwmPagerWindowLabelFormat \fIformat\fP"
+ This specifies a printf() like format for the labels in the mini window.
+ Possible flags are: %t, %i, %c, and %r for the window's title, icon, class,
+ or resource name, respectively. The default is "%i".
+
  .IP "*FvwmPagerLabel \fIdesk label\fP"
  Assigns the text \fIlabel\fP to desk \fIdesk\fP (or the current desk
  if desk is "*") in the pager window. Useful for assigning symbolic names
***************
*** 236,241 ****
--- 242,250 ----
  loop. Defaults to +2. The offset will change sign automatically, as needed,
  to keep the balloon on the screen.
  
+ .IP "*FvwmPagerBalloonStringFormat \fTformat\fP"
+ The same as \fI*FvwmPagerWindowLabelFormat\fP, it just specifies the string to
+ display in the balloons.
  
  .SH AUTHOR
  Robert Nation
diff -cr fvwm-2.1.10.orig/modules/FvwmPager/FvwmPager.c fvwm-2.1.10/modules/FvwmPager/FvwmPager.c
*** fvwm-2.1.10.orig/modules/FvwmPager/FvwmPager.c Sun Jan 10 22:00:03 1999
--- fvwm-2.1.10/modules/FvwmPager/FvwmPager.c Fri Jan 22 11:13:24 1999
***************
*** 70,75 ****
--- 70,76 ----
  char *WindowFore = NULL;
  char *WindowHiBack = NULL;
  char *WindowHiFore = NULL;
+ char *WindowLabelFormat = NULL;
  
  int ShowBalloons = 0, ShowPagerBalloons = 0, ShowIconBalloons = 0;
  char *BalloonTypeString = NULL;
***************
*** 77,82 ****
--- 78,84 ----
  char *BalloonFore = NULL;
  char *BalloonFont = NULL;
  char *BalloonBorderColor = NULL;
+ char *BalloonFormatString = NULL;
  int BalloonBorderWidth = 1;
  int BalloonYOffset = 2;
  
***************
*** 190,199 ****
--- 192,203 ----
  
    PagerFore = strdup("black");
    PagerBack = strdup("white");
+ WindowLabelFormat = strdup("%i");
    font_string = strdup("fixed");
    HilightC = strdup("black");
    BalloonFont = strdup("fixed");
    BalloonBorderColor = strdup("black");
+ BalloonTypeString = strdup("%i");
    Desks = (DeskInfo *)safemalloc(ndesks*sizeof(DeskInfo));
    for(i=0;i<ndesks;i++)
      {
***************
*** 236,241 ****
--- 240,248 ----
                   M_ICONIFY|
                   M_ICON_LOCATION|
                   M_DEICONIFY|
+ M_RES_NAME|
+ M_RES_CLASS|
+ M_WINDOW_NAME|
                   M_ICON_NAME|
                   M_CONFIG_INFO|
                   M_END_CONFIG_INFO|
***************
*** 326,331 ****
--- 333,343 ----
      case M_DEICONIFY:
        list_deiconify(body);
        break;
+ case M_RES_CLASS:
+ case M_RES_NAME:
+ case M_WINDOW_NAME:
+ list_window_name(body,type);
+ break;
      case M_ICON_NAME:
        list_icon_name(body);
        break;
***************
*** 394,399 ****
--- 406,415 ----
    (*prev)->icon_view_width = 0;
    (*prev)->icon_view_height = 0;
    (*prev)->icon_name = NULL;
+ (*prev)->window_name = NULL;
+ (*prev)->res_name = NULL;
+ (*prev)->res_class = NULL;
+ (*prev)->window_label = NULL;
    (*prev)->mini_icon.picture = 0;
    (*prev)->title_height = body[9];
    (*prev)->border_width = body[10];
***************
*** 812,817 ****
--- 828,868 ----
  }
  
  
+ void list_window_name(unsigned long *body,unsigned long type)
+ {
+ PagerWindow *t;
+ Window target_w;
+
+ target_w = body[0];
+ t = Start;
+ while((t!= NULL)&&(t->w != target_w))
+ {
+ t = t->next;
+ }
+ if(t!= NULL)
+ {
+ switch (type) {
+ case M_RES_CLASS:
+ if(t->res_class != NULL)
+ free(t->res_class);
+ CopyString(&t->res_class,(char *)(&body[3]));
+ break;
+ case M_RES_NAME:
+ if(t->res_name != NULL)
+ free(t->res_name);
+ CopyString(&t->res_name,(char *)(&body[3]));
+ break;
+ case M_WINDOW_NAME:
+ if(t->window_name != NULL)
+ free(t->window_name);
+ CopyString(&t->window_name,(char *)(&body[3]));
+ break;
+ }
+ LabelWindow(t);
+ LabelIconWindow(t);
+ }
+ }
+
  /***********************************************************************
   *
   * Procedure:
***************
*** 1235,1241 ****
                GetNextToken(tline2, &WindowHiBack);
              }
          }
!
  
        /* ... and get Balloon config options ...
           -- ric_at_giccs.georgetown.edu */
--- 1286,1297 ----
                GetNextToken(tline2, &WindowHiBack);
              }
          }
! else if (StrEquals(resource,"WindowLabelFormat"))
! {
! if (WindowLabelFormat)
! free(WindowLabelFormat);
! CopyString(&WindowLabelFormat,arg1);
! }
  
        /* ... and get Balloon config options ...
           -- ric_at_giccs.georgetown.edu */
***************
*** 1307,1312 ****
--- 1363,1374 ----
          {
            sscanf(arg1, "%d", &BalloonYOffset);
          }
+ else if (StrEquals(resource,"BalloonStringFormat"))
+ {
+ if (BalloonFormatString)
+ free(BalloonFormatString);
+ CopyString(&BalloonFormatString,arg1);
+ }
  
        free(resource);
        free(arg1);
diff -cr fvwm-2.1.10.orig/modules/FvwmPager/FvwmPager.h fvwm-2.1.10/modules/FvwmPager/FvwmPager.h
*** fvwm-2.1.10.orig/modules/FvwmPager/FvwmPager.h Wed Dec 9 00:40:57 1998
--- fvwm-2.1.10/modules/FvwmPager/FvwmPager.h Fri Jan 22 11:07:01 1999
***************
*** 55,60 ****
--- 55,64 ----
    Window icon_w;
    Window icon_pixmap_w;
    char *icon_name;
+ char *window_name;
+ char *res_name;
+ char *res_class;
+ char *window_label; /* This is displayed inside the mini window */
    Picture mini_icon;
    int pager_view_width;
    int pager_view_height;
***************
*** 73,78 ****
--- 77,83 ----
    Window w; /* ID of balloon window */
    PagerWindow *pw; /* pager window it's associated with */
    XFontStruct *font;
+ char *label; /* the label displayed inside the balloon */
    int height; /* height of balloon window based on font */
    int border; /* border width */
    int yoffset; /* pixels above (<0) or below (>0) pager win */
***************
*** 126,132 ****
  void list_unknown(unsigned long *body);
  void list_iconify(unsigned long *body);
  void list_deiconify(unsigned long *body);
! void list_window_name(unsigned long *body);
  void list_icon_name(unsigned long *body);
  void list_class(unsigned long *body);
  void list_res_name(unsigned long *body);
--- 131,137 ----
  void list_unknown(unsigned long *body);
  void list_iconify(unsigned long *body);
  void list_deiconify(unsigned long *body);
! void list_window_name(unsigned long *body,unsigned long type);
  void list_icon_name(unsigned long *body);
  void list_class(unsigned long *body);
  void list_res_name(unsigned long *body);
diff -cr fvwm-2.1.10.orig/modules/FvwmPager/x_pager.c fvwm-2.1.10/modules/FvwmPager/x_pager.c
*** fvwm-2.1.10.orig/modules/FvwmPager/x_pager.c Wed Jan 13 00:27:39 1999
--- fvwm-2.1.10/modules/FvwmPager/x_pager.c Fri Jan 22 11:15:25 1999
***************
*** 35,40 ****
--- 35,42 ----
  extern int StartIconic;
  extern int MiniIcons;
  extern int ShowBalloons, ShowPagerBalloons, ShowIconBalloons;
+ extern char *BalloonFormatString;
+ extern char *WindowLabelFormat;
  
  extern int icon_w, icon_h, icon_x, icon_y;
  XFontStruct *font, *windowFont;
***************
*** 80,85 ****
--- 82,89 ----
  Window icon_win; /* icon window */
  BalloonWindow balloon; /* balloon window */
  
+ static char *GetBalloonLabel(const PagerWindow *pw,const char *fmt);
+
  /***********************************************************************
   *
   * Procedure:
***************
*** 1625,1635 ****
        XChangeGC(dpy, StdGC,Globalgcm,&Globalgcv);
  
      }
    if(t->PagerView != None)
      {
        XClearWindow(dpy, t->PagerView);
        XDrawString (dpy, t->PagerView,StdGC,2,windowFont->ascent+2 ,
! t->icon_name, strlen(t->icon_name));
      }
  }
  
--- 1629,1644 ----
        XChangeGC(dpy, StdGC,Globalgcm,&Globalgcv);
  
      }
+ { /* Update the window label for this window */
+ if (t->window_label)
+ free(t->window_label);
+ t->window_label = GetBalloonLabel(t,WindowLabelFormat);
+ }
    if(t->PagerView != None)
      {
        XClearWindow(dpy, t->PagerView);
        XDrawString (dpy, t->PagerView,StdGC,2,windowFont->ascent+2 ,
! t->window_label, strlen(t->window_label));
      }
  }
  
***************
*** 1667,1675 ****
        XChangeGC(dpy,StdGC,Globalgcm,&Globalgcv);
  
      }
    XClearWindow(dpy, t->IconView);
    XDrawString (dpy, t->IconView,StdGC,2,windowFont->ascent+2 ,
! t->icon_name, strlen(t->icon_name));
  
  }
  void PictureWindow (PagerWindow *t)
--- 1676,1689 ----
        XChangeGC(dpy,StdGC,Globalgcm,&Globalgcv);
  
      }
+ { /* Update the window label for this window */
+ if (t->window_label)
+ free(t->window_label);
+ t->window_label = GetBalloonLabel(t,WindowLabelFormat);
+ }
    XClearWindow(dpy, t->IconView);
    XDrawString (dpy, t->IconView,StdGC,2,windowFont->ascent+2 ,
! t->window_label, strlen(t->window_label));
  
  }
  void PictureWindow (PagerWindow *t)
***************
*** 1924,1932 ****
    /* associate balloon with its pager window */
    balloon.pw = t;
  
! /* calculate window width to accommodate string */
! window_changes.width = 4 + XTextWidth(balloon.font, t->icon_name,
! strlen(t->icon_name));
  
    /* get x and y coords relative to pager window */
    x = (view_width / 2) - (window_changes.width / 2) - balloon.border;
--- 1938,1952 ----
    /* associate balloon with its pager window */
    balloon.pw = t;
  
! /* get the label for this balloon */
! if (balloon.label)
! free(balloon.label);
! balloon.label = GetBalloonLabel(balloon.pw,BalloonFormatString);
!
! { /* calculate window width to accommodate string */
! window_changes.width = 4 + XTextWidth(balloon.font,balloon.label,
! strlen(balloon.label));
! }
  
    /* get x and y coords relative to pager window */
    x = (view_width / 2) - (window_changes.width / 2) - balloon.border;
***************
*** 1983,1988 ****
--- 2003,2059 ----
  }
  
  
+ /* Generate the BallonLabel from the format string
+ -- disching_at_fmi.uni-passau.de */
+ char *GetBalloonLabel(const PagerWindow *pw,const char *fmt)
+ {
+ char *dest = strdup("");
+ unsigned int allocSize = 0;
+ const unsigned int enlargeSize = 32;
+ const char *pos = fmt;
+ char buffer[2];
+
+ buffer[1] = '\0';
+
+ #define INSERT(s) while (strlen(s)+strlen(dest)+1>allocSize) { \
+ dest = realloc(dest,allocSize+enlargeSize); \
+ allocSize += enlargeSize; \
+ } \
+ strcat(dest,s)
+
+ while (*pos) {
+ if (*pos=='%' && *(pos+1)!='\0') {
+ pos++;
+ switch (*pos) {
+ case 'i':
+ INSERT(pw->icon_name);
+ break;
+ case 't':
+ INSERT(pw->window_name);
+ break;
+ case 'r':
+ INSERT(pw->res_name);
+ break;
+ case 'c':
+ INSERT(pw->res_class);
+ break;
+ case '%':
+ buffer[0] = '%';
+ INSERT(buffer);
+ break;
+ default:
+ }
+ } else {
+ buffer[0] = *pos;
+ INSERT(buffer);
+ }
+ pos++;
+ }
+ #undef INSERT
+ return dest;
+ }
+
+
  /* -- ric_at_giccs.georgetown.edu */
  void UnmapBalloonWindow (void)
  {
***************
*** 2002,2006 ****
  
    XDrawString(dpy, balloon.w, BalloonGC,
                2, balloon.font->ascent,
! balloon.pw->icon_name, strlen(balloon.pw->icon_name));
  }
--- 2073,2077 ----
  
    XDrawString(dpy, balloon.w, BalloonGC,
                2, balloon.font->ascent,
! balloon.label,strlen(balloon.label));
  }
--8<----------------------------------------------
-- 
   //|       |\\
  //||       ||\\         http://degnet.de/~awd/
 //=||       ||//         email: disching_at_fmi.uni-passau.de
//  ||ndreas |//ischinger PGP-Key by finger.
Talking about my desk:
I just tell people that, as a programmer, I have an affinity for heap
storage...
--
Visit the official FVWM web page at <URL: http://fvwm.math.uh.edu/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Wed Feb 10 1999 - 02:19:37 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:38:02 BST