summaryrefslogtreecommitdiff
path: root/src/fl_overlay_visual.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1998-10-06 18:21:25 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1998-10-06 18:21:25 +0000
commitf9039b2ae21988783feae9b362818e7923e82d14 (patch)
tree6d6fe3679d73448758f9794e7d4d4f6b22a4adad /src/fl_overlay_visual.cxx
parent67e89232f9ba067825a158734a09e0fa21aacbe3 (diff)
Initial revision
git-svn-id: file:///fltk/svn/fltk/trunk@2 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_overlay_visual.cxx')
-rw-r--r--src/fl_overlay_visual.cxx76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/fl_overlay_visual.cxx b/src/fl_overlay_visual.cxx
new file mode 100644
index 000000000..a176bf69c
--- /dev/null
+++ b/src/fl_overlay_visual.cxx
@@ -0,0 +1,76 @@
+// Stupid X tricks
+
+// Return an overlay visual, if any. Also allocate a colormap and
+// record the depth for fl_color() to use.
+// Another disgusting X interface, based on code extracted and
+// purified with great difficulty from XLayerUtil.C:
+
+#include <config.h>
+#if HAVE_OVERLAY
+#include <FL/Fl.H>
+#include <FL/x.H>
+
+// SERVER_OVERLAY_VISUALS property element:
+struct OverlayInfo {
+ long overlay_visual;
+ long transparent_type;
+ long value;
+ long layer;
+};
+
+extern Colormap fl_overlay_colormap;
+extern XVisualInfo* fl_overlay_visual;
+extern ulong fl_transparent_pixel;
+
+XVisualInfo *fl_find_overlay_visual() {
+ static char beenhere;
+ if (beenhere) return fl_overlay_visual;
+ beenhere = 1;
+
+ fl_open_display();
+ Atom overlayVisualsAtom =
+ XInternAtom(fl_display,"SERVER_OVERLAY_VISUALS",1);
+ if (!overlayVisualsAtom) return 0;
+ OverlayInfo *overlayInfo;
+ ulong sizeData, bytesLeft;
+ Atom actualType;
+ int actualFormat;
+ if (XGetWindowProperty(fl_display, RootWindow(fl_display, fl_screen),
+ overlayVisualsAtom, 0L, 10000L, False,
+ overlayVisualsAtom, &actualType, &actualFormat,
+ &sizeData, &bytesLeft,
+ (unsigned char **) &overlayInfo)) return 0;
+
+ if (actualType == overlayVisualsAtom && actualFormat == 32) {
+ int n = int(sizeData/4);
+ XVisualInfo* v = 0;
+ // find the greatest depth that has a transparent pixel:
+ for (int i = 0; i < n; i++) {
+ if (overlayInfo[i].transparent_type != 1) continue;
+ if (overlayInfo[i].layer <= 0) continue;
+ XVisualInfo templt;
+ templt.visualid = overlayInfo[i].overlay_visual;
+ int num;
+ XVisualInfo *v1=XGetVisualInfo(fl_display, VisualIDMask, &templt, &num);
+ if (v1->screen == fl_screen &&
+ !v1->red_mask && (!v || v1->depth >= v->depth && v1->depth <= 8)) {
+ if (v) XFree((char*)v);
+ v = v1;
+ fl_transparent_pixel = overlayInfo[i].value;
+ } else {
+ XFree((char*)v1);
+ }
+ }
+ if (v) {
+ fl_overlay_visual = v;
+ fl_overlay_colormap =
+ XCreateColormap(fl_display, RootWindow(fl_display, fl_screen),
+ v->visual, AllocNone);
+ }
+ }
+ XFree((char*)overlayInfo);
+ // printf("overlay visual %d selected\n", fl_overlay_visual->visualid);
+ return fl_overlay_visual;
+}
+
+#endif