1 /* $Id: sample_server.c,v 1.1 2003/08/06 17:47:15 keithw Exp $ */
4 * Sample server that just keeps first available window mapped.
11 #include <GL/miniglx.h>
19 struct client
*clients
= 0, *mapped_client
= 0;
22 static struct client
*find_client( Window id
)
26 for (c
= clients
; c
; c
= c
->next
)
27 if (c
->windowid
== id
)
33 int main( int argc
, char *argv
[] )
38 dpy
= __miniglx_StartServer(NULL
);
40 fprintf(stderr
, "Error: __miniglx_StartServer failed\n");
44 while (XNextEvent( dpy
, &ev
)) {
49 fprintf(stderr
, "MapRequest\n");
50 c
= find_client(ev
.xmaprequest
.window
);
56 fprintf(stderr
, "UnmapNotify\n");
57 c
= find_client(ev
.xunmap
.window
);
60 if (c
== mapped_client
)
65 fprintf(stderr
, "CreateNotify\n");
66 c
= malloc(sizeof(*c
));
68 c
->windowid
= ev
.xcreatewindow
.window
;
74 fprintf(stderr
, "DestroyNotify\n");
75 c
= find_client(ev
.xdestroywindow
.window
);
81 for (t
= clients
; t
->next
!= c
; t
= t
->next
)
86 if (c
== mapped_client
)
96 /* Search for first mappable client if none already mapped.
99 for (c
= clients
; c
; c
= c
->next
) {
101 XMapWindow( dpy
, c
->windowid
);
109 XCloseDisplay( dpy
);