]> git.cworth.org Git - fips/commitdiff
test: Rename util.c and util.h to util-x11.c and util-x11.h
authorCarl Worth <cworth@cworth.org>
Mon, 1 Jul 2013 17:43:50 +0000 (10:43 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 1 Jul 2013 17:43:50 +0000 (10:43 -0700)
These utility functions are all specific to the libX11 interface already,
and since we're planning to add some other utility functions soon, (such
as EGL), it will help to not have a too-generic name already used.

While doing this, also split up the interfaces for Display and Window
creation. This will allow us to create the GL context in between to
guarantee that the Window is created with the same visual as the GL
context.

test/Makefile.local
test/glx-dlopen-dlsym.c
test/glx-dlopen-gpa.c
test/glx-dlopen-gpaa.c
test/glx-link-call.c
test/glx-link-gpa.c
test/glx-link-gpaa.c
test/util-x11.c [new file with mode: 0644]
test/util-x11.h [new file with mode: 0644]
test/util.c [deleted file]
test/util.h [deleted file]

index aae7fdac3e5156c3457b8568e47ecc0319824d3b..dfcbe8237b50c0bd24be3a59385883bb8cbedfeb 100644 (file)
@@ -17,7 +17,7 @@ endif
 
 glx_link_call_srcs = \
        $(dir)/glx-link-call.c \
-       $(dir)/util.c
+       $(dir)/util-x11.c
 
 glx_link_call_modules = $(glx_link_call_srcs:.c=.o)
 
@@ -26,7 +26,7 @@ $(dir)/glx-link-call: $(glx_link_call_modules)
 
 glx_link_gpa_srcs = \
        $(dir)/glx-link-gpa.c \
-       $(dir)/util.c
+       $(dir)/util-x11.c
 
 glx_link_gpa_modules = $(glx_link_gpa_srcs:.c=.o)
 
@@ -35,7 +35,7 @@ $(dir)/glx-link-gpa: $(glx_link_gpa_modules)
 
 glx_link_gpaa_srcs = \
        $(dir)/glx-link-gpaa.c \
-       $(dir)/util.c
+       $(dir)/util-x11.c
 
 glx_link_gpaa_modules = $(glx_link_gpaa_srcs:.c=.o)
 
@@ -44,7 +44,7 @@ $(dir)/glx-link-gpaa: $(glx_link_gpaa_modules)
 
 glx_dlopen_dlsym_srcs = \
        $(dir)/glx-dlopen-dlsym.c \
-       $(dir)/util.c
+       $(dir)/util-x11.c
 
 glx_dlopen_dlsym_modules = $(glx_dlopen_dlsym_srcs:.c=.o)
 
@@ -53,7 +53,7 @@ $(dir)/glx-dlopen-dlsym: $(glx_dlopen_dlsym_modules)
 
 glx_dlopen_gpa_srcs = \
        $(dir)/glx-dlopen-gpa.c \
-       $(dir)/util.c
+       $(dir)/util-x11.c
 
 glx_dlopen_gpa_modules = $(glx_dlopen_gpa_srcs:.c=.o)
 
@@ -62,7 +62,7 @@ $(dir)/glx-dlopen-gpa: $(glx_dlopen_gpa_modules)
 
 glx_dlopen_gpaa_srcs = \
        $(dir)/glx-dlopen-gpaa.c \
-       $(dir)/util.c
+       $(dir)/util-x11.c
 
 glx_dlopen_gpaa_modules = $(glx_dlopen_gpaa_srcs:.c=.o)
 
index a2a6f5dcfd5eb2ac030646e0d42238faf8b2b4f8..2ac98ac42996b933721dba1fb74131db20b2ab7e 100644 (file)
@@ -34,7 +34,7 @@
 #include <stdlib.h>
 #include <dlfcn.h>
 
-#include "util.h"
+#include "util-x11.h"
 
 void (*my_glClear) (GLbitfield);
 void (*my_glClearColor) (GLclampf, GLclampf, GLclampf, GLclampf);
@@ -150,13 +150,17 @@ main (void)
         Display *dpy;
         Window window;
 
