GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_system_top_root_find.c Lines: 13 13 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
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_utility.h"
29
#include "gx_system.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_system_top_root_find                            PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function finds the top root window for a given incoming event. */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    in_event                              Pointer to event              */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    GX_WINDOW_ROOT                        Pointer to found root window  */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _gx_utility_rectangle_shift           Shift a rectangle             */
57
/*    _gx_utility_rectangle_point_detect    Detect point in rectangle     */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    _gx_system_event_dispatch             Dispatch GUIX event           */
62
/*                                                                        */
63
/**************************************************************************/
64
16733
GX_WINDOW_ROOT  *_gx_system_top_root_find(GX_EVENT *in_event)
65
{
66
16733
GX_WINDOW_ROOT *root = _gx_system_root_window_created_list;
67
GX_RECTANGLE    testsize;
68
69
    /* Loop through the widgets in reverse order.  */
70
32609
    while (root)
71
    {
72
32607
        if (root -> gx_widget_status & GX_STATUS_VISIBLE)
73
        {
74
17528
            if (in_event -> gx_event_display_handle == (ULONG)(root -> gx_window_root_canvas -> gx_canvas_display -> gx_display_driver_data))
75
            {
76
                /* get the root window size */
77
17527
                testsize = root -> gx_widget_size;
78
79
                /* offset the size by the canvas offset */
80
17527
                _gx_utility_rectangle_shift(&testsize,
81
17527
                                            root -> gx_window_root_canvas -> gx_canvas_display_offset_x,
82
17527
                                            root -> gx_window_root_canvas -> gx_canvas_display_offset_y);
83
84
                /* Is the point in this widget?  */
85
17527
                if (_gx_utility_rectangle_point_detect(&testsize, in_event -> gx_event_payload.gx_event_pointdata))
86
                {
87
16731
                    break;
88
                }
89
            }
90
        }
91
92
        /* Move to the next root window.  */
93
15876
        root = (GX_WINDOW_ROOT *)root -> gx_widget_next;
94
    }
95
96
    /* Return the root widget.  */
97
16733
    return(root);
98
}
99