Tk Source Code

Artifact [81a783c2]
Login

Artifact 81a783c25ca090645c4ef6fc8135f6dace34930b:

Attachment "winwmattr.patch" to ticket [553926ff] added by hobbs 2002-05-31 10:41:41.
Index: win/tkWinWm.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinWm.c,v
retrieving revision 1.38
diff -b -u -r1.38 tkWinWm.c
--- win/tkWinWm.c	27 May 2002 22:54:42 -0000	1.38
+++ win/tkWinWm.c	31 May 2002 03:39:00 -0000
@@ -225,6 +225,8 @@
 				 * to eliminate redundant resize operations. */
     HMENU hMenu;		/* the hMenu associated with this menu */
     DWORD style, exStyle;	/* Style flags for the wrapper window. */
+    LONG styleConfig;		/* Extra user requested style bits */
+    LONG exStyleConfig;		/* Extra user requested extended style bits */
 
     /*
      * List of children of the toplevel which have private colormaps.
@@ -1398,12 +1400,13 @@
     register WmInfo *wmPtr;
 
     wmPtr = (WmInfo *) ckalloc(sizeof(WmInfo));
+
+    /*
+     * Initialize full structure, then set what isn't NULL
+     */
+    ZeroMemory(wmPtr, sizeof(WmInfo));
     winPtr->wmInfoPtr = wmPtr;
     wmPtr->winPtr = winPtr;
-    wmPtr->wrapper = NULL;
-    wmPtr->titleUid = NULL;
-    wmPtr->iconName = NULL;
-    wmPtr->masterPtr = NULL;
     wmPtr->hints.flags = InputHint | StateHint;
     wmPtr->hints.input = True;
     wmPtr->hints.initial_state = NormalState;
@@ -1412,23 +1415,16 @@
     wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0;
     wmPtr->hints.icon_mask = None;
     wmPtr->hints.window_group = None;
-    wmPtr->leaderName = NULL;
-    wmPtr->icon = NULL;
-    wmPtr->iconFor = NULL;
-    wmPtr->sizeHintsFlags = 0;
 
     /*
      * Default the maximum dimensions to the size of the display.
      */
 
     wmPtr->defMinWidth = wmPtr->defMinHeight = 0;
-    wmPtr->defMaxWidth = DisplayWidth(winPtr->display,
-	    winPtr->screenNum);
-    wmPtr->defMaxHeight = DisplayHeight(winPtr->display,
-	    winPtr->screenNum);
+    wmPtr->defMaxWidth = DisplayWidth(winPtr->display, winPtr->screenNum);
+    wmPtr->defMaxHeight = DisplayHeight(winPtr->display, winPtr->screenNum);
     wmPtr->minWidth = wmPtr->minHeight = 1;
     wmPtr->maxWidth = wmPtr->maxHeight = 0;
-    wmPtr->gridWin = NULL;
     wmPtr->widthInc = wmPtr->heightInc = 1;
     wmPtr->minAspect.x = wmPtr->minAspect.y = 1;
     wmPtr->maxAspect.x = wmPtr->maxAspect.y = 1;
@@ -1436,23 +1432,12 @@
     wmPtr->gravity = NorthWestGravity;
     wmPtr->width = -1;
     wmPtr->height = -1;
-    wmPtr->hMenu = NULL;
     wmPtr->x = winPtr->changes.x;
     wmPtr->y = winPtr->changes.y;
-    wmPtr->borderWidth = 0;
-    wmPtr->borderHeight = 0;
-    
-    wmPtr->cmapList = NULL;
-    wmPtr->cmapCount = 0;
-    wmPtr->numTransients = 0;
 
     wmPtr->configWidth = -1;
     wmPtr->configHeight = -1;
-    wmPtr->protPtr = NULL;
-    wmPtr->cmdArgv = NULL;
-    wmPtr->clientMachine = NULL;
     wmPtr->flags = WM_NEVER_MAPPED;
-    wmPtr->iconPtr = NULL;
     wmPtr->nextPtr = winPtr->dispPtr->firstWmPtr;
     winPtr->dispPtr->firstWmPtr = wmPtr;
 
@@ -1553,6 +1538,9 @@
 	    wmPtr->exStyle = EX_TOPLEVEL_STYLE;
 	}
 
+	wmPtr->style   |= wmPtr->styleConfig;
+	wmPtr->exStyle |= wmPtr->exStyleConfig;
+
 	if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE)
 		&& (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) {
 	    wmPtr->style &= ~ (WS_MAXIMIZEBOX | WS_SIZEBOX);
@@ -2121,7 +2109,81 @@
 	return TCL_ERROR;
     }
     wmPtr = winPtr->wmInfoPtr;
