[comp.windows.x] Virtual Screens for tvtwm

roman@sparc7.hri.com (Roman Budzianowski) (09/05/90)

I've added a simple Virtual Screen feature to tvtwm. In the .twmrc you put:

VScreens
{
  "news" 1200 0
  "mail" 1200 900
  "home" 0 0
}

and bind a button to the menu : f.menu "VirtualScreens".

It provides a primitive "rooms-like" feel, and it's easier than
scrolling (more accurate).


Here are the diffs if you are interested :

diff -c tvtwm/gram.y tvtwm.orig/gram.y
*** tvtwm/gram.y	Fri Aug 31 17:04:08 1990
--- tvtwm.orig/gram.y	Thu Aug 30 09:18:00 1990
***************
*** 53,59 ****
  static MenuRoot	*root, *pull = NULL;
  
  static MenuRoot *GetRoot();
! static Bool AddVScreen();
  static Bool CheckWarpScreenArg(), CheckWarpRingArg();
  static Bool CheckColormapArg();
  static void GotButton(), GotKey(), GotTitleButton();
--- 53,59 ----
  static MenuRoot	*root, *pull = NULL;
  
  static MenuRoot *GetRoot();
! 
  static Bool CheckWarpScreenArg(), CheckWarpRingArg();
  static Bool CheckColormapArg();
  static void GotButton(), GotKey(), GotTitleButton();
***************
*** 80,86 ****
  %token <num> ALL OR CURSORS PIXMAPS ICONS COLOR MONOCHROME FUNCTION 
  %token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS
  %token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE
! %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING STICKY VSCREENS
  %token <num> NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION 
  %token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME 
  %token <num> COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE
--- 80,86 ----
  %token <num> ALL OR CURSORS PIXMAPS ICONS COLOR MONOCHROME FUNCTION 
  %token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS
  %token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE
! %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING STICKY
  %token <num> NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION 
  %token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME 
  %token <num> COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE
***************
*** 195,202 ****
  		  win_list
  		| STICKY		{ list = &Scr->StickyL; }
  		  win_list
- 		| VSCREENS		{ list = &Scr->VScreens; }
- 		  vscreen_list
  		| MENU string LP string COLON string RP	{
  					root = GetRoot($2, $4, $6); }
  		  menu			{ root->real_menu = TRUE;}
--- 195,200 ----
***************
*** 398,410 ****
  			NewFontCursor(&Scr->DestroyCursor, $2); }
  		;
  
- vscreen_list    : LB vscreen_entries RB 
-                 ;
- vscreen_entries	: /* Empty */
- 		| vscreen_entries vscreen_entry
- 		;
- vscreen_entry   : string number number  { AddVScreen(list,$1,$2,$3); }
- 
  color_list	: LB color_entries RB
  		;
  
--- 396,401 ----
***************
*** 847,863 ****
      return False;
  }
  
! static Bool AddVScreen(l,s,x,y)
!      name_list**    l;
!      register char* s;
!      register int   x,y;
! {
!   XPoint *pt = (XPoint*)malloc(sizeof(XPoint));
!   pt->x=x; pt->y=y;
!   AddToList(list,s,(char*)pt);
!   return True;
! }
! 				       
  twmrc_error_prefix ()
  {
      fprintf (stderr, "%s:  line %d:  ", ProgramName, yylineno);
--- 838,844 ----
      return False;
  }
  
