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 /**   Dispaly Management (Dispaly)                                        */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_display.h"
28 #include "gx_utility.h"
29 
30 #if defined(GX_MOUSE_SUPPORT)
31 #if !defined(GX_HARDWARE_MOUSE_SUPPORT)
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_display_driver_generic_mouse_position_set       PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This service sets the mouse position for software mouse support.    */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    display                               Display control block         */
49 /*    position                              Position of mouse cursor      */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*                                                                        */
56 /*  CALLED BY                                                             */
57 /*                                                                        */
58 /*    Application Code                                                    */
59 /*                                                                        */
60 /*  RELEASE HISTORY                                                       */
61 /*                                                                        */
62 /*    DATE              NAME                      DESCRIPTION             */
63 /*                                                                        */
64 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
65 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
66 /*                                            resulting in version 6.1    */
67 /*                                                                        */
68 /**************************************************************************/
_gx_display_driver_generic_mouse_position_set(GX_DISPLAY * display,GX_POINT * pos)69 VOID  _gx_display_driver_generic_mouse_position_set(GX_DISPLAY *display, GX_POINT *pos)
70 {
71 GX_RECTANGLE mouse_rect;
72 GX_CANVAS   *canvas;
73 
74     if (display->gx_display_mouse.gx_mouse_cursor_info)
75     {
76         canvas = display -> gx_display_mouse.gx_mouse_canvas;
77         mouse_rect = display -> gx_display_mouse.gx_mouse_rect;
78 
79         /* First hide the mouse if the area under mouse has been captured */
80         if (display -> gx_display_mouse.gx_mouse_status & GX_MOUSE_VISIBLE)
81         {
82             display -> gx_display_mouse_restore(display);
83         }
84 
85         display -> gx_display_mouse.gx_mouse_position = *pos;
86 
87         if (display -> gx_display_mouse.gx_mouse_status & GX_MOUSE_ENABLED)
88         {
89             display -> gx_display_mouse_capture(display);
90             display -> gx_display_mouse_draw(display);
91         }
92 
93         if (display -> gx_display_driver_buffer_toggle)
94         {
95             _gx_utility_rectangle_combine(&mouse_rect, &display -> gx_display_mouse.gx_mouse_rect);
96             canvas -> gx_canvas_dirty_area = mouse_rect;
97             display -> gx_display_driver_buffer_toggle(canvas, &canvas -> gx_canvas_dirty_area);
98         }
99     }
100 }
101 #endif
102 #endif
103 
104