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 /**   Window Management (Window)                                          */
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_window.h"
31 #include "gx_canvas.h"
32 #include "gx_utility.h"
33 
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _gx_window_root_event_process                       PORTABLE C      */
40 /*                                                           6.1          */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    Kenneth Maxwell, Microsoft Corporation                              */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This function processes events for the specified root window.       */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    widget                                Window's widget control block */
52 /*    event_ptr                             Incoming event to process     */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Completion status             */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _gx_canvas_shift                      Shift the canvas              */
61 /*    _gx_window_event_process              Call widget event processing  */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    GUIX Internal Code                                                  */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
72 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_gx_window_root_event_process(GX_WINDOW_ROOT * win,GX_EVENT * event_ptr)76 UINT  _gx_window_root_event_process(GX_WINDOW_ROOT *win, GX_EVENT *event_ptr)
77 {
78 UINT     status;
79 GX_VALUE xShift;
80 GX_VALUE yShift;
81 
82     status = GX_SUCCESS;
83 
84     /* Process relative to the type of event.  */
85     switch (event_ptr -> gx_event_type)
86     {
87     case GX_EVENT_PEN_DRAG:
88         if (win -> gx_window_move_mode)
89         {
90             /* to move a root window we have to move the canvas. Calculate
91                the x,y shift amounts
92              */
93             xShift = (GX_VALUE)(event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_x -
94                                 win -> gx_window_move_start.gx_point_x);
95             yShift = (GX_VALUE)(event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_y -
96                                 win -> gx_window_move_start.gx_point_y);
97 
98             /* reset the starting point for next time */
99             win -> gx_window_move_start.gx_point_x =
100                 (GX_VALUE)(event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_x - xShift);
101             win -> gx_window_move_start.gx_point_y =
102                 (GX_VALUE)(event_ptr -> gx_event_payload.gx_event_pointdata.gx_point_y - yShift);
103 
104             /* move the canvas */
105             _gx_canvas_shift(win -> gx_window_root_canvas, xShift, yShift);
106         }
107         return(GX_SUCCESS);
108 
109 
110 
111     default:
112 
113         /* Call the window default processing function.  */
114         status =  _gx_window_event_process((GX_WINDOW *)win, event_ptr);
115     }
116     /* Return widget event processing status.  */
117     return(status);
118 }
119 
120