Re: FVWM: Patch: balloon help for Pager

From: Richard Lister <ric_at_giccs.georgetown.edu>
Date: Wed, 27 Aug 1997 00:44:45 -0400

On Tue, 26 Aug 1997 19:49:02 -0400
Richard Lister <ric_at_giccs.georgetown.edu>
wrote concerning 'FVWM: Patch: balloon help for Pager':
>
> I've only tested on Linux/X11R6 so far.

Well, that'll teach me, won't it! I just went to test it on Solaris
before going home for my tea and it blew up in my face. So its now
several hours later and I'm v hungry but I've fixed the problem.

Turns out I had done something very stupid with a pointer. Inexplicably
Linux let me get away with it, but Irix and Solaris weren't quite so
forgiving. Appropriately enough the pointer was called 'dummy' :-)

So, humble apologies for the previous broken patch, and here's a new
one, tested on Linux/X11R6, Solaris 2.5/OpenWindows, and Irix 6.3.

For some reason the diff I made doesn't work with either Solaris or
GNU patch on my Sun box, though it's fine on Linux and SGI. Tried
both unified and context diffs. Any patch gurus out there with ideas?
Meantime, if you have trouble, get the tarball off the web:

    http://www.giccs.georgetown.edu/~ric/software/fvwm/pager.html


Right, following that egg on my face I'm off for some egg on toast for
my tea.

Ric

Richard J Lister, Georgetown Institute for Cognitive and Computational Sciences
Georgetown University Medical Center, Washington, DC.
Phone: 202-687 2878
Email: ric_at_giccs.georgetown.edu
Web: http://www.giccs.georgetown.edu/


------------------------------cut here-----------------------------------
diff -rc modules/FvwmPager.orig/FvwmPager.c modules/FvwmPager/FvwmPager.c
*** modules/FvwmPager.orig/FvwmPager.c Tue Aug 26 18:46:54 1997
--- modules/FvwmPager/FvwmPager.c Tue Aug 26 18:55:02 1997
***************
*** 68,73 ****
--- 68,78 ----
  char *WindowHiBack = NULL;
  char *WindowHiFore = NULL;
  
+ int ShowBalloons = 0;
+ char *BalloonBack = NULL;
+ char *BalloonFore = NULL;
+ char *BalloonFont = "fixed";
+
  int window_w=0, window_h=0, window_x=0, window_y=0;
  int icon_x=-10000, icon_y=-10000, icon_w=0, icon_h=0;
  int usposition = 0,uselabel = 1;
***************
*** 1060,1065 ****
--- 1065,1100 ----
                          colors = GetNextToken (colors, &WindowHiBack);
                  }
          }
+
+
+ /* ... and get Balloon config options ...
+ -- ric_at_giccs.georgetown.edu */
+ else if ( (strlen(&tline[0]) > 1) &&
+ (strncasecmp (tline, CatString3 ("*", MyName, "Balloons"),
+ Clength + 9) == 0) ) {
+ ShowBalloons = 1;
+ }
+
+ else if ( (strlen(&tline[0]) > 1) &&
+ (strncasecmp (tline, CatString3 ("*", MyName, "BalloonBack"),
+ Clength + 12) == 0) ) {
+ if (Scr.d_depth > 1)
+ CopyString(&BalloonBack, &tline[Clength+12]);
+ }
+
+ else if ( (strlen(&tline[0]) > 1) &&
+ (strncasecmp (tline, CatString3 ("*", MyName, "BalloonFore"),
+ Clength + 12) == 0) ) {
+ if (Scr.d_depth > 1)
+ CopyString(&BalloonFore, &tline[Clength+12]);
+ }
+
+ else if ( (strlen(&tline[0]) > 1) &&
+ (strncasecmp (tline, CatString3 ("*", MyName, "BalloonFont"),
+ Clength + 12) == 0) ) {
+ CopyString(&BalloonFont, &tline[Clength+12]);
+ }
+
        GetConfigLine(fd,&tline);
      }
    return;
diff -rc modules/FvwmPager.orig/FvwmPager.h modules/FvwmPager/FvwmPager.h
*** modules/FvwmPager.orig/FvwmPager.h Tue Aug 26 18:46:55 1997
--- modules/FvwmPager/FvwmPager.h Tue Aug 26 18:55:02 1997
***************
*** 68,73 ****
--- 68,81 ----
  } PagerWindow;
  
  
