diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-04-19 14:07:21 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-04-19 14:07:37 +0200 |
| commit | d01aab2ecec3c437300c292536ffa0e91e494d0f (patch) | |
| tree | e98050a51bb89b7fa897cb05d0d59859a88dea05 /test | |
| parent | 72901a626c47502b3ab660b8a67ec82698ebe56d (diff) | |
Replace list of excluded platforms by name of chosen platform.
Since FL/platform.H defines USE_X11 for the X11 platform, it's better to target
the X11 platform by
#include <FL/platform.H>
#if USE_X11
rather than by
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__)
that would have to grow with future platforms.
Diffstat (limited to 'test')
| -rw-r--r-- | test/color_chooser.cxx | 6 | ||||
| -rw-r--r-- | test/list_visuals.cxx | 38 | ||||
| -rw-r--r-- | test/sudoku.cxx | 2 | ||||
| -rw-r--r-- | test/tiled_image.cxx | 4 |
4 files changed, 27 insertions, 23 deletions
diff --git a/test/color_chooser.cxx b/test/color_chooser.cxx index ffa89b1e5..67881f28d 100644 --- a/test/color_chooser.cxx +++ b/test/color_chooser.cxx @@ -26,9 +26,7 @@ #include <stdlib.h> #include <stdio.h> -#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__) #include "list_visuals.cxx" -#endif int width = 100; int height = 100; @@ -112,7 +110,7 @@ int main(int argc, char ** argv) { " - : default visual\n" " r : call Fl::visual(FL_RGB)\n" " c : call Fl::own_colormap()\n",argv[0]); -#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__) +#if USE_X11 printf(" # : use this visual with an empty colormap:\n"); list_visuals(); #endif @@ -125,7 +123,7 @@ int main(int argc, char ** argv) { } else if (argv[i][0] == 'c') { Fl::own_colormap(); } else if (argv[i][0] != '-') { -#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__) +#if USE_X11 int visid = atoi(argv[i]); fl_open_display(); XVisualInfo templt; int num; diff --git a/test/list_visuals.cxx b/test/list_visuals.cxx index a21e80ede..8d66c3012 100644 --- a/test/list_visuals.cxx +++ b/test/list_visuals.cxx @@ -4,7 +4,7 @@ // List all the visuals on the screen, and dumps anything interesting // about them to stdout. // -// Does not use FLTK. +// Does not use FLTK under X11. // // This file may be #included in another program to make a function to // call to list the visuals. Fl.H must be included first to indicate this. @@ -22,22 +22,19 @@ // https://www.fltk.org/bugs.php // -#if defined(_WIN32) || defined(__APPLE__) -#include <FL/Fl.H> -#include <FL/fl_message.H> +#ifndef Fl_H +# define NEED_MAIN 1 // when not included by another FLTK program +#endif -int main(int, char**) { - fl_alert("Currently, this program works only under X."); - return 1; -} +#include <FL/platform.H> // for USE_X11 -#else +#if USE_X11 #include <config.h> #define HAVE_MULTIBUF 0 -#ifndef Fl_H +#ifdef NEED_MAIN #include <X11/Xlib.h> #include <X11/Xutil.h> @@ -57,7 +54,7 @@ void fl_open_display() { fl_screen = DefaultScreen(fl_display); } -#endif +#endif // NEED_MAIN const char *ClassNames[] = { "StaticGray ", @@ -216,14 +213,25 @@ void list_visuals() { if ( overlayInfo ) { XFree(overlayInfo); overlayInfo = 0; } } -#endif +#endif // USE_X11 -#ifndef Fl_H -int main(int argc, char **argv) { +#ifdef NEED_MAIN + +# if ! USE_X11 +# include <FL/fl_ask.H> +# endif + +int main(int argc, char** argv) { +# if USE_X11 if (argc == 1); else if (argc == 2 && argv[1][0]!='-') dname = argv[1]; else {fprintf(stderr,"usage: %s <display>\n",argv[0]); exit(1);} list_visuals(); return 0; +# else + fl_alert("Currently, this program works only under X."); + return 1; +# endif // USE_X11 } -#endif + +#endif // NEED_MAIN diff --git a/test/sudoku.cxx b/test/sudoku.cxx index 2f116753f..2a1a14376 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -437,7 +437,7 @@ void SudokuSound::play(char note) { Sleep(NOTE_DURATION); } else Beep(frequencies[note - 'A'], NOTE_DURATION); -#else +#elif USE_X11 # ifdef HAVE_ALSA_ASOUNDLIB_H if (handle) { // Use ALSA to play the sound... diff --git a/test/tiled_image.cxx b/test/tiled_image.cxx index bb0a8ef55..1ab275493 100644 --- a/test/tiled_image.cxx +++ b/test/tiled_image.cxx @@ -33,9 +33,7 @@ void button_cb(Fl_Widget *,void *) { } #include <FL/platform.H> -#if !defined(_WIN32) && !defined(__APPLE__) #include "list_visuals.cxx" -#endif int visid = -1; int arg(int argc, char **argv, int &i) { @@ -49,7 +47,7 @@ int arg(int argc, char **argv, int &i) { } int main(int argc, char **argv) { -#if !defined(_WIN32) && !defined(__APPLE__) +#if USE_X11 int i = 1; Fl::args(argc,argv,i,arg); |
