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; |
312 |
} |
} |
313 |
} |
} |
314 |
|
|
|
/* todo the remaining translate function might need some big endian check ?? */ |
|
|
|
|
315 |
static void |
static void |
316 |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
translate15to16(uint16 * data, uint8 * out, uint8 * end) |
317 |
{ |
{ |
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 |
/* we use a colourmap, so any visual should do */ |
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 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 |
|
|
799 |
/* |
/* |
800 |
* Determine desktop size |
* Determine desktop size |
801 |
*/ |
*/ |
802 |
if (g_width < 0) |
if (g_fullscreen) |
803 |
|
{ |
804 |
|
g_width = WidthOfScreen(g_screen); |
805 |
|
g_height = HeightOfScreen(g_screen); |
806 |
|
} |
807 |
|
else if (g_width < 0) |
808 |
{ |
{ |
809 |
/* Percent of screen */ |
/* Percent of screen */ |
810 |
g_height = HeightOfScreen(g_screen) * (-g_width) / 100; |
g_height = HeightOfScreen(g_screen) * (-g_width) / 100; |
827 |
g_height = 600; |
g_height = 600; |
828 |
} |
} |
829 |
} |
} |
|
else if (g_fullscreen) |
|
|
{ |
|
|
g_width = WidthOfScreen(g_screen); |
|
|
g_height = HeightOfScreen(g_screen); |
|
|
} |
|
830 |
|
|
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 |
|
|
1853 |
{\ |
{\ |
1854 |
glyph = cache_get_font (font, ttext[idx]);\ |
glyph = cache_get_font (font, ttext[idx]);\ |
1855 |
if (!(flags & TEXT2_IMPLICIT_X))\ |
if (!(flags & TEXT2_IMPLICIT_X))\ |
1856 |
|
{\ |
1857 |
|
xyoffset = ttext[++idx];\ |
1858 |
|
if ((xyoffset & 0x80))\ |
1859 |
{\ |
{\ |
1860 |
xyoffset = ttext[++idx];\ |
if (flags & TEXT2_VERTICAL)\ |
1861 |
if ((xyoffset & 0x80))\ |
y += ttext[idx+1] | (ttext[idx+2] << 8);\ |
|
{\ |
|
|
if (flags & TEXT2_VERTICAL) \ |
|
|
y += ttext[idx+1] | (ttext[idx+2] << 8);\ |
|
|
else\ |
|
|
x += ttext[idx+1] | (ttext[idx+2] << 8);\ |
|
|
idx += 2;\ |
|
|
}\ |
|
1862 |
else\ |
else\ |
1863 |
{\ |
x += ttext[idx+1] | (ttext[idx+2] << 8);\ |
1864 |
if (flags & TEXT2_VERTICAL) \ |
idx += 2;\ |
|
y += xyoffset;\ |
|
|
else\ |
|
|
x += xyoffset;\ |
|
|
}\ |
|
1865 |
}\ |
}\ |
1866 |
if (glyph != NULL)\ |
else\ |
1867 |
{\ |
{\ |
1868 |
ui_draw_glyph (mixmode, x + glyph->offset,\ |
if (flags & TEXT2_VERTICAL)\ |
1869 |
y + glyph->baseline,\ |
y += xyoffset;\ |
1870 |
glyph->width, glyph->height,\ |
else\ |
1871 |
glyph->pixmap, 0, 0, bgcolour, fgcolour);\ |
x += xyoffset;\ |
|
if (flags & TEXT2_IMPLICIT_X)\ |
|
|
x += glyph->width;\ |
|
1872 |
}\ |
}\ |
1873 |
|
}\ |
1874 |
|
if (glyph != NULL)\ |
1875 |
|
{\ |
1876 |
|
x1 = x + glyph->offset;\ |
1877 |
|
y1 = y + glyph->baseline;\ |
1878 |
|
XSetStipple(g_display, g_gc, (Pixmap) glyph->pixmap);\ |
1879 |
|
XSetTSOrigin(g_display, g_gc, x1, y1);\ |
1880 |
|
FILL_RECTANGLE_BACKSTORE(x1, y1, glyph->width, glyph->height);\ |
1881 |
|
if (flags & TEXT2_IMPLICIT_X)\ |
1882 |
|
x += glyph->width;\ |
1883 |
|
}\ |
1884 |
} |
} |
1885 |
|
|
1886 |
void |
void |
1890 |
int fgcolour, uint8 * text, uint8 length) |
int fgcolour, uint8 * text, uint8 length) |
1891 |
{ |
{ |
1892 |
FONTGLYPH *glyph; |
FONTGLYPH *glyph; |
1893 |
int i, j, xyoffset; |
int i, j, xyoffset, x1, y1; |
1894 |
DATABLOB *entry; |
DATABLOB *entry; |
1895 |
|
|
1896 |
SET_FOREGROUND(bgcolour); |
SET_FOREGROUND(bgcolour); |
1904 |
FILL_RECTANGLE_BACKSTORE(clipx, clipy, clipcx, clipcy); |
FILL_RECTANGLE_BACKSTORE(clipx, clipy, clipcx, clipcy); |
1905 |
} |
} |
1906 |
|
|
1907 |
|
SET_FOREGROUND(fgcolour); |
1908 |
|
SET_BACKGROUND(bgcolour); |
1909 |
|
XSetFillStyle(g_display, g_gc, FillStippled); |
1910 |
|
|
1911 |
/* Paint text, character by character */ |
/* Paint text, character by character */ |
1912 |
for (i = 0; i < length;) |
for (i = 0; i < length;) |
1913 |
{ |
{ |
1958 |
break; |
break; |
1959 |
} |
} |
1960 |
} |
} |
1961 |
|
|
1962 |
|
XSetFillStyle(g_display, g_gc, FillSolid); |
1963 |
|
|
1964 |
if (g_ownbackstore) |
if (g_ownbackstore) |
1965 |
{ |
{ |
1966 |
if (boxcx > 1) |
if (boxcx > 1) |