[comp.windows.x] patch to vtwm to display labels in virtual desktop

orest@SNOWBIRD.PICST.BELLCORE.COM (Orest Jarosiewicz) (09/02/90)

Recently a posting appeared asking for a way to display a window's
label in the virtual desktop.  With this posting I am including an unofficial
patch (that can be applied to the vtwm sources on expo) that implements
a similar feature.  With this patch vtwm writes the icon name, or if
not found, the window name in the window's tiny representation in the virtual
desktop.  The text is written using the icon font.  I find that using
a 5x8 font works well.  I have also created a small "cd" function in ksh
that after a "cd" command updates the icon name with the current directory
name.  Since these names are displayed in the tiny windows of the virtual
desktop I can now locate the windows I am interested in at a glance.

Also included in this patch is a patch published by Stuart Marks in the
xviewbugs-trackers mailing list to fix the keyboard focus problem when
running XView applications under twm.

Finally, this patch includes some code I added to implement "stay up"
menus.  After using vtwm for two days and making numerous bad selections
because of the %@#$ drag menus :-) I altered the vtwm code to provide
a SunView-like "stay up" menu capability.  When this option is turned
on the first mouse click pops up the menu, and the second mouse click
takes it down.  The option is invoked by invoking vtwm with the -StayUpMenus
option (or -S option).  Note, that unlike olwm's sticky menus, you do not
have to click on a pullright item to get its submenu, vtwm will draw
the submenus automatically.
Also note, that if stay up menus are used window prompts (like the bullet
cursor to select a window) are broken.  For the time being, to get
around this problem you can assign window operations to a menu attached to
a window's decoration, or assign window function to function keys.

Orest Jarosiewicz
Bell Communications Research
bellcore!snowbir!orest
-------------------------cut here-----------------------------
*** d.expo_vtwm/ChangeLog	Sat Sep  1 12:28:05 1990
--- d.vtwm/ChangeLog	Fri Aug 31 14:44:41 1990
***************
*** 111,113 ****
--- 111,125 ----
  	* (util.c) creation of the new bitmaps (nailed and notnailed) for
  	the titlebar.
  
+ Thu Aug 23 09:37:43 EDT 1990 - Orest Jarosiewicz (bellcore!snowbir!orest)
+ 
+ 	* Added -S (-StayUpMenus) option.  This allows users to bring
+ 	  up menus by clicking the mouse button.  The menu stays up
+ 	  until the mouse is clicked again.  This functions like SunView's
+ 	  stay up menus.
+ 
+ Fri Aug 31 14:44:50 EDT 1990 - Orest Jarosiewicz (bellcore!snowbir!orest)
+ 
+ 	* Changed the windows in the virtual desktop to display a few
+ 	  characters from the window's icon name, or the window's name if
+ 	  the icon name is not found.
*** d.expo_vtwm/desktop.c	Sat Sep  1 12:28:13 1990
--- d.vtwm/desktop.c	Fri Aug 31 10:54:59 1990
***************
*** 128,133 ****
--- 128,134 ----
  			XCreateSimpleWindow(dpy, Scr->VirtualDesktopDisplay,
  					    0, 0, 1, 1, 1,
  					    border, background);
+ 		XSelectInput(dpy, tmp_win->VirtualDesktopDisplayWindow, ExposureMask); /** Orest **/
  
  	} else
  		/* unmap whilst re reconfigure it */
*** d.expo_vtwm/events.c	Sat Sep  1 12:28:19 1990
--- d.vtwm/events.c	Fri Aug 31 14:27:43 1990
***************
*** 78,83 ****
--- 78,85 ----
  int CurrentDragX;
  int CurrentDragY;
  
+ extern short Stay_up_menus, Button_clicks; /* Orest */
+ 
  static int enter_flag;
  static int ColortableThrashing;
  static TwmWindow *enter_win, *raise_win;
***************
*** 876,881 ****
--- 878,886 ----
  	if (Scr->SortIconMgr)
  	    SortIconManager(Tmp_win->list->iconmgr);
      }
