"Fossies" - the Fresh Open Source Software Archive

Member "xscreensaver-6.01/driver/exts.c" (8 May 2021, 7022 Bytes) of package /linux/misc/xscreensaver-6.01.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "exts.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.00_vs_6.01.

    1 /* xscreensaver, Copyright © 1991-2021 Jamie Zawinski <jwz@jwz.org>
    2  *
    3  * Permission to use, copy, modify, distribute, and sell this software and its
    4  * documentation for any purpose is hereby granted without fee, provided that
    5  * the above copyright notice appear in all copies and that both that
    6  * copyright notice and this permission notice appear in supporting
    7  * documentation.  No representations are made about the suitability of this
    8  * software for any purpose.  It is provided "as is" without express or 
    9  * implied warranty.
   10  */
   11 
   12 /* Some random diagnostics printed in -verbose mode about what extensions
   13    are available on the server, and their version numbers.
   14  */
   15 
   16 #ifdef HAVE_CONFIG_H
   17 # include "config.h"
   18 #endif
   19 
   20 #include <stdio.h>
   21 #include <X11/Xlib.h>
   22 #include <X11/Xlibint.h>
   23 #include <X11/Intrinsic.h>
   24 
   25 #include <X11/extensions/XInput2.h>
   26 
   27 #ifdef HAVE_XSHM_EXTENSION
   28 # include <X11/extensions/XShm.h>
   29 #endif /* HAVE_XSHM_EXTENSION */
   30 
   31 #ifdef HAVE_DPMS_EXTENSION
   32 # include <X11/extensions/dpms.h>
   33 #endif /* HAVE_DPMS_EXTENSION */
   34 
   35 
   36 #ifdef HAVE_DOUBLE_BUFFER_EXTENSION
   37 # include <X11/extensions/Xdbe.h>
   38 #endif /* HAVE_DOUBLE_BUFFER_EXTENSION */
   39 
   40 #ifdef HAVE_XF86VMODE
   41 # include <X11/extensions/xf86vmode.h>
   42 #endif /* HAVE_XF86VMODE */
   43 
   44 #ifdef HAVE_XINERAMA
   45 # include <X11/extensions/Xinerama.h>
   46 #endif /* HAVE_XINERAMA */
   47 
   48 #ifdef HAVE_RANDR
   49 # include <X11/extensions/Xrandr.h>
   50 #endif /* HAVE_RANDR */
   51 
   52 #ifdef HAVE_XCOMPOSITE_EXTENSION
   53 # include <X11/extensions/Xcomposite.h>
   54 #endif
   55 
   56 #ifdef HAVE_XKB
   57 # include <X11/XKBlib.h>
   58 #endif
   59 
   60 #include "xscreensaver.h"
   61 
   62 
   63 void
   64 print_available_extensions (saver_info *si)
   65 {
   66   int i, j;
   67   static struct {
   68     const char *name; const char *desc; 
   69     Bool useful_p;
   70     Status (*version_fn) (Display *, int *majP, int *minP);
   71   } exts[] = {
   72 
   73 # if 0
   74    { "MIT-SCREEN-SAVER",                        "MIT Screen-Saver",
   75         False, 0
   76    },
   77 # endif
   78    { "MIT-SHM",                                 "Shared Memory",
   79 #     ifdef HAVE_XSHM_EXTENSION
   80         True, (Status (*) (Display*,int*,int*)) XShmQueryVersion /* 4 args */
   81 #     else
   82         False, 0
   83 #     endif
   84    }, { "DOUBLE-BUFFER",                        "Double-Buffering",
   85 #     ifdef HAVE_DOUBLE_BUFFER_EXTENSION
   86         True, XdbeQueryExtension
   87 #     else
   88         False, 0
   89 #     endif
   90    }, { "DPMS",                                 "Power Management",
   91 #     ifdef HAVE_DPMS_EXTENSION
   92         True,  DPMSGetVersion
   93 #     else
   94         False, 0
   95 #     endif
   96    }, { "GLX",                                  "GLX",
   97 #     ifdef HAVE_GL
   98         True,  0
   99 #     else
  100         False, 0
  101 #     endif
  102    }, { "XFree86-VidModeExtension",             "XF86 Video-Mode",
  103 #     ifdef HAVE_XF86VMODE
  104         True,  XF86VidModeQueryVersion
  105 #     else
  106         False, 0
  107 #     endif
  108    }, { "XC-VidModeExtension",                  "XC Video-Mode",
  109 #     ifdef HAVE_XF86VMODE
  110         True,  XF86VidModeQueryVersion
  111 #     else
  112         False, 0
  113 #     endif
  114    }, { "XINERAMA",                             "Xinerama",
  115 #     ifdef HAVE_XINERAMA
  116         True,  XineramaQueryVersion
  117 #     else
  118         False, 0
  119 #     endif
  120    }, { "RANDR",                                "Resize-and-Rotate",
  121 #     ifdef HAVE_RANDR
  122         True,  XRRQueryVersion
  123 #     else
  124         False, 0
  125 #     endif
  126    }, { "Composite",                            "Composite",
  127 #     ifdef HAVE_XCOMPOSITE_EXTENSION
  128         True,  XCompositeQueryVersion
  129 #     else
  130         True, 0
  131 #     endif
  132    }, { "XKEYBOARD",                            "XKeyboard",
  133 #     ifdef HAVE_XKB
  134         True,  0,
  135 #     else
  136         False, 0
  137 #     endif
  138    }, { "DRI",          "DRI",      True, 0
  139    }, { "NV-CONTROL",       "NVidia",   True, 0
  140    }, { "NV-GLX",       "NVidia GLX",   True, 0
  141    }, { "Apple-DRI",        "Apple-DRI",    True, 0
  142    }, { "Apple-WM",     "Apple-WM", True, 0
  143    }, { "XInputExtension",  "XInput",   True, 0
  144    },
  145   };
  146 
  147   fprintf (stderr, "%s: running on display \"%s\"\n", blurb(), 
  148            DisplayString(si->dpy));
  149   fprintf (stderr, "%s: vendor is %s, %d\n", blurb(),
  150        ServerVendor(si->dpy), VendorRelease(si->dpy));
  151 
  152   fprintf (stderr, "%s: useful extensions:\n", blurb());
  153   for (i = 0; i < countof(exts); i++)
  154     {
  155       int op = 0, event = 0, error = 0;
  156       char buf [255];
  157       int maj = 0, min = 0;
  158       int dummy1, dummy2, dummy3;
  159 
  160       /* Most of the extension version functions take 3 args,
  161          writing results into args 2 and 3, but some take more.
  162          We only ever care about the first two results, but we
  163          pass in three extra pointers just in case.
  164        */
  165       Status (*version_fn_2) (Display*,int*,int*,int*,int*,int*) =
  166         (Status (*) (Display*,int*,int*,int*,int*,int*)) exts[i].version_fn;
  167 
  168       if (!XQueryExtension (si->dpy, exts[i].name, &op, &event, &error))
  169         continue;
  170       sprintf (buf, "%s:   ", blurb());
  171       strcat (buf, exts[i].desc);
  172 
  173       if (!strcmp (exts[i].desc, "XInput"))
  174         {
  175           int maj = 999, min = 999;              /* Desired */
  176           XIQueryVersion (si->dpy, &maj, &min);  /* Actual */
  177           sprintf (buf+strlen(buf), " (%d.%d)", maj, min);
  178         }
  179       else if (!version_fn_2)
  180         ;
  181       else if (version_fn_2 (si->dpy, &maj, &min, &dummy1, &dummy2, &dummy3))
  182         sprintf (buf+strlen(buf), " (%d.%d)", maj, min);
  183       else
  184         strcat (buf, " (unavailable)");
  185 
  186       if (!exts[i].useful_p)
  187         strcat (buf, " (disabled at compile time)");
  188       fprintf (stderr, "%s\n", buf);
  189     }
  190 
  191 # ifdef HAVE_LIBSYSTEMD
  192   fprintf (stderr, "%s:   libsystemd\n", blurb());
  193 # endif
  194 # ifdef HAVE_LIBELOGIND
  195   fprintf (stderr, "%s:   libelogind\n", blurb());
  196 # endif
  197 # if !defined(HAVE_LIBSYSTEMD) && !defined(HAVE_LIBELOGIND)
  198   fprintf (stderr, "%s:   libsystemd/libelogind (disabled at compile time)\n",
  199            blurb());
  200 # endif
  201 
  202   for (i = 0; i < si->nscreens; i++)
  203     {
  204       saver_screen_info *ssi = &si->screens[i];
  205       unsigned long colormapped_depths = 0;
  206       unsigned long non_mapped_depths = 0;
  207       XVisualInfo vi_in, *vi_out;
  208       int out_count;
  209 
  210       if (!ssi->real_screen_p) continue;
  211 
  212       vi_in.screen = ssi->real_screen_number;
  213       vi_out = XGetVisualInfo (si->dpy, VisualScreenMask, &vi_in, &out_count);
  214       if (!vi_out) continue;
  215       for (j = 0; j < out_count; j++) {
  216     if (vi_out[j].depth >= 32) continue;
  217     if (vi_out[j].class == PseudoColor)
  218       colormapped_depths |= (1 << vi_out[j].depth);
  219     else
  220       non_mapped_depths  |= (1 << vi_out[j].depth);
  221     }
  222       XFree ((char *) vi_out);
  223 
  224       if (colormapped_depths)
  225     {
  226       fprintf (stderr, "%s: screen %d colormapped depths:", blurb(),
  227                    ssi->real_screen_number);
  228       for (j = 0; j < 32; j++)
  229         if (colormapped_depths & (1 << j))
  230           fprintf (stderr, " %d", j);
  231       fprintf (stderr, "\n");
  232     }
  233       if (non_mapped_depths)
  234     {
  235       fprintf (stderr, "%s: screen %d non-colormapped depths:",
  236                    blurb(), ssi->real_screen_number);
  237       for (j = 0; j < 32; j++)
  238         if (non_mapped_depths & (1 << j))
  239           fprintf (stderr, " %d", j);
  240       fprintf (stderr, "\n");
  241     }
  242     }
  243 }