Index: src/hg/hgTracks/simpleTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/simpleTracks.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -b -B -U 4 -r1.115 -r1.116
--- src/hg/hgTracks/simpleTracks.c	5 Dec 2009 01:29:01 -0000	1.115
+++ src/hg/hgTracks/simpleTracks.c	9 Dec 2009 03:30:22 -0000	1.116
@@ -575,8 +575,29 @@
 if(theImgBox && curImgTrack)
     {
     char link[512];
     safef(link,sizeof(link),"%s?position=%s:%d-%d&%s",hgTracksName(), chrom, start+1, end, ui->string); // NOTE: position may need removing due to portal
+#if defined(IMAGEv2_DRAG_REORDER) && defined(FLAT_TRACK_LIST)
+    if(!revCmplDisp && x < insideX)  // Do not toggle on side label!
+        {
+        width -= (insideX+1 - x);
+        if(width <= 1)
+            {
+            freeDyString(&ui);
+            return;
+            }
+        x = insideX+1;
+        }
+    else if(revCmplDisp && (x+width) >= insideWidth)
+        {
+        width -= (x+width) - insideWidth + 1;
+        if(width <= 1)
+            {
+            freeDyString(&ui);
+            return;
+            }
+        }
+#endif// defined(IMAGEv2_DRAG_REORDER) && defined(FLAT_TRACK_LIST)
     //#ifdef IMAGEv2_SHORT_MAPITEMS
     //    if(x < insideX && x+width > insideX)
     //        warn("mapBoxReinvoke(%s) map item spanning slices. LX:%d TY:%d RX:%d BY:%d  link:[%s]",hStringFromTv(toggleGroup->visibility),x, y, x+width, y+height, link);
     //#endif//def IMAGEv2_SHORT_MAPITEMS
@@ -601,14 +622,14 @@
 /* Print out image map rectangle that would invoke this program again.
  * program with the current track expanded. */
 {
 char buf[256];
-if(curGroup->tdb->parent != NULL)
-    safef(buf, sizeof(buf),"Toggle the display density of %s and similar subtracks", curGroup->shortLabel);
-else if(curGroup->tdb->subtracks != NULL)
-    safef(buf, sizeof(buf),"Toggle the maximum display mode density for all %s subtracks", curGroup->shortLabel);
+if(tdbIsCompositeChild(curGroup->tdb))
+    safef(buf, sizeof(buf),"Click to alter the display density of %s and similar subtracks", curGroup->shortLabel);
+else if(tdbIsComposite(curGroup->tdb))
+    safef(buf, sizeof(buf),"Click to alter the maximum display mode density for all %s subtracks", curGroup->shortLabel);
 else
-    safef(buf, sizeof(buf),"Toggle the display density of %s", curGroup->shortLabel);
+    safef(buf, sizeof(buf),"Click to alter the display density of %s", curGroup->shortLabel);
 
     mapBoxReinvoke(hvg, x, y, width, height, curGroup, NULL, 0, 0, buf, NULL);
 }
 
@@ -2720,12 +2741,18 @@
 		    int x, int y, int width, int height)
 /* This is meant to be used by genericDrawItems to set to tg->mapItem in */
 /* case tg->mapItem isn't set to anything already. */
 {
-char *directUrl = trackDbSetting(tg->tdb, "directUrl");
-boolean withHgsid = (trackDbSetting(tg->tdb, "hgsid") != NULL);
-mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, tg->mapName,
+#ifdef FLAT_TRACK_LIST
+// Don't bother if we are flat, imgV2, dense and a child.
+if(!theImgBox || tg->limitedVis != tvDense || !tdbIsCompositeChild(tg->tdb))
+#endif//def FLAT_TRACK_LIST
+    {
+    char *directUrl = trackDbSetting(tg->tdb, "directUrl");
+    boolean withHgsid = (trackDbSetting(tg->tdb, "hgsid") != NULL);
+    mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, tg->mapName,
                   mapItemName, itemName, directUrl, withHgsid, NULL);
+    }
 }
 
 void genericDrawNextItemStuff(struct track *tg, struct hvGfx *hvg, enum trackVisibility vis, struct slList *item,
                     int x2, int textX, int y, int heightPer,

