[comp.sources.x] v04i034: rtl-wm patches, Patch1

argv@island.uu.net (Dan Heller) (06/29/89)

Submitted-by: ucbcad!cadillac.siemens.com!berman ( A. Michael Berman )
Posting-number: Volume 4, Issue 34
Archive-name: rtl-wm/patch1

[ These patches should be applied to the rtl window manager that exists
  in the windowmgrs directory under the "contrib" tree in the X11R3
  distribution.  This window manager has not been posted to comp.sources.x.
  You may or may not have 1 patch fail: menu.c has a line which looks
  like this:
	static char def_menu_font[] = "8x13bold.snf";
  Your version may not have the .snf at the end of the font.  If so, you
  will get a failed patch.  The new version should have "8x13" (no "bold"
  and no ".snf").  Edit by hand if you get a failed patch.  The following
  text comes from Michael Berman at Siemens Research --argv ]

June 6, 1989
Siemens Corporate Research

This is the first official patch to the RTL Tiled Window
Manager.  It should be applied to the source as included with
the original X11V3 distribution.  Two bugs are fixed:

1.	The font specified for the menus had the R2 name
instead of R3.  With an incorrect font name, the program
crashed or hung, depending on the environment.  (Thanks to
several people who quickly diagnosed this problem and sent patches.) 

2.	The menus would occasionally get into a "flashing"
state, where a submenu would quickly appear and disappear
repeatedly. 

NOTES: 	
1. This system does not compile properly with gcc.  Use cc. 
2. In order to show the correct patchlevel, force
recompilation of input.c  (the dependencies in the makefile
are not correct.)

Send comments, bugs, etc. to:
	rtl@siemens.com


*** ../Rel5.1/patchlevel.h	Wed Sep  7 10:07:13 1988
--- patchlevel.h	Fri Jun  2 17:21:37 1989
***************
*** 1 ****
! #define PATCHLEVEL 0
--- 1,2 ----
! /* @(#)patchlevel.h	5.2  6/2/89 */
! #define PATCHLEVEL 1
*** ../Rel5.1/track_menu.c	Wed Sep  7 10:49:05 1988
--- track_menu.c	Fri Jun  2 15:11:53 1989
***************
*** 1,5 ****
  #ifndef lint
! static char sccs_id[] = "%W%  %H%";
  #endif
  
  /*
--- 1,5 ----
  #ifndef lint
! static char sccs_id[] = "@(#)track_menu.c	5.2  6/2/89";
  #endif
  
  /*
***************
*** 38,44 ****
  #include "rtlmenuP.h"
  #include "evsaveX.h"
  
! #define CLICK_TIME 290 /* in milliseconds */
  #define CursorLockMask (ButtonReleaseMask)
  
  /* Event macros */
--- 38,44 ----
  #include "rtlmenuP.h"
  #include "evsaveX.h"
  
! #define CLICK_TIME 360 /* in milliseconds */
  #define CursorLockMask (ButtonReleaseMask)
  
  /* Event macros */
***************
*** 71,76 ****
--- 71,80 ----
       (EventType(rep) == FocusOut))
  #define KeyEvent(rep) \
      ((EventType(rep) == KeyPress) || (EventType(rep) == KeyRelease))
+ #define SelectChildX(menu, item, rep) \
+     (TestOptionFlag(menu, fixedchild)? \
+      (MenuX(menu) + ItemGetArrowPosition(item)): \
+      MIN(MenuX(menu) + ItemGetArrowPosition(item),EventXRootX(rep)))
  
  /* Possible states for the state machine */
  typedef enum
***************
*** 510,516 ****
  	/* entered item in "auto pop-up zone", i.e., over pull-right arrow. */
  	LockCursor(ItemWindow(current_item));
  	TossExtraMoves(ItemWindow(current_item));
