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.
This commit is contained in:
ManoloFLTK 2021-04-19 14:07:21 +02:00
parent 72901a626c
commit d01aab2ece
4 changed files with 27 additions and 23 deletions

View File

@ -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;

View File

@ -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

View File

@ -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...

View File

@ -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);