64 |
/* software backing store */ |
/* software backing store */ |
65 |
static BOOL g_ownbackstore; |
static BOOL g_ownbackstore; |
66 |
static Pixmap g_backstore; |
static Pixmap g_backstore; |
67 |
|
static BOOL g_backstore_initialized = False; |
68 |
|
|
69 |
/* Moving in single app mode */ |
/* Moving in single app mode */ |
70 |
static BOOL g_moving_wnd; |
static BOOL g_moving_wnd; |
700 |
XVisualInfo vi; |
XVisualInfo vi; |
701 |
XPixmapFormatValues *pfm; |
XPixmapFormatValues *pfm; |
702 |
uint16 test; |
uint16 test; |
703 |
int i, screen_num; |
int i, screen_num, nvisuals; |
704 |
|
XVisualInfo *vmatches = NULL; |
705 |
|
XVisualInfo template; |
706 |
|
Bool TrueColorVisual = False; |
707 |
|
|
708 |
g_display = XOpenDisplay(NULL); |
g_display = XOpenDisplay(NULL); |
709 |
if (g_display == NULL) |
if (g_display == NULL) |
717 |
g_screen = ScreenOfDisplay(g_display, screen_num); |
g_screen = ScreenOfDisplay(g_display, screen_num); |
718 |
g_depth = DefaultDepthOfScreen(g_screen); |
g_depth = DefaultDepthOfScreen(g_screen); |
719 |
|
|
720 |
if (g_server_bpp == 8) |
/* Search for best TrueColor depth */ |
721 |
|
template.class = TrueColor; |
722 |
|
vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &nvisuals); |
723 |
|
|
724 |
|
nvisuals--; |
725 |
|
while (nvisuals >= 0) |
726 |
|
{ |
727 |
|
if ((vmatches + nvisuals)->depth > g_depth) |
728 |
|
{ |
729 |
|
g_depth = (vmatches + nvisuals)->depth; |
730 |
|
} |
731 |
|
nvisuals--; |
732 |
|
TrueColorVisual = True; |
733 |
|
} |
734 |
|
|
735 |
|
if ((g_server_bpp == 8) && ((! TrueColorVisual) || (g_depth <= 8))) |
736 |
{ |
{ |
737 |
/* we use a colourmap, so any visual should do */ |
/* we use a colourmap, so the default visual should do */ |
738 |
g_visual = DefaultVisualOfScreen(g_screen); |
g_visual = DefaultVisualOfScreen(g_screen); |
739 |
|
g_depth = DefaultDepthOfScreen(g_screen); |
740 |
|
|
741 |
|
/* Do not allocate colours on a TrueColor visual */ |
742 |
|
if (g_visual->class == TrueColor) |
743 |
|
{ |
744 |
|
g_owncolmap = False; |
745 |
|
} |
746 |
} |
} |
747 |
else |
else |
748 |
{ |
{ |
784 |
|
|
785 |
if (!g_owncolmap) |
if (!g_owncolmap) |
786 |
{ |
{ |
787 |
g_xcolmap = DefaultColormapOfScreen(g_screen); |
g_xcolmap = XCreateColormap(g_display,RootWindowOfScreen(g_screen),g_visual,AllocNone); |
788 |
if (g_depth <= 8) |
if (g_depth <= 8) |
789 |
warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n"); |
warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n"); |
790 |
} |
} |
791 |
|
|
|
g_gc = XCreateGC(g_display, RootWindowOfScreen(g_screen), 0, NULL); |
|
|
|
|
792 |
if (DoesBackingStore(g_screen) != Always) |
if (DoesBackingStore(g_screen) != Always) |
793 |
g_ownbackstore = True; |
g_ownbackstore = True; |
794 |
|
|
831 |
/* make sure width is a multiple of 4 */ |
/* make sure width is a multiple of 4 */ |
832 |
g_width = (g_width + 3) & ~3; |
g_width = (g_width + 3) & ~3; |
833 |
|
|
|
if (g_ownbackstore) |
|
|
{ |
|
|
g_backstore = |
|
|
XCreatePixmap(g_display, RootWindowOfScreen(g_screen), g_width, g_height, |
|
|
g_depth); |
|
|
|
|
|
/* clear to prevent rubbish being exposed at startup */ |
|
|
XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); |
|
|
XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height); |
|
|
} |
|
|
|
|
834 |
g_mod_map = XGetModifierMapping(g_display); |
g_mod_map = XGetModifierMapping(g_display); |
835 |
|
|
836 |
xkeymap_init(); |
xkeymap_init(); |
877 |
wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height; |
wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height; |
878 |
|
|
879 |
attribs.background_pixel = BlackPixelOfScreen(g_screen); |
attribs.background_pixel = BlackPixelOfScreen(g_screen); |
880 |
|
attribs.border_pixel = WhitePixelOfScreen(g_screen); |
881 |
attribs.backing_store = g_ownbackstore ? NotUseful : Always; |
attribs.backing_store = g_ownbackstore ? NotUseful : Always; |
882 |
attribs.override_redirect = g_fullscreen; |
attribs.override_redirect = g_fullscreen; |
883 |
|
attribs.colormap = g_xcolmap; |
884 |
|
|
885 |
g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), 0, 0, wndwidth, wndheight, |
g_wnd = XCreateWindow(g_display, RootWindowOfScreen(g_screen), 0, 0, wndwidth, wndheight, |
886 |
0, CopyFromParent, InputOutput, CopyFromParent, |
0, g_depth, InputOutput, g_visual, |
887 |
CWBackPixel | CWBackingStore | CWOverrideRedirect, &attribs); |
CWBackPixel | CWBackingStore | CWOverrideRedirect | |
888 |
|
CWColormap | CWBorderPixel, &attribs); |
889 |
|
|
890 |
|
g_gc = XCreateGC(g_display, g_wnd, 0, NULL); |
891 |
|
|
892 |
|
if ((g_ownbackstore) && (! g_backstore_initialized)) |
893 |
|
{ |
894 |
|
g_backstore = |
895 |
|
XCreatePixmap(g_display, g_wnd, g_width, g_height, |
896 |
|
g_depth); |
897 |
|
|
898 |
|
/* clear to prevent rubbish being exposed at startup */ |
899 |
|
XSetForeground(g_display, g_gc, BlackPixelOfScreen(g_screen)); |
900 |
|
XFillRectangle(g_display, g_backstore, g_gc, 0, 0, g_width, g_height); |
901 |
|
g_backstore_initialized = True; |
902 |
|
} |
903 |
|
|
904 |
XStoreName(g_display, g_wnd, g_title); |
XStoreName(g_display, g_wnd, g_title); |
905 |
|
|