(interp, parent, name, screenName)
| 199 | *---------------------------------------------------------------------- |
| 200 | */ |
| 201 | |
| 202 | static Tk_Window |
| 203 | CreateTopLevelWindow(interp, parent, name, screenName) |
| 204 | Tcl_Interp *interp; /* Interpreter to use for error reporting. */ |
| 205 | Tk_Window parent; /* Token for logical parent of new window |
| 206 | * (used for naming, options, etc.). May |
| 207 | * be NULL. */ |
| 208 | char *name; /* Name for new window; if parent is |
| 209 | * non-NULL, must be unique among parent's |
| 210 | * children. */ |
| 211 | char *screenName; /* Name of screen on which to create |
| 212 | * window. NULL means use DISPLAY environment |
| 213 | * variable to determine. Empty string means |
| 214 | * use parent's screen, or DISPLAY if no |
| 215 | * parent. */ |
| 216 | { |
| 217 | register TkWindow *winPtr; |
| 218 | register TkDisplay *dispPtr; |
| 219 | int screenId; |
| 220 | |
| 221 | if (!initialized) { |
| 222 | initialized = 1; |
| 223 | tkWindowContext = XUniqueContext(); |
| 224 | tkActiveUid = Tk_GetUid("active"); |
| 225 | tkDisabledUid = Tk_GetUid("disabled"); |
| 226 | tkNormalUid = Tk_GetUid("normal"); |
| 227 | } |
| 228 | |
| 229 | if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) { |
| 230 | dispPtr = ((TkWindow *) parent)->dispPtr; |
| 231 | screenId = Tk_ScreenNumber(parent); |
| 232 | } else { |
| 233 | dispPtr = GetScreen(interp, screenName, &screenId); |
| 234 | if (dispPtr == NULL) { |
| 235 | return (Tk_Window) NULL; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | winPtr = NewWindow(dispPtr, screenId); |
| 240 | |
| 241 | /* |
| 242 | * Internal windows don't normally ask for StructureNotify events, |
| 243 | * since we can generate them internally. However, for top-level |
| 244 | * windows we need to as for the events because the window could |
| 245 | * be manipulated externally. |
| 246 | */ |
| 247 | |
| 248 | winPtr->atts.event_mask |= StructureNotifyMask; |
| 249 | |
| 250 | /* |
| 251 | * (Need to set the TK_TOP_LEVEL flag immediately here; otherwise |
| 252 | * Tk_DestroyWindow will core dump if it is called before the flag |
| 253 | * has been set.) |
| 254 | */ |
| 255 | |
| 256 | winPtr->flags |= TK_TOP_LEVEL; |
| 257 | if (parent != NULL) { |
| 258 | if (NameWindow(interp, winPtr, (TkWindow *) parent, name) != TCL_OK) { |
no test coverage detected