-    if ((c == 'a') && (strncmp(argv[1], "aspect", length) == 0)) {
+    if ((c == 'a') && (strncmp(argv[1], "attributes", length) == 0)
+	    && (length >= 2)) {
+	LONG style, exStyle, styleBit, *stylePtr;
+	char buf[TCL_INTEGER_SPACE];
+	int i, boolean;
+
+	if (argc < 3) {
+	    configArgs:
+	    Tcl_AppendResult(interp, "wrong # arguments: must be \"",
+		    argv[0], " attributes window",
+		    " ?-disabled ?bool??",
+		    " ?-toolwindow ?bool??",
+		    " ?-topmost ?bool??\"",
+		    (char *) NULL);
+	    return TCL_ERROR;
+	}
+	exStyle = wmPtr->exStyleConfig;
+	style   = wmPtr->styleConfig;
+	if (argc == 3) {
+	    sprintf(buf, "%d", ((style & WS_DISABLED) != 0));
+            Tcl_AppendResult(interp, "-disabled ", buf, (char *) NULL);
+	    sprintf(buf, "%d", ((exStyle & WS_EX_TOOLWINDOW) != 0));
+            Tcl_AppendResult(interp, " -toolwindow ", buf, (char *) NULL);
+	    sprintf(buf, "%d", ((exStyle & WS_EX_TOPMOST) != 0));
+            Tcl_AppendResult(interp, " -topmost ", buf, (char *) NULL);
+	    return TCL_OK;
+	}
+	for (i = 3; i < argc; i += 2) {
+	    length = strlen(argv[i]);
+	    if ((length < 2) || (argv[i][0] != '-')) {
+		goto configArgs;
+	    }
+	    if ((i < argc-1) &&
+		    (Tcl_GetBoolean(interp, argv[i+1], &boolean) != TCL_OK)) {
+		return TCL_ERROR;
+	    }
+	    if (strncmp(argv[i], "-disabled", length) == 0) {
+		stylePtr = &style;
+		styleBit = WS_DISABLED;
+	    } else if ((strncmp(argv[i], "-toolwindow", length) == 0)
+		    && (length >= 3)) {
+		stylePtr = &exStyle;
+		styleBit = WS_EX_TOOLWINDOW;
+	    } else if ((strncmp(argv[i], "-topmost", length) == 0)
+		    && (length >= 3)) {
+		stylePtr = &exStyle;
+		styleBit = WS_EX_TOPMOST;
+		if ((i < argc-1) &&
+			(winPtr->flags & TK_EMBEDDED)) {
+		    Tcl_AppendResult(interp, "can't set topmost flag on ",
+			    winPtr->pathName, ": it is an embedded window",
+			    (char *) NULL);
+		    return TCL_ERROR;
+		}
+	    } else {
+		goto configArgs;
+	    }
+	    if (i == argc-1) {
+		Tcl_SetIntObj(Tcl_GetObjResult(interp),
+			((*stylePtr & styleBit) != 0));
+	    } else if (boolean) {
+		*stylePtr |= styleBit;
+	    } else {
+		*stylePtr &= ~styleBit;
+	    }
+	}
+	if ((wmPtr->styleConfig != style) ||
+		(wmPtr->exStyleConfig != exStyle)) {
+	    wmPtr->styleConfig = style;
+	    wmPtr->exStyleConfig = exStyle;
+	    UpdateWrapper(winPtr);
+	}
+	return TCL_OK;
+    } else if ((c == 'a') && (strncmp(argv[1], "aspect", length) == 0)
+	    && (length >= 2)) {
 	int numer1, denom1, numer2, denom2;
 
 	if ((argc != 3) && (argc != 7)) {
@@ -3630,7 +3692,7 @@
     WmInfo *wmPtr;
 
     wmPtr = winPtr->wmInfoPtr;
-    if (winPtr->flags & TK_EMBEDDED) {
+    if ((winPtr->flags & TK_EMBEDDED) && (wmPtr->wrapper != NULL)) {
 	SendMessage(wmPtr->wrapper, TK_GEOMETRYREQ, Tk_ReqWidth(tkwin),
 	    Tk_ReqHeight(tkwin));
     }
@@ -3681,7 +3743,8 @@
      * state of the window changes.
      */
 
-    if (IsIconic(wmPtr->wrapper) || IsZoomed(wmPtr->wrapper)) {
+    if ((wmPtr->wrapper == NULL)
+	    || IsIconic(wmPtr->wrapper) || IsZoomed(wmPtr->wrapper)) {
 	return;
     }