#include #include #include #include #ifndef VISUAL_ID #error "VISUAL_ID must be defined when compiling" #endif typedef struct cinit CINIT; struct cinit { unsigned int pixel; unsigned short int r; unsigned short int g; unsigned short int b; } ; static Display *disp; static Screen *scr; static Window rootwin; static XVisualInfo vi; static int depth; static Colormap cmap; static Window win; static GC gc; static CINIT cinit[]; // forward static int ncinit; // forward static void setup_X(void) { XVisualInfo *xvi; int nvi; int i; unsigned long int mask; XSetWindowAttributes attr; XGCValues gcval; disp = XOpenDisplay(0); if (! disp) { printf("XOpenDisplay failed\n"); exit(1); } xvi = XGetVisualInfo(disp,0,0,&nvi); if (xvi == 0) { printf("no visuals reported\n"); exit(1); } for (i=0;i= nvi) { printf("no visual %#lx found\n",(unsigned long int)VISUAL_ID); exit(1); } scr = XDefaultScreenOfDisplay(disp); depth = vi.depth; rootwin = XRootWindowOfScreen(scr); cmap = XCreateColormap(disp,rootwin,vi.visual,AllocAll); mask = 0; attr.background_pixel = 0; mask |= CWBackPixel; attr.backing_store = NotUseful; mask |= CWBackingStore; attr.event_mask = ExposureMask; mask |= CWEventMask; attr.colormap = cmap; mask |= CWColormap; win = XCreateWindow(disp,rootwin,100,100,300,100,0,depth,InputOutput,vi.visual,mask,&attr); mask = 0; gcval.foreground = ~0U; mask |= GCForeground; gcval.background = 0; mask |= GCBackground; gc = XCreateGC(disp,win,mask,&gcval); XMapRaised(disp,win); } static void load_cmap(void) { int i; XColor c; for (i=0;icount > 0) return; if (e->window != win) return; XSetForeground(disp,gc,0x1e1e1e); XFillRectangle(disp,win,gc,0,0,100,100); XSetForeground(disp,gc,0x1f1f1f); XFillRectangle(disp,win,gc,100,0,100,100); XSetForeground(disp,gc,0x444444); XFillRectangle(disp,win,gc,200,0,100,100); /* e0 = black 1e = red 1f = green 2b = red 44 = blue ef = magenta fe = white */ } static void handle_event(XEvent *e) { switch (e->type) { case Expose: handle_expose(&e->xexpose); break; } } int main(void); int main(void) { XEvent e; setup_X(); load_cmap(); while (1) { XNextEvent(disp,&e); handle_event(&e); } } static CINIT cinit[] = { { 0, 0, 39835, 39835 }, { 65793, 0, 39835, 39835 }, { 131586, 0, 39835, 39835 }, { 197379, 0, 39835, 39835 }, { 263172, 0, 39835, 39835 }, { 328965, 0, 39835, 39835 }, { 1315860, 0, 39835, 39835 }, { 1579032, 0, 39835, 39835 }, { 1710618, 0, 39835, 39835 }, { 1776411, 0, 39835, 39835 }, { 1842204, 0, 39835, 39835 }, { 1907997, 0, 39835, 39835 }, { 1973790, 0, 39835, 39835 }, { 2039583, 0, 39835, 39835 }, { 2171169, 0, 39835, 39835 }, { 2236962, 0, 39835, 39835 }, { 2302755, 0, 39835, 39835 }, { 2368548, 0, 39835, 39835 }, { 2434341, 0, 39835, 39835 }, { 2500134, 0, 39835, 39835 }, { 2565927, 0, 39835, 39835 }, { 2697513, 0, 39835, 39835 }, { 2763306, 0, 39835, 39835 }, { 2894892, 0, 39835, 39835 }, { 2960685, 0, 39835, 39835 }, { 4210752, 0, 39835, 39835 }, { 4276545, 0, 39835, 39835 }, { 4342338, 0, 39835, 39835 }, { 4408131, 0, 39835, 39835 }, { 4473924, 0, 39835, 39835 }, { 4539717, 0, 39835, 39835 }, { 4605510, 0, 39835, 39835 }, { 4671303, 0, 39835, 39835 }, { 4737096, 0, 39835, 39835 }, { 4802889, 0, 39835, 39835 }, { 4868682, 0, 39835, 39835 }, { 4934475, 0, 39835, 39835 }, { 5000268, 0, 39835, 39835 }, { 5066061, 0, 39835, 39835 }, { 5131854, 0, 39835, 39835 }, { 5197647, 0, 39835, 39835 }, { 5263440, 0, 39835, 39835 }, { 5329233, 0, 39835, 39835 }, { 5395026, 0, 39835, 39835 }, { 5460819, 0, 39835, 39835 }, { 5526612, 0, 39835, 39835 }, { 5592405, 0, 39835, 39835 }, { 5658198, 0, 39835, 39835 }, { 5723991, 0, 39835, 39835 }, { 5789784, 0, 39835, 39835 }, { 5855577, 0, 39835, 39835 }, { 5921370, 0, 39835, 39835 }, { 5987163, 0, 39835, 39835 }, { 6052956, 0, 39835, 39835 }, { 6118749, 0, 39835, 39835 }, { 6184542, 0, 39835, 39835 }, { 6250335, 0, 39835, 39835 }, { 6316128, 0, 39835, 39835 }, { 6381921, 0, 39835, 39835 }, { 6447714, 0, 39835, 39835 }, { 6513507, 0, 39835, 39835 }, { 6579300, 0, 39835, 39835 }, { 6645093, 0, 39835, 39835 }, { 6710886, 0, 39835, 39835 }, { 6776679, 0, 39835, 39835 }, { 6842472, 0, 39835, 39835 }, { 6908265, 0, 39835, 39835 }, { 6974058, 0, 39835, 39835 }, { 7039851, 0, 39835, 39835 }, { 7105644, 0, 39835, 39835 }, { 7171437, 0, 39835, 39835 }, { 7237230, 0, 39835, 39835 }, { 7303023, 0, 39835, 39835 }, { 7368816, 0, 39835, 39835 }, { 7434609, 0, 39835, 39835 }, { 7500402, 0, 39835, 39835 }, { 7566195, 0, 39835, 39835 }, { 7631988, 0, 39835, 39835 }, { 7697781, 0, 39835, 39835 }, { 7763574, 0, 39835, 39835 }, { 7829367, 0, 39835, 39835 }, { 7895160, 0, 39835, 39835 }, { 7960953, 0, 39835, 39835 }, { 8026746, 0, 39835, 39835 }, { 8092539, 0, 39835, 39835 }, { 8158332, 0, 39835, 39835 }, { 8224125, 0, 39835, 39835 }, { 8289918, 0, 39835, 39835 }, { 8355711, 0, 39835, 39835 }, { 8421504, 0, 39835, 39835 }, { 8487297, 0, 39835, 39835 }, { 13421772, 0, 39835, 39835 }, { 13487565, 0, 39835, 39835 }, { 13553358, 0, 39835, 39835 }, { 13619151, 0, 39835, 39835 }, { 13684944, 0, 39835, 39835 }, { 13750737, 0, 39835, 39835 }, { 13816530, 0, 39835, 39835 }, { 13882323, 0, 39835, 39835 }, { 13948116, 0, 39835, 39835 }, { 14013909, 0, 39835, 39835 }, { 14079702, 0, 39835, 39835 }, { 14145495, 0, 39835, 39835 }, { 14211288, 0, 39835, 39835 }, { 14277081, 0, 39835, 39835 }, { 14342874, 0, 39835, 39835 }, { 14408667, 0, 39835, 39835 }, { 14474460, 0, 39835, 39835 }, { 14540253, 0, 39835, 39835 }, { 14606046, 0, 39835, 39835 }, { 14671839, 0, 39835, 39835 }, { 14737632, 0, 39835, 39835 }, { 14803425, 0, 39835, 39835 }, { 14869218, 0, 39835, 39835 }, { 14935011, 0, 39835, 39835 }, { 15000804, 0, 39835, 39835 }, { 15066597, 0, 39835, 39835 }, { 15132390, 0, 39835, 39835 }, { 15198183, 0, 39835, 39835 }, { 15263976, 0, 39835, 39835 }, { 15329769, 0, 39835, 39835 }, { 15395562, 0, 39835, 39835 }, { 15461355, 0, 39835, 39835 }, { 15527148, 0, 39835, 39835 }, { 15592941, 0, 39835, 39835 }, { 15658734, 0, 39835, 39835 }, { 15856113, 0, 39835, 39835 }, { 15921906, 0, 39835, 39835 }, { 15987699, 0, 39835, 39835 }, { 16053492, 0, 39835, 39835 }, { 16119285, 0, 39835, 39835 }, { 16185078, 0, 39835, 39835 }, { 16250871, 0, 39835, 39835 }, { 16316664, 0, 39835, 39835 }, { 16382457, 0, 39835, 39835 }, { 16448250, 0, 39835, 39835 }, { 16514043, 0, 39835, 39835 }, { 16579836, 0, 39835, 39835 }, { 16645629, 0, 39835, 39835 }, { 16711422, 0, 39835, 39835 }, { 16777215, 0, 39835, 39835 }, { 1250067, 0, 0, 0 }, { 2631720, 0, 0, 0 }, { 2829099, 65535, 0, 0 }, { 2565927, 0, 0, 257 }, { 15724527, 65535, 0, 65535 }, { 15790320, 0, 0, 0 }, { 15856113, 4626, 4626, 4626 }, { 15921906, 9252, 9252, 9252 }, { 15987699, 13878, 13878, 13878 }, { 16053492, 18504, 18504, 18504 }, { 16119285, 23387, 23387, 23387 }, { 16185078, 28013, 28013, 28013 }, { 16250871, 32639, 32639, 32639 }, { 16316664, 37265, 37265, 37265 }, { 16382457, 41891, 41891, 41891 }, { 16448250, 46774, 46774, 46774 }, { 16514043, 51400, 51400, 51400 }, { 16579836, 56026, 56026, 56026 }, { 16645629, 60652, 60652, 60652 }, { 16711422, 65535, 65535, 65535 }, { 2368548, 65535, 62965, 4626 }, { 1842204, 49087, 47031, 3341 }, { 1907997, 49087, 47031, 3341 }, { 2302755, 61166, 8224, 1028 }, { 1973790, 65535, 0, 0 }, { 1710618, 61166, 8224, 1028 }, { 1776411, 65535, 62965, 4626 }, { 14737632, 0, 0, 0 }, { 14803425, 4626, 4369, 257 }, { 14869218, 9252, 8738, 514 }, { 14935011, 13878, 13107, 771 }, { 15000804, 18504, 17476, 1028 }, { 15066597, 23130, 21845, 1285 }, { 15132390, 27756, 26214, 1542 }, { 15198183, 32382, 30583, 1799 }, { 15263976, 37008, 34952, 2056 }, { 15329769, 41634, 39321, 2313 }, { 15395562, 46260, 43690, 2570 }, { 15461355, 50886, 48059, 2827 }, { 15527148, 55512, 52428, 3084 }, { 15592941, 60138, 56797, 3341 }, { 15658734, 64764, 61166, 3598 }, { 13684944, 0, 0, 0 }, { 13750737, 4369, 514, 0 }, { 13816530, 8738, 1028, 0 }, { 13882323, 13107, 1542, 0 }, { 13948116, 17476, 2056, 0 }, { 14013909, 21845, 2570, 0 }, { 14079702, 26214, 3084, 0 }, { 14145495, 30583, 3598, 0 }, { 14211288, 34952, 4112, 0 }, { 14277081, 39321, 4626, 0 }, { 14342874, 43690, 5140, 0 }, { 14408667, 48059, 5654, 0 }, { 14474460, 52428, 6168, 0 }, { 14540253, 56797, 6682, 0 }, { 14606046, 61166, 7196, 0 }, { 131586, 49087, 47031, 3341 }, { 8421504, 49087, 47031, 3341 }, { 8487297, 49087, 47031, 3341 }, { 2039583, 0, 65535, 0 }, { 65793, 13878, 13878, 13878 }, { 328965, 36751, 36751, 36751 }, { 263172, 20817, 20817, 20817 }, { 197379, 11565, 11565, 11565 }, { 16777215, 0, 0, 0 }, { 0, 0, 0, 0 }, { 8355711, 0, 0, 0 }, { 4210752, 0, 0, 35980 }, { 4276545, 0, 0, 42405 }, { 4342338, 0, 0, 50886 }, { 4408131, 0, 0, 61423 }, { 4473924, 0, 0, 65535 }, { 4539717, 0, 9252, 65535 }, { 4605510, 0, 18761, 65535 }, { 4671303, 0, 23901, 65535 }, { 4737096, 0, 33410, 65535 }, { 4802889, 0, 42662, 65535 }, { 4868682, 0, 48830, 65535 }, { 4934475, 0, 58339, 65535 }, { 5000268, 0, 65535, 65535 }, { 5066061, 6168, 65535, 59367 }, { 5131854, 14649, 65535, 50886 }, { 5197647, 25443, 65535, 40092 }, { 5263440, 31611, 65535, 33924 }, { 5329233, 38036, 64507, 23130 }, { 5395026, 48573, 64507, 12593 }, { 5460819, 57054, 64507, 6168 }, { 5526612, 63479, 64507, 0 }, { 5592405, 63479, 57311, 0 }, { 5658198, 63479, 54227, 0 }, { 5723991, 63479, 44718, 0 }, { 5789784, 63993, 35466, 0 }, { 5855577, 64764, 17733, 0 }, { 5921370, 65535, 0, 0 }, { 5987163, 62965, 0, 0 }, { 6052956, 60395, 0, 0 }, { 6118749, 58082, 0, 0 }, { 6184542, 55769, 0, 0 }, { 6250335, 52942, 0, 0 }, { 6316128, 65535, 1285, 1285 }, { 6381921, 65535, 2570, 2570 }, { 6447714, 65535, 3855, 3855 }, { 6513507, 65535, 5140, 5140 }, { 6579300, 65535, 6425, 6425 }, { 6645093, 65535, 7710, 7710 }, { 6710886, 65535, 8995, 8995 }, { 6776679, 65535, 10280, 10280 }, { 6842472, 65535, 11565, 11565 }, { 6908265, 65535, 12850, 12850 }, { 6974058, 65535, 14135, 14135 }, { 7039851, 65535, 15420, 15420 }, { 7105644, 65535, 16705, 16705 }, { 7171437, 65535, 17990, 17990 }, { 7237230, 65535, 19275, 19275 }, { 7303023, 65535, 20560, 20560 }, { 7368816, 65535, 21845, 21845 }, { 7434609, 65535, 23130, 23130 }, { 7500402, 65535, 24415, 24415 }, { 7566195, 65535, 25700, 25700 }, { 7631988, 65535, 26985, 26985 }, { 7697781, 65535, 28270, 28270 }, { 7763574, 65535, 29555, 29555 }, { 7829367, 65535, 30840, 30840 }, { 7895160, 65535, 32125, 32125 }, { 7960953, 65535, 33410, 33410 }, { 8026746, 65535, 34695, 34695 }, { 8092539, 65535, 35980, 35980 }, { 8158332, 65535, 37265, 37265 }, { 8224125, 65535, 38550, 38550 }, { 8289918, 65535, 39835, 39835 }, { 2171169, 65535, 65535, 0 }, { 2763306, 0, 65535, 65535 }, { 14671839, 0, 12850, 12850 }, { 13619151, 0, 20560, 20560 }, { 13487565, 0, 35980, 35980 }, { 13421772, 0, 48830, 48830 }, { 13553358, 65535, 52428, 0 }, { 2236962, 0, 65535, 32639 }, { 2697513, 65535, 65535, 65535 }, { 2500134, 65021, 65021, 65021 }, { 2434341, 32896, 32896, 32896 }, { 2960685, 65021, 65021, 65021 }, { 2894892, 32896, 32896, 32896 }, { 1315860, 51400, 0, 51400 }, { 1579032, 57568, 57568, 0 }, }; static int ncinit = sizeof(cinit) / sizeof(cinit[0]);