Tk Source Code

Artifact [0e6893c4]
Login

Artifact 0e6893c4326fa0b0cbe6e0c438a5b742a31fa7fc74efd3f3985572637d5f16c2:

Attachment "winfo_container.patch" to ticket [b6f0d688] added by erikleunissen 2021-12-12 15:07:27.
diff -ur tk.old/generic/tkCmds.c tk.new/generic/tkCmds.c
--- tk.old/generic/tkCmds.c	2021-11-17 23:42:42.000000000 +0100
+++ tk.new/generic/tkCmds.c	2021-12-10 22:45:39.000000000 +0100
@@ -1297,15 +1297,16 @@
     };
     static const char *const optionStrings[] = {
 	"cells",	"children",	"class",	"colormapfull",
-	"depth",	"geometry",	"height",	"id",
-	"ismapped",	"manager",	"name",		"parent",
-	"pointerx",	"pointery",	"pointerxy",	"reqheight",
-	"reqwidth",	"rootx",	"rooty",	"screen",
-	"screencells",	"screendepth",	"screenheight",	"screenwidth",
-	"screenmmheight","screenmmwidth","screenvisual","server",
-	"toplevel",	"viewable",	"visual",	"visualid",
-	"vrootheight",	"vrootwidth",	"vrootx",	"vrooty",
-	"width",	"x",		"y",
+	"container",	"depth",	"geometry",	"height",
+	"id",		"ismapped",	"manager",	"master",
+	"name",		"parent",	"pointerx",	"pointery",
+	"pointerxy",	"reqheight",	"reqwidth",	"rootx",
+	"rooty",	"screen",	"screencells",	"screendepth",
+	"screenheight",	"screenwidth",	"screenmmheight","screenmmwidth",
+	"screenvisual",	"server",	"toplevel",	"viewable",
+	"visual",	"visualid",	"vrootheight",	"vrootwidth",
+	"vrootx",	"vrooty",	"width",	"x",
+	"y",
 
 	"atom",		"atomname",	"containing",	"interps",
 	"pathname",
@@ -1317,15 +1318,16 @@
     };
     enum options {
 	WIN_CELLS,	WIN_CHILDREN,	WIN_CLASS,	WIN_COLORMAPFULL,
-	WIN_DEPTH,	WIN_GEOMETRY,	WIN_HEIGHT,	WIN_ID,
-	WIN_ISMAPPED,	WIN_MANAGER,	WIN_NAME,	WIN_PARENT,
-	WIN_POINTERX,	WIN_POINTERY,	WIN_POINTERXY,	WIN_REQHEIGHT,
-	WIN_REQWIDTH,	WIN_ROOTX,	WIN_ROOTY,	WIN_SCREEN,
-	WIN_SCREENCELLS,WIN_SCREENDEPTH,WIN_SCREENHEIGHT,WIN_SCREENWIDTH,
-	WIN_SCREENMMHEIGHT,WIN_SCREENMMWIDTH,WIN_SCREENVISUAL,WIN_SERVER,
-	WIN_TOPLEVEL,	WIN_VIEWABLE,	WIN_VISUAL,	WIN_VISUALID,
-	WIN_VROOTHEIGHT,WIN_VROOTWIDTH,	WIN_VROOTX,	WIN_VROOTY,
-	WIN_WIDTH,	WIN_X,		WIN_Y,
+	WIN_CONTAINER,	WIN_DEPTH,	WIN_GEOMETRY,	WIN_HEIGHT,
+	WIN_ID,		WIN_ISMAPPED,	WIN_MANAGER,	WIN_MASTER,
+	WIN_NAME,	WIN_PARENT,	WIN_POINTERX,	WIN_POINTERY,
+	WIN_POINTERXY,	WIN_REQHEIGHT,	WIN_REQWIDTH,	WIN_ROOTX,
+	WIN_ROOTY,	WIN_SCREEN,	WIN_SCREENCELLS,WIN_SCREENDEPTH,
+	WIN_SCREENHEIGHT,WIN_SCREENWIDTH,WIN_SCREENMMHEIGHT,WIN_SCREENMMWIDTH,
+	WIN_SCREENVISUAL,WIN_SERVER,	WIN_TOPLEVEL,	WIN_VIEWABLE,
+	WIN_VISUAL,	WIN_VISUALID,	WIN_VROOTHEIGHT,WIN_VROOTWIDTH,
+	WIN_VROOTX,	WIN_VROOTY,	WIN_WIDTH,	WIN_X,
+	WIN_Y,
 
 	WIN_ATOM,	WIN_ATOMNAME,	WIN_CONTAINING,	WIN_INTERPS,
 	WIN_PATHNAME,
@@ -1377,6 +1379,13 @@
     case WIN_CLASS:
 	Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_Class(tkwin), -1));
 	break;
