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 /** System Management (System) */ 18 /** */ 19 /**************************************************************************/ 20 21 #define GX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "gx_api.h" 27 #include "gx_utility.h" 28 #include "gx_system.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _gx_system_top_root_find PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Kenneth Maxwell, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function finds the top root window for a given incoming event. */ 44 /* */ 45 /* INPUT */ 46 /* */ 47 /* in_event Pointer to event */ 48 /* */ 49 /* OUTPUT */ 50 /* */ 51 /* GX_WINDOW_ROOT Pointer to found root window */ 52 /* */ 53 /* CALLS */ 54 /* */ 55 /* _gx_utility_rectangle_shift Shift a rectangle */ 56 /* _gx_utility_rectangle_point_detect Detect point in rectangle */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* _gx_system_event_dispatch Dispatch GUIX event */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 67 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _gx_system_top_root_find(GX_EVENT * in_event)71GX_WINDOW_ROOT *_gx_system_top_root_find(GX_EVENT *in_event) 72 { 73 GX_WINDOW_ROOT *root = _gx_system_root_window_created_list; 74 GX_RECTANGLE testsize; 75 76 /* Loop through the widgets in reverse order. */ 77 while (root) 78 { 79 if (root -> gx_widget_status & GX_STATUS_VISIBLE) 80 { 81 if (in_event -> gx_event_display_handle == (ULONG)(root -> gx_window_root_canvas -> gx_canvas_display -> gx_display_driver_data)) 82 { 83 /* get the root window size */ 84 testsize = root -> gx_widget_size; 85 86 /* offset the size by the canvas offset */ 87 _gx_utility_rectangle_shift(&testsize, 88 root -> gx_window_root_canvas -> gx_canvas_display_offset_x, 89 root -> gx_window_root_canvas -> gx_canvas_display_offset_y); 90 91 /* Is the point in this widget? */ 92 if (_gx_utility_rectangle_point_detect(&testsize, in_event -> gx_event_payload.gx_event_pointdata)) 93 { 94 break; 95 } 96 } 97 } 98 99 /* Move to the next root window. */ 100 root = (GX_WINDOW_ROOT *)root -> gx_widget_next; 101 } 102 103 /* Return the root widget. */ 104 return(root); 105 } 106 107