FLTK logo

[master] d01aab2 - Replace list of excluded platforms by name of chosen platform.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] d01aab2 - Replace list of excluded platforms by name of chosen platform. "ManoloFLTK" Apr 19, 2021  
 
commit d01aab2ecec3c437300c292536ffa0e91e494d0f
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Apr 19 14:07:21 2021 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Apr 19 14:07:37 2021 +0200

    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.

 test/color_chooser.cxx |  6 ++----
 test/list_visuals.cxx  | 38 +++++++++++++++++++++++---------------
 test/sudoku.cxx        |  2 +-
 test/tiled_image.cxx   |  4 +---
 4 files changed, 27 insertions(+), 23 deletions(-)

diff --git test/color_chooser.cxx test/color_chooser.cxx
index ffa89b1..67881f2 100644
--- test/color_chooser.cxx
+++ 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 test/list_visuals.cxx test/list_visuals.cxx
index a21e80e..8d66c30 100644
--- test/list_visuals.cxx
+++ 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 test/sudoku.cxx test/sudoku.cxx
index 2f11675..2a1a143 100644
--- test/sudoku.cxx
+++ 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 test/tiled_image.cxx test/tiled_image.cxx
index bb0a8ef..1ab2754 100644
--- test/tiled_image.cxx
+++ 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);
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.