1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** GUIX Component                                                        */
17 /**                                                                       */
18 /**   System Management (System)                                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_system.h"
29 #include "gx_widget.h"
30 #include "gx_utility.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _gx_system_event_remove                             PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Kenneth Maxwell, Microsoft Corporation                              */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function removes events targetted to indicated widget          */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    remove                                Widget to be removed          */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    _gx_widget_child_detect               Detect a child widget         */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    _gx_widget_delete                     Delete a widget               */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
68 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_gx_system_event_remove(GX_WIDGET * widget)72 VOID  _gx_system_event_remove(GX_WIDGET *widget)
73 {
74 #ifdef GX_THREADX_BINDING
75 
76 TX_INTERRUPT_SAVE_AREA
77 
78 GX_EVENT *pEvent;
79 ULONG    *pSrc;
80 TX_QUEUE *pQueue;
81 GX_BOOL   Purge;
82 
83     TX_DISABLE
84 
85     pQueue = &_gx_system_event_queue;
86 
87     if (pQueue -> tx_queue_enqueued)
88     {
89         pSrc =  pQueue -> tx_queue_read;
90 
91         do
92         {
93             pEvent = (GX_EVENT *)pSrc;
94             Purge = GX_FALSE;
95 
96             if (pEvent -> gx_event_target)
97             {
98                 if (pEvent -> gx_event_target == widget)
99                 {
100                     Purge = GX_TRUE;
101                 }
102                 else
103                 {
104                     _gx_widget_child_detect(widget, pEvent -> gx_event_target, &Purge);
105                 }
106                 if (Purge)
107                 {
108                     pEvent -> gx_event_target = GX_NULL;
109                     pEvent -> gx_event_type = 0;
110                 }
111             }
112 
113             pSrc += pQueue -> tx_queue_message_size;
114 
115             if (pSrc >= pQueue -> tx_queue_end)
116             {
117                 pSrc = pQueue -> tx_queue_start;
118             }
119         } while (pSrc != pQueue->tx_queue_write);
120     }
121     TX_RESTORE
122 #else
123     GX_EVENT_PURGE(widget);
124 #endif
125 }
126 
127