From 64cf6f7515be41e3561f6062501571ceb84ddbb2 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 1 Jul 2013 10:43:50 -0700 Subject: [PATCH] test: Rename util.c and util.h to util-x11.c and util-x11.h 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 | 12 ++++++------ test/glx-dlopen-dlsym.c | 10 +++++++--- test/glx-dlopen-gpa.c | 10 +++++++--- test/glx-dlopen-gpaa.c | 10 +++++++--- test/glx-link-call.c | 10 +++++++--- test/glx-link-gpa.c | 10 +++++++--- test/glx-link-gpaa.c | 10 +++++++--- test/{util.c => util-x11.c} | 35 +++++++++++++++++++++++------------ test/{util.h => util-x11.h} | 16 +++++++++++----- 9 files changed, 82 insertions(+), 41 deletions(-) rename test/{util.c => util-x11.c} (77%) rename test/{util.h => util-x11.h} (81%) diff --git a/test/Makefile.local b/test/Makefile.local index aae7fda..dfcbe82 100644 --- a/test/Makefile.local +++ b/test/Makefile.local @@ -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) diff --git a/test/glx-dlopen-dlsym.c b/test/glx-dlopen-dlsym.c index a2a6f5d..2ac98ac 100644 --- a/test/glx-dlopen-dlsym.c +++ b/test/glx-dlopen-dlsym.c @@ -34,7 +34,7 @@ #include #include -#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; } diff --git a/test/glx-dlopen-gpa.c b/test/glx-dlopen-gpa.c index 3c2c325..24238b2 100644 --- a/test/glx-dlopen-gpa.c +++ b/test/glx-dlopen-gpa.c @@ -34,7 +34,7 @@ #include #include -#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; } diff --git a/test/glx-dlopen-gpaa.c b/test/glx-dlopen-gpaa.c index b4aea47..1189c3c 100644 --- a/test/glx-dlopen-gpaa.c +++ b/test/glx-dlopen-gpaa.c @@ -34,7 +34,7 @@ #include #include -#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; } diff --git a/test/glx-link-call.c b/test/glx-link-call.c index c5f8eb4..f685246 100644 --- a/test/glx-link-call.c +++ b/test/glx-link-call.c @@ -30,7 +30,7 @@ #include #include -#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; } diff --git a/test/glx-link-gpa.c b/test/glx-link-gpa.c index 04e5eb9..67338fb 100644 --- a/test/glx-link-gpa.c +++ b/test/glx-link-gpa.c @@ -33,7 +33,7 @@ #include #include -#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/glx-link-gpaa.c b/test/glx-link-gpaa.c index 2bf73be..7def0d8 100644 --- a/test/glx-link-gpaa.c +++ b/test/glx-link-gpaa.c @@ -33,7 +33,7 @@ #include #include -#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.c b/test/util-x11.c similarity index 77% rename from test/util.c rename to test/util-x11.c index 3bd13f6..7ab6ebc 100644 --- a/test/util.c +++ b/test/util-x11.c @@ -22,14 +22,11 @@ #include #include -#include "util.h" +#include "util-x11.h" void -util_init_display_window (Display **dpy, Window *window) +util_x11_init_display (Display **dpy) { - int width = 64; - int height = 64; - *dpy = XOpenDisplay (NULL); if (*dpy == NULL) { @@ -37,22 +34,36 @@ util_init_display_window (Display **dpy, Window *window) XDisplayName(NULL)); exit (1); } +} + +void +util_x11_fini_display (Display *dpy) +{ + XCloseDisplay (dpy); +} - *window = XCreateSimpleWindow(*dpy, DefaultRootWindow (*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))); + BlackPixel (dpy, DefaultScreen (dpy)), + BlackPixel (dpy, DefaultScreen (dpy))); - XSelectInput(*dpy, *window, + XSelectInput(dpy, *window, KeyPressMask | StructureNotifyMask | ExposureMask); - XMapWindow (*dpy, *window); + XMapWindow (dpy, *window); } void -util_fini_display_window (Display *dpy, Window window) +util_x11_fini_window (Display *dpy, Window window) { XDestroyWindow (dpy, window); - XCloseDisplay (dpy); } diff --git a/test/util.h b/test/util-x11.h similarity index 81% rename from test/util.h rename to test/util-x11.h index f795a00..398b263 100644 --- a/test/util.h +++ b/test/util-x11.h @@ -19,18 +19,24 @@ * THE SOFTWARE. */ -#ifndef UTIL_H -#define UTIL_H +#ifndef UTIL_X11_H +#define UTIL_X11_H #include void -util_init_display_window (Display **dpy, Window *window); +util_x11_init_display (Display **dpy); void -util_fini_display_window (Display *dpy, Window window); +util_x11_fini_display (Display *dpy); -#endif /* UTIL_H */ +void +util_x11_init_window (Display *dpy, Window *window); + +void +util_x11_fini_window (Display *dpy, Window window); + +#endif /* UTIL_X11_H */ -- 2.43.0