+    case WIN_CONTAINER:
+    case WIN_MASTER:
+	winPtr = TkGetContainer(winPtr);
+	if (winPtr != NULL) {
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->pathName, -1));
+	}
+	break;
     case WIN_COLORMAPFULL:
 	Tcl_SetObjResult(interp,
 		Tcl_NewBooleanObj(TkpCmapStressed(tkwin,Tk_Colormap(tkwin))));
diff -ur tk.old/generic/tkGrid.c tk.new/generic/tkGrid.c
--- tk.old/generic/tkGrid.c	2021-11-17 23:42:42.000000000 +0100
+++ tk.new/generic/tkGrid.c	2021-12-10 22:55:01.000000000 +0100
@@ -3367,9 +3367,7 @@
 		return TCL_ERROR;
 	    }
 	}
-	if (containerPtr->tkwin != Tk_Parent(content)) {
-	    ((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin;
-	}
+	((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin;
 
 	Tk_ManageGeometry(content, &gridMgrType, contentPtr);
 
diff -ur tk.old/generic/tkInt.h tk.new/generic/tkInt.h
--- tk.old/generic/tkInt.h	2021-11-17 23:42:42.000000000 +0100
+++ tk.new/generic/tkInt.h	2021-12-12 12:49:53.000000000 +0100
@@ -374,8 +374,7 @@
      */
 
 #define TkGetContainer(tkwin) (Tk_TopWinHierarchy((TkWindow *)tkwin) ? NULL : \
-	(((TkWindow *)tkwin)->maintainerPtr != NULL ? \
-	 ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr))
+ 	((TkWindow *)tkwin)->maintainerPtr)
 
     /*
      * Information used by tkGet.c only:
@@ -876,8 +875,7 @@
     char *geomMgrName;          /* Records the name of the geometry manager. */
     struct TkWindow *maintainerPtr;
 				/* The geometry container for this window. The
-				 * value is NULL if the window has no container or
-				 * if its container is its parent. */
+				 * value is NULL if the window has no container. */
 } TkWindow;
 
 /*
diff -ur tk.old/generic/tkPack.c tk.new/generic/tkPack.c
--- tk.old/generic/tkPack.c	2021-11-17 23:42:42.000000000 +0100
+++ tk.new/generic/tkPack.c	2021-12-10 22:25:31.000000000 +0100
@@ -1813,9 +1813,7 @@
 		return TCL_ERROR;
 	    }
 	}
-	if (containerPtr->tkwin != Tk_Parent(content)) {
-	    ((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin;
-	}
+	((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin;
 
 	/*
 	 * Unpack the content if it's currently packed, then position it after
diff -ur tk.old/generic/tkPlace.c tk.new/generic/tkPlace.c
--- tk.old/generic/tkPlace.c	2021-11-17 23:42:42.000000000 +0100
+++ tk.new/generic/tkPlace.c	2021-12-10 22:55:19.000000000 +0100
@@ -711,9 +711,7 @@
 		goto error;
 	    }
 	}
-	if (win != Tk_Parent(contentPtr->tkwin)) {
-	    ((TkWindow *)contentPtr->tkwin)->maintainerPtr = (TkWindow *)win;
-	}
+	((TkWindow *)contentPtr->tkwin)->maintainerPtr = (TkWindow *)win;
 
 	if ((contentPtr->containerPtr != NULL)
 		&& (contentPtr->containerPtr->tkwin == win)) {