+     /** Orest - repaint the label in the virtual desktop **/
+     if(Scr->Virtual && Tmp_win -> VirtualDesktopDisplayWindow)
+     	XClearArea(dpy, Tmp_win -> VirtualDesktopDisplayWindow, 0, 0, 0, 0, True);
  
      if (Tmp_win->icon_w == NULL)
  	return;
***************
*** 1058,1063 ****
--- 1063,1096 ----
  	    }
  	} 
      }
+     
+     /** Orest - 8/31/90 - if its a window in the virtual desktop,
+      ** write the first few characters of the icon name or window name
+      ** in that window.
+      **/
+     if(Scr -> Virtual){
+     	TwmWindow *w;
+     	
+     	for(w = Scr -> TwmRoot.next; w; w = w -> next){
+     		if(w -> VirtualDesktopDisplayWindow == Event.xany.window){
+ /*    			FBF(Scr->DefaultC.fore, Scr->DefaultC.back,*/
+ /*            		Scr->DefaultFont.font->fid);*/
+ /**/
+             	FBF(w -> title.fore, w -> title.back, Scr -> IconFont.font -> fid);
+             	
+     			if(w -> icon_name)
+     				XDrawImageString(dpy, Event.xany.window, Scr -> NormalGC,
+     					0, Scr -> IconFont.height,
+     					w -> icon_name, strlen(w -> icon_name));
+     			else if(w -> name)
+     				XDrawImageString(dpy, Event.xany.window, Scr -> NormalGC,
+     					0, Scr -> IconFont.height,
+     					w -> name, strlen(w -> name));
+     			
+     			return;
+     		}
+     	}
+     }
  }
  
  static void remove_window_from_ring (tmp)
