owncolmap reintroduced, basically the same code, but with a switch -C. didn't use the -v switch as in the patches. I believe it is confusing and should be reserved for -version information. Other than that I can say that the code does not work as it does in the patches... haven't found what's wrong with it. bit shifting?
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@278 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
517c36f2ef
commit
ba91c632d4
@ -57,6 +57,7 @@ BOOL desktop_save = True;
|
|||||||
BOOL fullscreen = False;
|
BOOL fullscreen = False;
|
||||||
BOOL grab_keyboard = True;
|
BOOL grab_keyboard = True;
|
||||||
BOOL hide_decorations = False;
|
BOOL hide_decorations = False;
|
||||||
|
extern BOOL owncolmap;
|
||||||
|
|
||||||
/* Display usage information */
|
/* Display usage information */
|
||||||
static void
|
static void
|
||||||
@ -79,6 +80,7 @@ usage(char *program)
|
|||||||
fprintf(stderr, " -b: force bitmap updates\n");
|
fprintf(stderr, " -b: force bitmap updates\n");
|
||||||
fprintf(stderr, " -e: disable encryption (French TS)\n");
|
fprintf(stderr, " -e: disable encryption (French TS)\n");
|
||||||
fprintf(stderr, " -m: do not send motion events\n");
|
fprintf(stderr, " -m: do not send motion events\n");
|
||||||
|
fprintf(stderr, " -C: use private colour map\n");
|
||||||
fprintf(stderr, " -K: keep window manager key bindings\n");
|
fprintf(stderr, " -K: keep window manager key bindings\n");
|
||||||
fprintf(stderr, " -T: window title\n");
|
fprintf(stderr, " -T: window title\n");
|
||||||
fprintf(stderr, " -D: hide window manager decorations\n");
|
fprintf(stderr, " -D: hide window manager decorations\n");
|
||||||
@ -141,7 +143,7 @@ main(int argc, char *argv[])
|
|||||||
domain[0] = password[0] = shell[0] = directory[0] = 0;
|
domain[0] = password[0] = shell[0] = directory[0] = 0;
|
||||||
strcpy(keymapname, "en-us");
|
strcpy(keymapname, "en-us");
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:fbemKT:Dh?")) != -1)
|
while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:fbemCKT:Dh?")) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -219,6 +221,10 @@ main(int argc, char *argv[])
|
|||||||
sendmotion = False;
|
sendmotion = False;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'C':
|
||||||
|
owncolmap = True;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'K':
|
case 'K':
|
||||||
grab_keyboard = False;
|
grab_keyboard = False;
|
||||||
break;
|
break;
|
||||||
|
179
xwin.c
179
xwin.c
@ -79,11 +79,13 @@ PropMotifWmHints;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* colour maps */
|
/* colour maps */
|
||||||
|
BOOL owncolmap = False;
|
||||||
static Colormap xcolmap;
|
static Colormap xcolmap;
|
||||||
static uint32 *colmap;
|
static uint32 *colmap;
|
||||||
|
|
||||||
#define SET_FOREGROUND(col) XSetForeground(display, gc, translate_colour(colmap[col]));
|
#define TRANSLATE(col) ( owncolmap ? col : translate_colour(colmap[col]) )
|
||||||
#define SET_BACKGROUND(col) XSetBackground(display, gc, translate_colour(colmap[col]));
|
#define SET_FOREGROUND(col) XSetForeground(display, gc, TRANSLATE(col));
|
||||||
|
#define SET_BACKGROUND(col) XSetBackground(display, gc, TRANSLATE(col));
|
||||||
|
|
||||||
static int rop2_map[] = {
|
static int rop2_map[] = {
|
||||||
GXclear, /* 0 */
|
GXclear, /* 0 */
|
||||||
@ -289,7 +291,16 @@ ui_init(void)
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
xcolmap = DefaultColormapOfScreen(screen);
|
if (owncolmap != True)
|
||||||
|
{
|
||||||
|
xcolmap = DefaultColormapOfScreen(screen);
|
||||||
|
if (depth <= 8)
|
||||||
|
{
|
||||||
|
printf("You're using a screen depth of 8-bits or lower\n");
|
||||||
|
printf("If you get scewed colours, try the -C switch\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gc = XCreateGC(display, RootWindowOfScreen(screen), 0, NULL);
|
gc = XCreateGC(display, RootWindowOfScreen(screen), 0, NULL);
|
||||||
|
|
||||||
if (DoesBackingStore(screen) != Always)
|
if (DoesBackingStore(screen) != Always)
|
||||||
@ -711,7 +722,7 @@ ui_create_bitmap(int width, int height, uint8 * data)
|
|||||||
Pixmap bitmap;
|
Pixmap bitmap;
|
||||||
uint8 *tdata;
|
uint8 *tdata;
|
||||||
|
|
||||||
tdata = translate_image(width, height, data);
|
tdata = (owncolmap ? data : translate_image(width, height, data));
|
||||||
bitmap = XCreatePixmap(display, wnd, width, height, depth);
|
bitmap = XCreatePixmap(display, wnd, width, height, depth);
|
||||||
image = XCreateImage(display, visual, depth, ZPixmap, 0,
|
image = XCreateImage(display, visual, depth, ZPixmap, 0,
|
||||||
(char *) tdata, width, height, 8, 0);
|
(char *) tdata, width, height, 8, 0);
|
||||||
@ -719,7 +730,8 @@ ui_create_bitmap(int width, int height, uint8 * data)
|
|||||||
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);
|
XPutImage(display, bitmap, gc, image, 0, 0, 0, 0, width, height);
|
||||||
|
|
||||||
XFree(image);
|
XFree(image);
|
||||||
xfree(tdata);
|
if (!owncolmap)
|
||||||
|
xfree(tdata);
|
||||||
return (HBITMAP) bitmap;
|
return (HBITMAP) bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,7 +741,7 @@ ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * dat
|
|||||||
XImage *image;
|
XImage *image;
|
||||||
uint8 *tdata;
|
uint8 *tdata;
|
||||||
|
|
||||||
tdata = translate_image(width, height, data);
|
tdata = (owncolmap ? data : translate_image(width, height, data));
|
||||||
image = XCreateImage(display, visual, depth, ZPixmap, 0,
|
image = XCreateImage(display, visual, depth, ZPixmap, 0,
|
||||||
(char *) tdata, width, height, 8, 0);
|
(char *) tdata, width, height, 8, 0);
|
||||||
|
|
||||||
@ -744,7 +756,8 @@ ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
XFree(image);
|
XFree(image);
|
||||||
xfree(tdata);
|
if (!owncolmap)
|
||||||
|
xfree(tdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -875,95 +888,125 @@ ui_destroy_cursor(HCURSOR cursor)
|
|||||||
(xc)->blue = ((c)->blue << 8) | (c)->blue; \
|
(xc)->blue = ((c)->blue << 8) | (c)->blue; \
|
||||||
(xc)->flags = DoRed | DoGreen | DoBlue;
|
(xc)->flags = DoRed | DoGreen | DoBlue;
|
||||||
|
|
||||||
|
|
||||||
HCOLOURMAP
|
HCOLOURMAP
|
||||||
ui_create_colourmap(COLOURMAP * colours)
|
ui_create_colourmap(COLOURMAP * colours)
|
||||||
{
|
{
|
||||||
COLOURENTRY *entry;
|
COLOURENTRY *entry;
|
||||||
int i, ncolours = colours->ncolours;
|
int i, ncolours = colours->ncolours;
|
||||||
uint32 *map = xmalloc(sizeof(*colmap) * ncolours);
|
if (!owncolmap)
|
||||||
XColor xentry;
|
|
||||||
XColor xc_cache[256];
|
|
||||||
uint32 colour;
|
|
||||||
int colLookup = 256;
|
|
||||||
for (i = 0; i < ncolours; i++)
|
|
||||||
{
|
{
|
||||||
entry = &colours->colours[i];
|
uint32 *map = xmalloc(sizeof(*colmap) * ncolours);
|
||||||
MAKE_XCOLOR(&xentry, entry);
|
XColor xentry;
|
||||||
|
XColor xc_cache[256];
|
||||||
if (XAllocColor(display, xcolmap, &xentry) == 0)
|
uint32 colour;
|
||||||
|
int colLookup = 256;
|
||||||
|
for (i = 0; i < ncolours; i++)
|
||||||
{
|
{
|
||||||
/* Allocation failed, find closest match. */
|
entry = &colours->colours[i];
|
||||||
int j = 256;
|
MAKE_XCOLOR(&xentry, entry);
|
||||||
int nMinDist = 3 * 256 * 256;
|
|
||||||
long nDist = nMinDist;
|
|
||||||
|
|
||||||
/* only get the colors once */
|
if (XAllocColor(display, xcolmap, &xentry) == 0)
|
||||||
while (colLookup--)
|
|
||||||
{
|
{
|
||||||
xc_cache[colLookup].pixel = colLookup;
|
/* Allocation failed, find closest match. */
|
||||||
xc_cache[colLookup].red = xc_cache[colLookup].green =
|
int j = 256;
|
||||||
xc_cache[colLookup].blue = 0;
|
int nMinDist = 3 * 256 * 256;
|
||||||
xc_cache[colLookup].flags = 0;
|
long nDist = nMinDist;
|
||||||
XQueryColor(display,
|
|
||||||
DefaultColormap(display, DefaultScreen(display)),
|
|
||||||
&xc_cache[colLookup]);
|
|
||||||
}
|
|
||||||
colLookup = 0;
|
|
||||||
|
|
||||||
/* approximate the pixel */
|
/* only get the colors once */
|
||||||
while (j--)
|
while (colLookup--)
|
||||||
{
|
|
||||||
if (xc_cache[j].flags)
|
|
||||||
{
|
{
|
||||||
nDist = ((long) (xc_cache[j].red >> 8) -
|
xc_cache[colLookup].pixel = colLookup;
|
||||||
(long) (xentry.red >> 8)) *
|
xc_cache[colLookup].red = xc_cache[colLookup].green =
|
||||||
((long) (xc_cache[j].red >> 8) -
|
xc_cache[colLookup].blue = 0;
|
||||||
(long) (xentry.red >> 8)) +
|
xc_cache[colLookup].flags = 0;
|
||||||
((long) (xc_cache[j].green >> 8) -
|
XQueryColor(display,
|
||||||
(long) (xentry.green >> 8)) *
|
DefaultColormap(display,
|
||||||
((long) (xc_cache[j].green >> 8) -
|
DefaultScreen(display)),
|
||||||
(long) (xentry.green >> 8)) +
|
&xc_cache[colLookup]);
|
||||||
((long) (xc_cache[j].blue >> 8) -
|
|
||||||
(long) (xentry.blue >> 8)) *
|
|
||||||
((long) (xc_cache[j].blue >> 8) -
|
|
||||||
(long) (xentry.blue >> 8));
|
|
||||||
}
|
}
|
||||||
if (nDist < nMinDist)
|
colLookup = 0;
|
||||||
|
|
||||||
|
/* approximate the pixel */
|
||||||
|
while (j--)
|
||||||
{
|
{
|
||||||
nMinDist = nDist;
|
if (xc_cache[j].flags)
|
||||||
xentry.pixel = j;
|
{
|
||||||
|
nDist = ((long) (xc_cache[j].red >> 8) -
|
||||||
|
(long) (xentry.red >> 8)) *
|
||||||
|
((long) (xc_cache[j].red >> 8) -
|
||||||
|
(long) (xentry.red >> 8)) +
|
||||||
|
((long) (xc_cache[j].green >> 8) -
|
||||||
|
(long) (xentry.green >> 8)) *
|
||||||
|
((long) (xc_cache[j].green >> 8) -
|
||||||
|
(long) (xentry.green >> 8)) +
|
||||||
|
((long) (xc_cache[j].blue >> 8) -
|
||||||
|
(long) (xentry.blue >> 8)) *
|
||||||
|
((long) (xc_cache[j].blue >> 8) -
|
||||||
|
(long) (xentry.blue >> 8));
|
||||||
|
}
|
||||||
|
if (nDist < nMinDist)
|
||||||
|
{
|
||||||
|
nMinDist = nDist;
|
||||||
|
xentry.pixel = j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
colour = xentry.pixel;
|
||||||
|
|
||||||
|
/* update our cache */
|
||||||
|
if (xentry.pixel < 256)
|
||||||
|
{
|
||||||
|
xc_cache[xentry.pixel].red = xentry.red;
|
||||||
|
xc_cache[xentry.pixel].green = xentry.green;
|
||||||
|
xc_cache[xentry.pixel].blue = xentry.blue;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* byte swap here to make translate_image faster */
|
||||||
|
map[i] = translate_colour(colour);
|
||||||
}
|
}
|
||||||
colour = xentry.pixel;
|
return map;
|
||||||
|
|
||||||
/* update our cache */
|
|
||||||
if (xentry.pixel < 256)
|
|
||||||
{
|
|
||||||
xc_cache[xentry.pixel].red = xentry.red;
|
|
||||||
xc_cache[xentry.pixel].green = xentry.green;
|
|
||||||
xc_cache[xentry.pixel].blue = xentry.blue;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* byte swap here to make translate_image faster */
|
|
||||||
map[i] = translate_colour(colour);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XColor *xcolours, *xentry;
|
||||||
|
Colormap map;
|
||||||
|
|
||||||
return map;
|
xcolours = xmalloc(sizeof(XColor) * ncolours);
|
||||||
|
for (i = 0; i < ncolours; i++)
|
||||||
|
{
|
||||||
|
entry = &colours->colours[i];
|
||||||
|
xentry = &xcolours[i];
|
||||||
|
xentry->pixel = i;
|
||||||
|
MAKE_XCOLOR(xentry, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
map = XCreateColormap(display, wnd, visual, AllocAll);
|
||||||
|
XStoreColors(display, map, xcolours, ncolours);
|
||||||
|
|
||||||
|
xfree(xcolours);
|
||||||
|
return (HCOLOURMAP) map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_destroy_colourmap(HCOLOURMAP map)
|
ui_destroy_colourmap(HCOLOURMAP map)
|
||||||
{
|
{
|
||||||
xfree(map);
|
if (!owncolmap)
|
||||||
|
xfree(map);
|
||||||
|
else
|
||||||
|
XFreeColormap(display, (Colormap) map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_set_colourmap(HCOLOURMAP map)
|
ui_set_colourmap(HCOLOURMAP map)
|
||||||
{
|
{
|
||||||
colmap = map;
|
if (!owncolmap)
|
||||||
|
colmap = map;
|
||||||
|
else
|
||||||
|
XSetWindowColormap(display, wnd, (Colormap) map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user