1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** GUIX Component                                                        */
16 /**                                                                       */
17 /**   Window Management (Window)                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_system.h"
28 #include "gx_window.h"
29 #include "gx_widget.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_window_root_delete                              PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function delets a previous-created root window                 */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    root_window                           Window control block          */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    status                                Completion status             */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    memset                                Set control block to zero     */
57 /*    _gx_system_all_views_free             Free up all view ports        */
58 /*    _gx_widget_delete                     Delete widget                 */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    GUIX Internal Code                                                  */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_gx_window_root_delete(GX_WINDOW_ROOT * root_window)73 UINT  _gx_window_root_delete(GX_WINDOW_ROOT *root_window)
74 {
75 GX_WINDOW_ROOT *previous;
76 
77     _gx_system_all_views_free(root_window);
78 
79     if (_gx_system_root_window_created_list == root_window)
80     {
81         _gx_system_root_window_created_list = (GX_WINDOW_ROOT *)_gx_system_root_window_created_list -> gx_widget_next;
82     }
83     else
84     {
85         previous = _gx_system_root_window_created_list;
86 
87         while (previous)
88         {
89             if ((GX_WINDOW_ROOT *)previous -> gx_widget_next == root_window)
90             {
91                 previous -> gx_widget_next = root_window -> gx_widget_next;
92                 break;
93             }
94 
95             previous = (GX_WINDOW_ROOT *)previous -> gx_widget_next;
96         }
97     }
98 
99     _gx_widget_delete((GX_WIDGET *)root_window);
100 
101     /* Clear the root window control block.  */
102     memset(root_window, 0, sizeof(GX_WINDOW_ROOT));
103 
104     return(GX_SUCCESS);
105 }
106 
107