-       util_init_display_window (&dpy, &window);
+       util_x11_init_display (&dpy);
+
+       util_x11_init_window (dpy, &window);
 
        resolve_symbols ();
 
         handle_events (dpy, window);
 
-       util_fini_display_window (dpy, window);
+       util_x11_fini_window (dpy, window);
+
+       util_x11_fini_display (dpy);
 
         return 0;
 }
index 3c2c325e874919069b67773d834b262315943cc4..24238b24adee1425cf7112d489e14027d714ae5a 100644 (file)
@@ -34,7 +34,7 @@
 #include <stdlib.h>
 #include <dlfcn.h>
 
-#include "util.h"
+#include "util-x11.h"
 
 void* (*my_glXGetProcAddress) (char *);
 void (*my_glClear) (GLbitfield);
@@ -147,13 +147,17 @@ main (void)
         Display *dpy;
         Window window;
 
-       util_init_display_window (&dpy, &window);
+       util_x11_init_display (&dpy);
+
+       util_x11_init_window (dpy, &window);
 
        resolve_symbols ();
 
         handle_events (dpy, window);
 
-       util_fini_display_window (dpy, window);
+       util_x11_fini_window (dpy, window);
+
+       util_x11_fini_display (dpy);
 
         return 0;
 }
index b4aea47a0a7be1531857cb1d7a83f3a17fb4cdca..1189c3c00d96bcf7e9948686b6b4dc78ea5e1b43 100644 (file)
@@ -34,7 +34,7 @@
 #include <stdlib.h>
 #include <dlfcn.h>
 
-#include "util.h"
+#include "util-x11.h"
 
 void* (*my_glXGetProcAddressARB) (char *);
 void (*my_glClear) (GLbitfield);
@@ -147,13 +147,17 @@ main (void)
         Display *dpy;
         Window window;
 
-       util_init_display_window (&dpy, &window);
+       util_x11_init_display (&dpy);
+
+       util_x11_init_window (dpy, &window);
 
        resolve_symbols ();
 
         handle_events (dpy, window);
 
-       util_fini_display_window (dpy, window);
+       util_x11_fini_window (dpy, window);
+
+       util_x11_fini_display (dpy);
 
         return 0;
 }
index c5f8eb46d25fba4d106b88172b885994f0d8283c..f685246e4315e667cc296e5b2f586ae9640f9ab5 100644 (file)
@@ -30,7 +30,7 @@
 #include <GL/gl.h>
 #include <GL/glx.h>
 
-#include "util.h"
+#include "util-x11.h"
 
 #define HANDLE_EVENTS_GL_PREFIX
 #include "handle-events.c"
@@ -41,11 +41,15 @@ main (void)
         Display *dpy;
         Window window;
 
-       util_init_display_window (&dpy, &window);
+       util_x11_init_display (&dpy);
+
+       util_x11_init_window (dpy, &window);
 
         handle_events (dpy, window);
 
-       util_fini_display_window (dpy, window);
+       util_x11_fini_window (dpy, window);
+
+       util_x11_fini_display (dpy);
 
         return 0;
 }
