278 |
|
|
279 |
if (ownbackstore) |
if (ownbackstore) |
280 |
{ |
{ |
281 |
backstore = XCreatePixmap(display, RootWindowOfScreen(screen), width, height, depth); |
backstore = |
282 |
|
XCreatePixmap(display, RootWindowOfScreen(screen), width, height, depth); |
283 |
|
|
284 |
/* clear to prevent rubbish being exposed at startup */ |
/* clear to prevent rubbish being exposed at startup */ |
285 |
XSetForeground(display, gc, BlackPixelOfScreen(screen)); |
XSetForeground(display, gc, BlackPixelOfScreen(screen)); |
317 |
long input_mask, ic_input_mask; |
long input_mask, ic_input_mask; |
318 |
XEvent xevent; |
XEvent xevent; |
319 |
|
|
320 |
wndwidth = fullscreen ? WidthOfScreen(screen) : width; |
wndwidth = fullscreen ? WidthOfScreen(screen) : width; |
321 |
wndheight = fullscreen ? HeightOfScreen(screen) : height; |
wndheight = fullscreen ? HeightOfScreen(screen) : height; |
322 |
|
|
323 |
attribs.background_pixel = BlackPixelOfScreen(screen); |
attribs.background_pixel = BlackPixelOfScreen(screen); |
361 |
IC = XCreateIC(IM, XNInputStyle, (XIMPreeditNothing | XIMStatusNothing), |
IC = XCreateIC(IM, XNInputStyle, (XIMPreeditNothing | XIMStatusNothing), |
362 |
XNClientWindow, wnd, XNFocusWindow, wnd, NULL); |
XNClientWindow, wnd, XNFocusWindow, wnd, NULL); |
363 |
|
|
364 |
if ((IC != NULL) && (XGetICValues(IC, XNFilterEvents, &ic_input_mask, NULL) == NULL)) |
if ((IC != NULL) |
365 |
|
&& (XGetICValues(IC, XNFilterEvents, &ic_input_mask, NULL) == NULL)) |
366 |
input_mask |= ic_input_mask; |
input_mask |= ic_input_mask; |
367 |
} |
} |
368 |
|
|
370 |
XMapWindow(display, wnd); |
XMapWindow(display, wnd); |
371 |
|
|
372 |
/* wait for MapNotify */ |
/* wait for MapNotify */ |
373 |
do { |
do |
374 |
|
{ |
375 |
XMaskEvent(display, StructureNotifyMask, &xevent); |
XMaskEvent(display, StructureNotifyMask, &xevent); |
376 |
} while (xevent.type != MapNotify); |
} |
377 |
|
while (xevent.type != MapNotify); |
378 |
|
|
379 |
if (fullscreen) |
if (fullscreen) |
380 |
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); |
XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime); |
783 |
long nDist = nMinDist; |
long nDist = nMinDist; |
784 |
|
|
785 |
/* only get the colors once */ |
/* only get the colors once */ |
786 |
while( colLookup-- ){ |
while (colLookup--) |
787 |
|
{ |
788 |
xc_cache[colLookup].pixel = colLookup; |
xc_cache[colLookup].pixel = colLookup; |
789 |
xc_cache[colLookup].red = xc_cache[colLookup].green = xc_cache[colLookup].blue = 0; |
xc_cache[colLookup].red = xc_cache[colLookup].green = |
790 |
|
xc_cache[colLookup].blue = 0; |
791 |
xc_cache[colLookup].flags = 0; |
xc_cache[colLookup].flags = 0; |
792 |
XQueryColor(display, DefaultColormap(display, DefaultScreen(display)), &xc_cache[colLookup]); |
XQueryColor(display, |
793 |
|
DefaultColormap(display, DefaultScreen(display)), |
794 |
|
&xc_cache[colLookup]); |
795 |
} |
} |
796 |
colLookup = 0; |
colLookup = 0; |
797 |
|
|
798 |
/* approximate the pixel */ |
/* approximate the pixel */ |
799 |
while( j-- ){ |
while (j--) |
800 |
if( xc_cache[j].flags ){ |
{ |
801 |
nDist = |
if (xc_cache[j].flags) |
802 |
((long) (xc_cache[j].red >> 8) - (long) (xentry.red >> 8)) * |
{ |
803 |
((long) (xc_cache[j].red >> 8) - (long) (xentry.red >> 8)) + |
nDist = ((long) (xc_cache[j].red >> 8) - |
804 |
((long) (xc_cache[j].green >> 8) - (long) (xentry.green >> 8)) * |
(long) (xentry.red >> 8)) * |
805 |
((long) (xc_cache[j].green >> 8) - (long) (xentry.green >> 8)) + |
((long) (xc_cache[j].red >> 8) - |
806 |
((long) (xc_cache[j].blue >> 8) - (long) (xentry.blue >> 8)) * |
(long) (xentry.red >> 8)) + |
807 |
((long) (xc_cache[j].blue >> 8) - (long) (xentry.blue >> 8)); |
((long) (xc_cache[j].green >> 8) - |
808 |
|
(long) (xentry.green >> 8)) * |
809 |
|
((long) (xc_cache[j].green >> 8) - |
810 |
|
(long) (xentry.green >> 8)) + |
811 |
|
((long) (xc_cache[j].blue >> 8) - |
812 |
|
(long) (xentry.blue >> 8)) * |
813 |
|
((long) (xc_cache[j].blue >> 8) - |
814 |
|
(long) (xentry.blue >> 8)); |
815 |
} |
} |
816 |
if( nDist < nMinDist ){ |
if (nDist < nMinDist) |
817 |
|
{ |
818 |
nMinDist = nDist; |
nMinDist = nDist; |
819 |
xentry.pixel = j; |
xentry.pixel = j; |
820 |
} |
} |
823 |
colour = xentry.pixel; |
colour = xentry.pixel; |
824 |
|
|
825 |
/* update our cache */ |
/* update our cache */ |
826 |
if( xentry.pixel < 256 ){ |
if (xentry.pixel < 256) |
827 |
|
{ |
828 |
xc_cache[xentry.pixel].red = xentry.red; |
xc_cache[xentry.pixel].red = xentry.red; |
829 |
xc_cache[xentry.pixel].green = xentry.green; |
xc_cache[xentry.pixel].green = xentry.green; |
830 |
xc_cache[xentry.pixel].blue = xentry.blue; |
xc_cache[xentry.pixel].blue = xentry.blue; |