summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2003-04-16 09:34:56 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2003-04-16 09:34:56 +0000
commit1b3edffdd12bd3a9273e9ff4254cd44093df2ae8 (patch)
treec3a1c8ad02da13a42f8d444b13d9d6fdd822ba0a /progs
parent12ee43bd7c14e6ed6beff4cd7cfde867b54250d8 (diff)
A simple "server" processes to manage a single cliprect between
multiple fullscreen clients.
Diffstat (limited to 'progs')
-rw-r--r--progs/tests/sample_server.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/progs/tests/sample_server.c b/progs/tests/sample_server.c
new file mode 100644
index 00000000000..a21c0c7f00d
--- /dev/null
+++ b/progs/tests/sample_server.c
@@ -0,0 +1,115 @@
+/* $Id: sample_server.c,v 1.1.2.1 2003/04/16 09:34:56 keithw Exp $ */
+
+/*
+ * Sample server that just keeps first available window mapped.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/gl.h>
+#include <GL/miniglx.h>
+
+struct client {
+ struct client *next;
+ Window windowid;
+ int mappable;
+};
+
+struct client *clients = 0, *mapped_client = 0;
+
+
+static struct client *find_client( Window id )
+{
+ struct client *c;
+
+ for (c = clients ; c ; c = c->next)
+ if (c->windowid == id)
+ return c;
+
+ return 0;
+}
+
+int main( int argc, char *argv[] )
+{
+ Display *dpy;
+ XEvent ev;
+
+ dpy = __miniglx_StartServer(NULL);
+ if (!dpy) {
+ fprintf(stderr, "Error: __miniglx_StartServer failed\n");
+ return 1;
+ }
+
+ /* How is vt switching communicated through the XNextEvent interface?
+ */
+
+ while (XNextEvent( dpy, &ev )) {
+ struct client *c;
+
+ switch (ev.type) {
+ case MapRequest:
+ fprintf(stderr, "MapRequest\n");
+ c = find_client(ev.xmaprequest.window);
+ if (!c) break;
+ c->mappable = True;
+ break;
+
+ case UnmapNotify:
+ fprintf(stderr, "UnmapNotify\n");
+ c = find_client(ev.xunmap.window);
+ if (!c) break;
+ c->mappable = False;
+ if (c == mapped_client)
+ mapped_client = 0;
+ break;
+
+ case CreateNotify:
+ fprintf(stderr, "CreateNotify\n");
+ c = malloc(sizeof(*c));
+ c->next = clients;
+ c->windowid = ev.xcreatewindow.window;
+ c->mappable = False;
+ clients = c;
+ break;
+
+ case DestroyNotify:
+ fprintf(stderr, "DestroyNotify\n");
+ c = find_client(ev.xdestroywindow.window);
+ if (!c) break;
+ if (c == clients)
+ clients = c->next;
+ else {
+ struct client *t;
+ for (t = clients ; t->next != c ; t = t->next)
+ ;
+ t->next = c->next;
+ }
+
+ if (c == mapped_client)
+ mapped_client = 0;
+
+ free(c);
+ break;
+
+ default:
+ break;
+ }
+
+ /* Search for first mappable client if none already mapped.
+ */
+ if (!mapped_client) {
+ for (c = clients ; c ; c = c->next) {
+ if (c->mappable) {
+ XMapWindow( dpy, c->windowid );
+ mapped_client = c;
+ break;
+ }
+ }
+ }
+ }
+
+ XCloseDisplay( dpy );
+
+ return 0;
+}