(tkwin)
| 845 | * Results: |
| 846 | * None. |
| 847 | * |
| 848 | * Side effects: |
| 849 | * The window is deleted, along with all of its children. |
| 850 | * Relevant callback procedures are invoked. |
| 851 | * |
| 852 | *-------------------------------------------------------------- |
| 853 | */ |
| 854 | |
| 855 | void |
| 856 | Tk_DestroyWindow(tkwin) |
| 857 | Tk_Window tkwin; /* Window to destroy. */ |
| 858 | { |
| 859 | register TkWindow *winPtr = (TkWindow *) tkwin; |
| 860 | XEvent event; |
| 861 | |
| 862 | /* |
| 863 | * Recursively destroy children. The TK_RECURSIVE_DESTROY |
| 864 | * flags means that the child's window needn't be explicitly |
| 865 | * destroyed (the destroy of the parent already did it), nor |
| 866 | * does it need to be removed from its parent's child list, |
| 867 | * since the parent is being destroyed too. |
| 868 | */ |
| 869 | |
| 870 | while (winPtr->childList != NULL) { |
| 871 | winPtr->childList->flags |= TK_RECURSIVE_DESTROY; |
| 872 | Tk_DestroyWindow((Tk_Window) winPtr->childList); |
| 873 | } |
| 874 | |
| 875 | /* |
| 876 | * Generate a DestroyNotify event. In order for the DestroyNotify |
| 877 | * event to be processed correctly, need to make sure the window |
| 878 | * exists. This is a bit of a kludge, and may be unnecessarily |
| 879 | * expensive, but without it no event handlers will get called for |
| 880 | * windows that don't exist yet. |
| 881 | */ |
| 882 | |
| 883 | if (winPtr->window == None) { |
| 884 | Tk_MakeWindowExist(tkwin); |
| 885 | } |
| 886 | winPtr->flags |= TK_ALREADY_DEAD; |
| 887 | event.type = DestroyNotify; |
| 888 | event.xdestroywindow.serial = |
| 889 | LastKnownRequestProcessed(winPtr->display); |
| 890 | event.xdestroywindow.send_event = False; |
| 891 | event.xdestroywindow.display = winPtr->display; |
| 892 | event.xdestroywindow.event = winPtr->window; |
| 893 | event.xdestroywindow.window = winPtr->window; |
| 894 | Tk_HandleEvent(&event); |
| 895 | |
| 896 | /* |
| 897 | * Cleanup the data structures associated with this window. |
| 898 | * No need to destroy windows during recursive destroys, since |
| 899 | * that will happen automatically when the parent window is |
| 900 | * destroyed (not true for top-level windows: must destroy |
| 901 | * them explicitly). |
| 902 | */ |
| 903 | |
| 904 | if (winPtr->window != None) { |
no test coverage detected