! 
  twmrc_error_prefix ()
  {
      fprintf (stderr, "%s:  line %d:  ", ProgramName, yylineno);

diff -c tvtwm/menus.c tvtwm.orig/menus.c
*** tvtwm/menus.c	Fri Aug 31 18:11:26 1990
--- tvtwm.orig/menus.c	Thu Aug 30 09:18:02 1990
***************
*** 136,173 ****
  /***********************************************************************
   *
   *  Procedure:
-  *	InitVScreensMenu - initialize vscreens menu 
-  *
-  ***********************************************************************
-  */
- void InitVScreensMenu(menu)
-      MenuRoot *menu;
- {
-    static Bool inited=False;
-    name_list *nl = Scr->VScreens;
- 
-    if(inited)
-      return;
- 
-    menu->first = NULL;
-    menu->last = NULL;
-    menu->items = 0;
-    menu->width = 0;
-    menu->mapped = NEVER_MAPPED;
- 
-    AddToMenu(menu, "Virtual Screens", NULLSTR, NULL,
F_TITLE,NULLSTR,NULLSTR);
- 
-    while(nl){
-       AddToMenu(menu, nl->name, nl->ptr, NULL, F_SCROLLTOVSCREEN,
- 		NULLSTR, NULLSTR);
-       nl = nl->next;
-    }
-    MakeMenu(menu);
- }
- 
- /***********************************************************************
-  *
-  *  Procedure:
   *	AddFuncKey - add a function key to the list
   *
   *  Inputs:
--- 136,141 ----
***************
*** 653,661 ****
      if (strcmp(name, TWM_WINDOWS) == 0)
  	Scr->Windows = tmp;
  
-     if (strcmp(name, TWM_VSCREENS) == 0)
- 	Scr->VScreensMenu = tmp;
- 
      return (tmp);
  }
  
--- 621,626 ----
***************
*** 996,1005 ****
  	MakeMenu(menu);
      }
  
-     if (menu == Scr->VScreensMenu)
-       InitVScreensMenu(menu);
- 
- 
      if (menu->w == None || menu->items == 0) return False;
  
      /* Prevent recursively bringing up menus. */
--- 961,966 ----
***************
*** 1229,1240 ****
  	ScrollDesktop(func);
  	break;
  
-     case F_SCROLLTOVSCREEN:
- 	{
- 	   XPoint* pt = (XPoint*)action;
- 	   MoveDesktop(pt->x,pt->y);
- 	   break;
- 	}
      case F_DELTASTOP:
  	if (WindowMoved) do_next_action = FALSE;
  	break;
--- 1190,1195 ----
diff -c tvtwm/menus.h tvtwm.orig/menus.h
*** tvtwm/menus.h	Fri Aug 31 14:53:08 1990
--- tvtwm.orig/menus.h	Thu Aug 30 09:18:02 1990
***************
*** 41,47 ****
  
  #define TWM_ROOT	"bLoB_GoOp"	/* my private root menu */
  #define TWM_WINDOWS	"TwmWindows"	/* for f.menu "TwmWindows" */
- #define TWM_VSCREENS    "VirtualScreens" /* for f.menu "VirtualScreens" */
  
  #define MAX_FILE_SIZE 4096	/* max chars to read from file for cut */
  
--- 41,46 ----

diff -c tvtwm/parse.c tvtwm.orig/parse.c
*** tvtwm/parse.c	Fri Aug 31 14:27:54 1990
--- tvtwm.orig/parse.c	Thu Aug 30 09:18:02 1990
***************
*** 599,605 ****
      { "virtualdesktopbackgroundpixmap",SKEYWORD,
  				    kws_VirtualDesktopBackgroundPixmap },
      { "virtualdesktopforeground",CKEYWORD, kwc_VirtualDesktopForeground },
-     { "vscreens",               VSCREENS, 0},
      { "w",			WINDOW, 0 },
      { "wait",			WAIT, 0 },
      { "warpcursor",		WARP_CURSOR, 0 },
--- 599,604 ----
diff -c tvtwm/parse.h tvtwm.orig/parse.h
*** tvtwm/parse.h	Fri Aug 31 18:04:44 1990
--- tvtwm.orig/parse.h	Thu Aug 30 09:18:03 1990
***************
*** 108,115 ****
  #define F_FUNCTION		108	/* string */
  #define F_WARPTOSCREEN		109	/* string */
  #define F_COLORMAP		110	/* string */
- #define F_SCROLLTOVSCREEN	111	/* string */
- 
  
  #define D_NORTH			1
  #define D_SOUTH			2
--- 108,113 ----

diff -c tvtwm/screen.h tvtwm.orig/screen.h
*** tvtwm/screen.h	Fri Aug 31 16:01:56 1990
--- tvtwm.orig/screen.h	Thu Aug 30 09:18:03 1990
***************
*** 79,85 ****
      int vdtPositionX;		/* where the virtual desktop is currently
positioned */
      int vdtPositionY;		/* where the virtual desktop is currently
positioned */
  
-     name_list *VScreens;	/* virtual screens in the desktop */
      name_list *Icons;		/* list of icon pixmaps */
      TitlebarPixmaps tbpm;	/* titlebar pixmaps */
      Pixmap UnknownPm;		/* the unknown icon pixmap */
--- 79,84 ----
***************
*** 92,98 ****
      MenuRoot *MenuList;		/* head of the menu list */
      MenuRoot *LastMenu;		/* the last menu (mostly unused?) */
      MenuRoot *Windows;		/* the TwmWindows menu */
!     MenuRoot *VScreensMenu;      /* the VirtualScreens menu */
      TwmWindow *Ring;		/* one of the windows in window ring */
      TwmWindow *RingLeader;	/* current winodw in ring */
  
--- 91,97 ----
      MenuRoot *MenuList;		/* head of the menu list */
      MenuRoot *LastMenu;		/* the last menu (mostly unused?) */
      MenuRoot *Windows;		/* the TwmWindows menu */
! 
      TwmWindow *Ring;		/* one of the windows in window ring */
      TwmWindow *RingLeader;	/* current winodw in ring */
  

roman@sparc7.hri.com (Roman Budzianowski) (09/05/90)

I've added a simple Virtual Screen feature to tvtwm. In the .twmrc you put:

VScreens
{
  "news" 1200 0
  "mail" 1200 900
  "home" 0 0
}

and bind a button to the menu : f.menu "VirtualScreens".

It provides a primitive "rooms-like" feel, and it's easier than
scrolling (more accurate).
Starting clients (say in .xinitrc)  with virtual geometry works (xterm
-geometry +1300+20
will place the window in the "news" screen).

Here are the diffs if you are interested :

diff -c tvtwm/gram.y tvtwm.orig/gram.y
*** tvtwm/gram.y	Fri Aug 31 17:04:08 1990
--- tvtwm.orig/gram.y	Thu Aug 30 09:18:00 1990
***************
*** 53,59 ****
  static MenuRoot	*root, *pull = NULL;
  
  static MenuRoot *GetRoot();
! static Bool AddVScreen();
  static Bool CheckWarpScreenArg(), CheckWarpRingArg();
  static Bool CheckColormapArg();
  static void GotButton(), GotKey(), GotTitleButton();
--- 53,59 ----
  static MenuRoot	*root, *pull = NULL;
  
  static MenuRoot *GetRoot();
! 
  static Bool CheckWarpScreenArg(), CheckWarpRingArg();
  static Bool CheckColormapArg();
  static void GotButton(), GotKey(), GotTitleButton();
***************
*** 80,86 ****
  %token <num> ALL OR CURSORS PIXMAPS ICONS COLOR MONOCHROME FUNCTION 
  %token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS
  %token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE
! %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING STICKY VSCREENS
  %token <num> NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION 
  %token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME 
  %token <num> COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE
--- 80,86 ----
  %token <num> ALL OR CURSORS PIXMAPS ICONS COLOR MONOCHROME FUNCTION 
  %token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS
  %token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE
! %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING STICKY
  %token <num> NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION 
  %token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME 
  %token <num> COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE
***************
*** 195,202 ****
  		  win_list
  		| STICKY		{ list = &Scr->StickyL; }
  		  win_list
- 		| VSCREENS		{ list = &Scr->VScreens; }
- 		  vscreen_list
  		| MENU string LP string COLON string RP	{
  					root = GetRoot($2, $4, $6); }
  		  menu			{ root->real_menu = TRUE;}
--- 195,200 ----
***************
*** 398,410 ****
  			NewFontCursor(&Scr->DestroyCursor, $2); }
  		;
  
