From: jason@peyote.tfs.com (Jason P. Venner)
Newsgroups: fj.mail-lists.x-window
Subject: R5 Pl11 twm question about WARPTO changes in name matching
Date: 8 Jan 93 20:19:34 GMT
Distribution: fj
Organization: /u1/jason/.organization

Date: Fri, 8 Jan 1993 18:15:48 GMT
Message-Id: <JASON.93Jan8101548@peyote.tfs.com>
Newsgroups: comp.windows.x


In R4, twm would look at the window name, as well as the res_class and
res_name when executing the f.warpto call.

In R4, twm only looks at the res_class and res_name' and looks at
res_name twice - is this a typeo/bug

    case F_WARPTO:
	{
	    register TwmWindow *t;
	    int len;

	    len = strlen(action);

	    for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
		if (!strncmp(action, t->class.res_name, len)) break;
	    }
	    if (!t) {
		for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
		    if (!strncmp(action, t->class.res_name, len)) break;
		}
		if (!t) {
		    for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
			if (!strncmp(action, t->class.res_class, len)) break;
		    }
		}
	    }



I have modified my twm to use a function I call MatchWinName that more
or less mimic's the R4 behaviour - and what I want to happen.

/*
 * This function is used by the WARPTO call to match the action name
 * against window names
 */

int	MatchWinName( action, action_len, t )
char* action;
int	action_len;
struct TwmWindow* t;
{

	if( strncmp( action, t->full_name, action_len ) == 0 ) {
		return True;
	} else if( strncmp( action, t->name, action_len ) == 0 ) {
		return True;
	} else if( strncmp( action, t->class.res_class, action_len ) == 0 ) {
		return True;
	} else if( strncmp( action, t->class.res_name, action_len ) == 0 ) {
		return True;
	}
	return False;
}

		for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
			if( MatchWinName( action, len, t ) ) {
				break;
			}
		}

diff -c /image_store1/X11R5/mit/clients/twm/menus.c menus.c
*** /image_store1/X11R5/mit/clients/twm/menus.c       Wed Jul 17 10:58:47 1991
--- menus.c     Fri Jan  8 10:08:56 1993
***************
*** 1297,1302 ****
--- 1297,1325 ----
      }
  } 
  
+ /*
+  * This function is used by the WARPTO call to match the action name
+  * against window names
+  */
+ 
+ int MatchWinName( action, action_len, t )
+ char* action;
+ int       action_len;
+ struct TwmWindow* t;
+ {
+ 
+         if( strncmp( action, t->full_name, action_len ) == 0 ) {
+               return True;
+   } else if( strncmp( action, t->name, action_len ) == 0 ) {
+             return True;
+   } else if( strncmp( action, t->class.res_class, action_len ) == 0 ) {
+          return True;
+   } else if( strncmp( action, t->class.res_name, action_len ) == 0 ) {
+           return True;
+   }
+      return False;
+ }
+ 
  
  
  /***********************************************************************
***************
*** 1319,1324 ****
--- 1342,1348 ----
   ***********************************************************************
   */
  
+ 
  int
  ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown)
      int func;
***************
*** 2088,2121 ****
  
      case F_WARPTO:
         {
!          register TwmWindow *t;
!         int len;
  
!             len = strlen(action);
  
-        for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
-              if (!strncmp(action, t->class.res_name, len)) break;
-       }
-      if (!t) {
           for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
!              if (!strncmp(action, t->class.res_name, len)) break;
                }
!              if (!t) {
!                  for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
!                      if (!strncmp(action, t->class.res_class, len)) break;
!              }
           }
-          }
- 
-            if (t) {
-           if (Scr->WarpUnmapped || t->mapped) {
-              if (!t->mapped) DeIconify (t);
-                 if (!Scr->NoRaiseWarp) XRaiseWindow (dpy, t->frame);
-                   WarpToWindow (t);
-          }
-          } else {
-           XBell (dpy, 0);
-            }
   }
       break;
  
--- 2112,2136 ----
  
      case F_WARPTO:
        {
!              register TwmWindow *t;
!                 int len;
  
!             len = strlen(action);
  
                 for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
!                  if( MatchWinName( action, len, t ) ) {
!                                 break;
!                         }
               }
!              if (t) {
!                       if (Scr->WarpUnmapped || t->mapped) {
!                          if (!t->mapped) DeIconify (t);
!                                 if (!Scr->NoRaiseWarp) XRaiseWindow (dpy, t->frame);
!                           WarpToWindow (t);
!                      }
!              } else {
!                       XBell (dpy, 0);
                 }
       }
       break;