***************
*** 1414,1420 ****
  {
      int xl, xr, yt, yb, w, h;
      unsigned mask;
! 
      if (moving_window) {
  	    EndMoveWindowOnDesktop();
      }
--- 1447,1458 ----
  {
      int xl, xr, yt, yb, w, h;
      unsigned mask;
!     
!     if(ActiveMenu && Stay_up_menus){
!     	/* Handle this release only if this is the second release - Orest */
!     	if(++Button_clicks < 2) return;
!     }
!     
      if (moving_window) {
  	    EndMoveWindowOnDesktop();
      }
***************
*** 1587,1593 ****
--- 1625,1635 ----
  	center = True;
      }
      if (PopUpMenu (menu, x, y, center)) {
+     if(Stay_up_menus) Button_clicks = 0; /* Orest */
+     
+     fflush(stdout);
  	UpdateMenu();
+ 	
      } else {
  	XBell (dpy, 0);
      }
***************
*** 1608,1615 ****
      Cursor cur;
  
      /* pop down the menu, if any */
!     if (ActiveMenu != NULL)
! 	PopDownMenu();
  
      if (InfoLines) {
  	XUnmapWindow(dpy, Scr->InfoWindow);
--- 1650,1661 ----
      Cursor cur;
  
      /* pop down the menu, if any */
!     if (ActiveMenu != NULL){
!     	/* Orest - if using stay up menus just return */
!     	if(Stay_up_menus) return;
!     	
! 		PopDownMenu();
! 	}
  
      if (InfoLines) {
  	XUnmapWindow(dpy, Scr->InfoWindow);
***************
*** 1616,1622 ****
  	InfoLines = 0;
      }
      XSync(dpy, 0);			/* XXX - remove? */
! 
      if (ButtonPressed != -1)
      {
  	/* we got another butt press in addition to one still held
--- 1662,1668 ----
  	InfoLines = 0;
      }
      XSync(dpy, 0);			/* XXX - remove? */
! 	
      if (ButtonPressed != -1)
      {
  	/* we got another butt press in addition to one still held
***************
*** 1950,1956 ****
  						    &Scr->TwmRoot);
  			SetBorder (Tmp_win, True);			/* 3 */
  			if (Tmp_win->title_w && Scr->TitleFocus)	/* 4 */
! 			  SetFocus (Tmp_win);
  			if (Tmp_win->protocols & DoesWmTakeFocus)	/* 5 */
  			  SendTakeFocusMessage (Tmp_win, ewp->time);
  			Scr->Focus = Tmp_win;
--- 1996,2003 ----
  						    &Scr->TwmRoot);
  			SetBorder (Tmp_win, True);			/* 3 */
  			if (Tmp_win->title_w && Scr->TitleFocus)	/* 4 */
! 			  XSetInputFocus(dpy, Tmp_win->w, RevertToPointerRoot,
!  					ewp->time);
  			if (Tmp_win->protocols & DoesWmTakeFocus)	/* 5 */
  			  SendTakeFocusMessage (Tmp_win, ewp->time);
  			Scr->Focus = Tmp_win;
***************
*** 2101,2107 ****
  		    SetBorder (Tmp_win, False);
  		    if (Scr->TitleFocus ||
  			Tmp_win->protocols & DoesWmTakeFocus)
! 		      SetFocus ((TwmWindow *) NULL);
  		    Scr->Focus = NULL;
  		} else if (Event.xcrossing.window == Tmp_win->w &&
  				!scanArgs.enters) {
--- 2148,2155 ----
  		    SetBorder (Tmp_win, False);
  		    if (Scr->TitleFocus ||
  			Tmp_win->protocols & DoesWmTakeFocus)
! 		      XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot,
!  				     Event.xcrossing.time);
  		    Scr->Focus = NULL;
  		} else if (Event.xcrossing.window == Tmp_win->w &&
  				!scanArgs.enters) {
*** d.expo_vtwm/menus.c	Sat Sep  1 12:28:31 1990
--- d.vtwm/menus.c	Thu Aug 23 14:30:52 1990
***************
*** 81,86 ****
--- 81,92 ----
  } MenuOrigins[MAXMENUDEPTH];
  static Cursor LastCursor;
  
+ short Button_clicks;	/* Orest - keeps track of the number of clicks used when dealing
+ 					     * with a stay up menu.   The first click brings up the menu,
+ 					     * the second brings it down.
+ 					     */
+ extern short Stay_up_menus; /* Orest */
+ 
  void WarpAlongRing(), WarpToWindow();
  
  extern char *Action;
***************
*** 470,476 ****
  	    EnterWindowMask | ExposureMask, &Event))
  	{
  	    if (!DispatchEvent ()) continue;
! 	    if (Event.type == ButtonRelease || Cancel)
  		return;
  	}
  
--- 476,488 ----
  	    EnterWindowMask | ExposureMask, &Event))
  	{
  	    if (!DispatchEvent ()) continue;
! 	    
! 	    if(Event.type == ButtonRelease && Stay_up_menus && Button_clicks >= 2){
! 	    	/* Orest - remove the menu */
! 	    	return;
! 	    }
! 	    /* Orest - added && clause */
! 	    if ((Event.type == ButtonRelease && !Stay_up_menus) || Cancel)
  		return;
  	}
  
*** d.expo_vtwm/twm.c	Sat Sep  1 12:28:41 1990
--- d.vtwm/twm.c	Thu Aug 23 08:16:41 1990
***************
*** 115,120 ****
--- 115,122 ----
  
  unsigned long black, white;
  
+ short Stay_up_menus;	/* Orest Jarosiewicz - true if we want SunView style stay up menus */
+ 
  /***********************************************************************
   *
   *  Procedure:
***************
*** 162,167 ****
--- 164,172 ----
  		continue;
  	      case 'q':				/* -quiet */
  		PrintErrorMessages = False;
+ 		continue;
+ 		  case 'S':		/* Orest: -StayUpMenus */
+ 		Stay_up_menus = True;
  		continue;
  	    }
  	}
-------------------------cut here-----------------------------