From: mpurtell@iastate.edu (Michael J Purtell)
Newsgroups: comp.lang.tcl
Subject: Re: Can't get tk to work correctly with tvtwm
Summary: tkMenu.c patch for users of tvtwm
Keywords: tkMenu Tk Tcl tvtwm virtual window manager
Date: 6 Oct 92 06:43:15 GMT
Organization: Iowa State University, Ames, IA

In article <WECKER.92Sep28160526@child.cxn.dec.com> wecker@child.cxn.dec.com (Dave Wecker/IGOR) writes:
>I'm having all sorts of trouble getting `tk' menus and popup windows to work
>correctly with `tvtwm' (window manager with virtual screens). As long as I
>keep the `tk' application on the base screen (1,1) everything works as
>expected however, as soon as I move the window to another screen the fun
>begins. Here is an example of what happens:
>
>    1. Start the application on screen 1,1.
>    2. Move it around on the screen (everything works).
>    3. Move it to another screen (everything works).
>    4. Move it around on the new screen (menus wind up at the far edge of
>    	the screen, popups wind up back on screen 1,1)!!!!
>
>The same behaviour can be observed if you just start up the application on any
>screen other than 1,1 (immediately all menus are at the far edge and popups
>are on 1,1). It appears that menus are sending absolute coordinates for their
>positions, but are probably using PPosition Hints (so that tvtwm adds in the
>current screen's virtual root position) sending them off the far edge.
>Toplevel popups appear to be doing the exact opposite.
>
>Am I doing something wrong, or is there a usable work around?
Nope.

But, the following patch to tkMenu.c will make things work much better for
you.  I don't believe this patch has any adverse effects on wish users
who are not using a virtual windowing manager.  Let me know if there 
are problems I'll try to tune.  Here it is:

*** tkMenu.c.orig	Sat Aug 29 05:57:33 1992
--- tkMenu.c	Sat Aug 29 06:01:13 1992
***************
*** 479,485 ****
      register Menu *menuPtr = (Menu *) clientData;
      register MenuEntry *mePtr;
      int result = TCL_OK;
!     int length, type;
      char c;
  
      if (argc < 2) {
--- 479,485 ----
      register Menu *menuPtr = (Menu *) clientData;
      register MenuEntry *mePtr;
      int result = TCL_OK;
!     int length, type, wos, hos;
      char c;
  
      if (argc < 2) {
***************
*** 774,795 ****
  	 * on-screen.
  	 */
  
! 	tmp = WidthOfScreen(Tk_Screen(menuPtr->tkwin))
! 		- Tk_Width(menuPtr->tkwin);
! 	if (x > tmp) {
! 	    x = tmp;
! 	}
! 	if (x < 0) {
! 	    x = 0;
! 	}
! 	tmp = HeightOfScreen(Tk_Screen(menuPtr->tkwin))
! 		- Tk_Height(menuPtr->tkwin);
! 	if (y > tmp) {
! 	    y = tmp;
! 	}
! 	if (y < 0) {
! 	    y = 0;
! 	}
  	if ((x != Tk_X(menuPtr->tkwin)) || (y != Tk_Y(menuPtr->tkwin))) {
  	    Tk_MoveWindow(menuPtr->tkwin, x, y);
  	}
--- 774,804 ----
  	 * on-screen.
  	 */
  
!         wos = WidthOfScreen(Tk_Screen(menuPtr->tkwin));
!         if (x > 0) {
!           x = x % wos;
!           if (x == 0) {
!             x = wos;
!           }
!         } else {
!           x = x % wos;
!         }  
!         tmp = wos - Tk_Width(menuPtr->tkwin);
!         if (x > tmp) {
!             x = tmp;
!         }
!         if (x < 0) {
!             x = 0;
!         }
!         hos = HeightOfScreen(Tk_Screen(menuPtr->tkwin));
!         y = y % hos;
!         tmp = hos - Tk_Height(menuPtr->tkwin);
!         if (y > tmp) {
!             y = tmp;
!         }
!         if (y < 0) {
!             y = 0;
!         }
  	if ((x != Tk_X(menuPtr->tkwin)) || (y != Tk_Y(menuPtr->tkwin))) {
  	    Tk_MoveWindow(menuPtr->tkwin, x, y);
  	}



-- Michael  Purtell -- | It's better to     | There's an Old Irish Recipe for
mpurtell@iastate.edu   | be lucky than      |  Longevity: Leave the Table
Iowa State University  | to rise early.     |  Hungry.  Leave the Bed Sleepy.
                       |  -- Celtic Proberb |  Leave the Tavern Thirsty.
Newsgroups: comp.lang.tcl