idallen@watdragon.waterloo.edu (01/14/90)
From: "Ian! D. Allen [CGL]" <idallen> X Window System Bug Report xbugs@expo.lcs.mit.edu VERSION: R4 CLIENT MACHINE and OPERATING SYSTEM: Any DISPLAY TYPE: Any WINDOW MANAGER: twm AREA: twm SYNOPSIS: Twm F_WARPTO function is documented in the man page as looking at the resource name as well as the name. The code doesn't do that. It only looks at a prefix of the name. DESCRIPTION: See above and below. I "fixed" more than the missing test for res_name, because I belive an exact match is better than a prefix match. I only use a prefix match if no exact match can be found. I test for a match on "res_name" before just "name" because all my users put $cwd in their csh prompt strings and set their xterm title and icon names with it; hence, nothing ever matches on "name". REPEAT BY: Create any application that has a name with a different prefix than the resource name and try to f.warpto "that_application_res_name". Won't find it. SAMPLE FIX: *** /tmp/,RCSt1002748 Sun Jan 14 01:20:58 1990 --- menus.c Sun Jan 14 01:04:24 1990 *************** *** 1767,1787 **** case F_WARPTO: { register TwmWindow *t; ! int len; len = strlen(action); for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { ! /* match only the first portion of WINDOW the name */ ! if (!strncmp(action, t->name, len)) { ! if (Scr->WarpUnmapped || t->mapped) { ! if (!t->mapped) DeIconify (t); ! XRaiseWindow (dpy, t->frame); ! WarpToWindow (t); ! break; } ! } } if (!t) XBell (dpy, 0); } --- 1767,1815 ---- case F_WARPTO: { + /* I redid this to find a better match and to conform + * more to the documentation. This should probably be + * user-configurable. It should also match the search + * algorithms done elsewhere in twm. -IAN! + */ register TwmWindow *t; ! register TwmWindow *tgoodname = NULL; ! register TwmWindow *tbettername = NULL; ! register TwmWindow *tgoodres = NULL; ! register int len; len = strlen(action); for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { ! /* Try to pick the best match, not just the first. ! * Exact match on res_name is best, followed by ! * exact match on name, prefix of res_name, prefix of name. ! */ ! if (!tbettername) { ! if (!tgoodres) { ! if (!tgoodname) { ! if (!strncmp(action, t->name, len)) ! tgoodname = t; ! } ! if (!strncmp(action, t->class.res_name, len)) ! tgoodres = t; } ! if (!strcmp(action, t->name)) ! tbettername = t; ! } ! if (!strcmp(action, t->class.res_name)) ! break; ! } ! t = t ? t : ( ! tbettername ? tbettername : ( ! tgoodres ? tgoodres : ( ! tgoodname ? tgoodname : NULL ) ) ) ; ! ! if (t && (Scr->WarpUnmapped || t->mapped)) { ! if (!t->mapped) DeIconify (t); ! XRaiseWindow (dpy, t->frame); ! WarpToWindow (t); ! break; } if (!t) XBell (dpy, 0); }