- vscreen_list    : LB vscreen_entries RB 
-                 ;
- vscreen_entries	: /* Empty */
- 		| vscreen_entries vscreen_entry
- 		;
- vscreen_entry   : string number number  { AddVScreen(list,$1,$2,$3); }
- 
  color_list	: LB color_entries RB
  		;
  
--- 396,401 ----
***************
*** 847,863 ****
      return False;
  }
  
! static Bool AddVScreen(l,s,x,y)
!      name_list**    l;
!      register char* s;
!      register int   x,y;
! {
!   XPoint *pt = (XPoint*)malloc(sizeof(XPoint));
!   pt->x=x; pt->y=y;
!   AddToList(list,s,(char*)pt);
!   return True;
! }
! 				       
  twmrc_error_prefix ()
  {
      fprintf (stderr, "%s:  line %d:  ", ProgramName, yylineno);
--- 838,844 ----
      return False;
  }
  
! 
  twmrc_error_prefix ()
  {
      fprintf (stderr, "%s:  line %d:  ", ProgramName, yylineno);
diff -c tvtwm/menus.c tvtwm.orig/menus.c
*** tvtwm/menus.c	Fri Aug 31 18:11:26 1990
--- tvtwm.orig/menus.c	Thu Aug 30 09:18:02 1990
***************
*** 136,173 ****
  /***********************************************************************
   *
   *  Procedure:
-  *	InitVScreensMenu - initialize vscreens menu 
-  *
-  ***********************************************************************
-  */
- void InitVScreensMenu(menu)
-      MenuRoot *menu;
- {
-    static Bool inited=False;
-    name_list *nl = Scr->VScreens;
- 
-    if(inited)
-      return;
- 
-    menu->first = NULL;
-    menu->last = NULL;
-    menu->items = 0;
-    menu->width = 0;
-    menu->mapped = NEVER_MAPPED;
- 
-    AddToMenu(menu, "Virtual Screens", NULLSTR, NULL,
F_TITLE,NULLSTR,NULLSTR);
- 
-    while(nl){
-       AddToMenu(menu, nl->name, nl->ptr, NULL, F_SCROLLTOVSCREEN,
- 		NULLSTR, NULLSTR);
-       nl = nl->next;
-    }
-    MakeMenu(menu);
- }
- 
- /***********************************************************************
-  *
-  *  Procedure:
   *	AddFuncKey - add a function key to the list
   *
   *  Inputs:
--- 136,141 ----
***************
*** 653,661 ****
      if (strcmp(name, TWM_WINDOWS) == 0)
  	Scr->Windows = tmp;
  
-     if (strcmp(name, TWM_VSCREENS) == 0)
- 	Scr->VScreensMenu = tmp;
- 
      return (tmp);
  }
  
--- 621,626 ----
***************
*** 996,1005 ****
  	MakeMenu(menu);
      }
  
-     if (menu == Scr->VScreensMenu)
-       InitVScreensMenu(menu);
- 
- 
      if (menu->w == None || menu->items == 0) return False;
  
      /* Prevent recursively bringing up menus. */
--- 961,966 ----
***************
*** 1229,1240 ****
  	ScrollDesktop(func);
  	break;
  
-     case F_SCROLLTOVSCREEN:
- 	{
- 	   XPoint* pt = (XPoint*)action;
- 	   MoveDesktop(pt->x,pt->y);
- 	   break;
- 	}
      case F_DELTASTOP:
  	if (WindowMoved) do_next_action = FALSE;
  	break;
--- 1190,1195 ----
diff -c tvtwm/menus.h tvtwm.orig/menus.h
*** tvtwm/menus.h	Fri Aug 31 14:53:08 1990
--- tvtwm.orig/menus.h	Thu Aug 30 09:18:02 1990
***************
*** 41,47 ****
  
  #define TWM_ROOT	"bLoB_GoOp"	/* my private root menu */
  #define TWM_WINDOWS	"TwmWindows"	/* for f.menu "TwmWindows" */
- #define TWM_VSCREENS    "VirtualScreens" /* for f.menu "VirtualScreens" */
  
  #define MAX_FILE_SIZE 4096	/* max chars to read from file for cut */
  
--- 41,46 ----

diff -c tvtwm/parse.c tvtwm.orig/parse.c
*** tvtwm/parse.c	Fri Aug 31 14:27:54 1990
--- tvtwm.orig/parse.c	Thu Aug 30 09:18:02 1990
***************
*** 599,605 ****
      { "virtualdesktopbackgroundpixmap",SKEYWORD,
  				    kws_VirtualDesktopBackgroundPixmap },
      { "virtualdesktopforeground",CKEYWORD, kwc_VirtualDesktopForeground },
-     { "vscreens",               VSCREENS, 0},
      { "w",			WINDOW, 0 },
      { "wait",			WAIT, 0 },
      { "warpcursor",		WARP_CURSOR, 0 },
--- 599,604 ----
diff -c tvtwm/parse.h tvtwm.orig/parse.h
*** tvtwm/parse.h	Fri Aug 31 18:04:44 1990
--- tvtwm.orig/parse.h	Thu Aug 30 09:18:03 1990
***************
*** 108,115 ****
  #define F_FUNCTION		108	/* string */
  #define F_WARPTOSCREEN		109	/* string */
  #define F_COLORMAP		110	/* string */
- #define F_SCROLLTOVSCREEN	111	/* string */
- 
  
  #define D_NORTH			1
  #define D_SOUTH			2
--- 108,113 ----

diff -c tvtwm/screen.h tvtwm.orig/screen.h
*** tvtwm/screen.h	Fri Aug 31 16:01:56 1990
--- tvtwm.orig/screen.h	Thu Aug 30 09:18:03 1990
***************
*** 79,85 ****
      int vdtPositionX;		/* where the virtual desktop is currently
positioned */
      int vdtPositionY;		/* where the virtual desktop is currently
positioned */
  
-     name_list *VScreens;	/* virtual screens in the desktop */
      name_list *Icons;		/* list of icon pixmaps */
      TitlebarPixmaps tbpm;	/* titlebar pixmaps */
      Pixmap UnknownPm;		/* the unknown icon pixmap */
--- 79,84 ----
***************
*** 92,98 ****
      MenuRoot *MenuList;		/* head of the menu list */
      MenuRoot *LastMenu;		/* the last menu (mostly unused?) */
      MenuRoot *Windows;		/* the TwmWindows menu */
!     MenuRoot *VScreensMenu;      /* the VirtualScreens menu */
      TwmWindow *Ring;		/* one of the windows in window ring */
      TwmWindow *RingLeader;	/* current winodw in ring */
  
--- 91,97 ----
      MenuRoot *MenuList;		/* head of the menu list */
      MenuRoot *LastMenu;		/* the last menu (mostly unused?) */
      MenuRoot *Windows;		/* the TwmWindows menu */
! 
      TwmWindow *Ring;		/* one of the windows in window ring */
      TwmWindow *RingLeader;	/* current winodw in ring */
  

jody@shell.COM (Jody Winston) (09/06/90)

Notice that several lines are rapped in the patch file

About line 118 in the patch file
-    AddToMenu(menu, "Virtual Screens", NULLSTR, NULL,F_TITLE,NULLSTR,NULLSTR);

About line 223 in the patch file
      int vdtPositionX;		/* where the virtual desktop is currently
positioned */
      int vdtPositionY;		/* where the virtual desktop is currently
positioned */

Jody Winston		jody@shell.com
..!{sun,psuvax1,bcm,rice,decwrl,cs.utexas.edu}!shell!jody
Shell Development Company, Bellaire Research Center
P.O. Box 481, Room 2103, Houston, TX 77001	(Voice: 713 663-2676)