3 * Sample server that just keeps first available window mapped.
10 #include <GL/miniglx.h>
18 struct client
*clients
= 0, *mapped_client
= 0;
21 static struct client
*find_client( Window id
)
25 for (c
= clients
; c
; c
= c
->next
)
26 if (c
->windowid
== id
)
32 int main( int argc
, char *argv
[] )
37 dpy
= __miniglx_StartServer(NULL
);
39 fprintf(stderr
, "Error: __miniglx_StartServer failed\n");
43 while (XNextEvent( dpy
, &ev
)) {
48 fprintf(stderr
, "MapRequest\n");
49 c
= find_client(ev
.xmaprequest
.window
);
55 fprintf(stderr
, "UnmapNotify\n");
56 c
= find_client(ev
.xunmap
.window
);
59 if (c
== mapped_client
)
64 fprintf(stderr
, "CreateNotify\n");
65 c
= malloc(sizeof(*c
));
67 c
->windowid
= ev
.xcreatewindow
.window
;
73 fprintf(stderr
, "DestroyNotify\n");
74 c
= find_client(ev
.xdestroywindow
.window
);
80 for (t
= clients
; t
->next
!= c
; t
= t
->next
)
85 if (c
== mapped_client
)
95 /* Search for first mappable client if none already mapped.
98 for (c
= clients
; c
; c
= c
->next
) {
100 XMapWindow( dpy
, c
->windowid
);
108 XCloseDisplay( dpy
);