+ typedef struct balloon_window
+ {
+ Window w; /* ID of balloon window */
+ PagerWindow *pw; /* pager window it's associated with */
+ XFontStruct *font;
+ } BalloonWindow;
+
+
  typedef struct desk_info
  {
    Window w;
***************
*** 144,149 ****
--- 152,161 ----
  void IconMoveWindow(XEvent *Event,PagerWindow *t);
  void HandleExpose(XEvent *Event);
  void MoveStickyWindows(void);
+ void MapBalloonWindow(XEvent *);
+ void UnmapBalloonWindow(void);
+ void DrawInBalloonWindow(void);
+
  #ifdef BROKEN_SUN_HEADERS
  #include "../../fvwm/sun_headers.h"
  #endif
diff -rc modules/FvwmPager.orig/FvwmPager.man modules/FvwmPager/FvwmPager.man
*** modules/FvwmPager.orig/FvwmPager.man Tue Aug 26 18:46:55 1997
--- modules/FvwmPager/FvwmPager.man Tue Aug 26 18:55:02 1997
***************
*** 181,190 ****
  Allow the pager to display a window's mini icon in the pager, if it has
  one, instead of showing the window's name.
  
  .SH AUTHOR
  Robert Nation
  .br
  DeskColor patch contributed by Alan Wild
  .br
  MiniIcons and WindowColors patch contributed by Rob Whapham
!
--- 181,208 ----
  Allow the pager to display a window's mini icon in the pager, if it has
  one, instead of showing the window's name.
  
+ .IP "*FvwmPagerBalloons"
+ Show a balloon describing the window when the pointer is moved into
+ a window in the pager. Currently only the window's icon name is shown.
+ Note that balloons are not shown for the iconified pager.
+
+ .IP "*FvwmPagerBalloonFore \fIcolor\fP"
+ Specifies the color for text in the balloon window. If omitted it
+ defaults to the foreground color for the window being described.
+
+ .IP "*FvwmPagerBalloonBack \fIcolor\fP"
+ Specifies the background color for the balloon window. If omitted it
+ defaults to the background color for the window being described.
+
+ .IP "*FvwmPagerBalloonFont \fIfont-name\fP"
+ Specifies a font to use for the balloon text.
+
+
  .SH AUTHOR
  Robert Nation
  .br
  DeskColor patch contributed by Alan Wild
  .br
  MiniIcons and WindowColors patch contributed by Rob Whapham
! .br
! Balloons patch contributed by Ric Lister <ric_at_giccs.georgetown.edu>
diff -rc modules/FvwmPager.orig/x_pager.c modules/FvwmPager/x_pager.c
*** modules/FvwmPager.orig/x_pager.c Tue Aug 26 18:46:55 1997
--- modules/FvwmPager/x_pager.c Tue Aug 26 23:50:36 1997
***************
*** 33,44 ****
--- 33,47 ----
  extern int window_w, window_h,window_x,window_y,usposition,uselabel,xneg,yneg;
  extern int StartIconic;
  extern int MiniIcons;
+ extern int ShowBalloons;
+
  extern int icon_w, icon_h, icon_x, icon_y;
  XFontStruct *font, *windowFont;
  
  GC NormalGC,DashedGC,HiliteGC,rvGC;
  GC StdGC;
  GC MiniIconGC;
+ GC BalloonGC;
  
  extern PagerWindow *Start;
  extern PagerWindow *FocusWin;
***************
*** 74,79 ****
--- 77,83 ----
  
  
  Window icon_win; /* icon window */
+ BalloonWindow balloon; /* balloon window */
  
  /***********************************************************************
   *
***************
*** 107,112 ****
--- 111,117 ----
    XSetWindowAttributes attributes;
    extern char *PagerFore, *PagerBack, *HilightC;
    extern char *WindowBack, *WindowFore, *WindowHiBack, *WindowHiFore;
+ extern char *BalloonFore, *BalloonBack, *BalloonFont;
    extern char *font_string, *smallFont;
    int n,m,w,h,i,x,y;
    XGCValues gcv;
***************
*** 402,407 ****
--- 407,456 ----
    gcv.background = back_pix;
    gcv.line_style = LineOnOffDash;
    DashedGC = XCreateGC(dpy, Scr.Root, gcm, &gcv);
+
+
+ /* create balloon window
+ -- ric_at_giccs.georgetown.edu */
+ if ( ShowBalloons ) {
+
+ /* tell WM to ignore this window */
+ attributes.override_redirect = True;
+
+ attributes.event_mask = ExposureMask;
+
+ /* if given in config set this now, otherwise it'll be set for each
+ pager window when drawn later */
+ attributes.background_pixel =
+ (BalloonBack == NULL) ? 0 : GetColor(BalloonBack);
+
+ /* get font for balloon */
+ if ( (balloon.font = XLoadQueryFont(dpy, BalloonFont)) == NULL ) {
+ if ( (balloon.font = XLoadQueryFont(dpy, "fixed")) == NULL ) {
+ fprintf(stderr,"%s: No fonts available.\n", MyName);
+ exit(1);
+ }
+ fprintf(stderr, "%s: Can't find font '%s', using fixed.\n",
+ MyName, BalloonFont);
+ }
+
+ balloon.w = XCreateWindow(dpy, Scr.Root,
+ 0, 0, /* coords set later */
+ 1, /* width set later */
+ balloon.font->ascent + balloon.font->descent + 1,
+ 1, /* border */
+ CopyFromParent,
+ InputOutput,
+ CopyFromParent,
+ CWOverrideRedirect | CWEventMask | CWBackPixel,
+ &attributes);
+
+ /* make gc for balloon */
+ gcv.font = balloon.font->fid;
+
+ BalloonGC = XCreateGC(dpy, balloon.w,
+ GCFont,
+ &gcv);
+ } /* ShowBalloons */
  }
  
  