index 04e5eb96cfc83d239721ccd1c66baca7c969fcee..67338fbd1e85eb3ee04415319c3d09354f7a9170 100644 (file)
@@ -33,7 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "util.h"
+#include "util-x11.h"
 
 /* The OpenGL header files give typedefs for the types of all
  * functions provided by etensisons. Here, though, we're using
@@ -151,13 +151,17 @@ main (void)
         Display *dpy;
         Window window;
 
-       util_init_display_window (&dpy, &window);
+       util_x11_init_display (&dpy);
+
+       util_x11_init_window (dpy, &window);
 
        resolve_symbols ();
 
         handle_events (dpy, window);
 
-       util_fini_display_window (dpy, window);
+       util_x11_fini_window (dpy, window);
+
+       util_x11_fini_display (dpy);
 
         return 0;
 }
index 2bf73be7c4a16d157e312197b31bad53424938fd..7def0d821bd27f8643a93654b2f18254b18c2071 100644 (file)
@@ -33,7 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "util.h"
+#include "util-x11.h"
 
 /* The OpenGL header files give typedefs for the types of all
  * functions provided by etensisons. Here, though, we're using
@@ -151,13 +151,17 @@ main (void)
         Display *dpy;
         Window window;
 
-       util_init_display_window (&dpy, &window);
+       util_x11_init_display (&dpy);
+
+       util_x11_init_window (dpy, &window);
 
        resolve_symbols ();
 
         handle_events (dpy, window);
 
-       util_fini_display_window (dpy, window);
+       util_x11_fini_window (dpy, window);
+
+       util_x11_fini_display (dpy);
 
         return 0;
 }
diff --git a/test/util-x11.c b/test/util-x11.c
new file mode 100644 (file)
index 0000000..7ab6ebc
--- /dev/null
@@ -0,0 +1,69 @@
+/* Copyright © 2013, Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "util-x11.h"
+
+void
+util_x11_init_display (Display **dpy)
+{
+        *dpy = XOpenDisplay (NULL);
+
+        if (*dpy == NULL) {
+                fprintf(stderr, "Failed to open display %s\n",
+                        XDisplayName(NULL));
+                exit (1);
+        }
+}
+
+void
+util_x11_fini_display (Display *dpy)
+{
+        XCloseDisplay (dpy);
+}
+
+void
+util_x11_init_window (Display *dpy, Window *window)
+{
+       int width = 64;
+       int height = 64;
+
+
+
+        *window = XCreateSimpleWindow(dpy, DefaultRootWindow (dpy),
+                                     0, 0, width, height, 0,
+                                     BlackPixel (dpy, DefaultScreen (dpy)),
+                                     BlackPixel (dpy, DefaultScreen (dpy)));
+
+        XSelectInput(dpy, *window,
+                     KeyPressMask | StructureNotifyMask | ExposureMask);
+
+        XMapWindow (dpy, *window);
+
+}
+
+void
+util_x11_fini_window (Display *dpy, Window window)
+{
+        XDestroyWindow (dpy, window);
+}
diff --git a/test/util-x11.h b/test/util-x11.h
new file mode 100644 (file)
index 0000000..398b263
--- /dev/null
@@ -0,0 +1,42 @@
+/* Copyright © 2013, Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef UTIL_X11_H
+#define UTIL_X11_H
+
+#include <X11/Xlib.h>
+
+void
+util_x11_init_display (Display **dpy);
+
+void
+util_x11_fini_display (Display *dpy);
+
+void
+util_x11_init_window (Display *dpy, Window *window);
+
+void
+util_x11_fini_window (Display *dpy, Window window);
+
+#endif /* UTIL_X11_H */
+
+
+
diff --git a/test/util.c b/test/util.c
deleted file mode 100644 (file)
index 3bd13f6..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Copyright © 2013, Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "util.h"
-
-void
-util_init_display_window (Display **dpy, Window *window)
-{
-       int width = 64;
-       int height = 64;
-
-        *dpy = XOpenDisplay (NULL);
-
-        if (*dpy == NULL) {
-                fprintf(stderr, "Failed to open display %s\n",
-                        XDisplayName(NULL));
-                exit (1);
-        }
-
-        *window = XCreateSimpleWindow(*dpy, DefaultRootWindow (*dpy),
-                                     0, 0, width, height, 0,
-                                     BlackPixel (*dpy, DefaultScreen (*dpy)),
-                                     BlackPixel (*dpy, DefaultScreen (*dpy)));
-
-        XSelectInput(*dpy, *window,
-                     KeyPressMask | StructureNotifyMask | ExposureMask);
-
-        XMapWindow (*dpy, *window);
-
-}
-
-void
-util_fini_display_window (Display *dpy, Window window)
-{
-        XDestroyWindow (dpy, window);
-        XCloseDisplay (dpy);
-}
diff --git a/test/util.h b/test/util.h
deleted file mode 100644 (file)
index f795a00..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright © 2013, Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef UTIL_H
-#define UTIL_H
-
-#include <X11/Xlib.h>
-
-void
-util_init_display_window (Display **dpy, Window *window);
-
-void
-util_fini_display_window (Display *dpy, Window window);
-
-#endif /* UTIL_H */
-
-
-