GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_window_scroll.c Lines: 20 20 100.0 %
Date: 2026-03-06 19:21:09 Branches: 14 14 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
/**   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_widget.h"
29
#include "gx_window.h"
30
#include "gx_system.h"
31
#include "gx_display.h"
32
#include "gx_canvas.h"
33
#include "gx_utility.h"
34
#include "gx_scrollbar.h"
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gx_window_scroll                                   PORTABLE C      */
41
/*                                                           6.1          */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This service scrolls the window client area by the specified amount */
49
/*                                                                        */
50
/*                                                                        */
51
/*  INPUT                                                                 */
52
/*                                                                        */
53
/*    window                                Pointer to window             */
54
/*    x_scroll                              Amount to scroll on x-axis    */
55
/*    y_scroll                              Amount to scroll on y-axis    */
56
/*                                                                        */
57
/*  OUTPUT                                                                */
58
/*                                                                        */
59
/*    status                                Completion status             */
60
/*                                                                        */
61
/*  CALLS                                                                 */
62
/*                                                                        */
63
/*    _gx_widget_scroll_shift               Widget scroll shift           */
64
/*    _gx_widget_block_move                 Widget block move             */
65
/*                                                                        */
66
/*  CALLED BY                                                             */
67
/*                                                                        */
68
/*    Application Code                                                    */
69
/*                                                                        */
70
/**************************************************************************/
71
1627
UINT _gx_window_scroll(GX_WINDOW *window, GX_VALUE x_scroll, GX_VALUE y_scroll)
72
{
73
1627
GX_WIDGET *child = window -> gx_widget_first_child;
74
1627
GX_BOOL    has_transparent_nonclient_children = GX_FALSE;
75
76
    /* if this window is not visible than nothing to do */
77
78
1627
    if (!(window -> gx_widget_status & GX_STATUS_VISIBLE))
79
    {
80
12
        return(GX_SUCCESS);
81
    }
82
83
    /* test to determine if transparent non-client children exist */
84
85
6428
    while (child)
86
    {
87
4842
        if (child -> gx_widget_status & GX_STATUS_NONCLIENT)
88
        {
89
3228
            if (child -> gx_widget_style & GX_STYLE_TRANSPARENT)
90
            {
91
29
                has_transparent_nonclient_children = GX_TRUE;
92
29
                break;
93
            }
94
        }
95
4813
        child = child -> gx_widget_next;
96
    }
97
98
    /* reset to first child */
99
1615
    child = window -> gx_widget_first_child;
100
101
6457
    while (child)
102
    {
103
4842
        if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT))
104
        {
105
1614
            _gx_widget_scroll_shift(child, x_scroll, y_scroll, GX_TRUE);
106
        }
107
4842
        child = child -> gx_widget_next;
108
    }
109
110
1615
    if (has_transparent_nonclient_children)
111
    {
112
        /* In this case we cannot use block-move. Just shift all child widgets */
113
29
        _gx_system_dirty_partial_add((GX_WIDGET *)window, &window -> gx_window_client);
114
    }
115
    else
116
    {
117
        /* here if we can do faster scrolling using block-move function */
118
1586
        _gx_widget_block_move((GX_WIDGET *)window, &window -> gx_window_client, x_scroll, y_scroll);
119
    }
120
121
1615
    return(GX_SUCCESS);
122
}
123