|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: fl_overlay_visual.cxx 7903 2010-11-28 21:06:39Z matt $" 00003 // 00004 // X overlay support for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 // Return an overlay visual, if any. Also allocate a colormap and 00029 // record the depth for fl_color() to use. 00030 // Another disgusting X interface, based on code extracted and 00031 // purified with great difficulty from XLayerUtil.cxx: 00032 00033 #include <config.h> 00034 #if HAVE_OVERLAY 00035 #include <FL/Fl.H> 00036 #include <FL/x.H> 00037 00038 // SERVER_OVERLAY_VISUALS property element: 00039 struct OverlayInfo { 00040 long overlay_visual; 00041 long transparent_type; 00042 long value; 00043 long layer; 00044 }; 00045 00046 extern Colormap fl_overlay_colormap; 00047 extern XVisualInfo* fl_overlay_visual; 00048 extern ulong fl_transparent_pixel; 00049 00050 XVisualInfo *fl_find_overlay_visual() { 00051 static char beenhere; 00052 if (beenhere) return fl_overlay_visual; 00053 beenhere = 1; 00054 00055 fl_open_display(); 00056 Atom overlayVisualsAtom = 00057 XInternAtom(fl_display,"SERVER_OVERLAY_VISUALS",1); 00058 if (!overlayVisualsAtom) return 0; 00059 OverlayInfo *overlayInfo; 00060 ulong sizeData, bytesLeft; 00061 Atom actualType; 00062 int actualFormat; 00063 if (XGetWindowProperty(fl_display, RootWindow(fl_display, fl_screen), 00064 overlayVisualsAtom, 0L, 10000L, False, 00065 overlayVisualsAtom, &actualType, &actualFormat, 00066 &sizeData, &bytesLeft, 00067 (unsigned char **) &overlayInfo)) return 0; 00068 00069 if (actualType == overlayVisualsAtom && actualFormat == 32) { 00070 int n = int(sizeData/4); 00071 XVisualInfo* v = 0; 00072 // find the greatest depth that has a transparent pixel: 00073 for (int i = 0; i < n; i++) { 00074 if (overlayInfo[i].transparent_type != 1) continue; 00075 if (overlayInfo[i].layer <= 0) continue; 00076 XVisualInfo templt; 00077 templt.visualid = overlayInfo[i].overlay_visual; 00078 int num; 00079 XVisualInfo *v1=XGetVisualInfo(fl_display, VisualIDMask, &templt, &num); 00080 if (v1->screen == fl_screen && v1->c_class == PseudoColor 00081 && (!v || v1->depth > v->depth && v1->depth <= 8)) { 00082 if (v) XFree((char*)v); 00083 v = v1; 00084 fl_transparent_pixel = overlayInfo[i].value; 00085 } else { 00086 XFree((char*)v1); 00087 } 00088 } 00089 if (v) { 00090 fl_overlay_visual = v; 00091 fl_overlay_colormap = 00092 XCreateColormap(fl_display, RootWindow(fl_display, fl_screen), 00093 v->visual, AllocNone); 00094 } 00095 } 00096 XFree((char*)overlayInfo); 00097 //printf("overlay visual %ld selected\n", fl_overlay_visual->visualid); 00098 return fl_overlay_visual; 00099 } 00100 00101 #endif 00102 00103 // 00104 // End of "$Id: fl_overlay_visual.cxx 7903 2010-11-28 21:06:39Z matt $". 00105 //