! 	if (PushSubmenu(EventXRootX(rep)))
  	{
  	    LockCursor(ItemWindow(current_item));
  	    PlacePointer(current_menu, current_item); 
--- 514,520 ----
  	/* entered item in "auto pop-up zone", i.e., over pull-right arrow. */
  	LockCursor(ItemWindow(current_item));
  	TossExtraMoves(ItemWindow(current_item));
! 	if (PushSubmenu(SelectChildX(current_menu, current_item, rep)))
  	{
  	    LockCursor(ItemWindow(current_item));
  	    PlacePointer(current_menu, current_item); 
***************
*** 636,644 ****
  	if (NewX >= Trigger)
  	{
  	    LockCursor(ItemWindow(current_item));
! 	    childX = TestOptionFlag(current_menu, fixedchild)?
! 		(MenuX(current_menu) + ItemGetArrowPosition(current_item)):
! 		    EventXRootX(rep);
  	    Trigger = NotSet;
  	    if (PushSubmenu(childX))
  	    {
--- 640,646 ----
  	if (NewX >= Trigger)
  	{
  	    LockCursor(ItemWindow(current_item));
! 	    childX = SelectChildX(current_menu, current_item, rep);
  	    Trigger = NotSet;
  	    if (PushSubmenu(childX))
  	    {
*** ../Rel5.1/menu.c	Wed Sep  7 10:49:02 1988
--- menu.c	Mon Jun  5 10:07:54 1989
***************
*** 1,5 ****
  #ifndef lint
! static char sccs_id[] = "%W%  %H%";
  #endif
  
  /*
--- 1,5 ----
  #ifndef lint
! static char sccs_id[] = "@(#)menu.c	5.2  6/5/89";
  #endif
  
  /*
***************
*** 87,93 ****
  #define MakeEven(x) ((x%2 == 0)? x : x-1)
  #define	InvertPlane		1
  
! static char def_menu_font[] = "8x13bold.snf";
  Menu MenuDefault;
  char *MenuDefaultFont;
  static XAssocTable *menu_table;
--- 87,93 ----
  #define MakeEven(x) ((x%2 == 0)? x : x-1)
  #define	InvertPlane		1
  
! static char def_menu_font[] = "8x13";
  Menu MenuDefault;
  char *MenuDefaultFont;
  static XAssocTable *menu_table;
***************
*** 220,228 ****
      MenuDefault.menuItemPad =
  	(cp = XGetDefault(MenuDefault.display, name, "MenuPad")) ? atoi(cp) : 3;
      MenuDefault.delta = Default_Delta;
!     MenuDefaultFont =
! 	(cp = XGetDefault(MenuDefault.display, name, "MenuFont")) ?
! 	    cp : def_menu_font;
      MenuDefault.menuOptions = options;
  }
  
--- 220,231 ----
      MenuDefault.menuItemPad =
  	(cp = XGetDefault(MenuDefault.display, name, "MenuPad")) ? atoi(cp) : 3;
      MenuDefault.delta = Default_Delta;
!     /* Find a font to use -- checking for defaults */
!     cp = XGetDefault(MenuDefault.display, name, "MenuFont");
!     if (cp == NULL)
! 	cp = XGetDefault(MenuDefault.display, name, "Font");
!     MenuDefaultFont = (cp == NULL)? def_menu_font : cp;
! 
      MenuDefault.menuOptions = options;
  }
  
***************
*** 277,283 ****
      MenuScreen(menu) = screen;
  
      /* If the menu font hasn't yet been gotten, go get it. */
!     MenuFontInfo(menu) = XLoadQueryFont (display, MenuDefaultFont);
      gcValues.font = MenuFontInfo(menu)->fid;
  
      /* If the menu cursor hasn't been given, make a default one. */
--- 280,309 ----
      MenuScreen(menu) = screen;
  
      /* If the menu font hasn't yet been gotten, go get it. */
!     /* Try to open selected default font.  If that fails, check to see      */
!     /* if the one we're opening is the "fall back" default, def_menu_font-- */
!     /* if it is, exit.  Otherwise, try def_menu_font -- if that fails, exit */
!     if ((MenuFontInfo(menu) = XLoadQueryFont (display, MenuDefaultFont))
! 	 == NULL)
!     {
! 	if (!strcmp(MenuDefaultFont,def_menu_font))
! 	{
! 	    fprintf(stderr, "rtl: couldn't open font \"%s\"\n",
! 		    MenuDefaultFont);
! 	    exit(1);
! 	}
! 	else
! 	{
! 	    if ((MenuFontInfo(menu) = XLoadQueryFont (display, def_menu_font))
! 		== NULL)
! 	    {
! 		fprintf(stderr, "rtl: couldn't open font \"%s\" or \"%s\"\n",
! 			MenuDefaultFont, def_menu_font);
! 		exit(1);
! 	    }
! 	}
!     }
! 
      gcValues.font = MenuFontInfo(menu)->fid;
  
      /* If the menu cursor hasn't been given, make a default one. */
*** ../Rel5.1/tilemenu.c	Wed Sep  7 10:49:04 1988
--- tilemenu.c	Mon Jun  5 13:57:47 1989
***************
*** 1,5 ****
  #ifndef lint
! static char sccs_id[] = "%W%  %H%";
  #endif
  
  /*
--- 1,5 ----
  #ifndef lint
! static char sccs_id[] = "@(#)tilemenu.c	5.2  6/5/89";
  #endif
  
  /*
***************
*** 37,43 ****
      
  #include <X11/Xlib.h>
      
! #define DEFAULT_MENU_MASK (RTLMenuOptionsMask)0x0f
  
  extern Display *dpy;
  extern int scrn;
--- 37,43 ----
      
  #include <X11/Xlib.h>
      
! #define DEFAULT_MENU_MASK (RTLMenuOptionsMask)0x0b /* clickokay, savebits, rightoffset */
  
  extern Display *dpy;
  extern int scrn;