mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 07:21:02 +00:00
back/ericwa-experimental: remove xcursor fallback; the xcursor library has built-in fallback for old x servers
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/branches/ericwa-experimental@34152 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0aca753728
commit
d3d7cc03a2
1 changed files with 1 additions and 150 deletions
|
@ -3022,132 +3022,6 @@ static BOOL cursor_hidden = NO;
|
|||
}
|
||||
}
|
||||
|
||||
#define ALPHA_THRESHOLD 158
|
||||
|
||||
Pixmap
|
||||
xgps_cursor_mask(Display *xdpy, Drawable draw, const unsigned char *data,
|
||||
int w, int h, int colors)
|
||||
{
|
||||
int j, i;
|
||||
unsigned char ialpha;
|
||||
Pixmap pix;
|
||||
int bitmapSize = ((w + 7) >> 3) * h; // (w/8) rounded up times height
|
||||
char *aData = calloc(1, bitmapSize);
|
||||
char *cData = aData;
|
||||
|
||||
if (colors == 4)
|
||||
{
|
||||
int k;
|
||||
for (j = 0; j < h; j++)
|
||||
{
|
||||
k = 0;
|
||||
for (i = 0; i < w; i++, k++)
|
||||
{
|
||||
if (k > 7)
|
||||
{
|
||||
cData++;
|
||||
k = 0;
|
||||
}
|
||||
data += 3;
|
||||
ialpha = (unsigned short)((char)*data++);
|
||||
if (ialpha > ALPHA_THRESHOLD)
|
||||
{
|
||||
*cData |= (0x01 << k);
|
||||
}
|
||||
}
|
||||
cData++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < bitmapSize; j++)
|
||||
{
|
||||
*cData++ = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
pix = XCreatePixmapFromBitmapData(xdpy, draw, (char *)aData, w, h,
|
||||
1L, 0L, 1);
|
||||
free(aData);
|
||||
return pix;
|
||||
}
|
||||
|
||||
Pixmap
|
||||
xgps_cursor_image(Display *xdpy, Drawable draw, const unsigned char *data,
|
||||
int w, int h, int colors, XColor *fg, XColor *bg)
|
||||
{
|
||||
int j, i, min, max;
|
||||
Pixmap pix;
|
||||
int bitmapSize = ((w + 7) >> 3) * h; // w/8 rounded up multiplied by h
|
||||
char *aData = calloc(1, bitmapSize);
|
||||
char *cData = aData;
|
||||
|
||||
min = 1 << 16;
|
||||
max = 0;
|
||||
if (colors == 4 || colors == 3)
|
||||
{
|
||||
int k;
|
||||
for (j = 0; j < h; j++)
|
||||
{
|
||||
k = 0;
|
||||
for (i = 0; i < w; i++, k++)
|
||||
{
|
||||
/* colors is in the range 0..65535
|
||||
and value is the percieved brightness, obtained by
|
||||
averaging 0.3 red + 0.59 green + 0.11 blue
|
||||
*/
|
||||
int color = ((77 * data[0]) + (151 * data[1]) + (28 * data[2]));
|
||||
|
||||
if (k > 7)
|
||||
{
|
||||
cData++;
|
||||
k = 0;
|
||||
}
|
||||
if (color > (1 << 15))
|
||||
{
|
||||
*cData |= (0x01 << k);
|
||||
}
|
||||
if (color < min)
|
||||
{
|
||||
min = color;
|
||||
bg->red = (int)data[0] * 256;
|
||||
bg->green = (int)data[1] * 256;
|
||||
bg->blue = (int)data[2] * 256;
|
||||
}
|
||||
else if (color > max)
|
||||
{
|
||||
max = color;
|
||||
fg->red = (int)data[0] * 256;
|
||||
fg->green = (int)data[1] * 256;
|
||||
fg->blue = (int)data[2] * 256;
|
||||
}
|
||||
data += 3;
|
||||
if (colors == 4)
|
||||
{
|
||||
data++;
|
||||
}
|
||||
}
|
||||
cData++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < bitmapSize; j++)
|
||||
{
|
||||
if ((unsigned short)((char)*data++) > 128)
|
||||
{
|
||||
*cData |= (0x01 << j);
|
||||
}
|
||||
cData++;
|
||||
}
|
||||
}
|
||||
|
||||
pix = XCreatePixmapFromBitmapData(xdpy, draw, (char *)aData, w, h,
|
||||
1L, 0L, 1);
|
||||
free(aData);
|
||||
return pix;
|
||||
}
|
||||
|
||||
- (void) hidecursor
|
||||
{
|
||||
if (cursor_hidden)
|
||||
|
@ -3315,30 +3189,7 @@ xgps_cursor_image(Display *xdpy, Drawable draw, const unsigned char *data,
|
|||
cursor = XcursorImageLoadCursor(dpy, xcursorImage);
|
||||
XcursorImageDestroy(xcursorImage);
|
||||
}
|
||||
#else // !HAVE_XCURSOR
|
||||
{
|
||||
Pixmap source, mask;
|
||||
unsigned int maxw, maxh;
|
||||
XColor fg, bg;
|
||||
|
||||
/* FIXME: Handle this better or return an error? */
|
||||
XQueryBestCursor(dpy, ROOT, w, h, &maxw, &maxh);
|
||||
if ((unsigned int)w > maxw)
|
||||
w = maxw;
|
||||
if ((unsigned int)h > maxh)
|
||||
h = maxh;
|
||||
|
||||
source = xgps_cursor_image(dpy, ROOT, data, w, h, colors, &fg, &bg);
|
||||
mask = xgps_cursor_mask(dpy, ROOT, data, w, h, colors);
|
||||
bg = [self xColorFromColor: bg forScreen: defScreen];
|
||||
fg = [self xColorFromColor: fg forScreen: defScreen];
|
||||
|
||||
cursor = XCreatePixmapCursor(dpy, source, mask, &fg, &bg,
|
||||
(int)hotp.x, (int)hotp.y);
|
||||
XFreePixmap(dpy, source);
|
||||
XFreePixmap(dpy, mask);
|
||||
}
|
||||
#endif
|
||||
#endif // !HAVE_XCURSOR
|
||||
|
||||
if (cid)
|
||||
*cid = (void *)cursor;
|
||||
|
|
Loading…
Reference in a new issue