OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [mw/] [src/] [demos/] [nanox/] [nxlsclients.c] - Blame information for rev 673

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (C) 2000 by VTech Informations LTD.
3
 * This program is released under MPL.
4
 *
5
 * Vladimir Cotfas <vladimircotfas@vtech.ca> Oct 25, 2000
6
 */
7
#include <stdio.h>
8
#include <stdlib.h>
9
#define MWINCLUDECOLORS
10
#include "nano-X.h"
11
#include "windef.h"
12
 
13
/* which is the maximim window id?!?!*/
14
#define LIMIT   10000
15
 
16
struct _colour {
17
        unsigned long colour;
18
        char* name;
19
};
20
typedef struct _colour COLOURS;
21
 
22
static COLOURS colour_table[] = {
23
        { BLACK, "Black" },
24
        { BLUE, "Blue" },
25
        { GREEN, "Green"},
26
        { CYAN, "Cyan" },
27
        { RED, "Red" },
28
        { MAGENTA, "Magenta" },
29
        { BROWN, "Brown" },
30
        { LTGRAY, "LightGray" },
31
        { GRAY, "Gray" },
32
        { DKGRAY, "DarkGray" },
33
        { LTBLUE, "LightBlue" },
34
        { LTGREEN, "LightGreen" },
35
        { LTCYAN, "LightCyan" },
36
        { LTRED, "LightRed" },
37
        { LTMAGENTA, "LightMagenta" },
38
        { YELLOW, "Yellow" },
39
        { WHITE, "White" }
40
};
41
#define NR_COLOURS      (sizeof(colour_table) / sizeof(colour_table[0]))
42
 
43
char*
44
lookupColour(unsigned long c)
45
{
46
        int i;
47
 
48
        for (i = 0; i < NR_COLOURS; i++)
49
                if (c == colour_table[i].colour)
50
                        return colour_table[i].name;
51
 
52
        return "UanbleToComply";
53
}
54
 
55
struct _xlat {
56
        unsigned event_type;
57
        char* event_desc;
58
};
59
typedef struct _xlat XLAT;
60
 
61
static XLAT event_table[] = {
62
        { GR_EVENT_TYPE_ERROR,          "GR_EVENT_MASK_ERROR"           },
63
/*      { GR_EVENT_TYPE_NONE,           "GR_EVENT_MASK_NONE"            }, */
64
        { GR_EVENT_TYPE_EXPOSURE,       "GR_EVENT_MASK_EXPOSURE"        },
65
        { GR_EVENT_TYPE_BUTTON_DOWN,    "GR_EVENT_MASK_BUTTON_DOWN"     },
66
        { GR_EVENT_TYPE_BUTTON_UP,      "GR_EVENT_MASK_BUTTON_UP"       },
67
        { GR_EVENT_TYPE_MOUSE_ENTER,    "GR_EVENT_MASK_MOUSE_ENTER"     },
68
        { GR_EVENT_TYPE_MOUSE_EXIT,     "GR_EVENT_MASK_MOUSE_EXIT"      },
69
        { GR_EVENT_TYPE_MOUSE_MOTION,   "GR_EVENT_MASK_MOUSE_MOTION"    },
70
        { GR_EVENT_TYPE_MOUSE_POSITION, "GR_EVENT_MASK_MOUSE_POSITION"  },
71
        { GR_EVENT_TYPE_KEY_DOWN,       "GR_EVENT_MASK_KEY_DOWN"        },
72
        { GR_EVENT_TYPE_KEY_UP,         "GR_EVENT_MASK_KEY_UP"          },
73
        { GR_EVENT_TYPE_FOCUS_IN,       "GR_EVENT_MASK_FOCUS_IN"        },
74
        { GR_EVENT_TYPE_FOCUS_OUT,      "GR_EVENT_MASK_FOCUS_OUT"       },
75
        { GR_EVENT_TYPE_FDINPUT,        "GR_EVENT_MASK_FDINPUT"         },
76
        { GR_EVENT_TYPE_UPDATE,         "GR_EVENT_MASK_UPDATE"          },
77
        { GR_EVENT_TYPE_CHLD_UPDATE,    "GR_EVENT_MASK_CHLD_UPDATE"     },
78
        { GR_EVENT_TYPE_CLOSE_REQ,      "GR_EVENT_MASK_CLOSE_REQ"       }
79
};
80
#define NR_MASKS        (sizeof(event_table) / sizeof(event_table[0]))
81
 
82
struct _wm_props {
83
        GR_WM_PROPS prop;
84
        char* prop_symbol;
85
        char* prop_descr;
86
};
87
typedef struct _wm_props WM_PROPS;
88
 
89
static WM_PROPS props_table[] = {
90
        /* Window properties */
91
        { GR_WM_PROPS_NOBACKGROUND, "GR_WM_PROPS_NOBACKGROUND", "Don't draw window background" },
92
        { GR_WM_PROPS_NOFOCUS, "GR_WM_PROPS_NOFOCUS", "Don't set focus to this window" },
93
        { GR_WM_PROPS_NOMOVE, "GR_WM_PROPS_NOMOVE", "Don't let user move window" },
94
        { GR_WM_PROPS_NORAISE, "GR_WM_PROPS_NORAISE", "Don't let user raise window" },
95
        { GR_WM_PROPS_NODECORATE, "GR_WM_PROPS_NODECORATE", "Don't redecorate window" },
96
        { GR_WM_PROPS_NOAUTOMOVE, "GR_WM_PROPS_NOAUTOMOVE", "Don't move window on decorating" },
97
 
98
        /* default decoration style */
99
        { GR_WM_PROPS_APPWINDOW, "GR_WM_PROPS_APPWINDOW", "Leave appearance to WM" },
100
        { GR_WM_PROPS_APPMASK, "GR_WM_PROPS_APPMASK", "Appearance mask" },
101
        { GR_WM_PROPS_BORDER, "GR_WM_PROPS_BORDER", "Single line border" },
102
        { GR_WM_PROPS_APPFRAME, "GR_WM_PROPS_APPFRAME", "3D app frame" },
103
        { GR_WM_PROPS_CAPTION, "GR_WM_PROPS_CAPTION", "Title bar" },
104
        { GR_WM_PROPS_CLOSEBOX, "GR_WM_PROPS_CLOSEBOX", "Close box" },
105
#if 0
106
        { GR_WM_PROPS_MAXIMIZED, "GR_WM_PROPS_MAXIMIZED", "Application is maximized" }
107
#endif
108
};
109
#define NR_PROPS        (sizeof(props_table) / sizeof(props_table[0]))
110
 
