summaryrefslogtreecommitdiff
path: root/src/Fl_visual.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1998-10-06 18:46:47 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1998-10-06 18:46:47 +0000
commite7d805a88ca71a0e6499fe72830e58fe594ef05b (patch)
tree8c0cd05b0f4098bba4b90b229c23ef8d96a80d8a /src/Fl_visual.cxx
parentf9039b2ae21988783feae9b362818e7923e82d14 (diff)
Commited Gustavo Hime's NT patches/fixes.
git-svn-id: file:///fltk/svn/fltk/trunk@7 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_visual.cxx')
-rw-r--r--src/Fl_visual.cxx157
1 files changed, 79 insertions, 78 deletions
diff --git a/src/Fl_visual.cxx b/src/Fl_visual.cxx
index d45c3ed49..05d90edd1 100644
--- a/src/Fl_visual.cxx
+++ b/src/Fl_visual.cxx
@@ -1,78 +1,79 @@
-// Fl_visual.C
-//
-// Set the default visual according to passed switches:
-
-#include <config.h>
-#include <FL/Fl.H>
-#include <FL/x.H>
-
-#ifdef WIN32
-int Fl::visual(int flags) {
- if (flags & FL_DOUBLE) return 0;
- if (!(flags & FL_INDEX) &&
- GetDeviceCaps(fl_GetDC(0),BITSPIXEL) <= 8) return 0;
- if ((flags & FL_RGB8) && GetDeviceCaps(fl_GetDC(0),BITSPIXEL)<24) return 0;
- return 1;
-}
-#else
-
-#if USE_XDBE
-#include <X11/extensions/Xdbe.h>
-#endif
-
-static int test_visual(XVisualInfo& v, int flags) {
- if (v.screen != fl_screen) return 0;
- if (!(flags & FL_INDEX)) {
- if (!v.red_mask) return 0; // detects static, true, and direct color
- if (v.depth <= 8) return 0; // fltk will work better in colormap mode
- }
- if (flags & FL_RGB8) {
- if (v.depth < 24) return 0;
- }
- // for now, fltk does not like colormaps of more than 8 bits:
- if (!v.red_mask && v.depth > 8) return 0;
-#if USE_XDBE
- if (flags & FL_DOUBLE) {
- static XdbeScreenVisualInfo *xdbejunk;
- if (!xdbejunk) {
- int event_base, error_base;
- if (!XdbeQueryExtension(fl_display, &event_base, &error_base)) return 0;
- Drawable root = RootWindow(fl_display,fl_screen);
- int numscreens = 1;
- xdbejunk = XdbeGetVisualInfo(fl_display,&root,&numscreens);
- if (!xdbejunk) return 0;
- }
- for (int j = 0; ; j++) {
- if (j >= xdbejunk->count) return 0;
- if (xdbejunk->visinfo[j].visual == v.visualid) break;
- }
- }
-#endif
- return 1;
-}
-
-int Fl::visual(int flags) {
-#if USE_XDBE == 0
- if (flags & FL_DOUBLE) return 0;
-#endif
- fl_open_display();
- // always use default if possible:
- if (test_visual(*fl_visual, flags)) return 1;
- // get all the visuals:
- XVisualInfo vTemplate;
- int num;
- XVisualInfo *visualList = XGetVisualInfo(fl_display, 0, &vTemplate, &num);
- // find all matches, use the one with greatest depth:
- XVisualInfo *found = 0;
- for (int i=0; i<num; i++) if (test_visual(visualList[i], flags)) {
- if (!found || found->depth < visualList[i].depth)
- found = &visualList[i];
- }
- if (!found) {XFree((void*)visualList); return 0;}
- fl_visual = found;
- fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
- fl_visual->visual, AllocNone);
- return 1;
-}
-
-#endif
+// Fl_visual.C
+//
+// Set the default visual according to passed switches:
+
+#include <config.h>
+#include <FL/Fl.H>
+#include <FL/x.H>
+
+#ifdef WIN32
+int Fl::visual(int flags) {
+ fl_GetDC(0);
+ if (flags & FL_DOUBLE) return 0;
+ if (!(flags & FL_INDEX) &&
+ GetDeviceCaps(fl_gc,BITSPIXEL) <= 8) return 0;
+ if ((flags & FL_RGB8) && GetDeviceCaps(fl_gc,BITSPIXEL)<24) return 0;
+ return 1;
+}
+#else
+
+#if USE_XDBE
+#include <X11/extensions/Xdbe.h>
+#endif
+
+static int test_visual(XVisualInfo& v, int flags) {
+ if (v.screen != fl_screen) return 0;
+ if (!(flags & FL_INDEX)) {
+ if (!v.red_mask) return 0; // detects static, true, and direct color
+ if (v.depth <= 8) return 0; // fltk will work better in colormap mode
+ }
+ if (flags & FL_RGB8) {
+ if (v.depth < 24) return 0;
+ }
+ // for now, fltk does not like colormaps of more than 8 bits:
+ if (!v.red_mask && v.depth > 8) return 0;
+#if USE_XDBE
+ if (flags & FL_DOUBLE) {
+ static XdbeScreenVisualInfo *xdbejunk;
+ if (!xdbejunk) {
+ int event_base, error_base;
+ if (!XdbeQueryExtension(fl_display, &event_base, &error_base)) return 0;
+ Drawable root = RootWindow(fl_display,fl_screen);
+ int numscreens = 1;
+ xdbejunk = XdbeGetVisualInfo(fl_display,&root,&numscreens);
+ if (!xdbejunk) return 0;
+ }
+ for (int j = 0; ; j++) {
+ if (j >= xdbejunk->count) return 0;
+ if (xdbejunk->visinfo[j].visual == v.visualid) break;
+ }
+ }
+#endif
+ return 1;
+}
+
+int Fl::visual(int flags) {
+#if USE_XDBE == 0
+ if (flags & FL_DOUBLE) return 0;
+#endif
+ fl_open_display();
+ // always use default if possible:
+ if (test_visual(*fl_visual, flags)) return 1;
+ // get all the visuals:
+ XVisualInfo vTemplate;
+ int num;
+ XVisualInfo *visualList = XGetVisualInfo(fl_display, 0, &vTemplate, &num);
+ // find all matches, use the one with greatest depth:
+ XVisualInfo *found = 0;
+ for (int i=0; i<num; i++) if (test_visual(visualList[i], flags)) {
+ if (!found || found->depth < visualList[i].depth)
+ found = &visualList[i];
+ }
+ if (!found) {XFree((void*)visualList); return 0;}
+ fl_visual = found;
+ fl_colormap = XCreateColormap(fl_display, RootWindow(fl_display,fl_screen),
+ fl_visual->visual, AllocNone);
+ return 1;
+}
+
+#endif