From: Carl Worth Date: Mon, 1 Jul 2013 17:43:50 +0000 (-0700) Subject: test: Rename util.c and util.h to util-x11.c and util-x11.h X-Git-Url: https://git.cworth.org/git?p=fips;a=commitdiff_plain;h=64cf6f7515be41e3561f6062501571ceb84ddbb2 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. --- 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-x11.c b/test/util-x11.c new file mode 100644 index 0000000..7ab6ebc --- /dev/null +++ b/test/util-x11.c @@ -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 +#include + +#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 index 0000000..398b263 --- /dev/null +++ b/test/util-x11.h @@ -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 + +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 index 3bd13f6..0000000 --- a/test/util.c +++ /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 -#include - -#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 index f795a00..0000000 --- a/test/util.h +++ /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 - -void -util_init_display_window (Display **dpy, Window *window); - -void -util_fini_display_window (Display *dpy, Window window); - -#endif /* UTIL_H */ - - -