***************
*** 449,454 ****
--- 498,511 ----
  
    switch(Event->xany.type)
      {
+ case EnterNotify:
+ if ( ShowBalloons )
+ MapBalloonWindow(Event);
+ break;
+ case LeaveNotify:
+ if ( ShowBalloons )
+ UnmapBalloonWindow();
+ break;
      case ConfigureNotify:
        ReConfigure();
        break;
***************
*** 556,561 ****
--- 613,624 ----
    int i;
    PagerWindow *t;
  
+ /* ric_at_giccs.georgetown.edu */
+ if ( Event->xany.window == balloon.w ) {
+ DrawInBalloonWindow();
+ return;
+ }
+
    for(i=0;i<ndesks;i++)
      {
        if((Event->xany.window == Desks[i].w)
***************
*** 953,958 ****
--- 1016,1025 ----
    attributes.border_pixel = fore_pix;
    attributes.event_mask = (ExposureMask);
  
+ /* ric_at_giccs.georgetown.edu -- added Enter and Leave events for
+ popping up balloon window */
+ attributes.event_mask = (ExposureMask | EnterWindowMask | LeaveWindowMask);
+
    if((i >= 0)&& (i <ndesks))
      {
        t->PagerView = XCreateWindow(dpy,Desks[i].w, x, y, w, h,1,
***************
*** 1804,1807 ****
--- 1871,1942 ----
          XSetInputFocus (dpy, t->w, RevertToParent, Event->xbutton.time);
      }
  
+ }
+
+
+ /* Just maps window ... draw stuff in it later after Expose event
+ -- ric_at_giccs.georgetown.edu */
+ void MapBalloonWindow (XEvent *event)
+ {
+ PagerWindow *t;
+ Window dummy;
+ XWindowChanges window_changes;
+ extern char *BalloonBack;
+
+ /* is this the best way to match X event window ID to PagerWindow ID? */
+ t = Start;
+
+ while ( (t != NULL) && (t->PagerView != event->xcrossing.window) )
+ t = t->next;
+
+ if (t == NULL)
+ return;
+
+ /* associate balloon with its pager window */
+ balloon.pw = t;
+
+ /* balloon is a top-level window, therefore need to
+ translate pager window coords to root window coords */
+ XTranslateCoordinates(dpy, t->PagerView, Scr.Root,
+ t->pager_view_width / 2,
+ t->pager_view_height + 5,
+ &window_changes.x, &window_changes.y,
+ &dummy);
+
+ /* change window width to accomodate string */
+ window_changes.width = 4 + XTextWidth(balloon.font, t->icon_name,
+ strlen(t->icon_name));
+ XConfigureWindow(dpy, balloon.w,
+ CWX | CWY | CWWidth,
+ &window_changes);
+
+ /* if background not set in config make it match pager window */
+ if ( BalloonBack == NULL )
+ XSetWindowBackground(dpy, balloon.w, t->back);
+
+
+ XMapRaised(dpy, balloon.w);
+ }
+
+
+ /* -- ric_at_giccs.georgetown.edu */
+ void UnmapBalloonWindow (void)
+ {
+ XUnmapWindow(dpy, balloon.w);
+ }
+
+
+ /* Draws string in balloon window -- call after it's received Expose event
+ -- ric_at_giccs.georgetown.edu */
+ void DrawInBalloonWindow (void)
+ {
+ extern char *BalloonFore;
+
+ /* if foreground not set in config make it match pager window */
+ if ( BalloonFore == NULL )
+ XSetForeground(dpy, BalloonGC, balloon.pw->text);
+
+ XDrawString(dpy, balloon.w, BalloonGC,
+ 2, balloon.font->ascent,
+ balloon.pw->icon_name, strlen(balloon.pw->icon_name));
  }
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
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 Tue Aug 26 1997 - 23:43:59 BST

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