Subject: Private colormaps in widget subwindows

From: [email-masked]
Date: Mon, 9 Aug 1999 06:02:27 -0500 (CDT)

Full_Name: Dr. Udo Grabowski
Version: 2.2.2
CVS_Date: --
OS: SunOS 2.5-7,Linux Suse 5.0
X_Server: Xsun (OW&X), XFree86 3.3.1
Submission from: (NULL) (141.52.25.11)

Hello !

Since the first release fvwm doesn't handle colormap installation for
subwindows in window hierarchies. Since it is needed for more and more
applications (IDL, PV-WAVE, try, e.g., xpalette), the time seems to be 
right for a patch. I've already got one from RSI Inc., written years
ago by Randy Frank, a former employee, for fvwm-1.24r. I have incorporated

it into the 2.2.2 release, and it works fine on all systems I could try 
(Sun ,Linux, Dec). Randy once posted it to the mailing list, but that was
in the early times and has been forgotten. I hope this time it will 
experience another fate, because it would help many desperate fans of
this marvelleous window manager. So here are the two patch
files (diff -c) for fvwm/events.c and fvwm/colormaps.c for 2.2.2:
################---------------- cut here ----------------################
*** events.c    Mon Aug  9 12:39:53 1999
--- events.c.new        Mon Aug  9 12:40:12 1999
***************
*** 1229,1236 ****
    }
  
    /* make sure its for one of our windows */
!   if (!Tmp_win)
      return;
  
    if(!(Tmp_win->flags & ClickToFocus))
      {
--- 1229,1241 ----
    }
  
    /* make sure its for one of our windows */
!   if (!Tmp_win) {
!   /* PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
! /* handle a subwindow cmap */
!     EnterSubWindowColormap(Event.xany.window);  
!   /* END PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
      return;
+   }
  
    if(!(Tmp_win->flags & ClickToFocus))
      {
***************
*** 1275,1281 ****
                SetBorder(Scr.Hilite,False,True,True,None);
            }
        }
!     }
  }

--- 1280,1292 ----
                SetBorder(Scr.Hilite,False,True,True,None);
            }
        }
!   /* PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
!     } else {
! /* handle a subwindow cmap */
!         LeaveSubWindowColormap(Event.xany.window); 
!    }
!   /* END PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
! 
  }
  
##############---------------- cut here ----------------###############
##############---------------- cut here ----------------###############
*** colormaps.c Mon Aug  9 12:39:59 1999
--- colormaps.c.new     Mon Aug  9 12:40:16 1999
***************
*** 244,249 ****
--- 244,256 ----
   ****************************************************************************/
  void FetchWmColormapWindows (FvwmWindow *tmp)
  {
+   /* PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
+    XWindowAttributes      getattribs;
+    XSetWindowAttributes   setattribs;
+    long int               i;
+    unsigned long          valuemask;
+   /* END PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
+ 
    if(tmp->cmap_windows != (Window *)NULL)
      XFree((void *)tmp->cmap_windows);
  
***************
*** 253,258 ****
        tmp->number_cmap_windows = 0;
        tmp->cmap_windows = NULL;
      }
  }
  
! 
--- 260,335 ----
        tmp->number_cmap_windows = 0;
        tmp->cmap_windows = NULL;
      }
+ /* PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA
+  * we need to be notified of Enter events into these subwindows 
+  * so we can set their colormaps 
+  */
+   if (tmp->number_cmap_windows != 0) {
+     for(i=0;i<tmp->number_cmap_windows;i++) {
+       XGetWindowAttributes(dpy, tmp->cmap_windows[i], &getattribs);
+       valuemask = CWEventMask;
+       setattribs.event_mask = getattribs.your_event_mask |
EnterWindowMask
+                 | LeaveWindowMask;
+       XChangeWindowAttributes(dpy,tmp->cmap_windows[i],valuemask,&setattribs);
+     }
+   }
+   /* END PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
+   return;
  }
  
! /* PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA*/
!  /*****************************************************************************
!   *
!   * Looks through the window list for any matching COLORMAP_WINDOWS
!   *   windows and installs the colormap if one exists.
!   *
!   ****************************************************************************/
!  
!  void EnterSubWindowColormap(Window win)
!  {
!    FvwmWindow         *t;
!    long int            i;
!    XWindowAttributes   attribs;
!  
!    for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) {
!      if (t->number_cmap_windows != 0) {
!        for(i=0;i<t->number_cmap_windows;i++) {
!          if (t->cmap_windows[i] == win) {
!            XGetWindowAttributes(dpy,win,&attribs);
!            XInstallColormap(dpy,attribs.colormap);
!            last_cmap = attribs.colormap;
!            return;
!          }
!        }
!      }
!    }
!    return;
!  }
!  
!  void LeaveSubWindowColormap(Window win)
!  {
!    FvwmWindow         *t;
!    long int            i;
!    int               bWinInList,bParentInList;
!  
!    for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) {
!      if (t->number_cmap_windows != 0) {
!        bWinInList = 0;
!        bParentInList = 0;
!        for(i=0;i<t->number_cmap_windows;i++) {
!          if (t->cmap_windows[i] == win)  bWinInList = 1;
!          if (t->cmap_windows[i] == t->w)  bParentInList = 1;
!        }
!        if (bWinInList) {
!          if (bParentInList) {
!          InstallWindowColormaps(t);
!         } else {
!          InstallWindowColormaps(NULL);
!          }
!          return;
!        }
!      }
!    }
!    return;
!   /* END PATCH BY RANDY FRANK, RSI INC., BOULDER, COLORADO, USA */
!  }

--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]