111
int
112
main(int argc, char* argv[])
113
{
114
        GR_WINDOW_ID w;
115
        GR_WINDOW_INFO info;
116
 
117
        if (GrOpen() < 0) {
118
                fprintf(stderr, "nxlsclients: cannot open graphics\n");
119
                exit(1);
120
        }
121
 
122
        for (w = 0; w < LIMIT; w++) {
123
                info.wid = -1; /* self-sabotaged like CCCP */
124
 
125
                GrGetWindowInfo(w, &info);
126
 
127
                if (info.wid == -1) {
128
                        printf("Query wid = %d, GrGetWindowInfo() is not working!\n", w);
129
                        continue;
130
                }
131
                if (info.wid == 0) {
132
#if 0
133
                        printf("Query wid = %d --> does not exist\n", w);
134
#endif
135
                        continue;
136
                }
137
                printf("Window id = %d\n", info.wid);
138
                printf("\tAbsolute upper-left X: %d\n", info.x);
139
                printf("\tAbsolute upper-left Y: %d\n", info.y);
140
                printf("\tWidth = %d\n", info.width);
141
                printf("\tHeight = %d\n", info.height);
142
                printf("\tBorder: size = %d, colour = %s (#%06lX)\n", \
143
                       info.bordersize,
144
                       lookupColour(info.bordercolor), info.bordercolor);
145
                printf("\tBackground colour = %s (#%06lX)\n", \
146
                       lookupColour(info.background), info.background);
147
 
148
                printf("\tParent = %d\n", info.parent);
149
                printf("\tFirst child = %d\n", info.child);
150
                printf("\tNext sibling? = %d\n", info.sibling);
151
 
152
                printf("\t%sinput-only, ", (info.inputonly == TRUE)?"": "not ");
153
                printf("%smapped", (info.mapped == TRUE)?"": "not ");
154
                if (info.mapped != TRUE)
155
                        printf(", unmapcount = %d", info.unmapcount);
156
                printf("\n");
157
 
158
                printf("\tEvent mask (0x%08lX):\n", info.eventmask);
159
                {
160
                        int i, n = 0;
161
                        GR_EVENT_MASK tmp = info.eventmask;
162
 
163
                        for (i = 0; i < NR_MASKS; i++) {
164
                                GR_EVENT_MASK mask = GR_EVENTMASK(event_table[i].event_type);
165
 
166
                                if ((tmp  & mask) == mask) {
167
                                        printf("\t\t%s\n", event_table[i].event_desc);
168
                                        n++;
169
                                }
170
                        }
171
                        if (!n)
172
                                printf("\t\tGR_EVENT_MASK_NONE (?!?!?)\n");
173
                }
174
 
175
                /* We don't use info.props, use GrGetWMProperties() intead */
176
                printf("\tWM Properties:\n");
177
                {
178
                        GR_WM_PROPERTIES wm_props;
179
 
180
                        GrGetWMProperties(w, &wm_props);
181
 
182
                        printf("\t\tTitle: ");
183
                        if ((wm_props.flags & GR_WM_FLAGS_TITLE ) == GR_WM_FLAGS_TITLE)
184
                                printf("'%s'\n", (char*)wm_props.title?:"(null)");
185
                        else
186
                                printf("<untitled>\n");
187
 
188
                        printf("\t\tBackground colour: ");
189
                        if ((wm_props.flags & GR_WM_FLAGS_BACKGROUND) == GR_WM_FLAGS_BACKGROUND)
190
                                printf("%s (#%06lX)\n", lookupColour(wm_props.background),
191
                                       wm_props.background);
192
                        else
193
                                printf("<unspecified>\n");
194
 
195
                        printf("\t\tBorder size: ");
196
                        if ((wm_props.flags & GR_WM_FLAGS_BORDERSIZE) == GR_WM_FLAGS_BORDERSIZE)
197
                                printf("%d\n", wm_props.bordersize);
198
                        else
199
                                printf("<unspecified>\n");
200
 
201
                        printf("\t\tProperty bits (0x%08lX):\n", wm_props.props);
202
                        {
203
                                int i, n = 0;
204
 
205
                                for (i = 0; i < NR_PROPS; i++) {
206
                                        GR_WM_PROPS prop = props_table[i].prop;
207
                                        if ((wm_props.props & prop) == prop) {
208
                                                printf("\t\t\t%s (%s)\n", \
209
                                                                props_table[i].prop_symbol, \
210
                                                                props_table[i].prop_descr);
211
                                                n++;
212
                                        }
213
                                }
214
 
215
                                if (!n)
216
                                        printf("\t\tNONE (?!?!?)\n");
217
                        }
218
 
219
                }
220
        }
221
 
222
        GrClose();
223
 
224
        return 0;
225
 }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.